diff --git a/Pages/login/index.js b/Pages/login/index.js index c8601e3..d850aa2 100644 --- a/Pages/login/index.js +++ b/Pages/login/index.js @@ -24,13 +24,7 @@ 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){ diff --git a/Pages/mobile_login/index.js b/Pages/mobile_login/index.js index 53f1ed0..09869af 100644 --- a/Pages/mobile_login/index.js +++ b/Pages/mobile_login/index.js @@ -8,6 +8,7 @@ Page({ title: '手机号登录', //导航栏 中间的标题 }, checked: false, + isLogin:false, phone: "", sms: "", btn_msg: "获取验证码", @@ -51,6 +52,13 @@ 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; @@ -91,7 +99,7 @@ Page({ }) }, mobileLogin(e){ - + let THIS=this; let phone_reg = /^1[3-9]\d{9}$/; let phone = this.data.phone; let sms = this.data.sms; @@ -128,6 +136,9 @@ Page({ params.wx_code = res.code; api.mobileLogin(params).then(response => { + THIS.setData({ + isLogin:true + }) console.log(response); wx.setStorageSync('AUTH_TOKEN_'+usertype, response.data.token); wx.setStorageSync('user_id_'+usertype, response.data.user_id);