import Vue from 'vue'; import Router from 'uni-simple-router'; Vue.use(Router) import utils from '../utils/common.js' //初始化 const router = new Router({ routes:ROUTES //路由表 }); const filters = ['/pages/auth/login','/pages/common/launch'] //进入的路由 要出去的路由 router.beforeEach((to, from, next) => { console.log("路由进入") console.log(to) let index = filters.indexOf(to.path); //过滤 console.log(index) if (index > -1) { next(); return; } var data=utils.isLogin(); console.log(data) if(utils.isLogin()){ console.log("ok") next(); } else{ next({path: "/pages/auth/login"}); } //判断是否校验路由 // if (to.meta.isAure) { // let name = sessionStorage.getItem('username'); // //有状态,并且存在sessionStorage,则next,否则返回登陆页面 // if (name) { // next(); // } else { // next({path: "/login",query:{redirect:to.name}}); // } // } else { // next(); // } }); export default router;