index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. const api = require("../../api/index.js")
  2. const app = getApp()
  3. const activity = require('../../utils/activity')
  4. // index.js
  5. const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
  6. Page({
  7. data: {
  8. phone:app.globalData.phone,
  9. motto: 'Hello World',
  10. userInfo: {
  11. avatarUrl: defaultAvatarUrl,
  12. nickName: '',
  13. },
  14. hasUserInfo: false,
  15. canIUseGetUserProfile: wx.canIUse('getUserProfile'),
  16. canIUseNicknameComp: wx.canIUse('input.type.nickname'),
  17. keyword:'',
  18. btnList:[
  19. {
  20. type:'1',
  21. label:'我要查风险',
  22. color:'#4095e5',
  23. page:'/pages/riskAssessment/riskAssessment'
  24. },
  25. {
  26. type:'2',
  27. label:'我要申诉',
  28. color:'#fcca00',
  29. page:'/pages/form/appeal/appeal'
  30. },
  31. {
  32. type:'3',
  33. label:'我要维权',
  34. color:'#bd3124',
  35. page:'/pages/form/rightsProtection/rightsProtection'
  36. },
  37. {
  38. type:'4',
  39. label:'我要申请',
  40. color:'#000a7b',
  41. page:'/pages/form/application/application'
  42. }
  43. ],
  44. visible1:false,
  45. activityList:activity.getActivityList()
  46. },
  47. bindViewTap() {
  48. wx.navigateTo({
  49. url: '../logs/logs'
  50. })
  51. },
  52. onReady(){
  53. },
  54. onLoad(){
  55. // wx.navigateTo({
  56. // url: '/pages/login/login',
  57. // })
  58. // api.search().then(res=>{
  59. // console.log(res)
  60. // })
  61. var a = wx.getStorageSync('showDialog')
  62. this.setData(
  63. {
  64. visible1:a
  65. }
  66. )
  67. },
  68. //点击活动
  69. clickActivity(e){
  70. var {item} = e.currentTarget.dataset
  71. var noLogin = item.noLogin
  72. if(!noLogin){
  73. var key = api.isLogin()
  74. if(!key){
  75. return false
  76. }
  77. }
  78. var page = item.page
  79. if(page){
  80. wx.navigateTo({
  81. url: page,
  82. })
  83. return
  84. }
  85. var url = item.url
  86. if(url){
  87. wx.navigateTo({
  88. url: '/pages/webView/webView?src='+url,
  89. })
  90. }
  91. },
  92. onClose1(){
  93. this.setData(
  94. {
  95. visible1:false
  96. }
  97. )
  98. wx.setStorageSync('showDialog', false)
  99. },
  100. makePhoneCall(){
  101. wx.makePhoneCall({
  102. phoneNumber: this.data.phone
  103. })
  104. },
  105. //修改输入的关键词
  106. changeKeyword(e){
  107. this.setData(
  108. {
  109. keyword:e.detail
  110. }
  111. )
  112. },
  113. //点击输入框内部图标
  114. clickInnerIcon(e){
  115. // console.log(e)
  116. },
  117. //点击搜索按钮
  118. search(e){
  119. // console.log(e)
  120. // this.setData(
  121. // {
  122. // result:this.data.keyword
  123. // }
  124. // )
  125. },
  126. //点击四个功能按钮(我要查风险)
  127. btnClick:function(e){
  128. console.log(e)
  129. var page = e.currentTarget.dataset.page
  130. console.log(page)
  131. wx.navigateTo({
  132. url:page
  133. })
  134. },
  135. onChooseAvatar(e) {
  136. const { avatarUrl } = e.detail
  137. const { nickName } = this.data.userInfo
  138. this.setData({
  139. "userInfo.avatarUrl": avatarUrl,
  140. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  141. })
  142. },
  143. onInputChange(e) {
  144. const nickName = e.detail.value
  145. const { avatarUrl } = this.data.userInfo
  146. this.setData({
  147. "userInfo.nickName": nickName,
  148. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  149. })
  150. },
  151. })