chending1994 пре 5 година
родитељ
комит
36e16daf6d
1 измењених фајлова са 49 додато и 40 уклоњено
  1. 49 40
      pages/news/newsView/_id.vue

+ 49 - 40
pages/news/newsView/_id.vue

@@ -52,17 +52,19 @@
           热门文章
         </div>
         <div class="hot-list">
-          <div class="hot-item" v-for="(item, index) in articleList" :key="index">
-            <div class="hot-title">
-              <nuxt-link target="_blank" :to="{name: 'news-newsView-id', params: { id: item.id }, query: {cateId: item.cateId } }">
-                {{ item.title }}
-              </nuxt-link>
-            </div>
-            <div class="hot-info">
-              <span class="time">{{ item.time }}</span>
-              <span class="views">观看人数:{{ item.views}}</span>
+          <template v-for="(item, index) in articleList">
+            <div class="hot-item" v-if="index < 3" :key="index">
+              <div class="hot-title">
+                <nuxt-link :to="{name: 'news-newsView-id', params: { id: item.id }, query: {cateId: item.typeId } }">
+                  {{ item.articleTitle }}
+                </nuxt-link>
+              </div>
+              <div class="hot-info">
+                <span class="time">{{ item.createTime }}</span>
+                <span class="views">观看人数:111</span>
+              </div>
             </div>
-          </div>
+          </template>
         </div>
         <div class="hot-top-style"></div>
       </div>
@@ -75,42 +77,49 @@ import axios from "axios";
 export default {
   data() {
     return {
-      articleList: [
-        {
-          title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
-          time: '2020-6-29',
-          content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
-          imgUrl: require('~/assets/images/news/img.png'),
-          id: '1',
-          cateId: '1',
-          views: 103,
-        },
-        {
-          title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
-          time: '2020-6-29',
-          content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
-          imgUrl: require('~/assets/images/news/img.png'),
-          id: '2',
-          cateId: '2',
-          views: 141,
-        },
-        {
-          title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
-          time: '2020-6-29',
-          content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
-          imgUrl: require('~/assets/images/news/img.png'),
-          id: '3',
-          cateId: '3',
-          views: 165,
-        }
-      ]
+      // articleList: [
+      //   {
+      //     title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
+      //     time: '2020-6-29',
+      //     content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
+      //     imgUrl: require('~/assets/images/news/img.png'),
+      //     id: '1',
+      //     cateId: '1',
+      //     views: 103,
+      //   },
+      //   {
+      //     title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
+      //     time: '2020-6-29',
+      //     content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
+      //     imgUrl: require('~/assets/images/news/img.png'),
+      //     id: '2',
+      //     cateId: '2',
+      //     views: 141,
+      //   },
+      //   {
+      //     title: '中德智慧乔迁逻辑狗智慧乔迁智慧乔迁标题中德智 迁标题中德智迁标题中德智慧乔迁……..',
+      //     time: '2020-6-29',
+      //     content: '个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人的何时去个人 的人的何时去个人的何时去…… ',
+      //     imgUrl: require('~/assets/images/news/img.png'),
+      //     id: '3',
+      //     cateId: '3',
+      //     views: 165,
+      //   }
+      // ]
     };
   },
   
   async asyncData({ params, query, store }) {
     const { data: { data: news} } = await axios(`${store.state.wordpressAPI}/official-api/article/get/${params.id}`);
+    const { data: { data: article }} = await axios(`${store.state.wordpressAPI}/official-api/article`, {
+      params: {
+        page: 1
+      }
+    });
+    const articleList = article.entityList || []; 
     return {
-      news
+      news,
+      articleList
     }
   },
   head() {