From 057007c4ad94e395b6e2e2478afe95dff245a2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=9E=E4=B8=9C=E6=97=AD?= <850374051@qq.com> Date: Wed, 6 Aug 2025 18:32:51 +0800 Subject: [PATCH] =?UTF-8?q?task=2045202=20=E5=A4=A7=E5=B1=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 4 ++-- src/utils/request.js | 11 ++++++++- src/views/login/index.js | 52 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 1bf88a3..f43ff87 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -46,8 +46,8 @@ const routes = [ ]; const router = new VueRouter({ - routes - // mode: 'history' + routes, + mode: 'history' }); export default router; diff --git a/src/utils/request.js b/src/utils/request.js index e1e9307..906d1dd 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -63,7 +63,16 @@ service.interceptors.response.use(res => { } ).then(() => { store.dispatch('LogOut').then(() => { - location.href = '/index'; + try { + const targetPath = window.location.pathname; + console.log(window.location) + if(targetPath) + location.href = '/login?redirect=' + encodeURIComponent(targetPath); + else + location.href = '/index'; + } catch(e) { + location.href = '/index'; + } }) }) } else if (code === 500) { diff --git a/src/views/login/index.js b/src/views/login/index.js index fd00451..e9d74a5 100644 --- a/src/views/login/index.js +++ b/src/views/login/index.js @@ -31,8 +31,56 @@ export default { code: [{ required: true, trigger: "blur", message: "验证码不能为空" }], // smsCode: [{ required: true, trigger: "blur", message: "验证码不能为空" }] }, + redirect: undefined, }; }, + watch: { + $route: { + handler: function (route) { + this.redirect = route.query && route.query.redirect; + console.log(route) + if (route.query && route.query.code && route.query.exiturl) { + let obj = { + code: route.query.code, + }; + this.singleLoading = true; + this.$store + .dispatch("SingleLogin", obj) + .then((res) => { + Cookies.set("singleUrl", route.query.exiturl, { expires: 30 }); + this.singleLoading = false; + if (this.viewChecked == true) { + this.$router.push({ path: "/viewPages/profile" }); + } else { + if (res && res.code && res.code == 200) { + let requireUpdatePassword = res.requireUpdatePassword; + if (requireUpdatePassword) { + //重置密码 + this.$set(this.resetPwd, "open", true); + } else { + this.$router + .push({ path: this.redirect || "/" }) + .catch(() => {}); + } + } + } + }) + .catch((error) => { + const errorString = error + ""; + this.loading = false; + if (errorString.indexOf("证书无效") > -1) { + loginError().then((res) => { + this.upload.open = true; + this.upload.loginJson = res.msg; + }); + } + this.singleLoading = false; + }); + } + }, + immediate: true, + }, + }, computed: { }, created () { @@ -136,8 +184,8 @@ export default { //重置密码 this.$set(this.resetPwd, "open", true); } else { - this.$router - .push({ path: this.redirect || "/nav" }) + console.log(this.redirect + 11111111111); + this.$router.push({ path: this.redirect || "/nav" }) } } }