微信小程序授权登录解决方案的代码实例(含未通过授权解决方案)
程序员文章站
2023-10-23 14:09:54
本文实例为大家分享了微信小程序授权登录解决方案的具体代码,供大家参考,具体内容如下
getuserinfof:function(){
var t...
本文实例为大家分享了微信小程序授权登录解决方案的具体代码,供大家参考,具体内容如下
getuserinfof:function(){ var that = this; wx.getsetting({ success: (res) => { console.info(res.authsetting); wx.getuserinfo({ success: res => { this.globaldata.userinfo = res.userinfo console.info("一开始同意授权"+res.userinfo.nickname); if (this.userinforeadycallback) { this.userinforeadycallback(res) } }, fail(err) { console.info(err.errmsg); wx.showmodal({ title: '警告', canceltext: '不授权', confirmtext: '授权', confirmcolor: '#37c31a', content: '若不授权微信登录,则无法使用xxxxxx;点击重新获取授权,则可重新使用;' + '若点击不授权,将无法使用便捷服务。', success: function (res) { if (res.confirm) { console.log('用户点击确定') wx.opensetting({ success: (res) => { if (res.authsetting['scope.userinfo']) { wx.getuserinfo({ success: res => { that.globaldata.userinfo = res.userinfo console.info("再次同意授权" + res.userinfo.nickname); if (that.userinforeadycallback) { that.userinforeadycallback(res) } } }) } else { console.info("再次不允许"); wx.redirectto({ url: 'home', }) } } }); } else if (res.cancel) { console.log('弹出框用户点击取消') wx.redirectto({ url: 'home', }) } } }) } }) } }) },
以上所述是小编给大家介绍的微信小程序授权登录解决方案详解整合,希望对大家有所帮助
下一篇: 企业推广文案应该这么写