guhongwei 4 年 前
コミット
ca8092b818
1 ファイル変更14 行追加58 行削除
  1. 14 58
      src/views/index.vue

+ 14 - 58
src/views/index.vue

@@ -47,12 +47,9 @@ export default {
     // 最新資訊
     zxzxList: [],
   }),
-  created() {
-    this.searchSite();
-    this.searchLink();
-    this.searchAffairs();
-    this.searchPolicy();
-    this.searchProduct();
+  async created() {
+    await this.searchSite();
+    await this.searchProduct();
   },
   computed: {},
   methods: {
@@ -63,34 +60,29 @@ export default {
     ...mapPolicyColumn({ policyColumnList: 'query', policyColumnInfo: 'fetch' }),
     ...mapPolicyNews({ policyNews: 'query' }),
     ...mapProduct({ productList: 'query', productInfo: 'fetch' }),
-    // 查询站点信息
-    async searchSite() {
+    // 查询站点信息+友情链接+科技政务栏目+科技政策栏目
+    async searchSite({ ...info } = {}) {
       let res = await this.showInfo();
       let object = JSON.parse(JSON.stringify(res.data));
       if (object) {
         this.$set(this, `info`, res.data);
-      } else {
-        this.$message.error(res.errmsg ? res.errmsg : 'error');
       }
-    },
-    // 查询友情链接
-    async searchLink({ ...info } = {}) {
-      const res = await this.query({ ...info });
+      res = await this.query({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `linkList`, res.data);
       }
-    },
-    // 最新資訊,通知公告(所属科技政务,国内动态,通知公告)
-    async searchAffairs({ ...info } = {}) {
-      const res = await this.affairsColumnList({ ...info });
+      res = await this.affairsColumnList({ ...info });
       if (this.$checkRes(res)) {
         this.$set(this, `affairsCol`, res.data);
         this.tpxwSearch();
       }
-      // for (const val of res.data) {
-      //   this.tpxwSearch({ column_id: val.id, site: val.site });
-      // }
+      res = await this.policyColumnList({ ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `affairsCol1`, res.data);
+        this.zhzcdPolicy();
+      }
     },
+    // 最新資訊,通知公告(所属科技政务,国内动态,通知公告)
     async tpxwSearch() {
       let zxzx = this.affairsCol.find(i => i.site == 'gndt');
       let tzgg = this.affairsCol.find(i => i.site == 'tzgg');
@@ -99,53 +91,17 @@ export default {
         this.$set(this, `${zxzx.site}List`, res.data);
       }
       let res1 = await this.affairsNews({ skip: 0, limit: 8, column_id: tzgg.id });
-      if (this.$checkRes(res)) {
+      if (this.$checkRes(res1)) {
         this.$set(this, `${tzgg.site}List`, res.data);
       }
-      // console.log(this.affairsCol); //媒体聚焦、通知公告6个是一个数组里面包含对象
-      // if (site === 'gndt') {
-      //   const res = await this.affairsNews({ skip, limit, column_id: column_id });
-      //   for (const val of res.data) {
-      //     const result = await this.affairsColumnInfo(val.column_id);
-      //     val.column_name = result.data.name;
-      //   }
-      //   this.$set(this, `${site}List`, res.data);
-      // } else if (site === 'tzgg') {
-      //   const res = await this.affairsNews({ skip, limit, column_id: column_id });
-      //   for (const val of res.data) {
-      //     const result = await this.affairsColumnInfo(val.column_id);
-      //     val.column_name = result.data.name;
-      //   }
-      //   this.$set(this, `${site}List`, res.data);
-      // }
     },
     // 政策法规(所属科技政策,综合政策指导)
-    async searchPolicy({ ...info } = {}) {
-      const res = await this.policyColumnList({ ...info });
-      if (this.$checkRes(res)) {
-        this.$set(this, `affairsCol1`, res.data);
-        this.zhzcdPolicy();
-      }
-      // for (const val of res.data) {
-      //   this.zhzcdPolicy({ column_id: val.id, site: val.site });
-      // }
-    },
     async zhzcdPolicy() {
       let zhzczd = this.affairsCol1.find(i => i.site == 'zhzczd');
-      console.log(zhzczd);
       let res = await this.policyNews({ skip: 0, limit: 8, column_id: zhzczd.id });
-      console.log(res);
       if (this.$checkRes(res)) {
         this.$set(this, `${zhzczd.site}List`, res.data);
       }
-      // if (site === 'zhzczd') {
-      //   const res = await this.policyNews({ skip, limit, column_id: column_id });
-      //   for (const val of res.data) {
-      //     const result = await this.policyColumnInfo(val.column_id);
-      //     val.column_name = result.data.name;
-      //   }
-      //   this.$set(this, `${site}List`, res.data);
-      // }
     },
     // 新品发布,创新服务
     async searchProduct({ skip = 0, limit = 6, ...info } = {}) {