import Vue from 'vue' import Router from 'vue-router' import {Message} from 'element-ui' const Login = () => { return import(`@/views/Login`) } const Home = () => { return import(`@/views/Home`) } // 首页 const Main = () => { return import(`@/views/main/main`) } // 个人中心 const Personal = () => { return import(`@/views/personal/personal`) } // 充值记录 const customerRechargeMoney = () => { return import(`@/views/customerRechargeMoney/customerRechargeMoney`) } // 个人中心 const Customer = () => { return import(`@/views/customer/Customer`) } const CustomerComPanyDetail = () => { return import(`@/views/customer/customerComPanyDetail`) } const CustomerRecharge = () => { return import(`@/views/customer/customerRecharge`) } const custRecTime = () => { return import(`@/views/customer/custRecTime`) } const custRecMoney = () => { return import(`@/views/customer/custRecMoney`) } const customerEtcChangeInfo = () => { return import(`@/views/customer/customerEtcChangeInfo`) } // 系统管理部分 const User = () => { return import(`@/views/sys/user`) } // 无车部分 const nocarRec = () => { return import(`@/views/noCar/nocarRec.vue`) } const billway = () => { return import(`@/views/noCar/billway.vue`) } const billwayHis = () => { return import(`@/views/noCar/billwayHis.vue`) } const noCarWaybillFile = () => { return import(`@/views/noCar/WaybillFile.vue`) } const nocarInvoice = () => { return import(`@/views/noCar/invoice.vue`) } const nocarInvoiceHis = () => { return import(`@/views/noCar/invoiceHis.vue`) } const billwayException = () => { return import(`@/views/noCar/billwayException.vue`) } const noCarCalculateInfo = () => { return import(`@/views/noCar/calculateInfo.vue`) } const noCarCalculateInfoStatis = () => { return import(`@/views/noCar/calculateInfostatis.vue`) } const hcInvoice = () => { return import(`@/views/noCar/hcInvoice.vue`) } const mothaccount = () => { return import(`@/views/noCar/mothaccount.vue`) } // 自有车部分 const selfcarRec = () => { return import(`@/views/selfCar/selfcarRec.vue`) } const selfCarTrade = () => { return import(`@/views/selfCar/selfCarTrade.vue`) } const selfInvoice = () => { return import(`@/views/selfCar/invoice.vue`) } const selfCarTradeException = () => { return import(`@/views/selfCar/selfCarTradeException.vue`) } const SelfCalculateInfo = () => { return import(`@/views/selfCar/calculateInfo.vue`) } const selfCarApply = () => { return import(`@/views/selfCar/selfCarApply`) } const tradeCarApply = () => { return import(`@/views/selfCar/tradeCarApply`) } // 平台菜单部分 // 发票管理部分(企业注册部分) const Check = () => { return import(`@/views/platform/check/check`) } const CustJb = () => { return import(`@/views/platform/check/customerComPanyDetailCust`) } // 自有车 const Apply = () => { return import(`@/views/platform/apply/apply`) } const Already = () => { return import(`@/views/platform/apply/already`) } const Packaging = () => { return import(`@/views/platform/apply/packaging`) } const selfCarTradeP = () => { return import(`@/views/platform/apply/selfCarTrade`) } const Carbinding = () => { return import(`@/views/platform/carbinding/carbinding`) } const Carbindinglist = () => { return import(`@/views/platform/carbinding/carbindinglist`) } const Carupload = () => { return import(`@/views/platform/car/carupload`) } const Carsuccess = () => { return import(`@/views/platform/car/carsuccess`) } const Waybill = () => { return import(`@/views/platform/waybill/waybill`) } const WaybillFile = () => { return import(`@/views/platform/waybill/WaybillFile`) } const Over = () => { return import(`@/views/platform/waybill/over`) } const History = () => { return import(`@/views/platform/waybill/history`) } const WaybillList = () => { return import(`@/views/platform/waybillmanagement/waybillList`) } const Noinvoice = () => { return import(`@/views/platform/waybillmanagement/noinvoice`) } const Trueinvoice = () => { return import(`@/views/platform/waybillmanagement/trueinvoice`) } const Invoice = () => { return import(`@/views/platform/invoice/invoice`) } const List = () => { return import(`@/views/platform/invoice/list`) } // 参数管理 const paramMagager = () => { return 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: `customerComPanyDetail`, path: `/customerComPanyDetail`, component: CustomerComPanyDetail}, {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: `tradeCarApply`, path: `/tradeCarApply`, component: tradeCarApply}, // 系统管理部分 {name: `User`, path: `/user`, component: User}, // 无车部分 {name: `nocarRec`, path: `/nocarRec`, component: nocarRec}, { name: `billway`, path: `/billway`, component: billway }, { name: `billwayHis`, path: `/billwayHis`, component: billwayHis }, { name: `noCarWaybillFile`, path: `/noCarWaybillFile`, component: noCarWaybillFile }, { name: `nocarInvoice`, path: `/nocarInvoice`, component: nocarInvoice }, { name: `nocarInvoiceHis`, path: `/nocarInvoiceHis`, component: nocarInvoiceHis }, { 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: `CustJb`, path: `/custJb`, component: CustJb }, { 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: `WaybillFile`, path: `/WaybillFile`, component: WaybillFile }, { 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