bindGetUserInfo: function (e) {
if (e.detail.errMsg == "getUserInfo:fail auth deny") { // 拒绝 授权 返回首页
wx.switchTab({
url: '../index/index',
})
}else{
app.globalData.userInfo = e.detail.userInfo;
var that = this;
util.toLogin(function () { //同意授权跳转签到页
wx.setStorageSync('Jurisdiction', '1')
{
wx.redirectTo({
url: '../Clock/Clock',
})
}
});
}
},
bindopensetting: function (e) {
if (e.detail.authSetting['scope.userInfo']) {
console.log("用户已经授权");
var url = '';
console.log(JSON.stringify(e))
console.log('to url:' + url)
// wx.switchTab({
// url: '../Clock/Clock'
// })
}
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
那就要看你 util.toLogin 里边写的啥了
wx.getSetting({
success: res => {
// console.log('getSetting success:' + JSON.stringify(res));
//用户允许小程序获取基本信息
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
app.globalData.userInfo = res.userInfo
app.globalData.showModal = false;
that.setData({
avatarurl: res.userInfo.avatarUrl
})
util.toLogin(function (){
setTimeout(function () {
wx.switchTab({
url: '../Clock/Clock'
})
}, 1000)
});
},
fail: res => {
console.log('getUserInfo fail:' + res);
},
complete: res => {
console.log('getUserInfo complete:' + JSON.stringify(res));
}
})
}
else {
this.setData({
toOpenSetting: true
})
}
}
});
},
getUserInfo: function (e) {
},
util.toLogin 里边又嵌套了个 util.toLogin?