已经向用户申请获取用户信息权限,但打开设置也什么也没有?
发布于 6 年前 作者 iduan 9716 次浏览 来自 官方Issues

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(“授权获取头像昵称”);

}

}

})

},

1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部