From bf501de628a45687473ba22d94278fb58b05d894 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Thu, 3 Sep 2026 11:45:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(detailedReport):=20=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=8C=87=E6=A0=87label=E5=86=99=E6=AD=BB=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E6=98=BE=E7=A4=BA-=E3=80=81=E8=BA=AF=E5=B9=B2=E5=9B=9B?= =?UTF-8?q?=E8=82=A2=E6=97=A0=E6=95=B0=E6=8D=AE=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- .../pages/detailedReport/detailedReport.ts | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/miniprogram/pages/detailedReport/detailedReport.ts b/miniprogram/pages/detailedReport/detailedReport.ts index 3f6cb96..d946fba 100644 --- a/miniprogram/pages/detailedReport/detailedReport.ts +++ b/miniprogram/pages/detailedReport/detailedReport.ts @@ -124,6 +124,15 @@ const BMI_TYPE_COLOR: Record = { 肥胖: '#F24439', } +/** 基础指标:label 前端写死 */ +const BASIC_INDICATORS: { key: string; label: string }[] = [ + { key: 'ppWeightKg', label: '体重' }, + { key: 'ppBMI', label: 'BMI' }, + { key: 'ppFat', label: '体脂率' }, + { key: 'ppBodyScore', label: '健康评分' }, + { key: 'ppBodyHealth', label: '健康评价' }, +] + /** 将 bodyDataList 转为 key -> 指标 的映射 */ const toMap = (list: LefuBodyDatum[] = []): Record => { const map: Record = {} @@ -259,21 +268,22 @@ Page({ changeText, } - // 基础指标(2 行 x 3 列,第 6 格留空保持布局) - const basicKeys = ['ppWeightKg', 'ppBMI', 'ppFat', 'ppBodyScore', 'ppBodyHealth'] - const basicCells: BasicCell[] = basicKeys.map((k) => { - const d = map[k] - if (!d) return { ...EMPTY_BASIC_CELL } - const isScore = k === 'ppBodyScore' - const isHealth = k === 'ppBodyHealth' - const isBmi = k === 'ppBMI' + // 基础指标(2 行 x 3 列,第 6 格留空保持布局;label 前端写死,缺失值显示 -) + const basicCells: BasicCell[] = BASIC_INDICATORS.map(({ key, label }) => { + const d = map[key] + const isScore = key === 'ppBodyScore' + const isHealth = key === 'ppBodyHealth' + const isBmi = key === 'ppBMI' + if (!d) { + return { label, labelExtra: '', labelExtraColor: '', value: '-', unit: '' } + } return { - label: d.bodyParamName || k, + label, // BMI 名称后跟体型状态(消瘦/正常/超重/肥胖) labelExtra: isBmi ? data.bmiType || '' : '', labelExtraColor: isBmi ? BMI_TYPE_COLOR[data.bmiType || ''] || DEFAULT_STATUS_COLOR : '', // 健康评价展示等级文案(如"亚健康"),其余展示测量数值 - value: isHealth ? d.standardTitle || d.currentValue || '' : d.currentValue || '', + value: isHealth ? d.standardTitle || d.currentValue || '-' : d.currentValue || '-', // 健康评分补"分" unit: isScore ? d.unit || '分' : isHealth ? '' : d.unit || '', } @@ -350,7 +360,8 @@ Page({ ['右腿', 'ppBodyFatKgRightLeg', 'ppBodyFatRateRightLeg'], ['躯干', 'ppBodyFatKgTrunk', 'ppBodyFatRateTrunk'], ] - const bodyFat = isEight + const hasBodyFatData = fatPartLabels.some(([, massKey, rateKey]) => map[massKey] || map[rateKey]) + const bodyFat = isEight && hasBodyFatData ? { title: '躯干/四肢脂肪', rows: chunkParts( @@ -368,7 +379,8 @@ Page({ ['右腿', 'ppMuscleKgRightLeg', 'ppMuscleRateRightLeg'], ['躯干', 'ppMuscleKgTrunk', 'ppMuscleRateTrunk'], ] - const bodyMuscle = isEight + const hasBodyMuscleData = musclePartLabels.some(([, massKey, rateKey]) => map[massKey] || map[rateKey]) + const bodyMuscle = isEight && hasBodyMuscleData ? { title: '躯干/四肢肌肉', rows: chunkParts(