1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import modules from './modules'
- import Vue from 'vue'
- import Router from '@/plugin/uni-simple-router/index.js'
- import {ACCESS_TOKEN} from '@/common/util/constants.js'
- import store from '@/store/index.js';
- Vue.use(Router)
- const router = new Router({
- encodeURI:true,
- routes: [...modules],
- });
- const whiteList = ['/pages/login/login']
- router.beforeEach((to, from, next) => {
-
- let token=store.getters.token
- console.log(token)
- if(token!=null &&token!=""){
- next()
- }else{
- if (whiteList.indexOf(to.path) !== -1) {
- console.log(to.path)
- next()
- }else{
- uni.clearStorageSync()
- store.commit('SET_TOKEN',"");
-
- uni.navigateTo({
- url:'/pages/login/login'
- })
-
- }
- }
- })
- router.afterEach((to, from) => {
- console.log("afterEach")
- })
- export default router;
|