Kaynağa Gözat

fix: 财富页邀请人数显示0 + 孩子页硬编码数据接口化

- 修复邀请人数始终为0:字段名不匹配,前端读取 totalCount/count,后端返回 invitedCount
- 孩子页 badgeCount / taskPercent 接入真实接口(/api/badges/statistics/child、/api/daily-task/overview)
- deltaPercent 硬编码 5.2 → 0,条件渲染避免显示假数据
- 新增 loadChildData() 获取孩子视角真实数据
Sisyphus Agent 4 gün önce
ebeveyn
işleme
1db308d5e7
2 değiştirilmiş dosya ile 36 ekleme ve 6 silme
  1. 34 4
      cfc-frontend/pages/wealth/index.vue
  2. 2 2
      cfc-frontend/utils/api.js

+ 34 - 4
cfc-frontend/pages/wealth/index.vue

@@ -144,7 +144,7 @@
         <view class="disc-card">
           <text class="disc-label">💰 累计收益</text>
           <text class="disc-value">¥{{ wealthData.totalEarnings || 0 }}</text>
-          <text class="disc-sub">较上月 ↑ {{ deltaPercent }}%</text>
+          <text class="disc-sub" v-if="deltaPercent > 0">较上月 ↑ {{ deltaPercent }}%</text>
         </view>
         <view class="disc-sub-row">
           <view class="disc-sub-card" @click="goToIncome">
@@ -246,7 +246,9 @@ import {
   getFamilyEnergySandbox,
   getEnergyOverview,
   productList,
-  extractReferralCode
+  extractReferralCode,
+  getChildBadgeStats,
+  getDailyTaskOverview
 } from '../../utils/api.js'
 import nav from '../../utils/nav.js'
 import config from '../../config.js'
@@ -278,7 +280,7 @@ export default {
         referralCode: ''
       },
       // 财富成长
-      deltaPercent: 5.2,
+      deltaPercent: 0,
       streamStages: [
         { key: 'start', icon: '💧', name: '起步', desc: '新人阶段', range: '0-30%' },
         { key: 'mid', icon: '🌊', name: '汇流', desc: '成长阶段', range: '30-70%' },
@@ -375,6 +377,7 @@ export default {
     this.loadChildren()
     this.loadWealthDetail()
     this.loadWealthData()
+    this.loadChildData()
     this.loadFamilyMembersVisible()
     this.loadInsuranceList()
     this.loadSandboxData()
@@ -532,7 +535,7 @@ export default {
       try {
         var summaryRes = await getReferralSummary()
         if (summaryRes && summaryRes.code === 200 && summaryRes.data) {
-          this.wealthData.referralCount = summaryRes.data.totalCount || summaryRes.data.count || 0
+          this.wealthData.referralCount = summaryRes.data.invitedCount || 0
         }
       } catch (e) {
         console.error('获取邀请统计失败', e)
@@ -547,6 +550,33 @@ export default {
         console.error('获取佣金统计失败', e)
       }
     },
+    async loadChildData() {
+      if (this.role !== 'child') return
+      var memberId = uni.getStorageSync('currentChildId')
+      if (!memberId && this.children.length > 0) {
+        memberId = this.children[0].id
+      }
+      if (!memberId) return
+      try {
+        var badgeRes = await getChildBadgeStats(memberId)
+        if (badgeRes && badgeRes.code === 200 && badgeRes.data) {
+          this.badgeCount = badgeRes.data.active || 0
+        }
+      } catch (e) {
+        console.error('获取徽章统计失败', e)
+      }
+      try {
+        var taskRes = await getDailyTaskOverview({ memberId: memberId })
+        if (taskRes && taskRes.code === 200 && taskRes.data && taskRes.data.tasks) {
+          var done = taskRes.data.tasks.doneToday || 0
+          var todo = taskRes.data.tasks.todoToday || 0
+          var total = done + todo
+          this.taskPercent = total > 0 ? Math.round(done / total * 100) : 0
+        }
+      } catch (e) {
+        console.error('获取任务概览失败', e)
+      }
+    },
     logout() {
       uni.showModal({
         title: '退出登录',

+ 2 - 2
cfc-frontend/utils/api.js

@@ -2841,8 +2841,8 @@ export const getNotificationList = () => request('/api/notification/list', 'POST
 export const readNotification = (data) => request('/api/notification/read', 'POST', data)
 
 // ===== 今日任务总览(首页卡片聚合:打卡/任务/阅读活动/测评报告) =====
-export const getDailyTaskOverview = () => {
-  return request('/api/daily-task/overview', 'POST', {})
+export const getDailyTaskOverview = (data) => {
+  return request('/api/daily-task/overview', 'POST', data || {})
 }
 
 // 体脂秤指标保存