// router.js import { RouterMount, createRouter, runtimeQuit } from '@/js_sdk/hhyang-uni-simple-router/uni-simple-router'; import tools from "@/service/tools"; const router = createRouter({ platform: process.env.VUE_APP_PLATFORM, routerErrorEach: ({ type, level, ...args }) => { // #ifdef APP-PLUS if (type === 3) { router.$lockStatus = false; tools.onBackPress() } // #endif }, routes: [...ROUTES] }); //全局路由前置守卫 const whiteList = ['/pages/login/index'] router.beforeEach((to, from, next) => { let userToken = uni.getStorageSync('token') // let school_id = uni.getStorageSync('school_id'); // let operate_id = uni.getStorageSync('operate_id'); if (whiteList.indexOf(to.path) < 0 && !userToken) { next('/pages/login/index') } else { // if (!school_id && !operate_id) { // if (whiteList.indexOf(to.path) > 0) { // next() // } else { // next('/pages-address/select-school') // } // } else { // next() // } next() } }); // 全局路由后置守卫 router.afterEach((to, from) => { // console.log('后置守卫to------', to) }) export { router, RouterMount }