Sfoglia il codice sorgente

chore: auto bump version and changelog [skip ci]

iwt 3 settimane fa
parent
commit
576b015bff
2 ha cambiato i file con 33 aggiunte e 12 eliminazioni
  1. 32 11
      cfc-frontend/pages/index-home/index.vue
  2. 1 1
      cfc-web/.last_build_commit

+ 32 - 11
cfc-frontend/pages/index-home/index.vue

@@ -514,6 +514,8 @@ components: {
       currentChildId: null,
       activeChallenges: [],
       pendingTasks: [],
+      familyTasks: [],
+      familyTodoCount: 0,
       familyFeed: [],
       notices: [],
       loggedInInitDone: false,
@@ -653,12 +655,12 @@ title: '添加家庭成员',
           color: 'blue'
         }
       }
-      // 4) 待办任务 — 用户已完成自检后的执行路径
-      if (this.pendingTasks && this.pendingTasks.length > 0) {
+      // 4) 家庭待办任务 — 用户已完成自检后的执行路径
+      if (this.familyTodoCount > 0) {
         return {
           type: 'task',
           icon: '🎯',
-          title: '今日有 ' + this.pendingTasks.length + ' 项待办',
+          title: '今天有 ' + this.familyTodoCount + ' 项家庭任务',
           sub: '完成可累积成长分',
           btn: '去完成',
           color: 'green'
@@ -1108,31 +1110,50 @@ title: '添加家庭成员',
     },
     loadTodayTasks: function() {
       var self = this
-      // 「我的任务」只展示当前登录用户自己的任务:
-      // 不传 memberId,由后端按 JWT 的 currentMemberId(始终是登录账号自己)返回,
-      // 不再按家庭聚合(familyWide),避免混入其他家庭成员的任务
-      getTodayTasks().then(function(res) {
-        if (res.code === 200 && Array.isArray(res.data)) {
-          self.pendingTasks = res.data.filter(function(t) {
+      // 并行请求:个人今日任务 + 全家今日任务(用于家庭任务数统计)
+      var personalPromise = getTodayTasks()
+      var familyPromise = getTodayTasks(null, { familyWide: true })
+      Promise.all([personalPromise, familyPromise]).then(function(results) {
+        var personalRes = results[0]
+        var familyRes = results[1]
+        // 个人待办任务(仅本人,含超期和联动类型标记)
+        if (personalRes.code === 200 && Array.isArray(personalRes.data)) {
+          self.pendingTasks = personalRes.data.filter(function(t) {
             if (t.status !== 'pending') return false
-            // 有 latestEnd 的任务:latestEnd 已过后前端标记为超期,不再显示「完成」按钮
             if (t.latestEnd) {
               var d = self.parseDate(t.latestEnd)
               if (d && d < new Date()) {
                 t._isOverdue = true
               }
             }
-            // 打卡/联动类任务在首页显示「去完成」,点击跳转对应功能页而非直接完成
             if (t.actionType && ['minigame', 'focus', 'survey', 'article', 'activity', 'cart', 'order', 'diet', 'sleep', 'exercise'].indexOf(t.actionType) >= 0) {
               t._isLinked = true
             }
             return true
           })
         }
+        // 全家待办数(pending + in_progress)
+        if (familyRes.code === 200 && Array.isArray(familyRes.data)) {
+          self.familyTasks = familyRes.data
+          self.familyTodoCount = self.countFamilyPendingInProgress(familyRes.data)
+        }
       }).catch(function() {
         self.pendingTasks = []
+        self.familyTasks = []
+        self.familyTodoCount = 0
       })
     },
+    // 统计 pending + in_progress 数量(全家)
+    countFamilyPendingInProgress: function(tasks) {
+      var count = 0
+      for (var i = 0; i < tasks.length; i++) {
+        var t = tasks[i]
+        if (t && (t.status === 'pending' || t.status === 'in_progress')) {
+          count += 1
+        }
+      }
+      return count
+    },
     loadFamilyFeed: function() {
       var self = this
       // 仅对第一个孩子拉取任务历史(避免 N 个孩子 N 次 /api/tasks/history 请求)

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-ad3a7d73ce05678205c8b1c593358705de59c157
+aef94503ccabc9ca1903934adcd63a0b2d9b74c6