求助:原来用的是getUserInfo,怎么改成getUserProfile?用下面的代码,按钮点了没反映,调用不了微信头像。
wxml:
<button open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo" class="btn">使用微信头像</button>
js:
bindGetUserInfo (e) {
const that = this
wx.getUserProfile({
success (res){
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success: function(res) {
wx.downloadFile({
url: res.userInfo.avatarUrl,
success (res) {
console.log(res.tempFilePath)
if (res.statusCode === 200) {
that.setData({
imgg:res.tempFilePath
})
that.create()
}
}
})
}
})
}
}
})
},
看看这理,希望对你有帮助 https://developers.weixin.qq.com/community/develop/article/doc/00040885c386f81e96cbf93cf51013
还有这两个API不要同时调用
<view bindtap="bindGetUserProfile">点击</view> bindGetUserProfile() { const that = this wx.getUserProfile({ desc:'测试' success (res){ console.log(res) } }) },