index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 page = item.page
  72. if(page){
  73. wx.navigateTo({
  74. url: page,
  75. })
  76. return
  77. }
  78. var url = item.url
  79. if(url){
  80. wx.navigateTo({
  81. url: '/pages/webView/webView?src='+url,
  82. })
  83. }
  84. },
  85. onClose1(){
  86. this.setData(
  87. {
  88. visible1:false
  89. }
  90. )
  91. wx.setStorageSync('showDialog', false)
  92. },
  93. makePhoneCall(){
  94. wx.makePhoneCall({
  95. phoneNumber: this.data.phone
  96. })
  97. },
  98. //修改输入的关键词
  99. changeKeyword(e){
  100. this.setData(
  101. {
  102. keyword:e.detail
  103. }
  104. )
  105. },
  106. //点击输入框内部图标
  107. clickInnerIcon(e){
  108. // console.log(e)
  109. },
  110. //点击搜索按钮
  111. search(e){
  112. // console.log(e)
  113. // this.setData(
  114. // {
  115. // result:this.data.keyword
  116. // }
  117. // )
  118. },
  119. //点击四个功能按钮(我要查风险)
  120. btnClick:function(e){
  121. console.log(e)
  122. var page = e.currentTarget.dataset.page
  123. console.log(page)
  124. wx.navigateTo({
  125. url:page
  126. })
  127. },
  128. onChooseAvatar(e) {
  129. const { avatarUrl } = e.detail
  130. const { nickName } = this.data.userInfo
  131. this.setData({
  132. "userInfo.avatarUrl": avatarUrl,
  133. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  134. })
  135. },
  136. onInputChange(e) {
  137. const nickName = e.detail.value
  138. const { avatarUrl } = this.data.userInfo
  139. this.setData({
  140. "userInfo.nickName": nickName,
  141. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  142. })
  143. },
  144. })