Browse Source

新增横幅从服务获取

fwinfo 10 months ago
parent
commit
58d57fb1ad
2 changed files with 21 additions and 20 deletions
  1. 13 0
      src/store/index.js
  2. 8 20
      src/views/Home.vue

+ 13 - 0
src/store/index.js

@@ -27,6 +27,7 @@ const state = () => ({
   contentsItem: null,
   pagesItem: null,
   upwindow: [],
+  scrollList: [],
   dict: {},
   searchList: []
 });
@@ -105,6 +106,11 @@ const actions = {
     commit('upWindewQuery', res);
     return res;
   },
+  async upScrollQuery ({ commit }) {
+    const res = await $axios.get(api.imgNewsQuery, { isshow: true, bind: 'scroll' });
+    commit('upScrollQuery', res);
+    return res;
+  },
   async leaderList ({ commit }, payload) {
     const res = await $axios.get(api.contentsQuery, payload);
     return res.data;
@@ -133,6 +139,13 @@ const mutations = {
   upWindewQuery(state, payload) {
     state.upwindow = payload.data;
   },
+  upScrollQuery(state, payload) {
+    if (payload.data.length == 2) {
+      state.scrollList = payload.data.concat(payload.data);
+    } else {
+      state.scrollList = payload.data;
+    }
+  },
   linkTypeQuery(state, payload) {
     state.linkTypeList = payload.data.filter(e => e.code.indexOf('link') !== -1);
   },

+ 8 - 20
src/views/Home.vue

@@ -1,25 +1,11 @@
 <template>
   <div class="home">
     <el-carousel height="100px" class="hfbox" direction="vertical" autoplay :interval="3000">
-      <el-carousel-item>
-        <a class="hf" href="http://www.news.cn/zt/djxxjy/index.html">
-          <img src="../assets/hf1.jpg" class="hfimg">
-        </a>
-      </el-carousel-item>
-      <el-carousel-item>
-        <a class="hf" href="http://www.gov.cn/zhuanti/zggcddescqgdbdh/index.htm">
-          <img src="../assets/hf2.jpg" class="hfimg">
-        </a>
-      </el-carousel-item>
-      <el-carousel-item>
-        <a class="hf" href="http://www.news.cn/zt/djxxjy/index.html">
-          <img src="../assets/hf1.jpg" class="hfimg">
-        </a>
-      </el-carousel-item>
-      <el-carousel-item>
-        <a class="hf" href="http://www.gov.cn/zhuanti/zggcddescqgdbdh/index.htm">
-          <img src="../assets/hf2.jpg" class="hfimg">
+      <el-carousel-item v-for="(item, index) in scrollList" :key="index">
+        <a class="hf" :href="item.url" v-if="item.url">
+          <img :src="item.img" class="hfimg">
         </a>
+        <img :src="item.img" class="hfimg" v-else>
       </el-carousel-item>
     </el-carousel>
     <div class="listBox">
@@ -63,7 +49,7 @@ export default {
     links
   },
   computed: {
-    ...mapState(['menusall'])
+    ...mapState(['menusall', 'scrollList'])
   },
   data() {
     return {
@@ -136,9 +122,11 @@ export default {
     await this.btnClick({ name: '10', type: 'threeDatagg', limit: 6, parentCode: true });
     // 所有菜单
     await this.menusQueryAll();
+    // 横幅
+    await this.upScrollQuery();
   },
   methods: {
-    ...mapActions(['contentsQuery', 'menusQueryAll', 'sourceQuery']),
+    ...mapActions(['contentsQuery', 'menusQueryAll', 'sourceQuery', 'upScrollQuery']),
     async btnClick(e) {
       const filter = { bind: e?.name };
       if (e?.parentCode) filter.parentCode = e?.name;