Browse Source

首页新闻推荐数据问题

yangc 8 years ago
parent
commit
b60c320b24
2 changed files with 11 additions and 7 deletions
  1. 4 4
      components/home/News.vue
  2. 7 3
      pages/store/_uuid/index.vue

+ 4 - 4
components/home/News.vue

@@ -43,13 +43,13 @@
         return this.$store.state.news.snapshot
       },
       news3 () {
-        if (this.news.data.content) {
-          return this.news.data.content.slice(0, 3)
+        if (this.news.data) {
+          return this.news.data.slice(0, 3)
         }
       },
       news5 () {
-        if (this.news.data.content) {
-          return this.news.data.content.slice(0, 5)
+        if (this.news.data) {
+          return this.news.data.slice(0, 5)
         }
       }
     }

+ 7 - 3
pages/store/_uuid/index.vue

@@ -22,9 +22,13 @@ export default {
       store.dispatch('shop/pageCommoditiesOfStore', params.uuid, { page: 1, count: 6 })
     ])
   },
-  async asyncData ({ params }) {
-    let { data } = await axios.get('/api/commodity/components/kinds', { params: { StoreUuid: params.uuid } })
-    return { kinds: data }
+//  async asyncData ({ params }) {
+  asyncData ({ params }) {
+//    let { data } = await axios.get('/api/commodity/components/kinds', { params: { StoreUuid: params.uuid } })
+    axios.get('/api/commodity/components/kinds', { params: { StoreUuid: params.uuid } })
+      .then(response => {
+        return { kinds: response.data }
+      })
   },
   components: {
     RecommendProduct,