Parcourir la source

fix(frontend): 健康主页身维度雷达图改用真实API数据

- 调用 /api/dimension/overview 获取七维健康数据替代硬编码假数据
- chartIsEmpty 和 currentScores 均改用 bodyData
- 与其他四维度(智/心/行/富)统一走后端API模式
Sisyphus il y a 1 mois
Parent
commit
7e488ad84e
1 fichiers modifiés avec 13 ajouts et 2 suppressions
  1. 13 2
      cfc-frontend/pages/health-main/index.vue

+ 13 - 2
cfc-frontend/pages/health-main/index.vue

@@ -305,6 +305,7 @@ export default {
       ],
       demoCogScores: [78, 72, 85, 68, 80],
       // 真实数据缓存
+      bodyData: null,
       cognitiveData: null,
       cognitiveFamilyData: [],
       emiData: null,
@@ -389,6 +390,10 @@ export default {
         if (!d) return [0, 0, 0, 0]
         return [d.wealthSkill || 0, d.wealthAltruism || 0, d.wealthIncome || 0, d.wealthFx || 0]
       }
+      // body: 从 API 真实维度数据取分
+      if (this.bodyData && this.bodyData.dimensions && this.bodyData.dimensions.length > 0) {
+        return this.bodyData.dimensions.map(function(d) { return Number(d.score) || 0 })
+      }
       // body: fallback to demo
       if (this.reports.length > 0) {
         var latest = this.reports[0]
@@ -434,7 +439,7 @@ export default {
       return []
     },
     chartIsEmpty: function() {
-      if (this.currentTab === 'body') return this.reports.length === 0
+      if (this.currentTab === 'body') return !this.bodyData || !this.bodyData.dimensions || this.bodyData.dimensions.length === 0
       if (this.currentTab === 'cognitive') return !this.cognitiveData || !this.cognitiveData.overallScore
       if (this.currentTab === 'mental') return !this.emiData || !this.emiData.overallScore
       if (this.currentTab === 'relationship') return !this.relationshipData || this.relationshipData.length === 0
@@ -529,7 +534,13 @@ export default {
             }
           }).catch(function() {})
         }
-        // 文章
+        // 身体七维概览
+      if (memberId) {
+        api.getDimensionOverview({ memberId: memberId }).then(function(res) {
+          if (res.code === 200 && res.data) self.bodyData = res.data
+        }).catch(function() {})
+      }
+      // 文章
         api.getFeaturedArticles({ size: 3, dimensionCode: 'body' }).then(function(res) {
           if (res.code === 200 && res.data) {
             var list = Array.isArray(res.data) ? res.data : (res.data.records || [])