|
@@ -72,7 +72,7 @@ export default {
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
- ...mapActions(['getSite', `getMenu`, 'getColumn', 'getModule', 'getNews', 'getJobInfo', 'getPosts', 'getLink']),
|
|
|
+ ...mapActions(['getSite', `getMenu`, 'getColumn', 'getAllNews', 'getAllColumn', 'getModule', 'getNews', 'getJobInfo', 'getPosts', 'getLink']),
|
|
|
//站点信息
|
|
|
async toGetSite() {
|
|
|
let site = sessionStorage.getItem('site');
|
|
@@ -159,18 +159,21 @@ export default {
|
|
|
},
|
|
|
async finishedModule() {
|
|
|
let modules = JSON.parse(JSON.stringify(this.modules));
|
|
|
- for (const item of modules) {
|
|
|
- if (`${item.is_use}` === `0`) {
|
|
|
- let res = await this.completeModules(item);
|
|
|
- item.children = res;
|
|
|
- this.$set(this, `${item.category}List`, item);
|
|
|
- }
|
|
|
- }
|
|
|
+ // for (const item of modules) {
|
|
|
+ // if (`${item.is_use}` === `0`) {
|
|
|
+ // let res = await this.completeModules(item);
|
|
|
+ // item.children = res;
|
|
|
+ // this.$set(this, `${item.category}List`, item);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //获取了所有栏目
|
|
|
+ let res = await this.completeAllModules(modules);
|
|
|
// for (const item of modules) {
|
|
|
// this.$set(this, `${item.category}List`, item);
|
|
|
// }
|
|
|
this.$set(this, `modules`, modules);
|
|
|
},
|
|
|
+ //弃用
|
|
|
async completeModules(item) {
|
|
|
let result = await this.getColumn({
|
|
|
type: `list`,
|
|
@@ -192,6 +195,7 @@ export default {
|
|
|
return columns;
|
|
|
}
|
|
|
},
|
|
|
+ //弃用
|
|
|
async completeColumn(item) {
|
|
|
let data = { skip: 0, limit: 8 };
|
|
|
if (item.type === `bugList`) {
|
|
@@ -228,8 +232,36 @@ export default {
|
|
|
let result = await this.getPosts({ type: 'fetch', data: { id: id } });
|
|
|
if (result.errcode === 0) return result.data;
|
|
|
},
|
|
|
+ //合并请求模块
|
|
|
+ async completeAllModules(modules) {
|
|
|
+ let ids = modules.map(item => item.id);
|
|
|
+ let result = await this.getAllColumn(ids);
|
|
|
+ // result = _.flattenDeep(result);
|
|
|
+ if (result.length > 0) {
|
|
|
+ //整理栏目
|
|
|
+ result = result.map(item => {
|
|
|
+ if (item.type === 'column') item.path = `/newsList/module/${item.id}`;
|
|
|
+ else item.path = `/newsList/module/${item.content_id}`;
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ //请求信息
|
|
|
+ let res = await this.getAllNews(result);
|
|
|
+ //合并栏目和信息
|
|
|
+ result = result.map(item => {
|
|
|
+ let newsList = res.filter(fil => fil.parent_id === item.id);
|
|
|
+ item.children = newsList;
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ modules = modules.map(item => {
|
|
|
+ let children = result.filter(fil => fil.parent_id === item.id);
|
|
|
+ item.children = children;
|
|
|
+ this.$set(this, `${item.category}List`, item);
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped></style>
|
|
|
+<style lang="less" scoped></style>
|