登录逻辑修改,扫码签到逻辑完善
This commit is contained in:
@@ -86,6 +86,8 @@ Page({
|
||||
wx.switchTab({
|
||||
url: '../home/home',
|
||||
})
|
||||
// 绑定微信
|
||||
this.wxBind()
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '登录失败',
|
||||
@@ -94,10 +96,34 @@ Page({
|
||||
})
|
||||
}
|
||||
})
|
||||
// 登录失败
|
||||
}
|
||||
},
|
||||
// 绑定微信
|
||||
wxBind(){
|
||||
// 获取openid进行手机号和微信的绑定
|
||||
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
|
||||
// 微信和该账号绑定
|
||||
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('授权失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user