wxy 4 tahun lalu
induk
melakukan
1fe77de694
1 mengubah file dengan 61 tambahan dan 27 penghapusan
  1. 61 27
      src/views/index.vue

+ 61 - 27
src/views/index.vue

@@ -34,10 +34,18 @@ export default {
     map: require('@/assets/map.jpg'),
     gndtList: [],
     tzggList: [],
+    //综合政策指导
     zhzczdList: [],
+    //友情链接
     linkList: [],
     xinpinList: [],
     chuangxinList: [],
+    // 科技政务栏目
+    affairsCol: [],
+    // 科技政策栏目
+    affairsCol1: [],
+    // 最新資訊
+    zxzxList: [],
   }),
   created() {
     this.searchSite();
@@ -75,43 +83,69 @@ export default {
     // 最新資訊,通知公告(所属科技政务,国内动态,通知公告)
     async searchAffairs({ ...info } = {}) {
       const res = await this.affairsColumnList({ ...info });
-      for (const val of res.data) {
-        this.tpxwSearch({ column_id: val.id, site: val.site });
+      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 });
+      // }
     },
-    async tpxwSearch({ skip = 0, limit = 8, column_id, site } = {}) {
-      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 tpxwSearch() {
+      let zxzx = this.affairsCol.find(i => i.site == 'gndt');
+      let tzgg = this.affairsCol.find(i => i.site == 'tzgg');
+      let res = await this.affairsNews({ skip: 0, limit: 8, column_id: zxzx.id });
+      if (this.$checkRes(res)) {
+        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)) {
+        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 });
-      for (const val of res.data) {
-        this.zhzcdPolicy({ column_id: val.id, site: val.site });
+      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({ skip = 0, limit = 8, column_id, site } = {}) {
-      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 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 } = {}) {