From a2a62fb9c2d556802dfec58fcf60eda236a074f3 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Thu, 4 Jan 2024 16:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/login/components/main.vue | 7 +++++-- pages/login/index.vue | 37 +++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/pages/login/components/main.vue b/pages/login/components/main.vue index d7cee79..65d17a5 100644 --- a/pages/login/components/main.vue +++ b/pages/login/components/main.vue @@ -107,9 +107,11 @@ created() { console.log('main created') }, + - methods: { + methods: { + // 账户类型 radioChange(evt) { this.userType = evt.detail.value @@ -244,7 +246,8 @@ this.$navTo("pages/findpass/findpass") }, - } + }, + } diff --git a/pages/login/index.vue b/pages/login/index.vue index 37985f1..f700270 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -31,6 +31,14 @@ partyData: {} } }, + + // + activated() { + if(window.history && window.history.pushState){ + history.pushState(null, null, document.URL); + window.addEventListener('popstate', this.goBack, false); + } + }, /** * 生命周期函数--监听页面加载 @@ -64,6 +72,27 @@ // console.log('setShowUserInfo complete') // }) }, + + //返回操作 + goBack(){ + // 获取url历史记录 + let history = store.state.urlHistory; + console.log(history,"history"); + + // 判断历史记录的长度 + // if(history.length > 1) { + // // 如果历史记录长度大于1,则跳转到倒数第三个历史记录的url + // router.push(history[history.length - 3]); + // } else { + // // 否则,跳转到首页 + // router.push('/'); + // } + + // // 再次执行以下两行代码,确保后退按钮可以再次触发popstate事件 + // window.history.pushState('forward', null, ''); + // window.history.forward(1); + // this.$router.replace({path: '/'}); + }, // 获取到用户信息的回调函数 onGetUserInfoSuccess({ oauth, code, userInfo }) { @@ -78,9 +107,13 @@ // 是否显示微信小程序授权登录 this.isMpWeixinAuth = false // 已获取到了第三方用户信息 - this.isParty = true + // this.isParty = true } - } + }, + // 离开页面销毁 + deactivated() { + window.removeEventListener('popstate', this.goBack, false); + } }