You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.4 KiB

3 years ago
<template>
<div class="content-1180">
<div class="d-flex mt-4">
<LeftNav :code="code" :list="list" class="mr-4" @chanegCode="chanegCode" />
<div class="flex-1 flex-column">
<Location />
<div class="content-detail p-4" :style="{ 'min-height': list.children.length * 56 + 'px' }">
<ListPage v-if="!introId" :code="code" @changeYear="changeYear" :content="content" @getData="getData" />
<RichText v-else :rich-obj="introContent" />
</div>
</div>
</div>
</div>
</template>
<script>
import { mapActions } from 'vuex';
import LeftNav from '@/components/LeftNav/LeftNav.vue';
import ListPage from '@/components/ListPage/ListPage.vue';
import RichText from '@/components/RichText/RichText.vue';
import Location from '@/components/Location/Location.vue';
export default {
components: { LeftNav, ListPage, Location, RichText },
data() {
return {
code: '0201',
list: {
title: '新闻中心',
url: '/news',
children: [
{
title: '集团新闻',
code: '0201',
},
{
title: '省公司新闻',
code: '0202',
},
{
title: '公司新闻',
code: '0203',
},
{
title: '图片新闻',
code: '0204',
},
{
title: '热点专题',
code: '0205',
},
{
title: '媒体关注',
code: '0206',
},
{
title: '视频新闻',
code: '0207',
},
{
title: '专题片',
code: '0208',
},
{
title: '企业画册',
code: '0209',
},
{
title: '现场风采',
code: '0210',
},
],
},
year: '2020',
content: {},
pageNum: 1,
introId: '',
introContent: {},
};
},
watch: {
'$route.query.code'(val) {
if (this.$route.path === this.list.url) {
this.code = val;
this.getContentData();
}
},
},
created() {
this.code = this.$route.query.code;
if (this.$route.query.introId) {
this.introId = this.$route.query.introId;
this.getIntroContent();
}
this.getContentData();
},
methods: {
...mapActions('home', ['getContent', 'getDetail']),
async getContentData() {
try {
const param = {
showPage: this.code,
year: this.year,
showType: '1',
pageNum: this.pageNum,
pageSize: 10,
};
const data = await this.getContent(param);
console.log('data: ', data);
this.content = data;
} catch (error) {}
},
// 获取文章信息
async getIntroContent() {
try {
const param = {
showPage: '',
introId: this.introId,
};
const data = await this.getDetail(param);
this.introContent = data;
} catch (error) {
console.error('error: ', error);
}
},
chanegCode(code) {
this.code = code;
this.introId = '';
},
changeYear(year) {
this.year = year;
this.getContentData();
},
getData(pageNum) {
console.log('pageNum: ', pageNum);
this.pageNum = pageNum;
this.getContentData();
},
},
};
</script>
<style scoped>
.content-detail {
background: #fff;
}
</style>