无法获取用户头像等信息
[代码]<!-- 如果只是展示用户头像昵称,可以使用 <open-data /> 组件 -->[代码][代码]<[代码][代码]open-data[代码] [代码]type[代码][代码]=[代码][代码]"userAvatarUrl"[代码][代码]></[代码][代码]open-data[代码][代码]>[代码][代码]<[代码][代码]open-data[代码] [代码]type[代码][代码]=[代码][代码]"userNickName"[代码][代码]></[代码][代码]open-data[代码][代码]>[代码][代码]<!-- 需要使用 button 来授权登录 -->[代码][代码]<[代码][代码]button[代码] [代码]open-type[代码][代码]=[代码][代码]"getUserInfo"[代码] [代码]bindgetuserinfo[代码][代码]=[代码][代码]"bindGetUserInfo"[代码][代码]>授权登录</[代码][代码]button[代码][代码]>[代码] [代码]//index.js[代码][代码]//获取应用实例[代码][代码]const app = getApp()[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]motto: [代码][代码]'Hello World'[代码][代码],[代码][代码] [代码][代码]userInfo: {},[代码][代码] [代码][代码]hasUserInfo: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]canIUse: wx.canIUse([代码][代码]'button.open-type.getUserInfo'[代码][代码])[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]// 查看是否授权[代码][代码] [代码][代码]wx.getSetting({[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]if[代码] [代码](res.authSetting[[代码][代码]'scope.userInfo'[代码][代码]]) {[代码][代码] [代码][代码]// 已经授权,可以直接调用 getUserInfo 获取头像昵称[代码][代码] [代码][代码]wx.getUserInfo({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res.userInfo)[代码][代码] [代码][代码]var[代码] [代码]str = JSON.stringify(res.userInfo);[代码][代码] [代码][代码]app.alertHui(str, [代码][代码]function[代码] [代码]() { [代码][代码]//回调弹窗[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]bindGetUserInfo: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]console.log(e)[代码][代码] [代码][代码]app.globalData.userInfo = e.detail.userInfo;[代码][代码] [代码][代码]var[代码] [代码]str = JSON.stringify(e.detail.userInfo)[代码][代码] [代码][代码]app.alertHui(str, [代码][代码]function[代码] [代码]() { [代码][代码]//回调弹窗[代码] [代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码][代码]})[代码] - 当前 Bug 的表现(可附上截图) [图片] [图片] - 预期表现 - 复现路径 - 提供一个最简复现 Demo