|
@@ -9,10 +9,10 @@ import {
|
|
|
} from "@/api/public.js"
|
|
|
Vue.use(VueRouter)
|
|
|
const routes = [
|
|
|
- // {
|
|
|
- // path: '/',
|
|
|
- // redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
|
- // },
|
|
|
+ {
|
|
|
+ path: '/',
|
|
|
+ redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
|
+ },
|
|
|
{
|
|
|
path: "/404",
|
|
|
name: "404页面",
|
|
@@ -87,99 +87,99 @@ const router = new VueRouter({
|
|
|
})
|
|
|
const ignore = ["/404"]
|
|
|
|
|
|
-router.beforeEach(async (to, from, next) => {
|
|
|
+// router.beforeEach(async (to, from, next) => {
|
|
|
|
|
|
- // 如果路径上有plazaId就保存
|
|
|
- let plazaId = to.query.plazaId ?to.query.plazaId:''
|
|
|
- if (plazaId) {
|
|
|
- localStorage.setItem('PLAZAID', plazaId)
|
|
|
- store.commit('STOREPLAZAID', plazaId);
|
|
|
- }
|
|
|
- let previewUrl = to.query.isPreview ? to.query.isPreview : '';
|
|
|
- if (previewUrl) {
|
|
|
- sessionStorage.setItem("SETISPREVIEW", previewUrl)
|
|
|
- store.commit('SETISPREVIEW', previewUrl)
|
|
|
- }
|
|
|
- // 取出刷新时的 ssoToken, 路由拦截时app.vue 生命周期还没有执行,store中还没有数据,
|
|
|
- let beforeunload = localStorage.getItem("beforeunload"),
|
|
|
- __token = null
|
|
|
- beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
|
|
|
- if (!ignore.includes(to.path)) {
|
|
|
- //都是需要token检验的页面 首先优先获取路由上带的token
|
|
|
- let token = null
|
|
|
- if (to.query.token) {
|
|
|
- store.commit("SETSSOTOKEN", to.query.token) //存vuex
|
|
|
- sessionStorage.setItem("SSOTOKEN", to.query.token)
|
|
|
- token = to.query.token
|
|
|
- } else {
|
|
|
- if (store.getters["ssoToken"]) {
|
|
|
- token = store.getters["ssoToken"]
|
|
|
- } else if (sessionStorage.getItem("SSOTOKEN")) {
|
|
|
- token = sessionStorage.getItem("SSOTOKEN")
|
|
|
- store.commit("SETSSOTOKEN", sessionStorage.getItem("SSOTOKEN")) //存vuex
|
|
|
- } else {
|
|
|
- redirectGetToken(to,from)
|
|
|
- }
|
|
|
- }
|
|
|
- // 如果有token
|
|
|
- if (token) {
|
|
|
- // 有token 将数据 isPreview赋给 vuex方便取值
|
|
|
- store.commit('SETISPREVIEW', sessionStorage.getItem("SETISPREVIEW"))
|
|
|
- // 如果在跳转获取token之前保存了指定的路径,则后去token后需要跳转到相关页面
|
|
|
+// // 如果路径上有plazaId就保存
|
|
|
+// let plazaId = to.query.plazaId ?to.query.plazaId:''
|
|
|
+// if (plazaId) {
|
|
|
+// localStorage.setItem('PLAZAID', plazaId)
|
|
|
+// store.commit('STOREPLAZAID', plazaId);
|
|
|
+// }
|
|
|
+// let previewUrl = to.query.isPreview ? to.query.isPreview : '';
|
|
|
+// if (previewUrl) {
|
|
|
+// sessionStorage.setItem("SETISPREVIEW", previewUrl)
|
|
|
+// store.commit('SETISPREVIEW', previewUrl)
|
|
|
+// }
|
|
|
+// // 取出刷新时的 ssoToken, 路由拦截时app.vue 生命周期还没有执行,store中还没有数据,
|
|
|
+// let beforeunload = localStorage.getItem("beforeunload"),
|
|
|
+// __token = null
|
|
|
+// beforeunload && (__token = JSON.parse(beforeunload).ssoToken)
|
|
|
+// if (!ignore.includes(to.path)) {
|
|
|
+// //都是需要token检验的页面 首先优先获取路由上带的token
|
|
|
+// let token = null
|
|
|
+// if (to.query.token) {
|
|
|
+// store.commit("SETSSOTOKEN", to.query.token) //存vuex
|
|
|
+// sessionStorage.setItem("SSOTOKEN", to.query.token)
|
|
|
+// token = to.query.token
|
|
|
+// } else {
|
|
|
+// if (store.getters["ssoToken"]) {
|
|
|
+// token = store.getters["ssoToken"]
|
|
|
+// } else if (sessionStorage.getItem("SSOTOKEN")) {
|
|
|
+// token = sessionStorage.getItem("SSOTOKEN")
|
|
|
+// store.commit("SETSSOTOKEN", sessionStorage.getItem("SSOTOKEN")) //存vuex
|
|
|
+// } else {
|
|
|
+// redirectGetToken(to,from)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // 如果有token
|
|
|
+// if (token) {
|
|
|
+// // 有token 将数据 isPreview赋给 vuex方便取值
|
|
|
+// store.commit('SETISPREVIEW', sessionStorage.getItem("SETISPREVIEW"))
|
|
|
+// // 如果在跳转获取token之前保存了指定的路径,则后去token后需要跳转到相关页面
|
|
|
|
|
|
- if(to.path !='/group' && to.path !='/home/homepage' && to.path !='/' ){
|
|
|
- if(!store.state.permissions || store.state.permissions.length ==0){
|
|
|
- // 如果没有请求permissions则请求getUserInfo
|
|
|
- await store.dispatch("getUserInfoNoPath", router)
|
|
|
- }
|
|
|
- }
|
|
|
+// if(to.path !='/group' && to.path !='/home/homepage' && to.path !='/' ){
|
|
|
+// if(!store.state.permissions || store.state.permissions.length ==0){
|
|
|
+// // 如果没有请求permissions则请求getUserInfo
|
|
|
+// await store.dispatch("getUserInfoNoPath", router)
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
- if (sessionStorage.getItem("TOURL")) {
|
|
|
- // 如果去的地址等于缓存的地址
|
|
|
- if (sessionStorage.getItem("TOURL") == to.path) {
|
|
|
- sessionStorage.setItem("TOURL", '')
|
|
|
- if (to.path == "/") {
|
|
|
- next("/group")
|
|
|
- }
|
|
|
- if (to.path == "/group" || to.path == "/home/homepage") {
|
|
|
- if (store.state.accessLevel == -1) {
|
|
|
- await store.dispatch("getUserInfo", router)
|
|
|
- await store.dispatch("getBrand")
|
|
|
- // await store.dispatch('getFact')
|
|
|
- }
|
|
|
- }
|
|
|
- await store.dispatch("getFloors")
|
|
|
- await store.dispatch("getBrand")
|
|
|
- next()
|
|
|
- } else {
|
|
|
- next(sessionStorage.getItem("TOURL"))
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (to.path == "/") {
|
|
|
- next("/group")
|
|
|
- }
|
|
|
- if (to.path == "/group" || to.path == "/home/homepage") {
|
|
|
- if (store.state.accessLevel == -1) {
|
|
|
- await store.dispatch("getUserInfo", router)
|
|
|
- console.log('getUserInfo', 4)
|
|
|
- await store.dispatch("getBrand")
|
|
|
- // await store.dispatch('getFact')
|
|
|
- }
|
|
|
- }
|
|
|
- await store.dispatch("getFloors")
|
|
|
- await store.dispatch("getBrand")
|
|
|
- next()
|
|
|
- }
|
|
|
+// if (sessionStorage.getItem("TOURL")) {
|
|
|
+// // 如果去的地址等于缓存的地址
|
|
|
+// if (sessionStorage.getItem("TOURL") == to.path) {
|
|
|
+// sessionStorage.setItem("TOURL", '')
|
|
|
+// if (to.path == "/") {
|
|
|
+// next("/group")
|
|
|
+// }
|
|
|
+// if (to.path == "/group" || to.path == "/home/homepage") {
|
|
|
+// if (store.state.accessLevel == -1) {
|
|
|
+// await store.dispatch("getUserInfo", router)
|
|
|
+// await store.dispatch("getBrand")
|
|
|
+// // await store.dispatch('getFact')
|
|
|
+// }
|
|
|
+// }
|
|
|
+// await store.dispatch("getFloors")
|
|
|
+// await store.dispatch("getBrand")
|
|
|
+// next()
|
|
|
+// } else {
|
|
|
+// next(sessionStorage.getItem("TOURL"))
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// if (to.path == "/") {
|
|
|
+// next("/group")
|
|
|
+// }
|
|
|
+// if (to.path == "/group" || to.path == "/home/homepage") {
|
|
|
+// if (store.state.accessLevel == -1) {
|
|
|
+// await store.dispatch("getUserInfo", router)
|
|
|
+// console.log('getUserInfo', 4)
|
|
|
+// await store.dispatch("getBrand")
|
|
|
+// // await store.dispatch('getFact')
|
|
|
+// }
|
|
|
+// }
|
|
|
+// await store.dispatch("getFloors")
|
|
|
+// await store.dispatch("getBrand")
|
|
|
+// next()
|
|
|
+// }
|
|
|
|
|
|
|
|
|
- } else {
|
|
|
- redirectGetToken(to,from)
|
|
|
- }
|
|
|
- } else {
|
|
|
- next()
|
|
|
- return
|
|
|
- }
|
|
|
-})
|
|
|
+// } else {
|
|
|
+// redirectGetToken(to,from)
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// next()
|
|
|
+// return
|
|
|
+// }
|
|
|
+// })
|
|
|
// 跳入路由后要对发送pvuv
|
|
|
router.afterEach((to) => {
|
|
|
let postParams = {
|