index.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. import { Message } from 'element-ui';
  4. const Login = () => import('@/views/Login');
  5. const Home = () => import('@/views/Home');
  6. // 首页
  7. const Main = () => import('@/views/main/main');
  8. // 个人中心
  9. const Personal = () => import('@/views/personal/personal');
  10. // 充值记录
  11. const customerRechargeMoney = () => import('@/views/customerRechargeMoney/customerRechargeMoney');
  12. // 个人中心
  13. const Customer = () => import('@/views/customer/Customer');
  14. const CustomerRecharge = () => import('@/views/customer/customerRecharge');
  15. const custRecTime = () => import('@/views/customer/custRecTime');
  16. const custRecMoney = () => import('@/views/customer/custRecMoney');
  17. const customerEtcChangeInfo = () => import('@/views/customer/customerEtcChangeInfo');
  18. // 系统管理部分
  19. const User = () => import('@/views/sys/user');
  20. // 无车部分
  21. const nocarRec = () => import('@/views/noCar/nocarRec.vue');
  22. const billway = () => import('@/views/noCar/billway.vue');
  23. const nocarInvoice = () => import('@/views/noCar/invoice.vue');
  24. const billwayException = () => import('@/views/noCar/billwayException.vue');
  25. const noCarCalculateInfo = () => import('@/views/noCar/calculateInfo.vue');
  26. const noCarCalculateInfoStatis = () => import('@/views/noCar/calculateInfostatis.vue');
  27. const hcInvoice = () => import('@/views/noCar/hcInvoice.vue');
  28. const mothaccount = () => import('@/views/noCar/mothaccount.vue');
  29. // 自有车部分
  30. const selfcarRec = () => import('@/views/selfCar/selfcarRec.vue');
  31. const selfCarTrade = () => import('@/views/selfCar/selfCarTrade.vue');
  32. const selfInvoice = () => import('@/views/selfCar/invoice.vue');
  33. const selfCarTradeException = () => import('@/views/selfCar/selfCarTradeException.vue');
  34. const SelfCalculateInfo = () => import('@/views/selfCar/calculateInfo.vue');
  35. const selfCarApply = () => import('@/views/selfCar/selfCarApply');
  36. // 平台菜单部分
  37. // 发票管理部分(企业注册部分)
  38. const Check = () => import('@/views/platform/check/check');
  39. // 自有车
  40. const Apply = () => import('@/views/platform/apply/apply');
  41. const Already = () => import('@/views/platform/apply/already');
  42. const Packaging = () => import('@/views/platform/apply/packaging');
  43. const selfCarTradeP = () => import('@/views/platform/apply/selfCarTrade');
  44. const Carbinding = () => import('@/views/platform/carbinding/carbinding');
  45. const Carbindinglist = () => import('@/views/platform/carbinding/carbindinglist');
  46. const Carupload = () => import('@/views/platform/car/carupload');
  47. const Carsuccess = () => import('@/views/platform/car/carsuccess');
  48. const Waybill = () => import('@/views/platform/waybill/waybill');
  49. const Over = () => import('@/views/platform/waybill/over');
  50. const History = () => import('@/views/platform/waybill/history');
  51. const WaybillList = () => import('@/views/platform/waybillmanagement/waybillList');
  52. const Noinvoice = () => import('@/views/platform/waybillmanagement/noinvoice');
  53. const Trueinvoice = () => import('@/views/platform/waybillmanagement/trueinvoice');
  54. const Invoice = () => import('@/views/platform/invoice/invoice');
  55. const List = () => import('@/views/platform/invoice/list');
  56. // 参数管理
  57. const paramMagager = () => import('@/views/manager/paramMagager.vue');
  58. Vue.use(Router);
  59. const router = new Router({
  60. base: '/jkcredit/',
  61. mode: 'history',
  62. routes: [
  63. { name: 'Login', path: '/login', component: Login },
  64. {
  65. name: 'Home',
  66. path: '/',
  67. component: Home,
  68. redirect: '/main',
  69. children: [
  70. // 首页
  71. { name: 'Main', path: '/main', component: Main },
  72. // 个人中心
  73. { name: 'Personal', path: '/personal', component: Personal },
  74. // 充值记录
  75. { name: 'customerRechargeMoney', path: '/customerRechargeMoney', component: customerRechargeMoney },
  76. // 客户管理
  77. { name: 'Customer', path: '/customer', component: Customer },
  78. { name: 'customerRecharge', path: '/CustomerRecharge', component: CustomerRecharge },
  79. { name: 'custRecTime', path: '/custRecTime', component: custRecTime },
  80. { name: 'custRecMoney', path: '/custRecMoney', component: custRecMoney },
  81. { name: 'customerEtcChangeInfo', path: '/customerEtcChangeInfo', component: customerEtcChangeInfo },
  82. { name: 'selfCarApply', path: '/selfCarApply', component: selfCarApply },
  83. // 系统管理部分
  84. { name: 'User', path: '/user', component: User },
  85. // 无车部分
  86. { name: 'nocarRec', path: '/nocarRec', component: nocarRec },
  87. { name: 'billway', path: '/billway', component: billway },
  88. { name: 'nocarInvoice', path: '/nocarInvoice', component: nocarInvoice },
  89. { name: 'billwayException', path: '/billwayException', component: billwayException },
  90. { name: 'noCarCalculateInfo', path: '/noCarCalculateInfo', component: noCarCalculateInfo },
  91. { name: 'noCarCalculateInfoStatis', path: '/noCarCalculateInfoStatis', component: noCarCalculateInfoStatis },
  92. { name: 'hcInvoice', path: '/hcInvoice', component: hcInvoice },
  93. { name: 'mothaccount', path: '/mothaccount', component: mothaccount },
  94. // 自有车部分
  95. { name: 'selfcarRec', path: '/selfcarRec', component: selfcarRec },
  96. { name: 'selfInvoice', path: '/selfInvoice', component: selfInvoice },
  97. { name: 'selfCarTrade', path: '/selfCarTrade', component: selfCarTrade },
  98. { name: 'selfCarTradeException', path: '/selfCarTradeException', component: selfCarTradeException },
  99. { name: 'SelfCalculateInfo', path: '/SelfCalculateInfo', component: SelfCalculateInfo },
  100. // 平台菜单部分
  101. { name: 'Check', path: '/check', component: Check },
  102. { name: 'Apply', path: '/apply', component: Apply },
  103. { name: 'Already', path: '/already', component: Already },
  104. { name: 'Packaging', path: '/packaging', component: Packaging },
  105. { name: 'selfCarTradeP', path: '/selfCarTradeP', component: selfCarTradeP },
  106. { name: 'Carbinding', path: '/carbinding', component: Carbinding },
  107. { name: 'Carbindinglist', path: '/carbindinglist', component: Carbindinglist },
  108. { name: 'Carupload', path: '/carupload', component: Carupload },
  109. { name: 'Carsuccess', path: '/carsuccess', component: Carsuccess },
  110. { name: 'Waybill', path: '/waybill', component: Waybill },
  111. { name: 'Over', path: '/over', component: Over },
  112. { name: 'History', path: '/history', component: History },
  113. { name: 'WaybillList', path: '/waybillList', component: WaybillList },
  114. { name: 'Noinvoice', path: '/noinvoice', component: Noinvoice },
  115. { name: 'Trueinvoice', path: '/trueinvoice', component: Trueinvoice },
  116. { name: 'Invoice', path: '/invoice', component: Invoice },
  117. { name: 'List', path: '/list', component: List },
  118. // 参数管理
  119. { name: 'paramMagager', path: '/paramMagager', component: paramMagager }
  120. ]
  121. }
  122. ]
  123. });
  124. router.beforeEach((to, from, next) => {
  125. // console.log(to);
  126. // console.log(from);
  127. // next();
  128. // 如果是登录的时候不判断token ,不是登录才判断token
  129. // console.log(to);
  130. if (to.name && to.name.toLocaleLowerCase() !== 'login') {
  131. // 判断token
  132. const token = sessionStorage.getItem('token');
  133. if (!token) {
  134. // 没有token,跳转到登录页面
  135. // this.$router.push('/login')
  136. router.push('/login');
  137. // 提示
  138. // this.$message.warning('请先登录');
  139. Message.warning('请先登录');
  140. return;
  141. }
  142. }
  143. next();
  144. });
  145. export default router;