diff --git a/src/utils/sist.js b/src/utils/sist.js index 618fcd0..f4cff90 100644 --- a/src/utils/sist.js +++ b/src/utils/sist.js @@ -5,32 +5,37 @@ * @email: clay@hchyun.com */ -export function getParentNode(id){ - let menuList = JSON.parse(sessionStorage.getItem("menu")); - for (let menu of menuList) { - for (let child of menu.children) { - if (id == child.encodeId){ - menu.children=[] - child.children=[] - return { - stair:menu, - second:child, - } - } - for (let item of child.children) { - if (id == item.encodeId){ - menu.children=[] - child.children=[] - item.children=[] +export function getParentNode(id) { + try { + + let menuList = JSON.parse(sessionStorage.getItem("menu")); + for (let menu of menuList) { + for (let child of menu.children) { + if (id == child.encodeId) { + menu.children = [] + child.children = [] return { - stair:menu, - second:child, - three:item + stair: menu, + second: child, + } + } + for (let item of child.children) { + if (id == item.encodeId) { + menu.children = [] + child.children = [] + item.children = [] + return { + stair: menu, + second: child, + three: item + } } } } } + return null + } catch (e) { + return null } - return null } diff --git a/src/views/content/index.vue b/src/views/content/index.vue index 0992e88..3d9fc43 100644 --- a/src/views/content/index.vue +++ b/src/views/content/index.vue @@ -141,24 +141,29 @@ export default { }, watch: { $route(to, from) { - console.log("触发了 $route") let arcId = this.$route.params && this.$route.query.id this.navId = this.$route.params && this.$route.params.navId; - this.secondId = this.$route.params && this.$route.params.secondId; + let id = this.$route.params && this.$route.params.secondId this.type = this.$route.query && this.$route.query.type - if (this.type != null&&this.type!=0){ + console.log("触发了 $route") + if (this.type==3||this.type==1||this.type==2){ + this.secondId = id + this.showSecond = false let info = getParentNode(this.secondId); + console.log("获取到info",info) if (arcId != undefined) { + console.log("getContext") this.getContext(arcId) } else { + console.log("getContent") this.getContent(info.second) } return } + this.showSecond = true if (arcId != undefined) { this.getContext(arcId) } - let id = this.$route.params && this.$route.params.secondId try { this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem' } catch (e) { @@ -171,12 +176,19 @@ export default { } } } else { + this.secondId = id this.getNav() } } }, created() { - this.getNav() + this.secondId = this.$route.params && this.$route.params.secondId; + this.navId = this.$route.params && this.$route.params.navId; + this.type = this.$route.query && this.$route.query.type + setTimeout(() => { + this.getNav() + }, 200); + //this.getNav() crumbs(this.secondId).then(res => { this.crumbs = res.data }) @@ -184,28 +196,36 @@ export default { methods: { getContext(arcId) { article(arcId).then(res => { - console.log(res); this.detailsData = res.data.data this.type = null }) }, getNav() { - this.secondId = this.$route.params && this.$route.params.secondId; - this.navId = this.$route.params && this.$route.params.navId; - this.type = this.$route.query && this.$route.query.type - if (this.type != null&&this.type!=0){ + if (this.type==3||this.type==1||this.type==2){ + console.log("进入二级") this.showSecond = false - let info = getParentNode(this.secondId); - let arcId = this.$route.query && this.$route.query.id + let info =null + info = getParentNode(this.secondId); + if (info == null){ + location.reload(); + } + let arcId = null + + arcId = this.$route.query && this.$route.query.id + console.log(arcId) if (arcId != undefined) { this.getContext(arcId) } else { + console.log("获取二级列表") this.getContent(info.second) } return - }else { - this.showSecond = true } + this.showSecond = true + this.getNodes() + }, + + getNodes(){ this.navList = [] getNode({id: this.secondId}).then(res => { this.navList = res.data @@ -231,10 +251,13 @@ export default { this.getContent(this.navList[this.showIndex]) } } - }) }, + + + getContent(menu) { + console.log("getContent内部,menu:",menu) this.type = menu.type this.contextData = null this.bgImage = menu.link @@ -251,6 +274,7 @@ export default { } } getNode(data).then(res => { + console.log(res,"res值") if (this.type == 2) { this.contextData = { data: res.rows, diff --git a/src/views/header/mobile_herder.vue b/src/views/header/mobile_herder.vue index b4c7fa1..7097385 100644 --- a/src/views/header/mobile_herder.vue +++ b/src/views/header/mobile_herder.vue @@ -30,23 +30,23 @@ -