From aabe8da62109d8a6d702ce5e46adc2dd6b7f41e7 Mon Sep 17 00:00:00 2001 From: zoujiandong <10130823232@qq.com> Date: Fri, 17 Nov 2023 14:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E8=BF=9B=E5=85=A5=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pages/login/index.js | 19 +++++++++++++++++++ app.js | 1 + 2 files changed, 20 insertions(+) diff --git a/Pages/login/index.js b/Pages/login/index.js index c89a801..c8601e3 100644 --- a/Pages/login/index.js +++ b/Pages/login/index.js @@ -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; diff --git a/app.js b/app.js index aa8d1e7..a835498 100644 --- a/app.js +++ b/app.js @@ -151,6 +151,7 @@ App({ wx.$TUIKit.logout(); wx.$TUIKit = undefined; } + wx.setStorageSync('usertype',''); this.clearAllInterval(); this.globalData.chat_sdk_ready = false; },