|
|
@@ -6,35 +6,35 @@
|
|
|
<view class="menu-item" @click="openDetail('physical','height')">
|
|
|
<image src="/static/icons/remixicon/height.svg" class="menu-icon" mode="widthFix" />
|
|
|
<text class="menu-text">身高</text>
|
|
|
- <text class="menu-value">--</text>
|
|
|
+ <text class="menu-value">{{ height !== null ? height + 'cm' : '--' }}</text>
|
|
|
<uni-icons class="menu-arrow" type="arrowright" size="20" color="#c0c0c0" />
|
|
|
</view>
|
|
|
<view class="menu-item" @click="openDetail('physical','weight')">
|
|
|
<image src="/static/icons/remixicon/weight.svg" class="menu-icon" mode="widthFix" />
|
|
|
<text class="menu-text">体重</text>
|
|
|
- <text class="menu-value">--</text>
|
|
|
+ <text class="menu-value">{{ weight !== null ? weight + 'kg' : '--' }}</text>
|
|
|
<uni-icons class="menu-arrow" type="arrowright" size="20" color="#c0c0c0" />
|
|
|
</view>
|
|
|
<view class="menu-item" @click="openDetail('physical','bmi')">
|
|
|
<image src="/static/icons/remixicon/bmi.svg" class="menu-icon" mode="widthFix" />
|
|
|
<text class="menu-text">BMI</text>
|
|
|
- <text class="menu-value">--</text>
|
|
|
+ <text class="menu-value">{{ bmi !== null ? (Number.isFinite(Number(bmi)) ? Number(bmi).toFixed(1) : bmi) : '--' }}</text>
|
|
|
<uni-icons class="menu-arrow" type="arrowright" size="20" color="#c0c0c0" />
|
|
|
</view>
|
|
|
<view class="menu-item" @click="openDetail('blood-pressure')"><image src="/static/icons/remixicon/scan-line.svg" class="menu-icon" mode="widthFix" />
|
|
|
<text class="menu-text">血压</text>
|
|
|
- <text class="menu-value">--</text>
|
|
|
+ <text class="menu-value">{{ systolic !== null && diastolic !== null ? systolic + '/' + diastolic : '--' }}</text>
|
|
|
<uni-icons class="menu-arrow" type="arrowright" size="20" color="#c0c0c0" />
|
|
|
</view>
|
|
|
<view class="menu-item" @click="openDetail('blood-glucose')"><image src="/static/icons/remixicon/contrast-drop-2-line.svg" class="menu-icon" mode="widthFix" />
|
|
|
<text class="menu-text">血糖</text>
|
|
|
- <text class="menu-value">--</text>
|
|
|
+ <text class="menu-value">{{ bloodGlucose !== null ? (bloodGlucoseType ? bloodGlucoseType + ' ' + bloodGlucose : String(bloodGlucose)) : '--' }}</text>
|
|
|
<uni-icons class="menu-arrow" type="arrowright" size="20" color="#c0c0c0" />
|
|
|
</view>
|
|
|
<view class="menu-item" @click="openDetail('heart-rate')">
|
|
|
<image src="/static/icons/remixicon/heart-pulse.svg" class="menu-icon" mode="widthFix" />
|
|
|
<text class="menu-text">心率</text>
|
|
|
- <text class="menu-value">--</text>
|
|
|
+ <text class="menu-value">{{ heartRate !== null ? heartRate + ' bpm' : '--' }}</text>
|
|
|
<uni-icons class="menu-arrow" type="arrowright" size="20" color="#c0c0c0" />
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -53,12 +53,59 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { ref } from 'vue'
|
|
|
+import { onShow } from '@dcloudio/uni-app'
|
|
|
+import { getLatestOverview } from '@/api/patientData'
|
|
|
|
|
|
import CustomNav from '@/components/custom-nav.vue'
|
|
|
import TabBar from '@/components/tab-bar.vue'
|
|
|
|
|
|
const title = ref('健康数据')
|
|
|
|
|
|
+const height = ref<number | null>(null)
|
|
|
+const weight = ref<number | null>(null)
|
|
|
+const bmi = ref<number | null>(null)
|
|
|
+const systolic = ref<number | null>(null)
|
|
|
+const diastolic = ref<number | null>(null)
|
|
|
+const bloodGlucose = ref<number | null>(null)
|
|
|
+const bloodGlucoseType = ref<string | null>(null)
|
|
|
+const heartRate = ref<number | null>(null)
|
|
|
+
|
|
|
+async function loadOverview() {
|
|
|
+ try {
|
|
|
+ console.log('[patient-data] loadOverview start')
|
|
|
+ const res: any = await getLatestOverview()
|
|
|
+ // `request()` 返回的 res 包含 data 字段,data 字段里才是后端返回的 { code, message, data }
|
|
|
+ // 为了兼容其他实现,支持两类响应结构:
|
|
|
+ // 1) res.data === { code, message, data }
|
|
|
+ // 2) res === { code, message, data }
|
|
|
+ let payload: any = null
|
|
|
+ if (res && res.data && res.data.code === 200 && res.data.data) {
|
|
|
+ payload = res.data.data
|
|
|
+ } else if (res && res.code === 200 && res.data) {
|
|
|
+ payload = res.data
|
|
|
+ }
|
|
|
+ if (payload) {
|
|
|
+ const data = payload
|
|
|
+ console.log('[patient-data] response data:', data)
|
|
|
+ height.value = data.height ?? null
|
|
|
+ weight.value = data.weight ?? null
|
|
|
+ bmi.value = data.bmi ?? null
|
|
|
+ systolic.value = data.systolicPressure ?? null
|
|
|
+ diastolic.value = data.diastolicPressure ?? null
|
|
|
+ bloodGlucose.value = data.bloodGlucose ?? null
|
|
|
+ bloodGlucoseType.value = data.bloodGlucoseType ?? null
|
|
|
+ heartRate.value = data.heartRate ?? null
|
|
|
+ console.log('[patient-data] height,weight,bmi:', height.value, weight.value, bmi.value)
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('[patient-data] loadOverview error', e)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onShow(() => {
|
|
|
+ loadOverview()
|
|
|
+})
|
|
|
+
|
|
|
const openDetail = (type: string, metric?: string) => {
|
|
|
const url = metric ? `details/${type}?metric=${metric}` : `details/${type}`
|
|
|
uni.navigateTo({ url })
|