index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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: "/merchant",
  100. component: Layout,
  101. children: [
  102. {
  103. path: "index",
  104. name: "Merchant",
  105. component: () => import("@/views/merchant/index"),
  106. meta: { title: "商户统计", icon: "el-icon-data-board" }
  107. }
  108. ]
  109. },
  110. //下单
  111. {
  112. path: "/shopping",
  113. component: Layout,
  114. children: [
  115. {
  116. path: "index",
  117. name: "Shopping",
  118. component: () => import("@/views/shopping/index"),
  119. meta: { title: "下单", icon: "el-icon-shopping-cart-2" }
  120. }
  121. ]
  122. },
  123. //订单
  124. {
  125. path: "/orders",
  126. component: Layout,
  127. redirect: "/orders/list",
  128. name: "Order",
  129. meta: { title: "订单", icon: "el-icon-notebook-2" },
  130. children: [
  131. {
  132. path: "list",
  133. name: "List",
  134. component: () => import("@/views/orders/list"),
  135. meta: { title: "列表" }
  136. },
  137. {
  138. path: "query",
  139. name: "Query",
  140. component: () => import("@/views/orders/query"),
  141. meta: { title: "查询", noCache: false }
  142. }
  143. ]
  144. },
  145. //统计
  146. {
  147. path: "/statistics",
  148. component: Layout,
  149. children: [
  150. {
  151. path: "index",
  152. name: "Census",
  153. component: () => import("@/views/statistics/census"),
  154. meta: { title: "统计", icon: "el-icon-s-grid" }
  155. }
  156. ]
  157. },
  158. //优惠券
  159. {
  160. path: "/coupon",
  161. component: Layout,
  162. redirect: "/coupon/list",
  163. meta: { title: "优惠券", icon: "el-icon-s-ticket" },
  164. children: [
  165. {
  166. path: "list",
  167. name: "List",
  168. component: () => import("@/views/coupon/list"),
  169. meta: { title: "列表" }
  170. },
  171. {
  172. path: "query",
  173. name: "Query",
  174. component: () => import("@/views/coupon/query"),
  175. meta: { title: "查询" }
  176. }
  177. ]
  178. },
  179. //营销
  180. // {
  181. // path: "/market",
  182. // component: Layout,
  183. // children: [
  184. // {
  185. // path: "index",
  186. // name: "Market",
  187. // component: () => import("@/views/market/index"),
  188. // meta: { title: "营销", icon: "el-icon-s-marketing" }
  189. // }
  190. // ]
  191. // },
  192. //拼团
  193. // {
  194. // path: "/group",
  195. // component: Layout,
  196. // children: [
  197. // {
  198. // path: "index",
  199. // name: "Group",
  200. // component: () => import("@/views/group/index"),
  201. // meta: { title: "拼团", icon: "el-icon-s-cooperation" }
  202. // }
  203. // ]
  204. // },
  205. //门店地图
  206. {
  207. path: "/shapmap",
  208. component: Layout,
  209. redirect: "/shapmap/map",
  210. name: "Shop",
  211. meta: { title: "门店地图", icon: "el-icon-place" },
  212. children: [
  213. {
  214. path: "map",
  215. name: "Map",
  216. component: () => import("@/views/shapmap/map/index"),
  217. meta: { title: "门店位置" }
  218. },
  219. {
  220. path: "marker",
  221. name: "Marker",
  222. component: () => import("@/views/shapmap/marker/index"),
  223. meta: { title: "门店覆盖区域" }
  224. },
  225. {
  226. path: "mtmap",
  227. name: "Mtmap",
  228. component: () => import("@/views/shapmap/mtmap/index"),
  229. meta: { title: "美团门店位置" }
  230. },
  231. {
  232. path: "mtmarker",
  233. name: "Mtmarker",
  234. component: () => import("@/views/shapmap/mtmarker/index"),
  235. meta: { title: "美团门店覆盖区域" }
  236. }
  237. ]
  238. },
  239. //other
  240. // {
  241. // path: '/example',
  242. // component: Layout,
  243. // redirect: '/example/table',
  244. // name: 'Example',
  245. // meta: { title: 'Example', icon: 'el-icon-s-help' },
  246. // children: [
  247. // {
  248. // path: 'table',
  249. // name: 'Table',
  250. // component: () => import('@/views/table/index'),
  251. // meta: { title: 'Table', icon: 'table' }
  252. // },
  253. // {
  254. // path: 'tree',
  255. // name: 'Tree',
  256. // component: () => import('@/views/tree/index'),
  257. // meta: { title: 'Tree', icon: 'tree' }
  258. // }
  259. // ]
  260. // },
  261. // {
  262. // path: '/form',
  263. // component: Layout,
  264. // children: [
  265. // {
  266. // path: 'index',
  267. // name: 'Form',
  268. // component: () => import('@/views/form/index'),
  269. // meta: { title: 'Form', icon: 'form' }
  270. // }
  271. // ]
  272. // },
  273. // {
  274. // path: '/nested',
  275. // component: Layout,
  276. // redirect: '/nested/menu1',
  277. // name: 'Nested',
  278. // meta: {
  279. // title: 'Nested',
  280. // icon: 'nested'
  281. // },
  282. // children: [
  283. // {
  284. // path: 'menu1',
  285. // component: () => import('@/views/nested/menu1/index'), // Parent router-view
  286. // name: 'Menu1',
  287. // meta: { title: 'Menu1' },
  288. // children: [
  289. // {
  290. // path: 'menu1-1',
  291. // component: () => import('@/views/nested/menu1/menu1-1'),
  292. // name: 'Menu1-1',
  293. // meta: { title: 'Menu1-1' }
  294. // },
  295. // {
  296. // path: 'menu1-2',
  297. // component: () => import('@/views/nested/menu1/menu1-2'),
  298. // name: 'Menu1-2',
  299. // meta: { title: 'Menu1-2' },
  300. // children: [
  301. // {
  302. // path: 'menu1-2-1',
  303. // component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  304. // name: 'Menu1-2-1',
  305. // meta: { title: 'Menu1-2-1' }
  306. // },
  307. // {
  308. // path: 'menu1-2-2',
  309. // component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  310. // name: 'Menu1-2-2',
  311. // meta: { title: 'Menu1-2-2' }
  312. // }
  313. // ]
  314. // },
  315. // {
  316. // path: 'menu1-3',
  317. // component: () => import('@/views/nested/menu1/menu1-3'),
  318. // name: 'Menu1-3',
  319. // meta: { title: 'Menu1-3' }
  320. // }
  321. // ]
  322. // },
  323. // {
  324. // path: 'menu2',
  325. // component: () => import('@/views/nested/menu2/index'),
  326. // name: 'Menu2',
  327. // meta: { title: 'menu2' }
  328. // }
  329. // ]
  330. // },
  331. // {
  332. // path: 'external-link',
  333. // component: Layout,
  334. // children: [
  335. // {
  336. // path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  337. // meta: { title: 'External Link', icon: 'link' }
  338. // }
  339. // ]
  340. // },
  341. // 404 page must be placed at the end !!!
  342. { path: "*", redirect: "/404", hidden: true }
  343. ];
  344. export const asyncRouterMap = [
  345. ////优惠券
  346. // {
  347. // path: "/coupon",
  348. // component: Layout,
  349. // meta: {
  350. // role: ["用户"]
  351. // },
  352. // children: [
  353. // {
  354. // path: "index",
  355. // name: "Coupon",
  356. // component: () => import("@/views/coupon/index"),
  357. // meta: { title: "优惠券", icon: "el-icon-s-ticket" }
  358. // }
  359. // ]
  360. // }
  361. ];
  362. const createRouter = () =>
  363. new Router({
  364. // mode: 'history', // require service support
  365. scrollBehavior: () => ({ y: 0 }),
  366. routes: constantRoutes
  367. });
  368. const router = createRouter();
  369. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  370. export function resetRouter() {
  371. const newRouter = createRouter();
  372. router.matcher = newRouter.matcher; // reset router
  373. }
  374. export default router;