index.js 10 KB

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