const api = require("../../api/index") // index.js const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' Page({ data: { motto: 'Hello World', userInfo: { avatarUrl: defaultAvatarUrl, nickName: '', }, hasUserInfo: false, canIUseGetUserProfile: wx.canIUse('getUserProfile'), canIUseNicknameComp: wx.canIUse('input.type.nickname'), keyword:'', btnList:[ { type:'1', label:'我要查风险', color:'blue' }, { type:'2', label:'我要申诉', color:'rgb(252 202 0)' }, { type:'3', label:'我要维权', color:'red' }, { type:'4', label:'我要申请', color:'#7232dd' } ] }, bindViewTap() { wx.navigateTo({ url: '../logs/logs' }) }, onReady(){ }, onLoad(){ api.search().then(res=>{ console.log(res) }) }, //修改输入的关键词 changeKeyword(e){ this.setData( { keyword:e.detail } ) }, //点击输入框内部图标 clickInnerIcon(e){ // console.log(e) }, //点击搜索按钮 search(e){ // console.log(e) // this.setData( // { // result:this.data.keyword // } // ) }, //点击四个功能按钮(我要查风险) btnClick:function(e){ console.log(e) var type = e.currentTarget.dataset.type console.log(type) }, onChooseAvatar(e) { const { avatarUrl } = e.detail const { nickName } = this.data.userInfo this.setData({ "userInfo.avatarUrl": avatarUrl, hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl, }) }, onInputChange(e) { const nickName = e.detail.value const { avatarUrl } = this.data.userInfo this.setData({ "userInfo.nickName": nickName, hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl, }) }, getUserProfile(e) { // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 wx.getUserProfile({ desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (res) => { console.log(res) this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } }) }, })