Procházet zdrojové kódy

fix: 成长页推荐只调用一次API,前端按growth_category分组显示

iwt před 1 měsícem
rodič
revize
4a9ac40744
1 změnil soubory, kde provedl 8 přidání a 8 odebrání
  1. 8 8
      cfc-frontend/pages/growth-main/index.vue

+ 8 - 8
cfc-frontend/pages/growth-main/index.vue

@@ -396,15 +396,15 @@ export default {
     async loadGrowthRecommendations() {
       var self = this
       try {
-        var res = await getGrowthRecommendations('health', 3)
+        var res = await getGrowthRecommendations('health', 6)
         if (res && res.code === 200 && res.data) {
-          self.healthArticles = res.data.articles || []
-          self.healthProducts = res.data.products || []
-        }
-        var res2 = await getGrowthRecommendations('growth', 3)
-        if (res2 && res2.code === 200 && res2.data) {
-          self.growthArticles = res2.data.articles || []
-          self.growthProducts = res2.data.products || []
+          var arts = res.data.articles || []
+          var prods = res.data.products || []
+          // 按 growth_category 分组
+          self.healthArticles = arts.filter(function(a){ return a.growthCategory === 'health' })
+          self.healthProducts = prods.filter(function(p){ return p.growthCategory === 'health' })
+          self.growthArticles = arts.filter(function(a){ return a.growthCategory === 'growth' })
+          self.growthProducts = prods.filter(function(p){ return p.growthCategory === 'growth' })
         }
       } catch(e) {}
     },