<button class='button auth_btn_yes' lang="zh_CN" bindtap="onGotUserInfo"> 允许 </button>
//微信授权登录
onGotUserInfo: function (e) {
var that = this;
wx.getUserProfile({
desc: '完善用户信息',
success:function (resinfo) { //微信授权,获取客人信息
wx.login({
success:function (reslogin) { //微信登录
var code = reslogin.code;
if (code) {
wx.request({
url: rootDocment + '/api/Logic/WxLogin',
data:{code: code,nickname: resinfo.userInfo.nickName,avatar: resinfo.userInfo.avatarUrl},
method:'GET',
header:{},
success:function (res) {
//console.log(res);
//console.log(resinfo.userInfo.avatarUrl);
if(res.data.success){
app.globalData.userInfo.openID = res.data.session_id,
app.globalData.userInfo.userID = res.data.user_id,
app.globalData.userInfo.session_key = res.data.session_key,
app.globalData.userInfo.mobile = res.data.mobile
}
app.globalData.userInfo.avatar = resinfo.userInfo.avatarUrl,
app.globalData.userInfo.nickName = resinfo.userInfo.nickName
wx.setStorageSync('UserInfo', app.globalData.userInfo);
wx.navigateBack();
}
})
} else {
console.log('获取用户登录态失败!' + res2.errMsg)
}
},
});
}
})
},
点击允许按钮不弹出授权按钮,折腾了好一阵子没结果。为什么突然不能弹出来呢,什么东西会影响到呢
调试库:2.27.1
微信开发工具版本:1.06.2210310
谢谢两位
getUserProfile接口回收了,所以没有弹框了,参考公告:https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01 。
请参考公告做出更改https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01
获取头像昵称请使用头像昵称填写能力