router.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. const routerPush = Router.prototype.push
  4. Router.prototype.push = function push(location) {
  5. // if(typeof(location)=="string"){
  6. // var Separator = "&";
  7. // if(location.indexOf('?')==-1) { Separator='?'; }
  8. // location = location + Separator + "random=" + Math.random();
  9. // }
  10. return routerPush.call(this, location).catch(error => error)
  11. }
  12. Vue.use(Router)
  13. let router = new Router({
  14. // mode: 'history',
  15. base: process.env.BASE_URL,
  16. routes: [{
  17. path: '/',
  18. redirect: '/home'
  19. },
  20. {
  21. path: '/login',
  22. name: 'login',
  23. component: () => import('./views/Login.vue'),
  24. meta: {
  25. title: '登录'
  26. }
  27. },
  28. {
  29. path: '/home',
  30. name: 'home',
  31. component: () => import('./views/Home.vue'),
  32. redirect: '/home/statistics',
  33. meta: {
  34. title: ''
  35. },
  36. children: [{
  37. path: 'regList',
  38. name: 'regList',
  39. component: () => import('./views/home/regList.vue'),
  40. meta: {
  41. title: 'Token列表'
  42. }
  43. },
  44. {
  45. path: 'buyReg',
  46. name: 'buyReg',
  47. component: () => import('./views/home/buyReg.vue'),
  48. meta: {
  49. title: '购买注册码'
  50. }
  51. },
  52. {
  53. path: 'abonementList',
  54. name: 'abonementList',
  55. component: () => import('./views/home/abonementList.vue'),
  56. meta: {
  57. title: '用户列表'
  58. }
  59. },
  60. {
  61. path: 'orderList',
  62. name: 'orderList',
  63. component: () => import('./views/home/orderList.vue'),
  64. meta: {
  65. title: '订单列表'
  66. }
  67. },
  68. {
  69. path: 'addOrder',
  70. name: 'addOrder',
  71. component: () => import('./views/home/addOrder.vue'),
  72. meta: {
  73. title: '添加订单'
  74. }
  75. },
  76. {
  77. path: 'addressList',
  78. name: 'addressList',
  79. component: () => import('./views/home/addressList.vue'),
  80. meta: {
  81. title: '地址列表'
  82. }
  83. },
  84. {
  85. path: 'rechangeList',
  86. name: 'rechangeList',
  87. component: () => import('./views/home/rechangeList.vue'),
  88. meta: {
  89. title: '充值记录'
  90. }
  91. },
  92. {
  93. path: 'rechange',
  94. name: 'rechange',
  95. component: () => import('./views/home/rechange.vue'),
  96. meta: {
  97. title: '充值'
  98. }
  99. },
  100. {
  101. path: 'taking',
  102. name: 'taking',
  103. component: () => import('./views/home/taking.vue'),
  104. meta: {
  105. title: '提现'
  106. }
  107. },
  108. {
  109. path: 'takingList',
  110. name: 'takingList',
  111. component: () => import('./views/home/takingList.vue'),
  112. meta: {
  113. title: '提现记录'
  114. }
  115. },
  116. {
  117. path: 'transferList',
  118. name: 'transferList',
  119. component: () => import('./views/home/transferList.vue'),
  120. meta: {
  121. title: '转账记录'
  122. }
  123. },
  124. {
  125. path: 'transfer',
  126. name: 'transferList',
  127. component: () => import('./views/home/transfer.vue'),
  128. meta: {
  129. title: '转账'
  130. }
  131. },
  132. {
  133. path: 'setAgent',
  134. name: 'setAgent',
  135. component: () => import('./views/home/setAgent.vue'),
  136. meta: {
  137. title: '设置下级代理'
  138. }
  139. },
  140. {
  141. path: 'statistics',
  142. name: 'statistics',
  143. component: () => import('./views/home/statistics.vue'),
  144. meta: {
  145. title: '统计'
  146. }
  147. },
  148. {
  149. path: 'dlstatistics',
  150. name: 'dlstatistics',
  151. component: () => import('./views/home/dlstatistics.vue'),
  152. meta: {
  153. title: '统计'
  154. }
  155. },
  156. {
  157. path: 'setPas',
  158. name: 'setPas',
  159. component: () => import('./views/home/setPas.vue'),
  160. meta: {
  161. title: '交易密码'
  162. }
  163. },
  164. {
  165. path: 'setUserinfo',
  166. name: 'setUserinfo',
  167. component: () => import('./views/home/setUserinfo.vue'),
  168. meta: {
  169. title: '修改个人信息'
  170. }
  171. },
  172. {
  173. path: 'money',
  174. name: 'money',
  175. component: () => import('./views/home/money.vue'),
  176. meta: {
  177. title: '资金流水'
  178. }
  179. },
  180. ]
  181. },
  182. {
  183. path: '*',
  184. redirect: '/home'
  185. }
  186. ]
  187. })
  188. // 路由导航守卫
  189. router.beforeEach((to, from, next) => {
  190. if (to.path === '/login') return next()
  191. const tokenStr = window.sessionStorage.getItem('token')
  192. if (!tokenStr) return next('/login')
  193. next()
  194. })
  195. export default router