|
|
|
@ -47,18 +47,22 @@ const router = new VueRouter({ |
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
|
//NProgress.start();
|
|
|
|
|
let user = JSON.parse(sessionStorage.getItem('user')); |
|
|
|
|
if (!user && to.path != '/login') { |
|
|
|
|
if (/yyyfLoginBack/.test(to.path)) { |
|
|
|
|
next() |
|
|
|
|
// } else if (/train/.test(to.path)) {//暂时这么写,user是需要有值的,这里先方便页面
|
|
|
|
|
// next()
|
|
|
|
|
} else { |
|
|
|
|
if (!user && to.path != '/login' && !/yyyfLoginBack/.test(to.path)) { |
|
|
|
|
next({path: '/login'}) |
|
|
|
|
} else if (user && to.path == '/login') { |
|
|
|
|
if (user.userType == 3) { |
|
|
|
|
next({name: 'Index'}) |
|
|
|
|
} else { |
|
|
|
|
next({path: '/yyyfLoginBack'})//next()
|
|
|
|
|
} |
|
|
|
|
}else if(user && to.path =='/login'){ |
|
|
|
|
next({name:'Index'}) |
|
|
|
|
} else if (user && user.userType == 3 && to.path == '/yyyfLoginBack') { |
|
|
|
|
} else if (user && user.userType == 3 && to.path == '/yyyfLoginBack') {//学校管理员
|
|
|
|
|
if (to.query && (to.query.userType == 1 || to.query.userType == 2)) { |
|
|
|
|
next() |
|
|
|
|
} else { |
|
|
|
|
next({name: 'Index'}) |
|
|
|
|
} |
|
|
|
|
} else if (user && (user.userType == 1 || user.userType == 2) && to.path == '/') { |
|
|
|
|
next({path: '/yyyfLoginBack'})//next({path: '/login'})
|
|
|
|
|
} else { |
|
|
|
|
next() |
|
|
|
|
} |
|
|
|
|