|
@ -151,7 +151,11 @@ router.beforeEach((to, from, next) => { |
|
|
// 添加动态(菜单)路由
|
|
|
// 添加动态(菜单)路由
|
|
|
// 已添加或者当前路由为页面路由, 可直接访问
|
|
|
// 已添加或者当前路由为页面路由, 可直接访问
|
|
|
if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) { |
|
|
if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) { |
|
|
return next() |
|
|
|
|
|
|
|
|
if (to.name === 'detail' && to.query.doctorId) { |
|
|
|
|
|
loginByDocId(to.query.doctorId, next, to) |
|
|
|
|
|
} else { |
|
|
|
|
|
return next() |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (to.path === from.path) { |
|
|
if (to.path === from.path) { |
|
|
return |
|
|
return |
|
@ -161,6 +165,7 @@ router.beforeEach((to, from, next) => { |
|
|
} else if (to.name === '360view' && to.query.doctorId) { |
|
|
} else if (to.name === '360view' && to.query.doctorId) { |
|
|
loginByDocId(to.query.doctorId, next, to.fullPath) |
|
|
loginByDocId(to.query.doctorId, next, to.fullPath) |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
if (to.name === 'detail') return |
|
|
// 获取字典列表, 添加并全局变量保存
|
|
|
// 获取字典列表, 添加并全局变量保存
|
|
|
// http.get('/sys/dict/type/all').then(({ data: res }) => {
|
|
|
// http.get('/sys/dict/type/all').then(({ data: res }) => {
|
|
|
// if (res.code !== 0) {
|
|
|
// if (res.code !== 0) {
|
|
@ -178,7 +183,6 @@ router.beforeEach((to, from, next) => { |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
return next({ name: 'login' }) |
|
|
return next({ name: 'login' }) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// 获取菜单管理菜单列表,并添加动态路由
|
|
|
// 获取菜单管理菜单列表,并添加动态路由
|
|
|
http.get('/sys/menu/nav', { |
|
|
http.get('/sys/menu/nav', { |
|
|
params: { |
|
|
params: { |
|
@ -195,7 +199,6 @@ router.beforeEach((to, from, next) => { |
|
|
|
|
|
|
|
|
next({ ...to, replace: true }) |
|
|
next({ ...to, replace: true }) |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
// console.log(123)
|
|
|
|
|
|
return next({ name: 'login' }) |
|
|
return next({ name: 'login' }) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
@ -228,7 +231,7 @@ function muneList(next) { |
|
|
return next({ name: 'login' }) |
|
|
return next({ name: 'login' }) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
function loginByDocId(doctorId, next) { |
|
|
|
|
|
|
|
|
function loginByDocId(doctorId, next, to) { |
|
|
const params = { |
|
|
const params = { |
|
|
doctorId: doctorId |
|
|
doctorId: doctorId |
|
|
} |
|
|
} |
|
@ -236,13 +239,14 @@ function loginByDocId(doctorId, next) { |
|
|
if (res.code !== 0) { |
|
|
if (res.code !== 0) { |
|
|
return this.$message.error(res.msg) |
|
|
return this.$message.error(res.msg) |
|
|
} |
|
|
} |
|
|
console.log(res) |
|
|
|
|
|
// Cookies.set('xa-token', res.data.token)
|
|
|
// Cookies.set('xa-token', res.data.token)
|
|
|
|
|
|
debugger |
|
|
window.sessionStorage.setItem('xa-token', res.data.token) |
|
|
window.sessionStorage.setItem('xa-token', res.data.token) |
|
|
window.sessionStorage.setItem('qg-userData', JSON.stringify(res.data.currentUser)) |
|
|
window.sessionStorage.setItem('qg-userData', JSON.stringify(res.data.currentUser)) |
|
|
getNavList(next) |
|
|
|
|
|
muneList(next) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (to.name !== 'detail') { |
|
|
|
|
|
getNavList(next) |
|
|
|
|
|
muneList(next) |
|
|
|
|
|
} |
|
|
return next() |
|
|
return next() |
|
|
}).catch(() => { }) |
|
|
}).catch(() => { }) |
|
|
} |
|
|
} |
|
@ -287,7 +291,6 @@ function fnAddDynamicMenuRoutes(menuList = [], menuListChildLength, routes = []) |
|
|
iframeURL: URL |
|
|
iframeURL: URL |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
// console.log(URL)
|
|
|
|
|
|
URL = URL.replace(/^\//, '').replace(/_/g, '-') |
|
|
URL = URL.replace(/^\//, '').replace(/_/g, '-') |
|
|
item['path'] = '/' + URL.replace(/\//g, '-') |
|
|
item['path'] = '/' + URL.replace(/\//g, '-') |
|
|
item['name'] = URL.replace(/\//g, '-') |
|
|
item['name'] = URL.replace(/\//g, '-') |
|
@ -297,7 +300,6 @@ function fnAddDynamicMenuRoutes(menuList = [], menuListChildLength, routes = []) |
|
|
item['component'] = () => Promise.resolve(require(`@/page-subspecialty/views/modules/${URL}`).default) |
|
|
item['component'] = () => Promise.resolve(require(`@/page-subspecialty/views/modules/${URL}`).default) |
|
|
// 如果是父级给父级添加重定向到子菜单第一项
|
|
|
// 如果是父级给父级添加重定向到子菜单第一项
|
|
|
if (item.children.length > 0 && item.children[0].url) { |
|
|
if (item.children.length > 0 && item.children[0].url) { |
|
|
// console.log(item)
|
|
|
|
|
|
// isShow:0显示不菜单 1显示菜单
|
|
|
// isShow:0显示不菜单 1显示菜单
|
|
|
item.children[0].isShow === 0 ? '' : item['redirect'] = '/' + item.children[0].url.replace(/\//g, '-') |
|
|
item.children[0].isShow === 0 ? '' : item['redirect'] = '/' + item.children[0].url.replace(/\//g, '-') |
|
|
} |
|
|
} |
|
@ -321,7 +323,6 @@ function fnAddDynamicMenuRoutes(menuList = [], menuListChildLength, routes = []) |
|
|
}, |
|
|
}, |
|
|
{ path: '*', redirect: { name: '404' }} |
|
|
{ path: '*', redirect: { name: '404' }} |
|
|
]) |
|
|
]) |
|
|
// console.log('----------------------')
|
|
|
|
|
|
window.SITE_CONFIG['dynamicMenuRoutes'] = routes |
|
|
window.SITE_CONFIG['dynamicMenuRoutes'] = routes |
|
|
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true |
|
|
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true |
|
|
} |
|
|
} |
|
|