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
*/
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
}

View File

@@ -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,

View File

@@ -30,23 +30,23 @@
</el-menu-item>
<el-submenu :index="menuIndex+2" v-for="(menu,menuIndex) in menuData" :key="menuIndex">
<template slot="title" >
<span v-show="!english">{{ menu.title }}</span>
<span v-show="english">{{ menu.title }}</span>
<span v-if="!english">{{ menu.title }}</span>
<span v-if="english">{{ menu.title }}</span>
</template>
<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>
</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>
</template>
<template v-show="!english" slot="title" v-if="item.children.length > 0" >{{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.title}}</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)">
<span v-show="!english">{{ chile.title }}</span>
<span v-show="english">{{ chile.title }}</span>
<span v-if="!english">{{ chile.title }}</span>
<span v-if="english">{{ chile.title }}</span>
</el-menu-item>
</el-submenu>
</el-submenu>

View File

@@ -138,7 +138,7 @@
<div class="grid-content"></div>
</el-col>
<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') }}
</div>
<div class="more_img">
@@ -168,6 +168,20 @@ export default {
this.getAcademiaList()
},
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() {
getArticleList({
type: "VPteru0OeW6GgYObAewMupY",

View File

@@ -114,30 +114,41 @@ export default {
created() {
this.secondId = this.$route.params && this.$route.params.secondId;
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
if (this.type != null&&this.type!=0){
//this.showSecond = false
let info = getParentNode(this.secondId);
let arcId = this.$route.query && this.$route.query.id
setTimeout(() => {
this.init()
}, 200);
},
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) {
this.getContext(arcId)
} 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) {
article(arcId).then(res => {
console.log(res);