diff --git a/src/utils/sist.js b/src/utils/sist.js index 638ef11..ab61a3b 100644 --- a/src/utils/sist.js +++ b/src/utils/sist.js @@ -15,7 +15,6 @@ export function setThis(that) { export function getParentNode(id) { try { let menuList = JSON.parse(sessionStorage.getItem("menu")); - console.log(menuList,"menuList") for (let menu of menuList) { for (let child of menu.children) { if (id == child.encodeId) { diff --git a/src/views/content/components/Introduction.vue b/src/views/content/components/Introduction.vue index 039e0ec..568e67f 100644 --- a/src/views/content/components/Introduction.vue +++ b/src/views/content/components/Introduction.vue @@ -3,8 +3,8 @@
-
{{ value.title }}
-
+
{{ introductionData.title }}
+
@@ -29,7 +29,7 @@ export default { } }, watch:{ - value(val){ + introduction(val){ this.introductionData = val } }, diff --git a/src/views/content/index.vue b/src/views/content/index.vue index 5cba822..890f047 100644 --- a/src/views/content/index.vue +++ b/src/views/content/index.vue @@ -24,7 +24,7 @@
-
+
@@ -32,7 +32,7 @@ {{ nav.title }}
-
+
@@ -235,7 +235,7 @@ export default { this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem' } catch (e) { } - if (this.secondId == id) { + if (this.secondId == id && this.navList) { for (let i = 0; i < this.navList.length; i++) { if (this.navId == this.navList[i].encodeId) { this.showIndex = i @@ -253,6 +253,7 @@ export default { 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 + console.log(this.type,"this.type") setTimeout(() => { this.getNav() }, 200); @@ -310,34 +311,60 @@ export default { /** * 获得节点信息 */ - getNodes() { + async getNodes() { this.navList = [] - getNode({id: this.secondId}).then(res => { - this.navList = res.data - try { - setTimeout(() => { - this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem' - }, 100); - } catch (e) { - console.log(e) + // await getNode({id: this.secondId}).then(res => { + // this.navList = res.data + // try { + // setTimeout(() => { + // this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem' + // }, 100); + // } catch (e) { + // console.log(e) + // } + // // if (!this.navList){ + // // return + // // } + // for (let i = 0; i < this.navList.length; i++) { + // if (this.navId == this.navList[i].encodeId) { + // this.showIndex = i + // } + // } + // let arcId = this.$route.query && this.$route.query.id + // if (arcId != undefined) { + // this.getContext(arcId) + // } else { + // console.log("测试,我被触发了!") + // if (this.navId == undefined) { + // this.getContent(this.navList[0]) + // } else { + // this.getContent(this.navList[this.showIndex]) + // } + // } + // }) + let res = await getNode({id: this.secondId}) + // todo 延时异步问题 + this.$refs.lab.style.height = res.data.length * 8 + 10 + 'rem' + this.navList = res.data + // if (!this.navList){ + // return + // } + for (let i = 0; i < this.navList.length; i++) { + if (this.navId == this.navList[i].encodeId) { + this.showIndex = i } - for (let i = 0; i < this.navList.length; i++) { - if (this.navId == this.navList[i].encodeId) { - this.showIndex = i - } - } - let arcId = this.$route.query && this.$route.query.id - if (arcId != undefined) { - this.getContext(arcId) + } + let arcId = this.$route.query && this.$route.query.id + if (arcId != undefined) { + this.getContext(arcId) + } else { + console.log("测试,我被触发了!") + if (this.navId == undefined) { + this.getContent(this.navList[0]) } else { - console.log("测试,我被触发了!") - if (this.navId == undefined) { - this.getContent(this.navList[0]) - } else { - this.getContent(this.navList[this.showIndex]) - } + this.getContent(this.navList[this.showIndex]) } - }) + } }, /** * 获取三级菜单 @@ -345,6 +372,10 @@ export default { */ getContent(menu) { console.log("getContent内部,menu:", menu) + console.log(menu) + if (menu == undefined){ + return + } this.type = menu.type this.contextData = null this.bgImage = menu.link diff --git a/src/views/mobile/index.vue b/src/views/mobile/index.vue index 6ff8af4..385919f 100644 --- a/src/views/mobile/index.vue +++ b/src/views/mobile/index.vue @@ -110,6 +110,7 @@ export default { this.getContext(arcId) } else { this.menuData = getParentNode(this.navId) + console.log(this.menuData,"menuData") this.getContent(this.menuData.three) } } @@ -125,6 +126,7 @@ export default { }, methods: { init(){ + console.log(this.navId) this.menuData = getParentNode(this.navId) crumbs(this.secondId).then(res => { this.crumbs = res.data @@ -148,6 +150,7 @@ export default { if (arcId != undefined) { this.getContext(arcId) } else { + console.log(this.menuData,"menuData") this.getContent(this.menuData.three) } }, @@ -161,7 +164,7 @@ export default { }, getContent(menu) { console.log(menu) - //let menu = this.menuData.three + // let menu = this.menuData.three this.type = menu.type this.contextData = null this.bgImage = menu.link