index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. // Home 页面
  10. {
  11. path: "/home",
  12. name: "home",
  13. component: () => import("@/views/home/HomeIndex.vue"),
  14. meta: { index: 1 },
  15. },
  16. // 登录页面
  17. {
  18. path: "/login",
  19. name: "login",
  20. component: () => import("@/views/login/LoginIndex.vue"),
  21. meta: { index: 1, noLogin: true },
  22. },
  23. // 注册页面
  24. {
  25. path: "/register",
  26. name: "register",
  27. component: () => import("@/views/login/Register.vue"),
  28. meta: { index: 1, noLogin: true },
  29. },
  30. // 忘记密码页面
  31. {
  32. path: "/forgetPassword",
  33. name: "forgetPassword",
  34. component: () => import("@/views/login/ForgetPassword.vue"),
  35. meta: { index: 1, noLogin: true },
  36. },
  37. // 修改密码页面
  38. {
  39. path: "/changepassword",
  40. name: "changePassword",
  41. component: () => import("@/views/user/ChangePassword.vue"),
  42. meta: { index: 1, noLogin: true },
  43. },
  44. // 交易中心
  45. {
  46. path: "/trading",
  47. name: "trading",
  48. component: () => import("@/views/trading/TradingIndex.vue"),
  49. meta: { index: 1 },
  50. },
  51. // 买入股票
  52. {
  53. path: "/tradingBuy",
  54. name: "tradingBuy",
  55. component: () => import("@/views/trading/TradingBuy.vue"),
  56. meta: { index: 1 },
  57. },
  58. // 卖出股票
  59. {
  60. path: "/tradingSell",
  61. name: "tradingSell",
  62. component: () => import("@/views/trading/TradingSell.vue"),
  63. meta: { index: 1 },
  64. },
  65. // 交易历史
  66. {
  67. path: "/transactionHistory",
  68. name: "transactionHistory",
  69. component: () => import("@/views/trading/TransactionHistory.vue"),
  70. meta: { index: 1 },
  71. },
  72. // 买家付款确认列表
  73. {
  74. path: "/buyConfList",
  75. name: "buyConfList",
  76. component: () => import("@/views/buyOrSell/BuyConfList.vue"),
  77. meta: { index: 1 },
  78. },
  79. // 买家付款
  80. {
  81. path: "/buyConf",
  82. name: "buyConf",
  83. component: () => import("@/views/buyOrSell/BuyConf.vue"),
  84. meta: { index: 1 },
  85. },
  86. // 卖家收款确认列表
  87. {
  88. path: "/sellConfList",
  89. name: "sellConfList",
  90. component: () => import("@/views/buyOrSell/SellConfList.vue"),
  91. meta: { index: 1 },
  92. },
  93. // 卖家确认收款
  94. {
  95. path: "/sellConf",
  96. name: "sellConf",
  97. component: () => import("@/views/buyOrSell/SellConf.vue"),
  98. meta: { index: 1 },
  99. },
  100. // 测试组件通信
  101. {
  102. path: '/testConf',
  103. name: 'testConf',
  104. component: () => import("@/views/test/Father.vue"),
  105. },
  106. // 持仓
  107. {
  108. path: "/position",
  109. name: "position",
  110. component: () => import("@/views/position/PositionIndex.vue"),
  111. meta: { index: 1 },
  112. },
  113. // 个人中心
  114. {
  115. path: "/user",
  116. name: "user",
  117. component: () => import("@/views/user/UserIndex.vue"),
  118. meta: { index: 1 },
  119. },
  120. // 公告编辑
  121. {
  122. path: "/announcement",
  123. name: "announcement",
  124. component: () => import("@/views/announcement/index"),
  125. meta: { index: 1 },
  126. },
  127. // 异议反馈
  128. {
  129. path: "/objectionFeedback",
  130. name: "feedback",
  131. component: () => import("@/views/feedback/FeedbackIndex.vue"),
  132. meta: { index: 1 },
  133. },
  134. // 任务消息/系统管理
  135. {
  136. path: "/taskMessage",
  137. name: "taskMessage",
  138. component: () => import("@/views/taskMessage/index"),
  139. meta: { index: 1 },
  140. },
  141. // 账号审核列表
  142. {
  143. path: "/taskAccountList",
  144. name: "taskAccountList",
  145. component: () => import("@/views/taskMessage/TaskAccountList.vue"),
  146. meta: { index: 1 },
  147. },
  148. // 账号审核
  149. {
  150. path: "/taskAccount",
  151. name: "taskAccount",
  152. component: () => import("@/views/taskMessage/TaskAccount.vue"),
  153. meta: { index: 1 },
  154. },
  155. // 用户管理列表
  156. {
  157. path: "/userManageList",
  158. name: "userManageList",
  159. component: () => import("@/views/taskMessage/UserManageList.vue"),
  160. meta: { index: 1 },
  161. },
  162. {
  163. path: "/userManage",
  164. name: "userManage",
  165. component: () => import("@/views/taskMessage/UserManage.vue"),
  166. meta: { index: 1 },
  167. },
  168. // 挂单匹配列表页
  169. {
  170. path: "/pendingOrderList",
  171. name: "pendingOrderList",
  172. component: () => import("@/views/taskMessage/PendingOrderList.vue"),
  173. meta: { index: 1 },
  174. },
  175. // 挂单匹配页
  176. {
  177. path: "/pendingOrder",
  178. name: "pendingOrder",
  179. component: () => import("@/views/taskMessage/PendingOrder.vue"),
  180. meta: { index: 1 },
  181. },
  182. // 成交列表页
  183. {
  184. path: "/transactionList",
  185. name: "transactionList",
  186. component: () => import("@/views/taskMessage/TransactionList.vue"),
  187. meta: { index: 1 },
  188. },
  189. // 成交页
  190. {
  191. path: "/transaction",
  192. name: "transaction",
  193. component: () => import("@/views/taskMessage/Transaction.vue"),
  194. meta: { index: 1 },
  195. },
  196. ],
  197. });
  198. // 路由守卫处理
  199. router.beforeEach((to, from, next) => {
  200. // 从账户操作页面回到home页面
  201. // if (from.name === "accountOperation" && to.name === "home") {
  202. // // router.push("/home");
  203. // location.reload();
  204. // // 阻止重定向回 账户操作页
  205. // if (to.path === '/accountOperation') {
  206. // next(false);
  207. // } else {
  208. // next();
  209. // }
  210. // }
  211. // 页面带有不需要识别登录状态的跳过登录验证
  212. if (to.meta.noLogin) {
  213. next();
  214. } else {
  215. const user = getLocal("loginUser");
  216. if (!user || user === "") {
  217. // 没有登录信息跳转登录页面
  218. router.push("/login");
  219. } else {
  220. const userObject = JSON.parse(user);
  221. console.log("userObject >>>", userObject);
  222. // 登录信息异常跳转登录页面
  223. if (!userObject) {
  224. router.push("/login");
  225. }
  226. }
  227. next();
  228. }
  229. });
  230. export default router;