guhongwei 4 years ago
parent
commit
f1b6ec135f
2 changed files with 36 additions and 3 deletions
  1. 2 1
      src/store/index.js
  2. 34 2
      src/views/news/index.vue

+ 2 - 1
src/store/index.js

@@ -1,5 +1,6 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
+import news from '@common/src/store/news';
 
 Vue.use(Vuex);
 
@@ -7,5 +8,5 @@ export default new Vuex.Store({
   state: {},
   mutations: {},
   actions: {},
-  modules: {},
+  modules: { news },
 });

+ 34 - 2
src/views/news/index.vue

@@ -39,6 +39,7 @@
 import top from './parts/top.vue';
 import list from './parts/list.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: news } = createNamespacedHelpers('news');
 export default {
   name: 'index',
   props: {},
@@ -116,10 +117,41 @@ export default {
           release_time: '2021-01-16',
         },
       ],
+      column: [
+        { name: '政务动态', site: 'one', limit: 11 },
+        { name: '通知通告', site: 'two', limit: 11 },
+        { name: '科技新闻', site: 'thr', limit: 4 },
+        { name: '媒体聚焦', site: 'four', limit: 11 },
+        { name: '信息公开', site: 'five', limit: 12 },
+      ],
     };
   },
-  created() {},
-  methods: {},
+  async created() {
+    await this.search();
+  },
+  methods: {
+    ...news(['query']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      for (const val of this.column) {
+        if (val.name == '政务动态') {
+          let res = await this.query({ skip, limit: val.limit, column_name: val.name, ...info });
+          if (this.$checkRes(res)) this.$set(this, `${val.site}List`, res.data);
+        } else if (val.name == '通知通告') {
+          let res = await this.query({ skip, limit: val.limit, column_name: val.name, ...info });
+          if (this.$checkRes(res)) this.$set(this, `${val.site}List`, res.data);
+        } else if (val.name == '科技新闻') {
+          let res = await this.query({ skip, limit: val.limit, column_name: val.name, ...info });
+          if (this.$checkRes(res)) this.$set(this, `${val.site}List`, res.data);
+        } else if (val.name == '媒体聚焦') {
+          let res = await this.query({ skip, limit: val.limit, column_name: val.name, ...info });
+          if (this.$checkRes(res)) this.$set(this, `${val.site}List`, res.data);
+        } else if (val.name == '信息公开') {
+          let res = await this.query({ skip, limit: val.limit, column_name: val.name, ...info });
+          if (this.$checkRes(res)) this.$set(this, `${val.site}List`, res.data);
+        }
+      }
+    },
+  },
   computed: {
     ...mapState(['user']),
   },