From 7c0f376058d2b69d4fa6a77ffd94cab35a61ea64 Mon Sep 17 00:00:00 2001 From: zoujiandong <10130823232@qq.com> Date: Fri, 17 Nov 2023 15:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=AB=E6=8F=8F=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E8=BF=9B=E5=85=A5=E9=80=89=E6=8B=A9=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pages/login/index.js | 8 +------- Pages/mobile_login/index.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) 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);