微信小程序授权及回调

html页面

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

js页面

    

bindGetUserInfo: function (e) {
var that = this;
console.log(e.detail.userInfo)
if (e.detail.userInfo) {
console.log( '000')
//用户按了允许授权按钮
wx.showModal({
content: "授权成功,第一次登陆请先修改个人信息",
showCancel: false,
confirmText: '知道了',
success: function (res) {
wx.switchTab({
url: '../my/my',
})
}
})
} else {
wx.showModal({
content: "您已拒绝授权",
showCancel: false,
confirmText: '知道了',
success: function (res) {
that.setData({
showModal2: false
});
}
})
}
}

猜你喜欢

转载自blog.csdn.net/qq_35181466/article/details/80984347