微信授权登录,获取授权凭证改为后端获取
This commit is contained in:
@@ -44,7 +44,7 @@ Page({
|
||||
if (res.success) {
|
||||
this.countDown()
|
||||
wx.showToast({
|
||||
title: '发送成功'+ res.result,
|
||||
title: '发送成功',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
@@ -272,26 +272,24 @@ Page({
|
||||
wx.login({
|
||||
success (res) {
|
||||
if (res.code) {
|
||||
//发起网络请求
|
||||
wx.request({
|
||||
url: 'https://api.weixin.qq.com/sns/jscode2session',
|
||||
data: {
|
||||
appid: 'wx24914e866df035fb',
|
||||
secret: '0d2830f26f57722716249f2b2236f409',
|
||||
js_code: res.code,
|
||||
grant_type: 'authorization_code'
|
||||
},
|
||||
success (res) { // 成功拿到openId
|
||||
let params = {
|
||||
appid: appId,
|
||||
secret: secret,
|
||||
js_code: res.code,
|
||||
grant_type: 'authorization_code'
|
||||
}
|
||||
UserApi.getWxLoginPromise(params).then(res => {
|
||||
if (res.success) { // 成功拿到openId
|
||||
// 微信和该账号绑定
|
||||
let params = {
|
||||
openId: res.openId,
|
||||
openId: res.result.openid,
|
||||
rsaPublicKey: that.data.rsaPublicKey
|
||||
}
|
||||
UserApi.wxBind(params).then(res=>{})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('授权失败!' + res.errMsg)
|
||||
console.log('授权失败!' + res.message)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user