diff --git a/src/permission.js b/src/permission.js index d18adaa8..f4dc612d 100644 --- a/src/permission.js +++ b/src/permission.js @@ -3,6 +3,7 @@ import store from './store' import NProgress from 'nprogress' import 'nprogress/nprogress.css' import { getToken } from '@/utils/auth' +import Cookies from "js-cookie"; NProgress.configure({ showSpinner: false }) @@ -126,6 +127,14 @@ router.beforeEach((to, from, next) => { next() }).catch(err => { store.dispatch('LogOut').then(() => { + try { + let loginUrl = Cookies.get("_Login_url"); + if(loginUrl && loginUrl.endsWith("onlineHomeLogin")) + { + next({ path: '/onlineHomeLogin' }) + return; + } + } catch (e) { console.log(e); } // Message.error(err) if ('/authenticRight/index'.indexOf(to.path) !== -1) { next({ path: '/authenticRight/login' }) @@ -157,6 +166,14 @@ router.beforeEach((to, from, next) => { console.log(to.path) next() } else { + try { + let loginUrl = Cookies.get("_Login_url"); + if(loginUrl && loginUrl.endsWith("onlineHomeLogin")) + { + next({ path: `/onlineHomeLogin?redirect=${to.fullPath}` }) + return; + } + } catch (e) { console.log(e); } if ('/authenticRight/index'.indexOf(to.path) !== -1) { next(`/authenticRight/login?redirect=${to.fullPath}`) } else if ('/homestead/index'.indexOf(to.path) !== -1) { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index c8415260..dad6e37a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -2,6 +2,7 @@ import { login, logout, getInfo, smsLogin } from '@/api/login'; import { registerOn } from "@/api/register"; import { getToken, setToken, removeToken } from '@/utils/auth' import { getSystemAttachmentUrl } from '@/api/system/config' +import Cookies from "js-cookie"; const user = { state: { @@ -63,6 +64,7 @@ const user = { login(username, password, code, uuid).then(res => { setToken(res.token) commit('SET_TOKEN', res.token) + Cookies.set("_Login_url", window.location.href); resolve() }).catch(error => { reject(error) @@ -79,6 +81,7 @@ const user = { smsLogin(mobile, smsCode, uuid).then(res => { setToken(res.token) commit('SET_TOKEN', res.token) + Cookies.set("_Login_url", window.location.href); resolve() }).catch(error => { reject(error) @@ -97,6 +100,7 @@ const user = { registerOn(memberName, idcard, mobile, smsCode, uuid).then(res => { setToken(res.token) commit('SET_TOKEN', res.token) + Cookies.set("_Login_url", window.location.href); resolve() }).catch(error => { reject(error) diff --git a/src/utils/request.js b/src/utils/request.js index 655175f4..f01bcfb4 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -4,6 +4,7 @@ import { Notify, Dialog, Toast } from 'vant'; import store from '@/store' import { getToken } from '@/utils/auth' import errorCode from '@/utils/errorCode' +import Cookies from "js-cookie"; axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 @@ -69,6 +70,14 @@ service.interceptors.response.use(res => { }) .then(() => { store.dispatch('LogOut').then(() => { + try { + let loginUrl = Cookies.get("_Login_url"); + if(loginUrl && loginUrl.endsWith("onlineHomeLogin")) + { + window.location.href = loginUrl; + return; + } + } catch (e) { console.log(e); } if (window.location.href.indexOf('lawEnforcement') != -1) { window.location.href = '/lawEnforcement/login'; } else if (window.location.href.indexOf('authenticRight') != -1) { diff --git a/src/views/onlineHome/homestead/homeApplication/proposerLite.vue b/src/views/onlineHome/homestead/homeApplication/proposerLite.vue index 33c30552..10046831 100644 --- a/src/views/onlineHome/homestead/homeApplication/proposerLite.vue +++ b/src/views/onlineHome/homestead/homeApplication/proposerLite.vue @@ -19,7 +19,7 @@
- +