index.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. // 加载条
  4. import NProgress from 'nprogress'
  5. import 'nprogress/nprogress.css'
  6. import VueAMap from 'vue-amap';
  7. Vue.use(VueRouter);
  8. // Vue.use(VueAMap);
  9. // VueAMap.initAMapApiLoader({
  10. // key: 'your amap key',
  11. // plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
  12. // // 默认高德 sdk 版本为 1.4.4
  13. // v: '1.4.4'
  14. // });
  15. const routes = [
  16. {
  17. path: '/',
  18. component: () => import( '../views/Index.vue'),
  19. children: [
  20. {
  21. path: '/',
  22. name: 'Main',
  23. component: () => import('@/views/Main.vue'),
  24. meta: {
  25. title: "首页",
  26. clmid: "1",
  27. }
  28. }, {
  29. path: '/member',
  30. name: 'Member',
  31. component: () => import('@/views/Member.vue'),
  32. meta: {
  33. title: "会员管理",
  34. clmid: "2",
  35. }
  36. },
  37. {
  38. path: '/tempUser',
  39. name: 'tempUser',
  40. component: () => import('@/views/tempUser.vue'),
  41. meta: {
  42. title: "临时用户",
  43. clmid: "33",
  44. }
  45. },{
  46. path: '/lesson',
  47. name: 'Lesson',
  48. component: () => import('@/views/Lesson.vue'),
  49. meta: {
  50. title: "课程模板",
  51. clmid: "3",
  52. }
  53. }, {
  54. path: '/lessonTable',
  55. name: 'lessonTable',
  56. component: () => import('@/views/LessonTable.vue'),
  57. meta: {
  58. title: "课程表模板",
  59. clmid: "4",
  60. }
  61. }, {
  62. path: '/editLessonTable',
  63. name: 'EditLessonTable',
  64. component: () => import('@/views/EditLessonTable.vue'),
  65. meta: {
  66. title: "编辑课程表模板",
  67. clmid: "4",
  68. }
  69. }, {
  70. path: '/editLessonManage',
  71. name: 'EditLessonManage',
  72. component: () => import('@/views/EditLessonManage.vue'),
  73. meta: {
  74. title: "编辑课程表",
  75. clmid: "5",
  76. }
  77. }, {
  78. path: '/adminManage',
  79. name: 'AdminManage',
  80. component: () => import('@/views/AdminManage.vue'),
  81. meta: {
  82. title: "管理员管理",
  83. clmid: "13",
  84. }
  85. }, {
  86. path: '/log',
  87. name: 'Log',
  88. component: () => import('@/views/Log.vue'),
  89. meta: {
  90. title: "操作日志",
  91. clmid: "14",
  92. }
  93. }, {
  94. path: '/shopManage',
  95. name: 'ShopManage',
  96. component: () => import('@/views/ShopManage.vue'),
  97. meta: {
  98. title: "店面管理",
  99. clmid: "12",
  100. }
  101. }, {
  102. path: '/adminSetting',
  103. name: 'AdminSetting',
  104. component: () => import('@/views/AdminSetting.vue'),
  105. meta: {
  106. title: "系统设置",
  107. clmid: "22",
  108. }
  109. }, {
  110. path: '/lessonManage',
  111. name: 'lessonManage',
  112. component: () => import('@/views/lessonManage.vue'),
  113. meta: {
  114. title: "课程表管理",
  115. clmid: "5",
  116. }
  117. }, {
  118. path: '/coach',
  119. name: 'coach',
  120. component: () => import('@/views/coach.vue'),
  121. meta: {
  122. title: "教练管理",
  123. clmid: "6",
  124. }
  125. }, {
  126. path: '/appoint',
  127. name: 'appoint',
  128. component: () => import('@/views/appoint.vue'),
  129. meta: {
  130. title: "预约管理",
  131. clmid: "7",
  132. }
  133. }, {
  134. path: '/record',
  135. name: 'record',
  136. component: () => import('@/views/record.vue'),
  137. meta: {
  138. title: "预约记录",
  139. clmid: "8",
  140. }
  141. }, {
  142. path: '/cost',
  143. name: 'cost',
  144. component: () => import('@/views/cost.vue'),
  145. meta: {
  146. title: "消费记录",
  147. clmid: "9",
  148. }
  149. }, {
  150. path: '/setting',
  151. name: 'setting',
  152. component: () => import('@/views/setting.vue'),
  153. meta: {
  154. title: "系统设置",
  155. clmid: "22",
  156. }
  157. }, {
  158. path: '/finish',
  159. name: 'finish',
  160. component: () => import('@/views/finish.vue'),
  161. meta: {
  162. title: "下课管理",
  163. clmid: "10",
  164. }
  165. }, {
  166. path: '/finishDetail',
  167. name: 'finishDetail',
  168. component: () => import('@/views/finishDetail.vue'),
  169. meta: {
  170. title: "下课管理",
  171. clmid: "10",
  172. }
  173. }, {
  174. path: '/courses',
  175. name: 'courses',
  176. component: () => import('@/views/courses.vue'),
  177. meta: {
  178. title: "课程管理",
  179. clmid: "10",
  180. }
  181. },{
  182. path: '/coursesHistory',
  183. name: 'coursesHistory',
  184. component: () => import('@/views/coursesHistory.vue'),
  185. meta: {
  186. title: "课程管理 历史记录",
  187. clmid: "10",
  188. }
  189. }, {
  190. path: '/classPrepare',
  191. name: 'classPrepare',
  192. component: () => import('@/views/classPrepare.vue'),
  193. meta: {
  194. title: "准备上课",
  195. clmid: "10",
  196. }
  197. }, {
  198. path: '/classInfoDetail',
  199. name: 'classInfoDetail',
  200. component: () => import('@/views/classInfoDetail.vue'),
  201. meta: {
  202. title: "课程成绩",
  203. clmid: "10",
  204. }
  205. }, {
  206. path: '/courseEdit',
  207. name: 'courseEdit',
  208. component: () => import('@/views/courseEdit.vue'),
  209. meta: {
  210. title: "课程管理",
  211. clmid: "10",
  212. }
  213. }, {
  214. path: '/heartEquip',
  215. name: 'heartEquip',
  216. component: () => import('@/views/heartEquip.vue'),
  217. meta: {
  218. title: "心率设备",
  219. clmid: "10",
  220. }
  221. }, {
  222. path: '/heartEquipPerson',
  223. name: 'heartEquipPerson',
  224. component: () => import('@/views/heartEquipPerson.vue'),
  225. meta: {
  226. title: "私有心率设备",
  227. clmid: "10",
  228. }
  229. }, {
  230. path: '/heartLog',
  231. name: 'heartLog',
  232. component: () => import('@/views/heartLog.vue'),
  233. meta: {
  234. title: "设备记录",
  235. clmid: "10",
  236. }
  237. }, {
  238. path: '/bindRecord',
  239. name: 'bindRecord',
  240. component: () => import('@/views/bindRecord.vue'),
  241. meta: {
  242. title: "绑定记录",
  243. clmid: "10",
  244. }
  245. }, {
  246. path: '/region',
  247. name: 'region',
  248. component: () => import('@/views/region.vue'),
  249. meta: {
  250. title: "区域管理",
  251. clmid: "10",
  252. }
  253. },{
  254. path: '/test',
  255. name: 'Test',
  256. component: () => import('@/views/Test.vue'),
  257. meta: {
  258. title: "test",
  259. clmid: "10",
  260. }
  261. }, {
  262. path: '/regionEquip',
  263. name: 'regionEquip',
  264. component: () => import('@/views/regionEquip.vue'),
  265. meta: {
  266. title: "区域设备",
  267. clmid: "10",
  268. }
  269. }, {
  270. path: '/relevancePhone',
  271. name: 'relevancePhone',
  272. component: () => import('@/views/relevancePhone.vue'),
  273. meta: {
  274. title: "关联手机",
  275. clmid: "2",
  276. }
  277. },{
  278. path: '/AcrossVip',
  279. name: 'AcrossVip',
  280. component: () => import('@/views/AcrossVip.vue'),
  281. meta: {
  282. title: "跨店会员",
  283. clmid: "11",
  284. }
  285. },{
  286. path: '/versionControlMefisto',
  287. name: 'versionControlMefisto',
  288. component: () => import('@/views/versionControlMefisto.vue'),
  289. meta: {
  290. title: "app版本控制",
  291. clmid: "999",
  292. }
  293. },
  294. ]
  295. }, {
  296. path: '/login',
  297. name: 'Login',
  298. component: () => import( '../views/Login.vue')
  299. }, , {
  300. path: '*',
  301. name: '404',
  302. component: () => import( '../views/404.vue')
  303. },
  304. ]
  305. const originalPush = VueRouter.prototype.push;
  306. VueRouter.prototype.push = function push(location) {
  307. return originalPush.call(this, location).catch(err => err)
  308. };
  309. const router = new VueRouter({
  310. mode: 'history',
  311. base: process.env.BASE_URL,
  312. routes
  313. });
  314. // 路由守卫
  315. router.beforeEach((to, from, next) => {
  316. NProgress.start()
  317. const isLogin = localStorage.token ? true : false;
  318. if (to.path == '/login' || to.path == '/register') {//'login'和'register'相当于是路由白名单
  319. next();
  320. } else {
  321. //如果token存在,就正常跳转,如果不存在,则说明未登陆,则跳转到'login'
  322. isLogin ? next() : next("/login");
  323. }
  324. });
  325. router.afterEach(() => {
  326. NProgress.done()
  327. })
  328. export default router