index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. const api = require("../../api/index.js")
  2. // index.js
  3. const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
  4. Page({
  5. data: {
  6. motto: 'Hello World',
  7. userInfo: {
  8. avatarUrl: defaultAvatarUrl,
  9. nickName: '',
  10. },
  11. hasUserInfo: false,
  12. canIUseGetUserProfile: wx.canIUse('getUserProfile'),
  13. canIUseNicknameComp: wx.canIUse('input.type.nickname'),
  14. keyword:'',
  15. btnList:[
  16. {
  17. type:'1',
  18. label:'我要查风险',
  19. color:'#4095e5',
  20. page:'/pages/riskAssessment/riskAssessment'
  21. },
  22. {
  23. type:'2',
  24. label:'我要申诉',
  25. color:'#fcca00',
  26. page:'/pages/form/appeal/appeal'
  27. },
  28. {
  29. type:'3',
  30. label:'我要维权',
  31. color:'#bd3124',
  32. page:'/pages/form/rightsProtection/rightsProtection'
  33. },
  34. {
  35. type:'4',
  36. label:'我要申请',
  37. color:'#000a7b',
  38. page:'/pages/form/application/application'
  39. }
  40. ]
  41. },
  42. bindViewTap() {
  43. wx.navigateTo({
  44. url: '../logs/logs'
  45. })
  46. },
  47. onReady(){
  48. },
  49. onLoad(){
  50. // wx.navigateTo({
  51. // url: '/pages/login/login',
  52. // })
  53. // api.search().then(res=>{
  54. // console.log(res)
  55. // })
  56. },
  57. //修改输入的关键词
  58. changeKeyword(e){
  59. this.setData(
  60. {
  61. keyword:e.detail
  62. }
  63. )
  64. },
  65. //点击输入框内部图标
  66. clickInnerIcon(e){
  67. // console.log(e)
  68. },
  69. //点击搜索按钮
  70. search(e){
  71. // console.log(e)
  72. // this.setData(
  73. // {
  74. // result:this.data.keyword
  75. // }
  76. // )
  77. },
  78. //点击四个功能按钮(我要查风险)
  79. btnClick:function(e){
  80. console.log(e)
  81. var page = e.currentTarget.dataset.page
  82. console.log(page)
  83. wx.navigateTo({
  84. url:page
  85. })
  86. },
  87. onChooseAvatar(e) {
  88. const { avatarUrl } = e.detail
  89. const { nickName } = this.data.userInfo
  90. this.setData({
  91. "userInfo.avatarUrl": avatarUrl,
  92. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  93. })
  94. },
  95. onInputChange(e) {
  96. const nickName = e.detail.value
  97. const { avatarUrl } = this.data.userInfo
  98. this.setData({
  99. "userInfo.nickName": nickName,
  100. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  101. })
  102. },
  103. })