index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. },
  21. {
  22. type:'2',
  23. label:'我要申诉',
  24. color:'#fcca00'
  25. },
  26. {
  27. type:'3',
  28. label:'我要维权',
  29. color:'#bd3124'
  30. },
  31. {
  32. type:'4',
  33. label:'我要申请',
  34. color:'#000a7b'
  35. }
  36. ]
  37. },
  38. bindViewTap() {
  39. wx.navigateTo({
  40. url: '../logs/logs'
  41. })
  42. },
  43. onReady(){
  44. },
  45. onLoad(){
  46. // wx.navigateTo({
  47. // url: '/pages/login/login',
  48. // })
  49. // api.search().then(res=>{
  50. // console.log(res)
  51. // })
  52. },
  53. //修改输入的关键词
  54. changeKeyword(e){
  55. this.setData(
  56. {
  57. keyword:e.detail
  58. }
  59. )
  60. },
  61. //点击输入框内部图标
  62. clickInnerIcon(e){
  63. // console.log(e)
  64. },
  65. //点击搜索按钮
  66. search(e){
  67. // console.log(e)
  68. // this.setData(
  69. // {
  70. // result:this.data.keyword
  71. // }
  72. // )
  73. },
  74. //点击四个功能按钮(我要查风险)
  75. btnClick:function(e){
  76. console.log(e)
  77. var type = e.currentTarget.dataset.type
  78. console.log(type)
  79. if(type == 1){
  80. wx.navigateTo({
  81. url:'/pages/riskAssessment/riskAssessment'
  82. })
  83. }
  84. },
  85. onChooseAvatar(e) {
  86. const { avatarUrl } = e.detail
  87. const { nickName } = this.data.userInfo
  88. this.setData({
  89. "userInfo.avatarUrl": avatarUrl,
  90. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  91. })
  92. },
  93. onInputChange(e) {
  94. const nickName = e.detail.value
  95. const { avatarUrl } = this.data.userInfo
  96. this.setData({
  97. "userInfo.nickName": nickName,
  98. hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
  99. })
  100. },
  101. })