|
@@ -7,10 +7,10 @@ let level = 0
|
|
|
Vue.use(VueRouter)
|
|
|
const routes = [
|
|
|
// 登陆页面
|
|
|
- // {
|
|
|
- // path: '/',
|
|
|
- // redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
|
- // },
|
|
|
+ {
|
|
|
+ path: '/',
|
|
|
+ redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
|
+ },
|
|
|
{
|
|
|
path: "/404",
|
|
|
component: () => import("../components/404"),
|
|
@@ -19,6 +19,10 @@ const routes = [
|
|
|
path:'/group',
|
|
|
component: () => import('../views/statistics/index')
|
|
|
},
|
|
|
+ {
|
|
|
+ path:'/group',
|
|
|
+ component: () => import('../views/statistics/index')
|
|
|
+ },
|
|
|
// home
|
|
|
{
|
|
|
path: '/home',
|
|
@@ -73,47 +77,49 @@ const router = new VueRouter({
|
|
|
routes,
|
|
|
})
|
|
|
//不需要token的路由
|
|
|
-// const ignore = ['/404', '/legendLibrary', '/legendRules']
|
|
|
-// router.beforeEach(async (to, from, next) => {
|
|
|
-// if (!ignore.includes(to.path)) {
|
|
|
-// const token = query().token
|
|
|
-// const ssoToken = store.getters['ssoToken']
|
|
|
-// if (ssoToken) {
|
|
|
-// // if (to.path === '/group' || to.path === '/home/overview') {
|
|
|
-// // next()
|
|
|
-// // return
|
|
|
-// // }
|
|
|
-// store.commit('SETSSOTOKEN', ssoToken)
|
|
|
-// await store.dispatch('getUserInfo', router)
|
|
|
-// await store.dispatch('getFloors')
|
|
|
-// await store.dispatch('getBrand')
|
|
|
-// let level =store.state.accessLevel
|
|
|
-// console.log(level)
|
|
|
-// // if (level ===0) {
|
|
|
-// // next('/group')
|
|
|
-// // } else {
|
|
|
-// // next('/home/overview')
|
|
|
-// // }
|
|
|
-// } else if (token) {
|
|
|
-// store.commit('SETSSOTOKEN', token)
|
|
|
-// await store.dispatch('getUserInfo', router)
|
|
|
-// next()
|
|
|
-// } else {
|
|
|
-// let lastRoute = {
|
|
|
-// path: to.path,
|
|
|
-// params: to.params,
|
|
|
-// query: to.query,
|
|
|
-// }
|
|
|
-// store.commit('SETLASTROUTER', lastRoute)
|
|
|
-// let ssoServer = 'http://oauth.wanda-dev.cn'
|
|
|
-// let systemcode = 'CAD156',
|
|
|
-// signal = new Date().getTime(),
|
|
|
-// version = '1.0.0'
|
|
|
-// window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// next()
|
|
|
-// return
|
|
|
-// }
|
|
|
-// })
|
|
|
+const ignore = ['/404', '/legendLibrary', '/legendRules']
|
|
|
+router.beforeEach(async (to, from, next) => {
|
|
|
+ if (!ignore.includes(to.path)) {
|
|
|
+ const token = query().token
|
|
|
+ const ssoToken = store.getters['ssoToken']
|
|
|
+ if (ssoToken) {
|
|
|
+ // if (to.path === '/group' || to.path === '/home/homepage') {
|
|
|
+ // next()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ store.commit('SETSSOTOKEN', ssoToken)
|
|
|
+ await store.dispatch('getUserInfo', router)
|
|
|
+ await store.dispatch('getFloors')
|
|
|
+ await store.dispatch('getBrand')
|
|
|
+ let level =store.state.accessLevel
|
|
|
+ console.log(level)
|
|
|
+ // if (level ===0) {
|
|
|
+ // next('/group')
|
|
|
+ // } else {
|
|
|
+ // next('/home/homepage')
|
|
|
+ // }
|
|
|
+ next()
|
|
|
+ } else if (token) {
|
|
|
+ store.commit('SETSSOTOKEN', token)
|
|
|
+ await store.dispatch('getUserInfo', router)
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ let lastRoute = {
|
|
|
+ path: to.path,
|
|
|
+ params: to.params,
|
|
|
+ query: to.query,
|
|
|
+ }
|
|
|
+ store.commit('SETLASTROUTER', lastRoute)
|
|
|
+ let ssoServer = 'http://oauth.wanda-dev.cn'
|
|
|
+ let systemcode = 'CAD156',
|
|
|
+ signal = new Date().getTime(),
|
|
|
+ version = '1.0.0'
|
|
|
+ window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ return
|
|
|
+ }
|
|
|
+})
|
|
|
export default router
|