登录和绑定微信的完善,我的页面需要登录验证
This commit is contained in:
+11
-9
@@ -80,10 +80,11 @@ Page({
|
||||
},
|
||||
// 微信登录
|
||||
wxLogin(){
|
||||
const that = this
|
||||
wxBind((res)=>{
|
||||
let params = {
|
||||
openId: res.data.openid,
|
||||
rsaPublicKey: this.data.rsaPublicKey
|
||||
rsaPublicKey: that.data.rsaPublicKey
|
||||
}
|
||||
UserApi.wxLogin(params).then(res=>{
|
||||
if(res.success) {// 已经用手机号登录过,此时用微信快捷登录时,把微信的个人信息存进缓存(微信信息在缓存的userInfoTemp)
|
||||
@@ -96,11 +97,7 @@ Page({
|
||||
url: '../home/home',
|
||||
})
|
||||
}else{ // 首次登录不能直接用微信快捷登录
|
||||
wx.showToast({
|
||||
title: '暂未授权手机号',
|
||||
duration: 2000,
|
||||
icon: "none",
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -120,6 +117,7 @@ Page({
|
||||
key: 'userInfo',
|
||||
data: res.result.userInfo
|
||||
})
|
||||
// 第一次登录系统,需要设置密码
|
||||
if(res.message === "updatePassword") {
|
||||
// 存临时token
|
||||
wx.setStorage({
|
||||
@@ -136,8 +134,11 @@ Page({
|
||||
key: 'X-Access-Token',
|
||||
data: res.result.token
|
||||
})
|
||||
// 绑定微信
|
||||
this.wxBind()
|
||||
// 如果绑定过微信就不再进行绑定
|
||||
if(!res.result.userInfo.openId){
|
||||
// 绑定微信
|
||||
this.wxBindPhone()
|
||||
}
|
||||
// 跳转首页
|
||||
wx.switchTab({
|
||||
url: '../home/home',
|
||||
@@ -167,7 +168,8 @@ Page({
|
||||
})
|
||||
},
|
||||
// 绑定微信
|
||||
wxBind(){
|
||||
wxBindPhone(){
|
||||
const that = this
|
||||
wxBind((res)=>{
|
||||
let params = {
|
||||
openId: res.data.openid,
|
||||
|
||||
Reference in New Issue
Block a user