import Vue from 'vue'; import Router from 'vue-router'; import { Message } from 'element-ui'; const Login = () => import('@/views/Login'); const Home = () => import('@/views/Home'); // 首页 const Main = () => import('@/views/main/main'); // 个人中心 const Personal = () => import('@/views/personal/personal'); // 充值记录 const customerRechargeMoney = () => import('@/views/customerRechargeMoney/customerRechargeMoney'); // 个人中心 const Customer = () => import('@/views/customer/Customer'); const CustomerRecharge = () => import('@/views/customer/customerRecharge'); const custRecTime = () => import('@/views/customer/custRecTime'); const custRecMoney = () => import('@/views/customer/custRecMoney'); const customerEtcChangeInfo = () => import('@/views/customer/customerEtcChangeInfo'); // 系统管理部分 const User = () => import('@/views/sys/user'); // 无车部分 const nocarRec = () => import('@/views/noCar/nocarRec.vue'); const billway = () => import('@/views/noCar/billway.vue'); const nocarInvoice = () => import('@/views/noCar/invoice.vue'); const billwayException = () => import('@/views/noCar/billwayException.vue'); const noCarCalculateInfo = () => import('@/views/noCar/calculateInfo.vue'); const noCarCalculateInfoStatis = () => import('@/views/noCar/calculateInfostatis.vue'); const hcInvoice = () => import('@/views/noCar/hcInvoice.vue'); const mothaccount = () => import('@/views/noCar/mothaccount.vue'); // 自有车部分 const selfcarRec = () => import('@/views/selfCar/selfcarRec.vue'); const selfCarTrade = () => import('@/views/selfCar/selfCarTrade.vue'); const selfInvoice = () => import('@/views/selfCar/invoice.vue'); const selfCarTradeException = () => import('@/views/selfCar/selfCarTradeException.vue'); const SelfCalculateInfo = () => import('@/views/selfCar/calculateInfo.vue'); const selfCarApply = () => import('@/views/selfCar/selfCarApply'); // 平台菜单部分 // 发票管理部分(企业注册部分) const Check = () => import('@/views/platform/check/check'); // 自有车 const Apply = () => import('@/views/platform/apply/apply'); const Already = () => import('@/views/platform/apply/already'); const Packaging = () => import('@/views/platform/apply/packaging'); const selfCarTradeP = () => import('@/views/platform/apply/selfCarTrade'); const Carbinding = () => import('@/views/platform/carbinding/carbinding'); const Carbindinglist = () => import('@/views/platform/carbinding/carbindinglist'); const Carupload = () => import('@/views/platform/car/carupload'); const Carsuccess = () => import('@/views/platform/car/carsuccess'); const Waybill = () => import('@/views/platform/waybill/waybill'); const Over = () => import('@/views/platform/waybill/over'); const History = () => import('@/views/platform/waybill/history'); const WaybillList = () => import('@/views/platform/waybillmanagement/waybillList'); const Noinvoice = () => import('@/views/platform/waybillmanagement/noinvoice'); const Trueinvoice = () => import('@/views/platform/waybillmanagement/trueinvoice'); const Invoice = () => import('@/views/platform/invoice/invoice'); const List = () => import('@/views/platform/invoice/list'); // 参数管理 const paramMagager = () => import('@/views/manager/paramMagager.vue'); Vue.use(Router); const router = new Router({ base: '/jkcredit/', mode: 'history', routes: [ { name: 'Login', path: '/login', component: Login }, { name: 'Home', path: '/', component: Home, redirect: '/main', children: [ // 首页 { name: 'Main', path: '/main', component: Main }, // 个人中心 { name: 'Personal', path: '/personal', component: Personal }, // 充值记录 { name: 'customerRechargeMoney', path: '/customerRechargeMoney', component: customerRechargeMoney }, // 客户管理 { name: 'Customer', path: '/customer', component: Customer }, { name: 'customerRecharge', path: '/CustomerRecharge', component: CustomerRecharge }, { name: 'custRecTime', path: '/custRecTime', component: custRecTime }, { name: 'custRecMoney', path: '/custRecMoney', component: custRecMoney }, { name: 'customerEtcChangeInfo', path: '/customerEtcChangeInfo', component: customerEtcChangeInfo }, { name: 'selfCarApply', path: '/selfCarApply', component: selfCarApply }, // 系统管理部分 { name: 'User', path: '/user', component: User }, // 无车部分 { name: 'nocarRec', path: '/nocarRec', component: nocarRec }, { name: 'billway', path: '/billway', component: billway }, { name: 'nocarInvoice', path: '/nocarInvoice', component: nocarInvoice }, { name: 'billwayException', path: '/billwayException', component: billwayException }, { name: 'noCarCalculateInfo', path: '/noCarCalculateInfo', component: noCarCalculateInfo }, { name: 'noCarCalculateInfoStatis', path: '/noCarCalculateInfoStatis', component: noCarCalculateInfoStatis }, { name: 'hcInvoice', path: '/hcInvoice', component: hcInvoice }, { name: 'mothaccount', path: '/mothaccount', component: mothaccount }, // 自有车部分 { name: 'selfcarRec', path: '/selfcarRec', component: selfcarRec }, { name: 'selfInvoice', path: '/selfInvoice', component: selfInvoice }, { name: 'selfCarTrade', path: '/selfCarTrade', component: selfCarTrade }, { name: 'selfCarTradeException', path: '/selfCarTradeException', component: selfCarTradeException }, { name: 'SelfCalculateInfo', path: '/SelfCalculateInfo', component: SelfCalculateInfo }, // 平台菜单部分 { name: 'Check', path: '/check', component: Check }, { name: 'Apply', path: '/apply', component: Apply }, { name: 'Already', path: '/already', component: Already }, { name: 'Packaging', path: '/packaging', component: Packaging }, { name: 'selfCarTradeP', path: '/selfCarTradeP', component: selfCarTradeP }, { name: 'Carbinding', path: '/carbinding', component: Carbinding }, { name: 'Carbindinglist', path: '/carbindinglist', component: Carbindinglist }, { name: 'Carupload', path: '/carupload', component: Carupload }, { name: 'Carsuccess', path: '/carsuccess', component: Carsuccess }, { name: 'Waybill', path: '/waybill', component: Waybill }, { name: 'Over', path: '/over', component: Over }, { name: 'History', path: '/history', component: History }, { name: 'WaybillList', path: '/waybillList', component: WaybillList }, { name: 'Noinvoice', path: '/noinvoice', component: Noinvoice }, { name: 'Trueinvoice', path: '/trueinvoice', component: Trueinvoice }, { name: 'Invoice', path: '/invoice', component: Invoice }, { name: 'List', path: '/list', component: List }, // 参数管理 { name: 'paramMagager', path: '/paramMagager', component: paramMagager } ] } ] }); router.beforeEach((to, from, next) => { // console.log(to); // console.log(from); // next(); // 如果是登录的时候不判断token ,不是登录才判断token // console.log(to); if (to.name && to.name.toLocaleLowerCase() !== 'login') { // 判断token const token = sessionStorage.getItem('token'); if (!token) { // 没有token,跳转到登录页面 // this.$router.push('/login') router.push('/login'); // 提示 // this.$message.warning('请先登录'); Message.warning('请先登录'); return; } } next(); }); export default router;