微信小程序的授权登录
dologgin(e) {
console.log(e.detail.errMsg);
console.log(e.detail.userInfo);
console.log(e.detail.rawData);
wx.login({
success(res) {
console.log(res);
var code = res.code;
wx.getUserInfo({
withCredentials: true,
success(res) {
wx.request({
url: 'http://xxxxxxxxxxxxxx.com/wxLogin?code=' + code,
header: { "Content-Type": "application/x-www-form-urlencoded" },
method: 'POST',
success(result) {
wx.setStorageSync('key', result.data.data.openid);
wx.reLaunch({
url: '/pages/index/index'
});
}
})
}, fail(res) {
console.log("没有授权!!!!!")
}
})
}
})
},