<button open-type="getUserInfo" @getuserinfo="getUserInfo">登录</button> getUserInfo() { var that = this; wx.showLoading({ title: "授权中...", //提示的内容, mask: true, //显示透明蒙层,防止触摸穿透, }); wx.getSetting({ success(res) { console.log(res); //信息授权 if (!res.authSetting["scope.userInfo"]) { //未授权getUserInfo wx.authorize({ scope: "scope.userInfo", success(res) { console.log("授权成功"); //授权成功直接登录 // console.log(res); that.userInfo = res.userInfo; wx.hideLoading(); that.getUserLocation(); }, fail(err) { wx.hideLoading(); console.log("授权失败"); console.log(err); }, }); } else { //已授权 wx.getUserInfo({ success(res) { // console.log(res); console.log("已授权"); //授权就可直接登录 that.userInfo = res.userInfo; wx.hideLoading(); that.getUserLocation(); }, fail(err) { console.log("未授权"); }, }); } }, }); },
为什么拿不到授权信息,而且清除授权后也不弹授权窗,每次调接口都是授权成功,而且获取的信息都是空!?errMsg: "authorize:fail 系统错误,错误码:-12007,scope unauthorized
2021-04-06