index.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. import Vue from "vue";
  2. import Router from "vue-router";
  3. Vue.use(Router);
  4. /* Layout */
  5. import Layout from "@/layout";
  6. /**
  7. * Note: sub-menu only appear when route children.length >= 1
  8. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  9. *
  10. * hidden: true if set true, item will not show in the sidebar(default is false)
  11. * alwaysShow: true if set true, will always show the root menu
  12. * if not set alwaysShow, when item has more than one children route,
  13. * it will becomes nested mode, otherwise not show the root menu
  14. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  15. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  16. * meta : {
  17. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  18. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  19. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  20. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  21. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  22. }
  23. */
  24. /**
  25. * constantRoutes
  26. * a base page that does not have permission requirements
  27. * all roles can be accessed
  28. */
  29. export const constantRoutes = [
  30. {
  31. path: "/login",
  32. component: () => import("@/views/login/index"),
  33. hidden: true
  34. },
  35. {
  36. path: "/404",
  37. component: () => import("@/views/404"),
  38. hidden: true
  39. },
  40. // {
  41. // path: '/',
  42. // component: Layout,
  43. // redirect: '/dashboard',
  44. // children: [{
  45. // path: 'dashboard',
  46. // name: 'Dashboard',
  47. // component: () => import('@/views/dashboard/index'),
  48. // meta: { title: 'Dashboard', icon: 'dashboard' }
  49. // }]
  50. // },
  51. {
  52. path: "/",
  53. component: Layout,
  54. redirect: "/shop/message"
  55. // children: [{
  56. // path: 'message',
  57. // name: 'Message',
  58. // component: () => import('@/views/shop/message/index'),
  59. // meta: { title: '门店管理' }
  60. // }]
  61. },
  62. //门店
  63. {
  64. path: "/shop",
  65. component: Layout,
  66. redirect: "/shop/message",
  67. name: "Shop",
  68. meta: { title: "门店", icon: "el-icon-s-shop" },
  69. children: [
  70. {
  71. path: "message",
  72. name: "Message",
  73. component: () => import("@/views/shop/message/index"),
  74. meta: { title: "门店管理" }
  75. }
  76. // {
  77. // path: "trim",
  78. // name: "Trim",
  79. // component: () => import("@/views/shop/trim/index"),
  80. // meta: { title: "门店装修" }
  81. // }
  82. ]
  83. },
  84. //商品
  85. {
  86. path: "/goods",
  87. component: Layout,
  88. children: [
  89. {
  90. path: "index",
  91. name: "Goods",
  92. component: () => import("@/views/goods/index"),
  93. meta: { title: "商品", icon: "el-icon-s-goods" }
  94. }
  95. ]
  96. },
  97. //下单
  98. {
  99. path: "/shopping",
  100. component: Layout,
  101. children: [
  102. {
  103. path: "index",
  104. name: "Shopping",
  105. component: () => import("@/views/shopping/index"),
  106. meta: { title: "下单", icon: "el-icon-shopping-cart-2" }
  107. }
  108. ]
  109. },
  110. //订单
  111. {
  112. path: "/orders",
  113. component: Layout,
  114. redirect: "/orders/list",
  115. name: "Order",
  116. meta: { title: "订单", icon: "el-icon-notebook-2" },
  117. children: [
  118. {
  119. path: "list",
  120. name: "List",
  121. component: () => import("@/views/orders/list"),
  122. meta: { title: "列表" }
  123. },
  124. {
  125. path: "query",
  126. name: "Query",
  127. component: () => import("@/views/orders/query"),
  128. meta: { title: "查询", noCache: false }
  129. }
  130. ]
  131. },
  132. //统计
  133. {
  134. path: "/statistics",
  135. component: Layout,
  136. children: [
  137. {
  138. path: "index",
  139. name: "Census",
  140. component: () => import("@/views/statistics/census"),
  141. meta: { title: "统计", icon: "el-icon-s-grid" }
  142. }
  143. ]
  144. },
  145. //优惠券
  146. {
  147. path: "/coupon",
  148. component: Layout,
  149. redirect: "/coupon/list",
  150. meta: { title: "优惠券", icon: "el-icon-s-ticket" },
  151. children: [
  152. {
  153. path: "list",
  154. name: "List",
  155. component: () => import("@/views/coupon/list"),
  156. meta: { title: "列表" }
  157. },
  158. {
  159. path: "query",
  160. name: "Query",
  161. component: () => import("@/views/coupon/query"),
  162. meta: { title: "查询" }
  163. }
  164. ]
  165. },
  166. //营销
  167. // {
  168. // path: "/market",
  169. // component: Layout,
  170. // children: [
  171. // {
  172. // path: "index",
  173. // name: "Market",
  174. // component: () => import("@/views/market/index"),
  175. // meta: { title: "营销", icon: "el-icon-s-marketing" }
  176. // }
  177. // ]
  178. // },
  179. //拼团
  180. // {
  181. // path: "/group",
  182. // component: Layout,
  183. // children: [
  184. // {
  185. // path: "index",
  186. // name: "Group",
  187. // component: () => import("@/views/group/index"),
  188. // meta: { title: "拼团", icon: "el-icon-s-cooperation" }
  189. // }
  190. // ]
  191. // },
  192. //门店地图
  193. {
  194. path: "/shapmap",
  195. component: Layout,
  196. redirect: "/shapmap/map",
  197. name: "Shop",
  198. meta: { title: "门店地图", icon: "el-icon-place" },
  199. children: [
  200. {
  201. path: "map",
  202. name: "Map",
  203. component: () => import("@/views/shapmap/map/index"),
  204. meta: { title: "门店位置" }
  205. },
  206. {
  207. path: "marker",
  208. name: "Marker",
  209. component: () => import("@/views/shapmap/marker/index"),
  210. meta: { title: "门店覆盖区域" }
  211. }
  212. ]
  213. },
  214. //other
  215. // {
  216. // path: '/example',
  217. // component: Layout,
  218. // redirect: '/example/table',
  219. // name: 'Example',
  220. // meta: { title: 'Example', icon: 'el-icon-s-help' },
  221. // children: [
  222. // {
  223. // path: 'table',
  224. // name: 'Table',
  225. // component: () => import('@/views/table/index'),
  226. // meta: { title: 'Table', icon: 'table' }
  227. // },
  228. // {
  229. // path: 'tree',
  230. // name: 'Tree',
  231. // component: () => import('@/views/tree/index'),
  232. // meta: { title: 'Tree', icon: 'tree' }
  233. // }
  234. // ]
  235. // },
  236. // {
  237. // path: '/form',
  238. // component: Layout,
  239. // children: [
  240. // {
  241. // path: 'index',
  242. // name: 'Form',
  243. // component: () => import('@/views/form/index'),
  244. // meta: { title: 'Form', icon: 'form' }
  245. // }
  246. // ]
  247. // },
  248. // {
  249. // path: '/nested',
  250. // component: Layout,
  251. // redirect: '/nested/menu1',
  252. // name: 'Nested',
  253. // meta: {
  254. // title: 'Nested',
  255. // icon: 'nested'
  256. // },
  257. // children: [
  258. // {
  259. // path: 'menu1',
  260. // component: () => import('@/views/nested/menu1/index'), // Parent router-view
  261. // name: 'Menu1',
  262. // meta: { title: 'Menu1' },
  263. // children: [
  264. // {
  265. // path: 'menu1-1',
  266. // component: () => import('@/views/nested/menu1/menu1-1'),
  267. // name: 'Menu1-1',
  268. // meta: { title: 'Menu1-1' }
  269. // },
  270. // {
  271. // path: 'menu1-2',
  272. // component: () => import('@/views/nested/menu1/menu1-2'),
  273. // name: 'Menu1-2',
  274. // meta: { title: 'Menu1-2' },
  275. // children: [
  276. // {
  277. // path: 'menu1-2-1',
  278. // component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  279. // name: 'Menu1-2-1',
  280. // meta: { title: 'Menu1-2-1' }
  281. // },
  282. // {
  283. // path: 'menu1-2-2',
  284. // component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  285. // name: 'Menu1-2-2',
  286. // meta: { title: 'Menu1-2-2' }
  287. // }
  288. // ]
  289. // },
  290. // {
  291. // path: 'menu1-3',
  292. // component: () => import('@/views/nested/menu1/menu1-3'),
  293. // name: 'Menu1-3',
  294. // meta: { title: 'Menu1-3' }
  295. // }
  296. // ]
  297. // },
  298. // {
  299. // path: 'menu2',
  300. // component: () => import('@/views/nested/menu2/index'),
  301. // name: 'Menu2',
  302. // meta: { title: 'menu2' }
  303. // }
  304. // ]
  305. // },
  306. // {
  307. // path: 'external-link',
  308. // component: Layout,
  309. // children: [
  310. // {
  311. // path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  312. // meta: { title: 'External Link', icon: 'link' }
  313. // }
  314. // ]
  315. // },
  316. // 404 page must be placed at the end !!!
  317. { path: "*", redirect: "/404", hidden: true }
  318. ];
  319. export const asyncRouterMap = [
  320. ////优惠券
  321. // {
  322. // path: "/coupon",
  323. // component: Layout,
  324. // meta: {
  325. // role: ["用户"]
  326. // },
  327. // children: [
  328. // {
  329. // path: "index",
  330. // name: "Coupon",
  331. // component: () => import("@/views/coupon/index"),
  332. // meta: { title: "优惠券", icon: "el-icon-s-ticket" }
  333. // }
  334. // ]
  335. // }
  336. ];
  337. const createRouter = () =>
  338. new Router({
  339. // mode: 'history', // require service support
  340. scrollBehavior: () => ({ y: 0 }),
  341. routes: constantRoutes
  342. });
  343. const router = createRouter();
  344. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  345. export function resetRouter() {
  346. const newRouter = createRouter();
  347. router.matcher = newRouter.matcher; // reset router
  348. }
  349. export default router;