跳转加loading

This commit is contained in:
zyn
2023-07-17 18:32:01 +08:00
parent f629882927
commit 189dbe557f
+50 -2
View File
@@ -62,17 +62,28 @@ import VConsole from 'vuex'
import isMobile from "./store/isMobile"; import isMobile from "./store/isMobile";
import { Loading } from 'element-ui';
let loading = Loading.service({
text: '加载中...',
background: '#fff'
});
function closeLoading(){
loading.close()
loading = null
}
// 路由拦截 // 路由拦截
router.beforeEach(function (to, from, next) { router.beforeEach(function (to, from, next) {
let fromName = from.name let fromName = from.name
if(fromName === undefined || fromName === null){ if(fromName === undefined || fromName === null){
window.sessionStorage.clear() window.sessionStorage.clear()
} }
console.log(to)
console.log(from)
let toName = to.name let toName = to.name
if (toName === 'CheckPage' || toName === 'loginStandDetails' || toName === 'error' if (toName === 'CheckPage' || toName === 'loginStandDetails' || toName === 'error'
|| toName === 'LoginVerifyPhone') { || toName === 'LoginVerifyPhone') {
next() next()
closeLoading()
return return
} }
@@ -150,13 +161,16 @@ router.beforeEach(function (to, from, next) {
window.sessionStorage.clear() window.sessionStorage.clear()
localStorage.setItem("routerName","phoneHome") localStorage.setItem("routerName","phoneHome")
next('/loginVerifyPhone') next('/loginVerifyPhone')
closeLoading()
}else if(toName === 'phoneHome' && token != null && (fromName === undefined || fromName === null)){ }else if(toName === 'phoneHome' && token != null && (fromName === undefined || fromName === null)){
localStorage.removeItem('token') localStorage.removeItem('token')
token = localStorage.getItem("token") token = localStorage.getItem("token")
window.sessionStorage.clear() window.sessionStorage.clear()
next() next()
closeLoading()
}else if(toName === 'phoneHome' && token != null){ }else if(toName === 'phoneHome' && token != null){
next() next()
closeLoading()
} else if(toName === 'processCenter'){ } else if(toName === 'processCenter'){
// hwh5.close(); // hwh5.close();
//关闭当前窗口 //关闭当前窗口
@@ -183,17 +197,21 @@ router.beforeEach(function (to, from, next) {
window.sessionStorage.clear() window.sessionStorage.clear()
localStorage.setItem("routerName","phoneHome") localStorage.setItem("routerName","phoneHome")
next('/loginVerifyPhone') next('/loginVerifyPhone')
closeLoading()
}else if(toName === 'databaseSearch' || toName === 'standDynamics' || }else if(toName === 'databaseSearch' || toName === 'standDynamics' ||
toName === 'domesticStand' || toName === 'domesticDetails' || toName === 'zlzxDetails'){ toName === 'domesticStand' || toName === 'domesticDetails' || toName === 'zlzxDetails'){
localStorage.setItem("routerName",toName) localStorage.setItem("routerName",toName)
next('/loginVerifyPhone') next('/loginVerifyPhone')
closeLoading()
}else { }else {
if(fromName === 'phoneHome'){ if(fromName === 'phoneHome'){
next() next()
closeLoading()
}else { }else {
localStorage.removeItem("param"); localStorage.removeItem("param");
localStorage.setItem('param',JSON.stringify(param4)) localStorage.setItem('param',JSON.stringify(param4))
next('/phoneIndex') next('/phoneIndex')
closeLoading()
} }
} }
}else { }else {
@@ -202,14 +220,17 @@ router.beforeEach(function (to, from, next) {
fromName === 'domesticStand' || fromName === 'domesticDetails' || toName === 'zlzxDetails'){ fromName === 'domesticStand' || fromName === 'domesticDetails' || toName === 'zlzxDetails'){
localStorage.setItem("routerName",toName) localStorage.setItem("routerName",toName)
next('/loginVerifyPhone') next('/loginVerifyPhone')
closeLoading()
}else { }else {
next() next()
closeLoading()
} }
} }
} else { } else {
if(toName === 'databaseSearch' || toName === 'standDynamics' || toName === 'zlzxDetails' || if(toName === 'databaseSearch' || toName === 'standDynamics' || toName === 'zlzxDetails' ||
toName === 'domesticStand' || toName === 'domesticDetails'){ toName === 'domesticStand' || toName === 'domesticDetails'){
next() next()
closeLoading()
}else if (toName.slice(0,5) !== 'phone') { }else if (toName.slice(0,5) !== 'phone') {
if(toName === 'LoginVerify'){ if(toName === 'LoginVerify'){
if(toName === 'phoneHome'){ if(toName === 'phoneHome'){
@@ -219,13 +240,18 @@ router.beforeEach(function (to, from, next) {
window.sessionStorage.clear() window.sessionStorage.clear()
localStorage.setItem("routerName","phoneHome") localStorage.setItem("routerName","phoneHome")
next('/loginVerifyPhone') next('/loginVerifyPhone')
closeLoading()
}else{ }else{
next('/blankPage') next('/blankPage')
closeLoading()
} }
}else { }else {
if(toName === 'blankPage' || toName === 'processedPage') { if(toName === 'blankPage' || toName === 'processedPage') {
next() next()
closeLoading()
}else { }else {
console.log('-bussLibrary4-')
extractedVerify() extractedVerify()
} }
} }
@@ -239,14 +265,19 @@ router.beforeEach(function (to, from, next) {
window.sessionStorage.clear() window.sessionStorage.clear()
localStorage.setItem("routerName","phoneHome") localStorage.setItem("routerName","phoneHome")
next('/loginVerifyPhone') next('/loginVerifyPhone')
closeLoading()
}else{ }else{
next('/blankPage') next('/blankPage')
closeLoading()
} }
}else { }else {
console.log('-phoneBussLibrary4-')
next() next()
closeLoading()
} }
}else { }else {
next() next()
closeLoading()
} }
} }
} }
@@ -255,6 +286,7 @@ router.beforeEach(function (to, from, next) {
if ((token === null || token === '' ) && toName === 'OtherStandardDetails') { if ((token === null || token === '' ) && toName === 'OtherStandardDetails') {
if (document.cookie) { if (document.cookie) {
next() next()
closeLoading()
return return
} }
} }
@@ -262,6 +294,7 @@ router.beforeEach(function (to, from, next) {
if(webLoginType != null && webLoginType === 'idm' ){ if(webLoginType != null && webLoginType === 'idm' ){
if(code){ if(code){
next() next()
closeLoading()
}else { }else {
if (taskId !== undefined && taskId !== null && prcId !== undefined && prcId !== null) { if (taskId !== undefined && taskId !== null && prcId !== undefined && prcId !== null) {
extractedVerify(token) extractedVerify(token)
@@ -270,9 +303,11 @@ router.beforeEach(function (to, from, next) {
extractedLocalStorage("standardSearch/All",userName) extractedLocalStorage("standardSearch/All",userName)
localStorage.setItem('external', "external") localStorage.setItem('external', "external")
next('/LoginVerifyNoEncryption') next('/LoginVerifyNoEncryption')
closeLoading()
}else { }else {
if (toName === 'LoginVerifyNoEncryption') { if (toName === 'LoginVerifyNoEncryption') {
next() next()
closeLoading()
}else { }else {
if(path === '/standardSearch/All'){ if(path === '/standardSearch/All'){
extractedLocalStorage('standardSearch/All',''); extractedLocalStorage('standardSearch/All','');
@@ -290,6 +325,7 @@ router.beforeEach(function (to, from, next) {
extractedVerify(token) extractedVerify(token)
} else { } else {
next('/Login') next('/Login')
closeLoading()
} }
} }
@@ -324,8 +360,10 @@ router.beforeEach(function (to, from, next) {
if ((hisCount && hisCount > 0)) { // 业务系统 当前节点已完成 if ((hisCount && hisCount > 0)) { // 业务系统 当前节点已完成
if(isMobile()){ if(isMobile()){
next('/processedPage') next('/processedPage')
closeLoading()
}else { }else {
next() next()
closeLoading()
} }
} else { // 业务系统 当前节点未完成 } else { // 业务系统 当前节点未完成
// commitStatus 大于0 表示当前节点存在未完成干活流程 // commitStatus 大于0 表示当前节点存在未完成干活流程
@@ -379,6 +417,7 @@ router.beforeEach(function (to, from, next) {
window.location.href = ssoLoginUrlDev window.location.href = ssoLoginUrlDev
} else { } else {
next({path: routerPath + '?' +param}) next({path: routerPath + '?' +param})
closeLoading()
} }
} }
@@ -389,6 +428,7 @@ router.beforeEach(function (to, from, next) {
window.location.href = ssoLoginUrlDev window.location.href = ssoLoginUrlDev
} else { } else {
next() next()
closeLoading()
} }
} }
@@ -396,7 +436,9 @@ router.beforeEach(function (to, from, next) {
let paramPhone = 'taskIds=' + taskId + '&prcId=' + prcId + '&prcNum=' + prcNum + let paramPhone = 'taskIds=' + taskId + '&prcId=' + prcId + '&prcNum=' + prcNum +
'&taskAssignee=' + toName + '&prcName=' + prcName + '&prcType=' + prcType '&taskAssignee=' + toName + '&prcName=' + prcName + '&prcType=' + prcType
let phoneRouter = 'phone' + toName.charAt(0).toUpperCase() + toName.slice(1) let phoneRouter = 'phone' + toName.charAt(0).toUpperCase() + toName.slice(1)
next({path: phoneRouter + '?' + paramPhone}) console.log(phoneRouter);
next({path: phoneRouter + '?' + paramPhone})
closeLoading()
} }
function extracted2(routerPath,param2) { function extracted2(routerPath,param2) {
if (token === null || token === '') { if (token === null || token === '') {
@@ -405,6 +447,7 @@ router.beforeEach(function (to, from, next) {
window.location.href = ssoLoginUrlDev window.location.href = ssoLoginUrlDev
} else { } else {
next({path: routerPath + '?' + param2}) next({path: routerPath + '?' + param2})
closeLoading()
} }
} }
function extracted4(routerPath,param4) { function extracted4(routerPath,param4) {
@@ -414,6 +457,7 @@ router.beforeEach(function (to, from, next) {
window.location.href = ssoLoginUrlDev window.location.href = ssoLoginUrlDev
} else { } else {
next({path: routerPath + '?' + param4}) next({path: routerPath + '?' + param4})
closeLoading()
} }
} }
}) })
@@ -421,16 +465,20 @@ router.beforeEach(function (to, from, next) {
if(path === '/loginVerify'){ if(path === '/loginVerify'){
if(webLoginType != null && webLoginType === 'dev'){ if(webLoginType != null && webLoginType === 'dev'){
next('/Login') next('/Login')
closeLoading()
}else { }else {
next() next()
closeLoading()
} }
}else { }else {
if((fromName === undefined || fromName === null) && (path.indexOf("/standardSearch/All&userName") !== -1 || (path.indexOf("/standardSearch/All") !== -1 && userName !== undefined))) { if((fromName === undefined || fromName === null) && (path.indexOf("/standardSearch/All&userName") !== -1 || (path.indexOf("/standardSearch/All") !== -1 && userName !== undefined))) {
extractedLocalStorage("standardSearch/All",userName) extractedLocalStorage("standardSearch/All",userName)
localStorage.setItem('external', "external") localStorage.setItem('external', "external")
next('/LoginVerifyNoEncryption') next('/LoginVerifyNoEncryption')
closeLoading()
}else { }else {
next() next()
closeLoading()
} }
} }
} }