electron-ban-pai/src/components/newsInformation.vue

132 lines
3.3 KiB
Vue
Raw Normal View History

2021-12-23 10:00:27 +08:00
<template>
<div>
2022-01-03 16:38:59 +08:00
<error-page v-if="showError" @closeError="closeError"></error-page>
<div v-if="!showError">
<template v-if="!showDetail">
<div class="news-box" v-for="(item,index) in dataArr" :key="index" @click="goDetail(index)">
<img class="news-img" :src="item.Head_Img || '../../static/img/seconds/tu-01.png'" >
<div class="news-right-box">
<div>
<div class="news-content-box">
<div class="clips1">{{item.Title}}</div>
<div class="new-time-box">
<span>{{item.dateyear}}</span>
<span>{{item.datetime}}</span>
</div>
2021-12-23 19:27:42 +08:00
</div>
2022-01-03 16:38:59 +08:00
<div class="clips3">{{item.Content}}</div>
</div>
<div class="news-num-box">
<img src="../../static/img/kindergartenIntroduce/icon-browse.png">
<div>{{item.BroweTotal}}人浏览</div>
2021-12-23 19:27:42 +08:00
</div>
</div>
</div>
2022-01-03 16:38:59 +08:00
</template>
<newsInformationDetail v-if="showDetail" :dataObj="dataObj" @backNews="backNews"></newsInformationDetail>
<loading :isShow="showLoading"></loading>
</div>
2021-12-23 10:00:27 +08:00
</div>
</template>
<script>
2021-12-23 19:27:42 +08:00
import newsInformationDetail from '@/components/newsInformationDetail.vue';
2021-12-23 10:00:27 +08:00
export default {
2021-12-23 19:27:42 +08:00
components:{
newsInformationDetail
},
2021-12-23 10:00:27 +08:00
name: 'newsInformation',
data() {
return {
2021-12-23 19:27:42 +08:00
showDetail:false,
2021-12-26 12:04:11 +08:00
dataArr:[],
2022-01-03 16:38:59 +08:00
dataObj:'',
showLoading:true,
showError:false
2021-12-23 10:00:27 +08:00
}
},
methods: {
2022-01-03 16:38:59 +08:00
closeError(){
this.showError = false;
},
2021-12-23 19:27:42 +08:00
// 查看详情
goDetail(e) {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
this.showLoading = true;
this.dataObj = this.dataArr[e];
this.classnewsdetailsEv(this.dataObj.Guid);
} else {
this.showError = true;
}
2021-12-23 19:27:42 +08:00
},
// 继承详情返回事件
backNews(e){
this.showDetail = e;
2021-12-25 13:09:46 +08:00
},
2021-12-26 12:04:11 +08:00
async getnewsEv() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
this.showError = false;
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.getnews,
methods: "get",
params: {
EquipmentID: "yaohaotest001",
},
});
if(data.data.data!=undefined){
data.data.data.forEach(item=>{
let obj = {
BroweTotal: item.BroweTotal,
Content: item.Content,
DisplayName: item.DisplayName,
Guid: item.Guid,
Head_Img: item.Head_Img,
dateyear: item.PublishTime.split(' ')[0],
datetime: item.PublishTime.split(' ')[1],
Title: item.Title
}
this.dataArr.push(obj)
})
this.$storage.set('dataArrnew',this.dataArr);
2021-12-26 12:04:11 +08:00
}
2022-01-03 16:38:59 +08:00
} else {
this.dataArr = this.$storage.get('dataArrnew');
if(this.dataArr==undefined){
this.showError = true;
}
}
this.showLoading = false;
2021-12-26 12:04:11 +08:00
},
async classnewsdetailsEv(guid) {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.classnewsdetails,
methods: "get",
params: {
EquipmentID: "yaohaotest001",
Guid:guid
},
});
if(data.data.data!=undefined){
this.dataObj = data.data.data;
this.$storage.set('dataObjnew',this.dataObj);
}
} else {
this.dataObj = this.$storage.get('dataObjnew');
}
this.showDetail = true;
this.showLoading = false;
2021-12-25 13:09:46 +08:00
},
2021-12-23 10:00:27 +08:00
},
mounted() {
2021-12-26 12:04:11 +08:00
this.getnewsEv();
2021-12-23 10:00:27 +08:00
}
}
</script>
<style>
</style>