更新扫描二维码进入选择身份

This commit is contained in:
zoujiandong 2023-11-17 15:01:05 +08:00
parent aabe8da621
commit 7c0f376058
2 changed files with 13 additions and 8 deletions

View File

@ -24,13 +24,7 @@ Page({
checked: false, checked: false,
static_host: api.getStaticHost() static_host: api.getStaticHost()
}, },
onHide: function() {
let isLogin=this.data.isLogin;
if(!isLogin){
wx.setStorageSync('usertype','');
}
// 页面从前台变为后台时执行
},
onUnload: function() { onUnload: function() {
let isLogin=this.data.isLogin; let isLogin=this.data.isLogin;
if(!isLogin){ if(!isLogin){

View File

@ -8,6 +8,7 @@ Page({
title: '手机号登录', //导航栏 中间的标题 title: '手机号登录', //导航栏 中间的标题
}, },
checked: false, checked: false,
isLogin:false,
phone: "", phone: "",
sms: "", sms: "",
btn_msg: "获取验证码", btn_msg: "获取验证码",
@ -51,6 +52,13 @@ Page({
}) })
} }
}, },
onUnload: function() {
let isLogin=this.data.isLogin;
if(!isLogin){
wx.setStorageSync('usertype','');
}
// 页面销毁时执行
},
getCodePhone(e){ getCodePhone(e){
let phone_reg = /^1[3-9]\d{9}$/; let phone_reg = /^1[3-9]\d{9}$/;
let phone = this.data.phone; let phone = this.data.phone;
@ -91,7 +99,7 @@ Page({
}) })
}, },
mobileLogin(e){ mobileLogin(e){
let THIS=this;
let phone_reg = /^1[3-9]\d{9}$/; let phone_reg = /^1[3-9]\d{9}$/;
let phone = this.data.phone; let phone = this.data.phone;
let sms = this.data.sms; let sms = this.data.sms;
@ -128,6 +136,9 @@ Page({
params.wx_code = res.code; params.wx_code = res.code;
api.mobileLogin(params).then(response => { api.mobileLogin(params).then(response => {
THIS.setData({
isLogin:true
})
console.log(response); console.log(response);
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token); wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
wx.setStorageSync('user_id_'+usertype, response.data.user_id); wx.setStorageSync('user_id_'+usertype, response.data.user_id);