getUesrMessage:function(){
var that = this;
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting[‘scope.userInfo’]) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
var username = res.userInfo.nickName;
var avatarUrl = res.userInfo.avatarUrl;
wx.setStorageSync(‘username’, username);
wx.setStorageSync(‘avatarUrl’, avatarUrl);
},
fail(res){
wx.showToast({
icon: ‘none’,
title: ‘获取用户信息失败’
})
}
})
}else{
wx.showToast({
icon: ‘none’,
title: ‘未授权’
})
that.showSettingToast(“授权获取头像昵称”);
}
}
})
},
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)