diff --git a/Pages/index/index.js b/Pages/index/index.js index 78bf2f1..9e3e34b 100644 --- a/Pages/index/index.js +++ b/Pages/index/index.js @@ -126,6 +126,7 @@ Page({ } let token = wx.getStorageSync('AUTH_TOKEN_'+usertype); console.log(token); + console.log(url); if(token){ wx.switchTab({ url: url diff --git a/Pages/login/index.js b/Pages/login/index.js index d850aa2..225520f 100644 --- a/Pages/login/index.js +++ b/Pages/login/index.js @@ -6,7 +6,6 @@ Page({ data: { showEntryTip:false, showEntryTip_second:false, - isLogin:false, beforeClose(action){ return new Promise((resolve) => { if (action === 'confirm') { @@ -24,14 +23,6 @@ Page({ checked: false, static_host: api.getStaticHost() }, - - onUnload: function() { - let isLogin=this.data.isLogin; - if(!isLogin){ - wx.setStorageSync('usertype',''); - } - // 页面销毁时执行 - }, onLoad(){ let usertype = wx.getStorageSync('usertype'); this.setData({ @@ -139,12 +130,10 @@ 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; + app.globalData.isLogin=true; app.imInit(); //跳转页面 wx.switchTab({ diff --git a/Pages/mobile_login/index.js b/Pages/mobile_login/index.js index 09869af..28d5687 100644 --- a/Pages/mobile_login/index.js +++ b/Pages/mobile_login/index.js @@ -8,7 +8,6 @@ Page({ title: '手机号登录', //导航栏 中间的标题 }, checked: false, - isLogin:false, phone: "", sms: "", btn_msg: "获取验证码", @@ -52,13 +51,7 @@ Page({ }) } }, - onUnload: function() { - let isLogin=this.data.isLogin; - if(!isLogin){ - wx.setStorageSync('usertype',''); - } - // 页面销毁时执行 - }, + getCodePhone(e){ let phone_reg = /^1[3-9]\d{9}$/; let phone = this.data.phone; @@ -136,9 +129,7 @@ Page({ params.wx_code = res.code; api.mobileLogin(params).then(response => { - THIS.setData({ - isLogin:true - }) + app.globalData.isLogin=true; console.log(response); wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token); wx.setStorageSync('user_id_'+usertype, response.data.user_id); diff --git a/Pages/yaoshi/my/my.js b/Pages/yaoshi/my/my.js index df59c91..0f2c357 100644 --- a/Pages/yaoshi/my/my.js +++ b/Pages/yaoshi/my/my.js @@ -38,6 +38,8 @@ Page({ wx.setStorageSync('AUTH_TOKEN_'+usertype, ""); wx.setStorageSync('user_id_'+usertype, ""); wx.setStorageSync('client_user_id_'+usertype, ""); + app.globalData.isLogin=false; + wx.setStorageSync('usertype','') app.go("/Pages/index/index"); } else if (res.cancel) { console.log('用户点击取消') diff --git a/Pages/yishi/myinfo/index.js b/Pages/yishi/myinfo/index.js index 09763d3..9c80c64 100644 --- a/Pages/yishi/myinfo/index.js +++ b/Pages/yishi/myinfo/index.js @@ -53,8 +53,11 @@ Page({ let usertype = wx.getStorageSync('usertype'); wx.setStorageSync('AUTH_TOKEN_'+usertype, ""); wx.setStorageSync('user_id_'+usertype, ""); + wx.setStorageSync('client_user_id_'+usertype, ""); app.imLogout(); + app.globalData.isLogin=false; + wx.setStorageSync('usertype','') app.go("/Pages/index/index"); } else if (res.cancel) { console.log('用户点击取消') diff --git a/app.js b/app.js index a835498..a777328 100644 --- a/app.js +++ b/app.js @@ -151,7 +151,6 @@ App({ wx.$TUIKit.logout(); wx.$TUIKit = undefined; } - wx.setStorageSync('usertype',''); this.clearAllInterval(); this.globalData.chat_sdk_ready = false; }, @@ -219,6 +218,7 @@ App({ wx.$TUIKit = undefined } this.globalData.chat_sdk_ready = false + this.globalData.isLogin=false; this.go("/Pages/kickedout/index"); }, $onSystemPushReceived(e){ @@ -307,6 +307,11 @@ App({ formatWenZhenInfo(){ this.getConversationList(); }, + onHide(){ + if(!this.globalData.isLogin){ + wx.setStorageSync('usertype',''); + } + }, getConversationList(){ wx.$TUIKit.getConversationList().then((imResponse) => { // console.log("getConversationList from app js: ", imResponse.data.conversationList);