index.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import { createRouter, createWebHashHistory } from 'vue-router'
  2. import { getLocal } from '@/common/js/utils';
  3. const router = createRouter({
  4. // hash模式:createWebHashHistory,history模式:createWebHistory
  5. history: createWebHashHistory(),
  6. routes: [
  7. // 首页
  8. { path: '/', redirect: '/home' },
  9. { path: '/home', name: 'home', component: () => import('@/views/home/index.vue'), meta: { index: 1 } },
  10. // 登录页面
  11. { path: '/login', name: 'login', component: () => import('@/views/login.vue'), meta: { index: 1, noLogin: true } },
  12. // 注册页面
  13. { path: '/register', name: 'register', component: () => import('@/views/register.vue'), meta: { index: 1, noLogin: true } },
  14. // 忘记密码页面
  15. { path: '/forgetpassword', name: 'forgetPassword', component: () => import('@/views/forgetPassword'), meta: { index: 1, noLogin: true } },
  16. // 修改密码页面
  17. { path: '/changepassword', name: 'changePassword', component: () => import('@/views/changePassword'), meta: { index: 1, noLogin: true } },
  18. // 设备页面
  19. { path: '/device', name: 'device', component: () => import('@/views/device/index'), meta: { index: 1 } },
  20. // 设备详情
  21. { path: '/deviceSet', name: 'deviceSet', component: () => import('@/views/device/deviceSet'), meta: { index: 1 } },
  22. // 编辑标签
  23. { path: '/editTag', name: 'editTag', component: () => import('@/views/device/tagSet/index.vue'), meta: { index: 1 } },
  24. // { path: '/deviceOpr', name: 'deviceOpr', component: () => import('@/views/device/deviceOper2.vue'), meta: { index: 1 } },
  25. // 音量调节
  26. { path: '/modulation', name: 'modulation', component: () => import('@/views/device/modulation.vue'), meta: { index: 1} },
  27. // 远程开门
  28. { path: '/openDoor', name: 'openDoor', component: () => import('@/views/device/openDoor.vue'), meta: { index: 1} },
  29. // 远程做糖
  30. { path: '/doSugar', name: 'doSugar', component: () => import('@/views/device/doSugar.vue'), meta: { index: 1} },
  31. // 今日做糖列表
  32. { path: '/toDaySugarList', name: 'toDaySugarList', component: () => import('@/views/device/toDaySugarList.vue'), meta: { index: 1} },
  33. // 定时开关
  34. { path: '/alarmClock', name: 'alarmClock', component: () => import('@/views/device/alarmClock.vue'), meta: { index: 1} },
  35. // 设置闹钟
  36. { path: '/alarmClockAdd', name: 'alarmClockAdd', component: () => import('@/views/device/alarmClockSet/index.vue'), meta: { index: 1} },
  37. { path: '/alarmClockSet', name: 'alarmClockSet', component: () => import('@/views/device/alarmClockSet/index.vue'), meta: { index: 1} },
  38. // 参数设置
  39. { path: '/paramsSet', name: 'paramsSet', component: () => import('@/views/device/paramsSet/index.vue'), meta: { index: 1} },
  40. { path: '/paramsSetInfo', name: 'paramsSetInfo', component: () => import('@/views/device/paramsSet/paramsSetInfo.vue'), meta: { index: 1} },
  41. // 添加分销人
  42. { path: '/saveProportion', name: 'saveProportion', component: () => import('@/views/device/saveProportion/index.vue'), meta: { index: 1} },
  43. // 设备充值
  44. { path: '/recharge', name: 'recharge', component: () => import('@/views/device/recharge.vue'), meta: { index: 1} },
  45. // 机器排行
  46. { path: '/robotranking', name: 'robotranking', component: () => import('@/views/robotRanking.vue'), meta: { index: 1 } },
  47. // 个人中心
  48. { path: '/user', name: 'user', component: () => import('@/views/user.vue'), meta: { index: 1 } },
  49. // 备用提现账号
  50. { path: '/shandeMch', name: 'shandeMch', component: () => import('@/views/shandeMch/index'), meta: { index: 1 } },
  51. // 提现账号
  52. { path: '/joinpayMch', name: 'joinpayMch', component: () => import('@/views/joinpayMch/index'), meta: { index: 1 } },
  53. // 自充值
  54. { path: '/uniPay', name: 'uniPay', component: () => import('@/views/uniPay/index'), meta: { index: 1 } },
  55. // 优惠码
  56. { path: '/discountCode', name: 'discountCode', component: () => import('@/views/discountCode/index'), meta: { index: 1 } },
  57. { path: '/payCode', name: 'payCode', component: () => import('@/views/discountCode/payCode'), meta: { index: 1 } },
  58. // 分销设置
  59. { path: '/distributionSet', name: 'distributionSet', component: () => import('@/views/distributionSet/index'), meta: { index: 1 } },
  60. { path: '/distributionDetail', name: 'distributionDetail', component: () => import('@/views/distributionSet/detail'), meta: { index: 1 } },
  61. // 账号权限
  62. { path: '/accountPer', name: 'accountPer', component: () => import('@/views/accountPer/index'), meta: { index: 1 } },
  63. // 添加账号
  64. { path: '/accountPerAdd', name: 'accountPerAdd', component: () => import('@/views/accountPer/add'), meta: { index: 1 } },
  65. // 角色权限
  66. { path: '/role', name: 'role', component: () => import('@/views/role/index'), meta: { index: 1 } },
  67. { path: '/roleSet', name: 'roleSet', component: () => import('@/views/role/add'), meta: { index: 1 } },
  68. // 商户管理
  69. { path: '/merchantManage', name: 'merchantManage', component: () => import('@/views/merchantManage/index'), meta: { index: 1 } },
  70. { path: '/merchantSet', name: 'merchantSet', component: () => import('@/views/merchantManage/set'), meta: { index: 1 } },
  71. // 广告管理
  72. { path: '/advertManage', name: 'advertManage', component: () => import('@/views/advertManage/index'), meta: { index: 1 } },
  73. { path: '/advertSet', name: 'advertSet', component: () => import('@/views/advertManage/adSet.vue'), meta: { index: 1 } },
  74. // 广告规则
  75. { path: '/advertRule', name: 'advertRule', component: () => import('@/views/advertManage/advertRule/index.vue'), meta: { index: 1 } },
  76. // 广告规则新增
  77. { path: '/advertRuleAdd', name: 'advertRuleAdd', component: () => import('@/views/advertManage/advertRule/add.vue'), meta: { index: 1 } },
  78. { path: '/advertRuleAddScreen', name: 'advertRuleAddScreen', component: () => import('@/views/advertManage/advertRule/screen.vue'), meta: { index: 1 } },
  79. // apk管理
  80. { path: '/apkManage', name: 'apkManage', component: () => import('@/views/apkManage/index'), meta: { index: 1 } },
  81. // apk管理-新增
  82. { path: '/apkManageAdd', name: 'apkManageAdd', component: () => import('@/views/apkManage/add'), meta: { index: 1 } },
  83. // 报警历史
  84. { path: '/alarmHistory', name: 'alarmHistory', component: () => import('@/views/alarmHistory/index'), meta: { index: 1 } },
  85. // 订单导出
  86. { path: '/orderExport', name: 'orderExport', component: () => import('@/views/orderExport/index'), meta: { index: 1 } },
  87. // 杉德分账导出
  88. { path: '/subLedgerManage', name: 'subLedgerManage', component: () => import('@/views/subLedgerManage/index'), meta: { index: 1 } },
  89. // 任务消息
  90. { path: '/taskMessage', name: 'taskMessage', component: () => import('@/views/taskMessage/index'), meta: { index: 1 } },
  91. // 设备审批
  92. { path: '/taskEquipment', name: 'taskEquipment', component: () => import('@/views/taskMessage/equipment'), meta: { index: 1 } },
  93. // 提现审批
  94. { path: '/taskJoinPayMchCheck', name: 'taskJoinPayMchCheck', component: () => import('@/views/taskMessage/joinpayMchCheck'), meta: { index: 1 } },
  95. // 提现审批详情
  96. { path: '/taskJoinPayMchCheckInfo', name: 'taskJoinPayMchCheckInfo', component: () => import('@/views/taskMessage/joinpayMchCheck/info'), meta: { index: 1 } },
  97. // 分销审批
  98. { path: '/taskProportion', name: 'taskProportion', component: () => import('@/views/taskMessage/proportion'), meta: { index: 1 } },
  99. // 订单中心
  100. { path: '/orderCenter', name: 'orderCenter', component: () => import('@/views/orderCenter/index'), meta: { index: 1 } },
  101. // 测试
  102. { path: '/test', name: 'test', component: () => import('@/views/test'), meta: { index: 1 } },
  103. // 标签管理
  104. { path: '/labelMan', name: 'labelMan', component: () => import('@/views/labelMan/index'), meta: { index: 1 } },
  105. // 标签管理-新增
  106. { path: '/labelManAdd', name: 'labelManAdd', component: () => import('@/views/labelMan/add'), meta: { index: 1 } },
  107. // 修改价格
  108. { path: '/modifyPrice', name: 'modifyPrice', component: () => import('@/views/device/modifyPrice/index'), meta: { index: 1 } },
  109. // 查看定位
  110. { path: '/viewPosition', name: 'viewPosition', component: () => import('@/views/device/viewPosition/index'), meta: { index: 1 } },
  111. // 设备编辑-编辑规则
  112. { path: '/editAdRule', name: 'editAdRule', component: () => import('@/views/device/editAdRule/index'), meta: { index: 1 } },
  113. // 跳转空中云汇
  114. { path: '/hpp', name: 'Hpp', component: () => import('@/views/Hpp.vue'), meta: { index: 1, noLogin: true } },
  115. ]
  116. });
  117. // 路由守卫处理
  118. router.beforeEach((to, from, next) => {
  119. // 页面带有不需要识别登录状态的跳过登录验证
  120. if (to.meta.noLogin) {
  121. next();
  122. } else {
  123. const user = getLocal('loginUser');
  124. if (!user || user === '') {
  125. // 没有登录信息跳转登录页面
  126. router.push('/login');
  127. } else {
  128. const userObject = JSON.parse(user);
  129. // 登录信息异常跳转登录页面
  130. if (!userObject) { router.push('/login'); }
  131. if (typeof userObject.id !== 'number') { router.push('/login'); }
  132. }
  133. next();
  134. }
  135. });
  136. export default router;