弹出授权是否同意或者拒绝按钮,可是感觉这个就是形式,感觉不可以控制,拒绝和同意后结果在哪获取,然后控制下一步动作。
var isAuth=false; //是否授权
onLoad: function() {
授权登陆判断用户是否已经授权
wx.getSetting({
success: (res) => {
if (res.authSetting['scope.userInfo']) {//授权了,可以获取用户信息了
isAuth=true;
}
}
})
}
getUserProfilep: function(e) { //微信授权登录
var t = this;
//授权通过
isAuth=true;
var id = '0';
if (wx.getStorageSync(id)){
console.log("id1111111111",id);
}
t.adduserinfo();
if(isAuth==true)
{
wx.switchTab({
url: '../index/index',
});
}
...
adduserinfo(){ //新增用户信息步骤
wx.getUserProfile({
desc: "用于完善会员资料",
success: function(e) {
var a = e.userInfo;
wx.cloud.callFunction({
name: 'vi_login',
success(res) {
var openId=res.result.openid;
var unionId=res.result.unionid;
//新增微信信息到用户信息表
console.log("openId",openId);
db.collection("userinfo").where({
openId : openId
}).get({
success(res){
console.log("res",res);
if(res.data.length==0){//判断是否用户是否在信息表存在,如果存在不新增
console.log("res.data.length",res.data.length);
wx.cloud.callFunction({
name:'update_userinfo',
data:{
a: 1,
openId : openId,
unionId: unionId,
userInfo: a, //用户信息对象
jifen_value: 0,//用户积分
mobile: ''//手机号
},
success(res){
console.log("success update_userinfo setUserWechat");
}
})
}
}
})
}
})
}
})
},
目前已经没有任何方式获取用户信息的授权状态了。
App.WxService.getSetting()({
success: (res) => {
console.log("scope.userInfo11",res.authSetting['scope.userInfo']);
if (res.authSetting['scope.userInfo']) {//授权了,可以获取用户信息了,scope.userInfo为true为同意
wx.switchTab({
url: '../index/index',
});
console.log("scope.userInfo22",res.authSetting['scope.userInfo']);
}
}
还是不行,就是允许同意或者拒绝,都不能跳转到 wx.switchTab({
url: '../index/index',
});