|
@@ -20,12 +20,7 @@ export default {
|
|
|
logolist:{
|
|
|
logo: require('@/assets/logo.png'),
|
|
|
},
|
|
|
- newslist:[
|
|
|
- {
|
|
|
- title:'新闻动态',
|
|
|
- time:'2019-10-28',
|
|
|
- }
|
|
|
- ],
|
|
|
+ newslist:[],
|
|
|
noticelist:[
|
|
|
{
|
|
|
title:'通知公告',
|
|
@@ -50,10 +45,11 @@ export default {
|
|
|
}),
|
|
|
created() {
|
|
|
this.getSite();
|
|
|
+ this.getModule();
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
- ...mapActions(['siteOperation','moduleOperation']),
|
|
|
+ ...mapActions(['siteOperation','moduleOperation','columnOperation','newsOperation']),
|
|
|
async getSite() {
|
|
|
let site = sessionStorage.getItem('site');
|
|
|
if (!site) {
|
|
@@ -67,6 +63,69 @@ export default {
|
|
|
}
|
|
|
this.$set(this, `loading`, false);
|
|
|
},
|
|
|
+ async getModule() {
|
|
|
+ //获取分站所有模块
|
|
|
+ let result = await this.moduleOperation({ type: 'list', data: { site: this.$site } });
|
|
|
+ if (`${result.errcode}` === '0') {
|
|
|
+ let moduleList = result.data;
|
|
|
+ for (let item of moduleList) {
|
|
|
+ //item为模块信息,拿着模块信息去查该模块下有什么栏目
|
|
|
+ item = await this.getColumn(item);
|
|
|
+ this.makeList(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getColumn(item) {
|
|
|
+ let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
|
|
|
+ if (`${res.errcode}` === '0') {
|
|
|
+ //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
|
|
|
+ for (const col of res.data) {
|
|
|
+ col.path = `/info/list/${col.id}`;
|
|
|
+ //再将栏目下的前几条数据查出来(暂定limit=6)
|
|
|
+ col.children = await this.getNews(col);
|
|
|
+ }
|
|
|
+ item.children = res.data;
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getNews(item) {
|
|
|
+ //这个item是栏目列表,循环查每个栏目6条信息
|
|
|
+ let res = await this.newsOperation({ type: 'list', data: { parent_id: item.id, site: item.site, skip: 0, limit: 6 } });
|
|
|
+ if (`${res.errcode}` === '0') {
|
|
|
+ return res.data;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ makeList(item) {
|
|
|
+ if (item.category === 'news') {
|
|
|
+ let arr = [];
|
|
|
+ let colObject = {};
|
|
|
+ for (const col of item.children) {
|
|
|
+ if (!colObject.id) colObject = col;
|
|
|
+ for (const news of col.children) {
|
|
|
+ arr.push(news);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
|
|
|
+ // eslint-disable-next-line no-console
|
|
|
+ console.log(object);
|
|
|
+ this.$set(this, `newslist`, object);
|
|
|
+ } else if (item.category === 'notice') {
|
|
|
+ let arr = [];
|
|
|
+ let colObject = {};
|
|
|
+ for (const col of item.children) {
|
|
|
+ if (!colObject.id) colObject = col;
|
|
|
+ for (const news of col.children) {
|
|
|
+ arr.push(news);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
|
|
|
+ this.$set(this, `notice`, object);
|
|
|
+ } else if (item.category === 'self1') {
|
|
|
+ this.$set(this, `self1List`, item.children);
|
|
|
+ } else if (item.category === 'self2') {
|
|
|
+ this.$set(this, `self2List`, item.children);
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|