This commit is contained in:
clay
2022-01-19 20:38:16 +08:00
parent d0b9848102
commit d6374440d2
5 changed files with 118 additions and 64 deletions

View File

@@ -5,32 +5,37 @@
* @email: clay@hchyun.com * @email: clay@hchyun.com
*/ */
export function getParentNode(id){ export function getParentNode(id) {
let menuList = JSON.parse(sessionStorage.getItem("menu")); try {
for (let menu of menuList) {
for (let child of menu.children) { let menuList = JSON.parse(sessionStorage.getItem("menu"));
if (id == child.encodeId){ for (let menu of menuList) {
menu.children=[] for (let child of menu.children) {
child.children=[] if (id == child.encodeId) {
return { menu.children = []
stair:menu, child.children = []
second:child,
}
}
for (let item of child.children) {
if (id == item.encodeId){
menu.children=[]
child.children=[]
item.children=[]
return { return {
stair:menu, stair: menu,
second:child, second: child,
three:item }
}
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
} }

View File

@@ -141,24 +141,29 @@ export default {
}, },
watch: { watch: {
$route(to, from) { $route(to, from) {
console.log("触发了 $route")
let arcId = this.$route.params && this.$route.query.id let arcId = this.$route.params && this.$route.query.id
this.navId = this.$route.params && this.$route.params.navId; 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 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); let info = getParentNode(this.secondId);
console.log("获取到info",info)
if (arcId != undefined) { if (arcId != undefined) {
console.log("getContext")
this.getContext(arcId) this.getContext(arcId)
} else { } else {
console.log("getContent")
this.getContent(info.second) this.getContent(info.second)
} }
return return
} }
this.showSecond = true
if (arcId != undefined) { if (arcId != undefined) {
this.getContext(arcId) this.getContext(arcId)
} }
let id = this.$route.params && this.$route.params.secondId
try { try {
this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem' this.$refs.lab.style.height = this.navList.length * 8 + 10 + 'rem'
} catch (e) { } catch (e) {
@@ -171,12 +176,19 @@ export default {
} }
} }
} else { } else {
this.secondId = id
this.getNav() this.getNav()
} }
} }
}, },
created() { 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 => { crumbs(this.secondId).then(res => {
this.crumbs = res.data this.crumbs = res.data
}) })
@@ -184,28 +196,36 @@ export default {
methods: { methods: {
getContext(arcId) { getContext(arcId) {
article(arcId).then(res => { article(arcId).then(res => {
console.log(res);
this.detailsData = res.data.data this.detailsData = res.data.data
this.type = null this.type = null
}) })
}, },
getNav() { getNav() {
this.secondId = this.$route.params && this.$route.params.secondId; if (this.type==3||this.type==1||this.type==2){
this.navId = this.$route.params && this.$route.params.navId; console.log("进入二级")
this.type = this.$route.query && this.$route.query.type
if (this.type != null&&this.type!=0){
this.showSecond = false this.showSecond = false
let info = getParentNode(this.secondId); let info =null
let arcId = this.$route.query && this.$route.query.id 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) { if (arcId != undefined) {
this.getContext(arcId) this.getContext(arcId)
} else { } else {
console.log("获取二级列表")
this.getContent(info.second) this.getContent(info.second)
} }
return return
}else {
this.showSecond = true
} }
this.showSecond = true
this.getNodes()
},
getNodes(){
this.navList = [] this.navList = []
getNode({id: this.secondId}).then(res => { getNode({id: this.secondId}).then(res => {
this.navList = res.data this.navList = res.data
@@ -231,10 +251,13 @@ export default {
this.getContent(this.navList[this.showIndex]) this.getContent(this.navList[this.showIndex])
} }
} }
}) })
}, },
getContent(menu) { getContent(menu) {
console.log("getContent内部,menu:",menu)
this.type = menu.type this.type = menu.type
this.contextData = null this.contextData = null
this.bgImage = menu.link this.bgImage = menu.link
@@ -251,6 +274,7 @@ export default {
} }
} }
getNode(data).then(res => { getNode(data).then(res => {
console.log(res,"res值")
if (this.type == 2) { if (this.type == 2) {
this.contextData = { this.contextData = {
data: res.rows, data: res.rows,

View File

@@ -30,23 +30,23 @@
</el-menu-item> </el-menu-item>
<el-submenu :index="menuIndex+2" v-for="(menu,menuIndex) in menuData" :key="menuIndex"> <el-submenu :index="menuIndex+2" v-for="(menu,menuIndex) in menuData" :key="menuIndex">
<template slot="title" > <template slot="title" >
<span v-show="!english">{{ menu.title }}</span> <span v-if="!english">{{ menu.title }}</span>
<span v-show="english">{{ menu.title }}</span> <span v-if="english">{{ menu.title }}</span>
</template> </template>
<el-submenu :index="menuIndex +'-'+itemIndex" v-for="(item,itemIndex) in menu.children" :key="itemIndex" > <el-submenu :index="menuIndex +'-'+itemIndex" v-for="(item,itemIndex) in menu.children" :key="itemIndex" >
<template v-show="!english" slot="title" v-if="item.children.length == 0"> <template slot="title" v-if="item.children.length == 0 && !english">
<span @click="clickSecondMenu(item)">{{item.title}}</span> <span @click="clickSecondMenu(item)">{{item.title}}</span>
</template> </template>
<template v-show="english" slot="title" v-if="item.children.length == 0"> <template slot="title" v-if="item.children.length == 0&& english">
<span @click="clickSecondMenu(item)">{{item.englishTitle}}</span> <span @click="clickSecondMenu(item)">{{item.englishTitle}}</span>
</template> </template>
<template v-show="!english" slot="title" v-if="item.children.length > 0" >{{item.title}}</template> <template slot="title" v-if="item.children.length > 0 &&!english " >{{item.title}}</template>
<template v-show="english" slot="title" v-if="item.children.length > 0" >{{item.englishTitle}}</template> <template slot="title" v-if="item.children.length > 0 && english" >{{item.englishTitle}}</template>
<el-menu-item v-for="(chile ,chileIndex) in item.children" :key="chileIndex" :index="menuIndex +'-'+itemIndex +'-' +chileIndex" @click="clickMenu(chile,item)"> <el-menu-item v-for="(chile ,chileIndex) in item.children" :key="chileIndex" :index="menuIndex +'-'+itemIndex +'-' +chileIndex" @click="clickMenu(chile,item)">
<span v-show="!english">{{ chile.title }}</span> <span v-if="!english">{{ chile.title }}</span>
<span v-show="english">{{ chile.title }}</span> <span v-if="english">{{ chile.title }}</span>
</el-menu-item> </el-menu-item>
</el-submenu> </el-submenu>
</el-submenu> </el-submenu>

View File

@@ -138,7 +138,7 @@
<div class="grid-content"></div> <div class="grid-content"></div>
</el-col> </el-col>
<el-col class="headline" :xs="22" :sm="20" :md="16" :lg="12" :xl="12"> <el-col class="headline" :xs="22" :sm="20" :md="16" :lg="12" :xl="12">
<div style="background: #FFFFFF;color: #1956BC;" class="more"> <div style="background: #FFFFFF;color: #1956BC;" class="more"@click="lookMore(academiaData[0])">
{{ $t('message.more') }} {{ $t('message.more') }}
</div> </div>
<div class="more_img"> <div class="more_img">
@@ -168,6 +168,20 @@ export default {
this.getAcademiaList() this.getAcademiaList()
}, },
methods: { methods: {
lookMore(news){
info(news.id).then(res=>{
let info = getParentNode(res.data.encodeId)
console.log(res)
if (this.width){
this.$router.push("/pc/" + info.second.encodeId +"?type=" + info.second.type);
}else {
this.$router.push("/mobile/" + info.second.encodeId +"?type=" + info.second.type);
}
})
},
getScientificList() { getScientificList() {
getArticleList({ getArticleList({
type: "VPteru0OeW6GgYObAewMupY", type: "VPteru0OeW6GgYObAewMupY",

View File

@@ -114,30 +114,41 @@ export default {
created() { created() {
this.secondId = this.$route.params && this.$route.params.secondId; this.secondId = this.$route.params && this.$route.params.secondId;
this.navId = this.$route.params && this.$route.params.navId; this.navId = this.$route.params && this.$route.params.navId;
this.menuData = getParentNode(this.navId)
crumbs(this.secondId).then(res => {
this.crumbs = res.data
})
this.type = this.$route.query && this.$route.query.type this.type = this.$route.query && this.$route.query.type
if (this.type != null&&this.type!=0){ setTimeout(() => {
//this.showSecond = false this.init()
let info = getParentNode(this.secondId); }, 200);
let arcId = this.$route.query && this.$route.query.id
},
methods: {
init(){
this.menuData = getParentNode(this.navId)
crumbs(this.secondId).then(res => {
this.crumbs = res.data
})
if (this.type != null&&this.type!=0){
//this.showSecond = false
let info =null
info = getParentNode(this.secondId);
if (info == null){
location.reload();
}
let arcId = this.$route.query && this.$route.query.id
if (arcId != undefined) {
this.getContext(arcId)
} else {
this.getContent(info.second)
}
return
}
let arcId = this.$route.params && this.$route.query.id
if (arcId != undefined) { if (arcId != undefined) {
this.getContext(arcId) this.getContext(arcId)
} else { } else {
this.getContent(info.second) this.getContent(this.menuData.three)
} }
return },
}
let arcId = this.$route.params && this.$route.query.id
if (arcId != undefined) {
this.getContext(arcId)
} else {
this.getContent(this.menuData.three)
}
},
methods: {
getContext(arcId) { getContext(arcId) {
article(arcId).then(res => { article(arcId).then(res => {
console.log(res); console.log(res);