扫码进入选择身份

This commit is contained in:
zoujiandong 2023-11-17 14:06:08 +08:00
parent edb10af380
commit aabe8da621
2 changed files with 20 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Page({
data: {
showEntryTip:false,
showEntryTip_second:false,
isLogin:false,
beforeClose(action){
return new Promise((resolve) => {
if (action === 'confirm') {
@ -23,6 +24,20 @@ Page({
checked: false,
static_host: api.getStaticHost()
},
onHide: function() {
let isLogin=this.data.isLogin;
if(!isLogin){
wx.setStorageSync('usertype','');
}
// 页面从前台变为后台时执行
},
onUnload: function() {
let isLogin=this.data.isLogin;
if(!isLogin){
wx.setStorageSync('usertype','');
}
// 页面销毁时执行
},
onLoad(){
let usertype = wx.getStorageSync('usertype');
this.setData({
@ -115,6 +130,7 @@ Page({
})
return;
}
let THIS=this;
let usertype = wx.getStorageSync('usertype');
let next_url = wx.getStorageSync('next_url');
wx.login({
@ -129,6 +145,9 @@ Page({
api.wechatMobileLogin(params).then(response => {
console.log(response);
wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token);
THIS.setData({
isLogin:true
})
wx.setStorageSync('user_id_'+usertype, response.data.user_id);
wx.setStorageSync('client_user_id_'+usertype, response.data.client_user_id);
app.globalData.config.userID = response.data.user_id;

1
app.js
View File

@ -151,6 +151,7 @@ App({
wx.$TUIKit.logout();
wx.$TUIKit = undefined;
}
wx.setStorageSync('usertype','');
this.clearAllInterval();
this.globalData.chat_sdk_ready = false;
},