Commit 9db9a3ee by 田爽

资讯中心闪动问题

parent bda7f078
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<img :src="tmp.picFile" alt="" /> <img :src="tmp.picFile" alt="" />
</div> </div>
<div class="picNews-li-bt"> <div class="picNews-li-bt">
<a :href="tmp.href" v-html="tmp.title" target="_blank"></a> <a :href="tmp.href" @click.prevent="InfoFn(tmp.articleId, tmp.href)" v-html="tmp.title" target="_blank"></a>
</div> </div>
</li> </li>
<li style=" height: 0;margin:0" v-for="(i,a) in 4" :key="'a'+a"></li> <li style=" height: 0;margin:0" v-for="(i,a) in 4" :key="'a'+a"></li>
...@@ -115,6 +115,7 @@ export default { ...@@ -115,6 +115,7 @@ export default {
} }
]; ];
this.setMatche(matche); this.setMatche(matche);
// if(directpath&&directpath!==''&& directpath.length>0){ // if(directpath&&directpath!==''&& directpath.length>0){
// this.clickDetailSave(id,directpath) // this.clickDetailSave(id,directpath)
// }else{ // }else{
...@@ -137,7 +138,7 @@ export default { ...@@ -137,7 +138,7 @@ export default {
// window.open(directpath,'_blank'); // window.open(directpath,'_blank');
} }
}, },
async InfoFn(id) { async InfoFn(id, href) {
const params = { const params = {
id: id, id: id,
token:this.$route.query.token ||'' token:this.$route.query.token ||''
...@@ -145,15 +146,21 @@ export default { ...@@ -145,15 +146,21 @@ export default {
const listRes = await this.$api.news.newsInfo(params); const listRes = await this.$api.news.newsInfo(params);
const { returnCode, data ,returnMsg} = listRes; const { returnCode, data ,returnMsg} = listRes;
if (returnCode === "0" && data !=null) { if (returnCode === "0" && data !=null) {
localStorage.setItem("msg"+id, JSON.stringify(data)); localStorage.setItem("msg"+id, JSON.stringify(listRes));
localStorage.setItem("isList"+id, 1); localStorage.setItem("isList"+id, 1);
// let link = this.$router.resolve({ // let link = this.$router.resolve({
// path: `/News/msg?id=${id}`, // path: `/News/msg?id=${id}`,
// }); // });
// window.open(link.href,'_blank') // window.open(link.href,'_blank')
if (data.directpath && data.directpath !== "" && data.directpath.length > 0) {
window.open(data.directpath, "_blank");
localStorage.removeItem('msg'+this.id)
localStorage.removeItem('isList'+this.id)
} else {
window.open(href,'_blank')
}
}else{ }else{
this.$message.error(returnMsg) window.open(href,'_blank')
} }
}, },
}, },
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div v-for="(tmp, i) in list" :key="i" class="row" @click="giveId(tmp.id,tmp.directpath)"> <div v-for="(tmp, i) in list" :key="i" class="row" @click="giveId(tmp.id,tmp.directpath)">
<div class="col-lg-10 list-left"> <div class="col-lg-10 list-left">
<span></span> <span></span>
<span><a :href="tmp.href" v-html="tmp.title" target="_blank"></a></span> <span><a :href="tmp.href" @click.prevent="InfoFn(tmp.id, tmp.href)" v-html="tmp.title" target="_blank"></a></span>
</div> </div>
<div class="col-lg-2 list-right">{{tmp.showtime}}</div> <div class="col-lg-2 list-right">{{tmp.showtime}}</div>
</div> </div>
...@@ -16,7 +16,32 @@ export default { ...@@ -16,7 +16,32 @@ export default {
methods:{ methods:{
giveId(id,directpath){ giveId(id,directpath){
this.$emit('getInfo',id,directpath) this.$emit('getInfo',id,directpath)
} },
async InfoFn(id, href) {
const params = {
id: id,
token:this.$route.query.token ||''
};
const listRes = await this.$api.news.newsInfo(params);
const { returnCode, data ,returnMsg} = listRes;
if (returnCode === "0" && data !=null) {
localStorage.setItem("msg"+id, JSON.stringify(listRes));
localStorage.setItem("isList"+id, 1);
// let link = this.$router.resolve({
// path: `/News/msg?id=${id}`,
// });
// window.open(link.href,'_blank')
if (data.directpath && data.directpath !== "" && data.directpath.length > 0) {
window.open(data.directpath, "_blank");
localStorage.removeItem('msg'+this.id)
localStorage.removeItem('isList'+this.id)
} else {
window.open(href,'_blank')
}
}else{
window.open(href,'_blank')
}
},
} }
} }
</script> </script>
......
...@@ -218,26 +218,27 @@ export default { ...@@ -218,26 +218,27 @@ export default {
Loading.service({customClass: 'el-loading-custom-class'}); Loading.service({customClass: 'el-loading-custom-class'});
}, },
created() { created() {
if(JSON.parse(localStorage.getItem('isList'+this.id)) && JSON.parse(localStorage.getItem('isList'+this.id)) == 1){ this.InfoFn();
let matche=[ // if(JSON.parse(localStorage.getItem('isList'+this.id)) && JSON.parse(localStorage.getItem('isList'+this.id)) == 1){
{ // let matche=[
name: "中心活动", // {
path: "/News/Center", // name: "中心活动",
} // path: "/News/Center",
] // }
// ]
this.setMatche(matche); // this.setMatche(matche);
let data = localStorage.getItem('msg'+this.id) ? JSON.parse(localStorage.getItem('msg'+this.id)) : null // let data = localStorage.getItem('msg'+this.id) ? JSON.parse(localStorage.getItem('msg'+this.id)) : null
this.content = data.content; // this.content = data.content;
this.title = data.title; // this.title = data.title;
this.showtime = data.showtime; // this.showtime = data.showtime;
this.author = data.author; // this.author = data.author;
this.source = data.source; // this.source = data.source;
this.editor = data.editor; // this.editor = data.editor;
this.xgljList(data.keyword); // this.xgljList(data.keyword);
}else{ // }else{
this.InfoFn(); // this.InfoFn();
} // }
this.newsTop10(); this.newsTop10();
this.announceList(); this.announceList();
...@@ -255,16 +256,21 @@ export default { ...@@ -255,16 +256,21 @@ export default {
}), }),
async InfoFn() { async InfoFn() {
this.loading=true this.loading=true
const params = { let listRes = {}
id: this.id, if(JSON.parse(localStorage.getItem('isList'+this.id)) && JSON.parse(localStorage.getItem('isList'+this.id)) == 1){
token:this.$route.query.token ||'' listRes = localStorage.getItem('msg'+this.id) ? JSON.parse(localStorage.getItem('msg'+this.id)) : null
}; } else {
const listRes = await this.$api.news.newsInfo(params); const params = {
id: this.id,
token:this.$route.query.token ||''
};
listRes = await this.$api.news.newsInfo(params);
}
const { returnCode, data ,returnMsg} = listRes; const { returnCode, data ,returnMsg} = listRes;
if (returnCode === "0" && data !=null) { if (returnCode === "0" && data !=null) {
if (data.directpath && data.directpath !== "" && data.directpath.length > 0) { // if (data.directpath && data.directpath !== "" && data.directpath.length > 0) {
window.open(data.directpath, "_self"); // window.open(data.directpath, "_self");
} // }
let matche = this.matcheList.filter((item) => item.classid ===data.classid)[0]; let matche = this.matcheList.filter((item) => item.classid ===data.classid)[0];
if(typeof(matche)==='undefined'){ if(typeof(matche)==='undefined'){
matche = [ matche = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment