Browse Source

调整热门新闻

wangxy 2 years ago
parent
commit
2bc1e4695c
3 changed files with 42 additions and 3 deletions
  1. 14 1
      components/footer.vue
  2. 14 1
      components/footer2.vue
  3. 14 1
      store/index.js

+ 14 - 1
components/footer.vue

@@ -42,6 +42,10 @@
             <dd class="two-code-box">微信公众号<i class="two-dimensional-code"></i></dd>
             <!--<dd>新浪微博</dd>-->
           </dl>
+          <dl>
+            <dt>热门新闻</dt>
+            <dd v-for="item in hotList" :key="item.iiId" @click="checkNews(item)">{{item.title}}</dd>
+          </dl>
         </div>
         <div class="contact-right-box">
           <div class="right-sw-box">
@@ -86,7 +90,10 @@
       requestData() {
         return this.getFooterYouQingLianJie;
       },
-      ...mapGetters(['getFooterYouQingLianJie','getBaseUrl']),
+      hotList() {
+        return this.getHotList;
+      },
+      ...mapGetters(['getFooterYouQingLianJie','getBaseUrl', 'getHotList']),
     },
     data() {
       return {
@@ -113,6 +120,12 @@
       }
     },
     methods: {
+      checkNews(item) {
+        const opt = {
+          id: item.code,
+        };
+        this.$router.push({ name: 'news-id', params: opt });
+      },
       goToPage(item) {
         window.location.href = item.url
       },

+ 14 - 1
components/footer2.vue

@@ -33,6 +33,10 @@
                <dd class="two-code-box">微信公众号<i class="two-dimensional-code"></i></dd>
                <!--<dd>新浪微博</dd>-->
              </dl>
+             <dl>
+               <dt>热门新闻</dt>
+               <dd v-for="item in hotList" :key="item.iiId" @click="checkNews(item)">{{item.title}}</dd>
+             </dl>
            </div>
            <div class="contact-right-box">
              <div class="right-sw-box">
@@ -61,7 +65,10 @@
   export default {
     name:    'mtaFooter',
     computed: {
-
+      hotList() {
+        return this.getHotList;
+      },
+      ...mapGetters(['getHotList']),
     },
     data() {
       return {
@@ -69,6 +76,12 @@
       }
     },
     methods: {
+      checkNews(item) {
+        const opt = {
+          id: item.code,
+        };
+        this.$router.push({ name: 'news-id', params: opt });
+      },
       // 考试链接
       goExamPage(){
         this.$router.push({ name: 'examsystem' });

+ 14 - 1
store/index.js

@@ -5,11 +5,15 @@
 
 export const state = () => ({
   FooterYouQingLianJie: [],
+  hotList: [],
   BASE_URL: process.env.baseUrl,
   ActiveNav: '/'
 })
 
 export const getters = {
+  getHotList(state) {
+    return state.hotList;
+  },
   getFooterYouQingLianJie(state) {
     return state.FooterYouQingLianJie;
   },
@@ -28,10 +32,19 @@ export const mutations = {
   },
   setActiveNav(state, payload) {
     state.ActiveNav = payload;
+  },
+  setHotList(state, payload) {
+    state.hotList = payload;
   }
 }
 
-
+export const actions = {
+  async nuxtServerInit({commit}, {$axios}) {
+    // 初始化store
+    const { data:data2 } = await $axios.post('/home/news/hot');
+    commit('setHotList', data2.data || []);
+  }
+}