|
@@ -17,7 +17,7 @@ const router = createRouter({
|
|
|
//全局路由前置守卫
|
|
//全局路由前置守卫
|
|
|
const whiteList = ['/pages/login/index','/pages/login/register']
|
|
const whiteList = ['/pages/login/index','/pages/login/register']
|
|
|
|
|
|
|
|
-router.beforeEach((to, from, next) => {
|
|
|
|
|
|
|
+router.beforeEach(async (to, from, next) => {
|
|
|
// tools.showLoading()
|
|
// tools.showLoading()
|
|
|
let userToken=''
|
|
let userToken=''
|
|
|
if (to.query.token ) {
|
|
if (to.query.token ) {
|
|
@@ -29,8 +29,19 @@ router.beforeEach((to, from, next) => {
|
|
|
console.log('userToken:'+userToken)
|
|
console.log('userToken:'+userToken)
|
|
|
|
|
|
|
|
if(whiteList.indexOf(to.path)<0 && !userToken){
|
|
if(whiteList.indexOf(to.path)<0 && !userToken){
|
|
|
- // next('/pages/login/index');
|
|
|
|
|
- next();
|
|
|
|
|
|
|
+ console.log('----------------------')
|
|
|
|
|
+ await tools.weiXinLogin().then(isLogin=>{
|
|
|
|
|
+ console.log('-----------isLogin-----------')
|
|
|
|
|
+ if(isLogin){
|
|
|
|
|
+ next();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ next('/pages/login/index');
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(e=>{
|
|
|
|
|
+ next('/pages/login/index');
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // next();
|
|
|
}else {
|
|
}else {
|
|
|
next();
|
|
next();
|
|
|
}
|
|
}
|