From 13d23376c29447c1990525b7db18afc42d3f881a Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Fri, 28 Aug 2026 15:49:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(detailedReport):=20BMI=20=E5=88=BB=E5=BA=A6?= =?UTF-8?q?=E8=90=BD=E7=82=B9=E6=8C=89=E5=9B=9B=E6=AE=B5=E5=88=86=E7=95=8C?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=B9=B6=E8=AE=A1=E5=85=A5=E8=89=B2=E5=9D=97?= =?UTF-8?q?=E9=97=B4=E9=9A=99?= 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 | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/miniprogram/pages/detailedReport/detailedReport.ts b/miniprogram/pages/detailedReport/detailedReport.ts index 40db345..4267d58 100644 --- a/miniprogram/pages/detailedReport/detailedReport.ts +++ b/miniprogram/pages/detailedReport/detailedReport.ts @@ -159,11 +159,28 @@ const splitWeight = (weight: number): { int: string; decimal: string } => { return { int, decimal: `.${dec}` } } -/** 根据 BMI 计算刻度圆圈位置(百分比) */ +/** + * 刻度轨道结构(rpx):屏宽 750 - basicIndicators 左右 padding 30*2 - 左右 border 4*2 = 682。 + * BLOCK_GAP 与 less 中 basicIndicatorsTrack 的 gap: 6rpx 保持同步。 + */ +const TRACK_WIDTH = 682 +const BLOCK_GAP = 6 +const BLOCK_WIDTH = (TRACK_WIDTH - BLOCK_GAP * 3) / 4 + +/** 根据 BMI 计算刻度圆圈圆心位置(百分比),对齐消瘦/正常/超重/肥胖四段分界 18.5/24/28,并计入色块间隙 */ const calcBmiLeft = (bmi?: number): number => { if (bmi == null || isNaN(bmi)) return 0 - const pct = (bmi - 14) / (40 - 14) - return Math.min(Math.max(pct, 0), 1) * 100 + let left: number + if (bmi < 18.5) { + left = (bmi / 18.5) * BLOCK_WIDTH + } else if (bmi < 24) { + left = BLOCK_WIDTH + BLOCK_GAP + ((bmi - 18.5) / (24 - 18.5)) * BLOCK_WIDTH + } else if (bmi < 28) { + left = BLOCK_WIDTH * 2 + BLOCK_GAP * 2 + ((bmi - 24) / (28 - 24)) * BLOCK_WIDTH + } else { + left = BLOCK_WIDTH * 3 + BLOCK_GAP * 3 + ((bmi - 28) / (40 - 28)) * BLOCK_WIDTH + } + return Math.min(Math.max(left / TRACK_WIDTH, 0), 1) * 100 } Page({