Răsfoiți Sursa

fix(frontend): 戒备食材链路修复——caution-detail key 编译报错 + gut-flora 按报告主体传参

- caution-detail 成员 Tab 的 key 绑定原为运算符表达式(id 或 userId 兜底),
  微信小程序模板编译器不支持,改为 getMemberKey(item) 方法调用
- gut-flora-detail 戒备食材数量与戒备页跳转按报告 subjectId 传参,
  修复家长账号查询不到孩子推荐指数的问题
liaoxg 1 săptămână în urmă
părinte
comite
9abfe21d84

+ 2 - 1
cfc-frontend/pages/growth/caution-detail.vue

@@ -8,7 +8,7 @@
 
     <view class="member-bar" v-if="memberList.length > 1">
       <view class="member-tab" :class="{'active': currentMemberId === (item.id || item.userId)}"
-        v-for="item in memberList" :key="item.id || item.userId"
+        v-for="item in memberList" :key="getMemberKey(item)"
         @tap="switchMember(item)">
         <text class="member-name">{{ item.nickname || item.roleLabel || '全部' }}</text>
       </view>
@@ -85,6 +85,7 @@ export default {
   },
   methods: {
     getItemKey: function(item) { return item.foodId || item.id || Math.random() },
+    getMemberKey: function(item) { return item.id || item.userId || 'all' },
     goBack: function() {
       uni.navigateBack()
     },

+ 7 - 5
cfc-frontend/pages/health/gut-flora-detail.vue

@@ -596,10 +596,10 @@ export default {
               self.foodCount = (Array.isArray(foodRes.data) ? foodRes.data : []).length
             }
           }).catch(function() {})
-          // 异步加载戒备食材数量
-          var userId = uni.getStorageSync('userId')
-          if (userId) {
-            getFoodCautionList().then(function(cautionRes) {
+          // 异步加载戒备食材数量(按报告 subjectId 查,家长 userId 查不到孩子的推荐指数)
+          var cautionUserId = (self.report && self.report.subjectId) || uni.getStorageSync('userId')
+          if (cautionUserId) {
+            getFoodCautionList(cautionUserId).then(function(cautionRes) {
               if (cautionRes && cautionRes.code === 200) {
                 self.cautionCount = (cautionRes.data || []).length
               }
@@ -974,7 +974,9 @@ report.gutType = s.gutType || ''
       uni.navigateTo({ url: '/pages/health/gut-flora-foods-detail?reportId=' + this.reportId })
     },
     goToCaution: function() {
-      uni.navigateTo({ url: '/pages/growth/caution-detail' })
+      // 报告绑定主体(subjectId)即 food_recommend_idx 写入的用户维度,作为 memberId 传入戒备页
+      var mid = (this.report && this.report.subjectId) || uni.getStorageSync('currentMemberId') || ''
+      uni.navigateTo({ url: '/pages/growth/caution-detail' + (mid ? '?memberId=' + mid : '') })
     },
     goToIndicators: function() {
       // 展开所有营养分组手风琴