wuhongyuq 5 years ago
parent
commit
f060f339cc

+ 8 - 26
src/layout/government/photoNews.vue

@@ -1,10 +1,13 @@
 <template>
 <template>
   <div id="phontoNews">
   <div id="phontoNews">
     <el-col :span="24" class="info">
     <el-col :span="24" class="info">
-      <el-link :underline="false">
-        <el-image style="width:550px;height:360px;" :src="photoNews.pic"> </el-image>
-        <p>{{ photoNews.title }}</p>
-      </el-link>
+      <div class="block">
+        <el-carousel height="150px">
+          <el-carousel-item v-for="(item, index) in photoNews" :key="index">
+            <el-image style="width:369px;height:242px;" :src="item.picture"></el-image>
+          </el-carousel-item>
+        </el-carousel>
+      </div>
     </el-col>
     </el-col>
   </div>
   </div>
 </template>
 </template>
@@ -23,25 +26,4 @@ export default {
 };
 };
 </script>
 </script>
 
 
-<style lang="less" scoped>
-p {
-  padding: 0;
-  margin: 0;
-}
-.info {
-  position: relative;
-  padding: 20px;
-}
-.info p {
-  display: block;
-  width: 540px;
-  height: 30px;
-  background-color: #22529a;
-  color: #fff;
-  position: absolute;
-  bottom: 4px;
-  left: 0px;
-  line-height: 30px;
-  padding: 0 0 0 10px;
-}
-</style>
+<style lang="less" scoped></style>

+ 38 - 0
src/store/affairsColumn.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  columnInfo: `/api/affairs/column`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.columnInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.columnInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.columnInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.columnInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.columnInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 38 - 0
src/store/affairsNews.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  newsInfo: `/api/affairs/news`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, column_id, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.newsInfo}`, { skip, limit, column_id, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.newsInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.newsInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 5 - 0
src/store/index.js

@@ -4,6 +4,9 @@ import site from './site';
 import link from './link';
 import link from './link';
 import policyColumn from './policyColumn';
 import policyColumn from './policyColumn';
 import policyNews from './policyNews';
 import policyNews from './policyNews';
+import affairsColumn from './affairsColumn';
+import affairsNews from './affairsNews';
+
 Vue.use(Vuex);
 Vue.use(Vuex);
 
 
 export default new Vuex.Store({
 export default new Vuex.Store({
@@ -12,6 +15,8 @@ export default new Vuex.Store({
     link,
     link,
     policyColumn,
     policyColumn,
     policyNews,
     policyNews,
+    affairsColumn,
+    affairsNews,
   },
   },
   state: {},
   state: {},
   mutations: {},
   mutations: {},

+ 48 - 3
src/views/government/government.vue

@@ -2,7 +2,7 @@
   <div id="government">
   <div id="government">
     <government-detail
     <government-detail
       :info="info"
       :info="info"
-      :photoNews="photoNews"
+      :photoNews="tpxwList"
       :zhengwu="zhengwu"
       :zhengwu="zhengwu"
       :chuangxinList="chuangxinList"
       :chuangxinList="chuangxinList"
       :guoneiList="guoneiList"
       :guoneiList="guoneiList"
@@ -20,6 +20,8 @@ import governmentDetail from '@/components/government/government.vue';
 import { createNamespacedHelpers, mapGetters } from 'vuex';
 import { createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: mapSite } = createNamespacedHelpers('site');
 const { mapActions: mapSite } = createNamespacedHelpers('site');
 const { mapActions: mapLink } = createNamespacedHelpers('link');
 const { mapActions: mapLink } = createNamespacedHelpers('link');
+const { mapActions: mapColumn } = createNamespacedHelpers('affairsColumn');
+const { mapActions: mapNews } = createNamespacedHelpers('affairsNews');
 export default {
 export default {
   name: 'government',
   name: 'government',
   props: {},
   props: {},
@@ -28,6 +30,7 @@ export default {
   },
   },
   data: () => ({
   data: () => ({
     info: {},
     info: {},
+    // 图片新闻
     photoNews: {
     photoNews: {
       pic: require('@/assets/photoNews.jpg'),
       pic: require('@/assets/photoNews.jpg'),
       title: '标题',
       title: '标题',
@@ -157,15 +160,25 @@ export default {
       },
       },
     ],
     ],
     linkList: [],
     linkList: [],
+    leftId: '',
+    tzggList: [],
+    mtjjList: [],
+    zwhdList: [],
+    gndtList: [],
+    cxjlList: [],
+    tpxwList: [],
   }),
   }),
   created() {
   created() {
     this.searchSite();
     this.searchSite();
     this.searchLink();
     this.searchLink();
+    this.searchColumn();
   },
   },
   computed: {},
   computed: {},
   methods: {
   methods: {
     ...mapSite(['showInfo']),
     ...mapSite(['showInfo']),
-    ...mapLink(['query']),
+    ...mapLink({ linksList: 'query' }),
+    ...mapColumn({ columnList: 'query', columnInfo: 'fetch' }),
+    ...mapNews({ newsList: 'query' }),
     // 查询站点信息
     // 查询站点信息
     async searchSite() {
     async searchSite() {
       let res = await this.showInfo();
       let res = await this.showInfo();
@@ -178,11 +191,43 @@ export default {
     },
     },
     //查询标题
     //查询标题
     async searchLink({ ...info } = {}) {
     async searchLink({ ...info } = {}) {
-      const res = await this.query({ ...info });
+      const res = await this.linksList({ ...info });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
         this.$set(this, `linkList`, res.data);
         this.$set(this, `linkList`, res.data);
       }
       }
     },
     },
+    // 查询科技政务栏目
+    async searchColumn({ ...info } = {}) {
+      const res = await this.columnList({ ...info });
+      for (const val of res.data) {
+        // if (val.site == 'tpxw') {
+        //   console.log(val.id);
+        //   this.$set(this, `leftId`, val.id);
+        //   this.tpxwSearch();
+        // } else if (val.site == 'cxjl') {
+        //   console.log(val.id);
+        // } else if (val.site == 'gndt') {
+        //   console.log(val.id);
+        // } else if (val.site == 'zwhd') {
+        //   console.log(val.id);
+        // } else if (val.site == 'mtjj') {
+        //   console.log(val.id);
+        // } else if (val.site == 'tzgg') {
+        //   console.log(val.id);
+        // }
+        this.tpxwSearch({ column_id: val.id, site: val.site });
+      }
+    },
+    // 查询信息列表
+    async tpxwSearch({ skip = 0, limit = 10, column_id, site } = {}) {
+      console.log(column_id, site);
+      const res = await this.newsList({ skip, limit, column_id: column_id });
+      for (const val of res.data) {
+        const result = await this.columnInfo(val.column_id);
+        val.column_name = result.data.name;
+      }
+      this.$set(this, `${site}List`, res.data);
+    },
   },
   },
 };
 };
 </script>
 </script>