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; },