| | |
| | | { |
| | | path: '/', |
| | | name: 'root', |
| | | component: () => import('@/pages/index') |
| | | // component: () => import('@/pages/index') |
| | | // component: () => import('@/pages/login/index') |
| | | component: () => import('@/pages/room/list') |
| | | }, |
| | | { |
| | | path: '/index', |
| | | name: 'index', |
| | | component: () => import('@/pages/index') |
| | | }, |
| | | // { |
| | | // path: '/login', |
| | | // name: 'login', |
| | | // component: () => import('@/pages/login/index') |
| | | // }, |
| | | // { |
| | | // path: '/index', |
| | | // name: 'index', |
| | | // component: () => import('@/pages/index') |
| | | // }, |
| | | { |
| | | path: '/room/list', |
| | | name: 'roomList', |
| | | component: () => import('@/pages/room/list') |
| | | component: () => import('@/pages/room/list'), |
| | | meta: { title: '治疗室列表', keepAlive: true } |
| | | }, |
| | | { |
| | | path: '/room/detail', |
| | | name: 'roomDetail', |
| | | component: () => import('@/pages/room/detail') |
| | | component: () => import('@/pages/room/detail'), |
| | | meta: { title: '治疗室详情', isPush: false } |
| | | } |
| | | ] |
| | | }) |
| | | |
| | | // 路由跳转之前 |
| | | // 是否已经跳转过房间详情 |
| | | var isJumpeRoomDetail = localStorage.getItem('isJumpeRoomDetail') |
| | | if (!isJumpeRoomDetail) { |
| | | localStorage.setItem('isJumpeRoomDetail', '0') // 是否已经跳转过房间详情 |
| | | } |
| | | |
| | | // 跳转房间详情 |
| | | function jumpRoomDetail() { |
| | | var roomId = localStorage.getItem('roomId') |
| | | var isJumpeRoomDetail = localStorage.getItem('isJumpeRoomDetail') |
| | | // 还没跳转且有localroomId的 |
| | | // console.log('7777777777777777777777777777', isJumpeRoomDetail, roomId) |
| | | if (isJumpeRoomDetail === '0' && roomId) { |
| | | localStorage.setItem('isJumpeRoomDetail', '1') |
| | | return { path: `./room/detail?id=${roomId}` } |
| | | } else { |
| | | localStorage.setItem('isJumpeRoomDetail', '1') |
| | | return true |
| | | } |
| | | } |
| | | |
| | | // 路由跳转之前 |
| | | router.beforeEach(function(to, from, next) { |
| | | // var isJumpeRoomDetail = localStorage.getItem('isJumpeRoomDetail') |
| | | // console.log('999999999999999999999999999999999', to, from, isJumpeRoomDetail) |
| | | var nextPage = true // 默认true |
| | | // 直接进入首页(列表页) |
| | | if ((to.name === 'root' || to.name === 'roomList') && !from.name) { |
| | | nextPage = jumpRoomDetail() |
| | | } |
| | | // 直接进入详情页 |
| | | if (to.name === 'roomDetail' && !from.name) { |
| | | localStorage.setItem('isJumpeRoomDetail', '1') |
| | | if (to.query.id) { |
| | | localStorage.setItem('roomId', to.query.id) |
| | | } |
| | | } |
| | | |
| | | // 列表页进入详情页 |
| | | if (to.name === 'roomDetail' && (from.name === 'root' || from.name === 'roomList')) { |
| | | localStorage.setItem('isJumpeRoomDetail', '0') |
| | | if (to.query.id) { |
| | | localStorage.setItem('roomId', to.query.id) |
| | | } |
| | | } |
| | | |
| | | // 详情页返回列表 |
| | | if ((to.name === 'root' || to.name === 'roomList') && from.name === 'roomDetail') { |
| | | localStorage.setItem('isJumpeRoomDetail', '1') |
| | | } |
| | | next(nextPage) |
| | | }) |
| | | |
| | | export default router |