小程序授权框无法弹出?
onLoad: function () {
var that =this;
console.log("openid:"+app.globalData.openid);
// 查看是否授权
wx.getSetting({
success(res) {
if (res.authSetting['scope.userInfo']) {
// 已经授权,直接调用getUserInfo获取用户信息
that.getuserinfo();
}
}
})
},
getUserInfo: async function(e) {
debugger;
var openid = app.globalData.openid;
var username = e.detail.userInfo.nickName;
var photo = e.detail.userInfo.avatarUrl;
var gender = e.detail.userInfo.gender;
var province = e.detail.userInfo.province;
var city = e.detail.userInfo.city;
var country = e.detail.userInfo.country;
}
在开发工具上 可以弹出授权框 让用户选择同意还是不同意, 但是发布以后再手机上不会弹出, 然后直接拿到用户名 "微信用户" 然后头像拿不到