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); + } }