进入 wx.getSetting后 res.authSetting为空

今天发现微信废弃了授权API:’scope.userInfo’

授权允许-> wx. getSetting ,进入success()  后 res.authSetting={}

我不得不说其实腾讯真心垃圾,做的东西全是坑


这个问题主要是因为微信最近刚好废弃了授权API;

大家可以去看调整的公告:https://developers.weixin.qq.com/blogdetail?action=get_post_info&lang=zh_CN&token=384460955&docid=000aee01f98fc0cbd4b6ce43b56c01

没办法,我只能改,想想只能在首页的时候加一个BUTTON授权了

<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">授权</button>

然后首页的JS再添加getUserInfo方法进行授权,然后就OK了。

getUserInfo: function(){
var that = this
wx.getSetting({
success(res) {
if (!res.authSetting[ 'scope.userInfo']) {
wx.authorize({
scope: 'scope.userInfo',
success() {
that.UserLogin();
}
})
}
else{
that.UserLogin();
}
}
})
},

that.UserLogin()登录方法大家可以加自己的业务,这里就不写了;

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值