From 601b2d7f52e92d8b33b0878d706198ba5b347c09 Mon Sep 17 00:00:00 2001 From: iven Date: Tue, 28 Apr 2026 19:42:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(mp):=20=E9=A6=96=E9=A1=B5=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=8A=B6=E6=80=81=E5=8D=A1=E7=89=87=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=20=E2=80=94=20=E8=A1=80=E5=8E=8B=E8=AE=A1/=E8=A1=80=E7=B3=96?= =?UTF-8?q?=E4=BB=AA=E5=BF=AB=E6=8D=B7=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/DeviceCard/index.scss | 51 +++++++++++++++++++ .../src/components/DeviceCard/index.tsx | 39 ++++++++++++++ apps/miniprogram/src/pages/index/index.tsx | 24 +++++++-- 3 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 apps/miniprogram/src/components/DeviceCard/index.scss create mode 100644 apps/miniprogram/src/components/DeviceCard/index.tsx diff --git a/apps/miniprogram/src/components/DeviceCard/index.scss b/apps/miniprogram/src/components/DeviceCard/index.scss new file mode 100644 index 0000000..1708aa7 --- /dev/null +++ b/apps/miniprogram/src/components/DeviceCard/index.scss @@ -0,0 +1,51 @@ +@import '../../styles/variables.scss'; + +.device-card { + display: flex; + align-items: center; + padding: 24rpx; + background: $card; + border-radius: $r; + margin-bottom: 16rpx; + box-shadow: $shadow-sm; + + .device-icon { + font-size: 48rpx; + margin-right: 20rpx; + } + + .device-info { + flex: 1; + + .device-name { + font-size: 28rpx; + font-weight: 600; + color: $tx; + display: block; + } + + .device-status { + font-size: 24rpx; + margin-top: 4rpx; + display: block; + + &.connected { color: $pri; } + &.idle { color: $tx3; } + } + + .last-sync { + font-size: 22rpx; + color: $tx3; + margin-top: 4rpx; + display: block; + } + } + + .sync-btn { + padding: 12rpx 28rpx; + background: $pri; + color: #fff; + border-radius: $r-pill; + font-size: 24rpx; + } +} diff --git a/apps/miniprogram/src/components/DeviceCard/index.tsx b/apps/miniprogram/src/components/DeviceCard/index.tsx new file mode 100644 index 0000000..8961b2a --- /dev/null +++ b/apps/miniprogram/src/components/DeviceCard/index.tsx @@ -0,0 +1,39 @@ +import { View, Text } from '@tarojs/components'; +import Taro from '@tarojs/taro'; +import './index.scss'; + +interface DeviceCardProps { + deviceName: string; + deviceType: string; + lastSyncAt?: string; + status: 'connected' | 'disconnected' | 'never'; +} + +const DEVICE_ICONS: Record = { + blood_pressure: '\u{1FA7A}', + blood_glucose: '\u{1FA78}', + heart_rate: '\u{2764}', + blood_oxygen: '\u{1FAB1}', +}; + +export default function DeviceCard({ deviceName, deviceType, lastSyncAt, status }: DeviceCardProps) { + const icon = DEVICE_ICONS[deviceType] || '\u{1F4F1}'; + const statusLabel = status === 'connected' ? '已连接' : status === 'disconnected' ? '未连接' : '未配对'; + const statusClass = status === 'connected' ? 'connected' : 'idle'; + + const handleSync = () => { + Taro.navigateTo({ url: '/pages/device-sync/index' }); + }; + + return ( + + {icon} + + {deviceName} + {statusLabel} + {lastSyncAt && 最近同步: {lastSyncAt}} + + 同步 + + ); +} diff --git a/apps/miniprogram/src/pages/index/index.tsx b/apps/miniprogram/src/pages/index/index.tsx index 4186e4c..0f59a88 100644 --- a/apps/miniprogram/src/pages/index/index.tsx +++ b/apps/miniprogram/src/pages/index/index.tsx @@ -3,7 +3,7 @@ import { useState } from 'react'; import Taro, { useDidShow } from '@tarojs/taro'; import { useAuthStore } from '../../stores/auth'; import { useHealthStore } from '../../stores/health'; -import EmptyState from '../../components/EmptyState'; +import DeviceCard from '../../components/DeviceCard'; import Loading from '../../components/Loading'; import { trackPageView } from '@/services/analytics'; import * as appointmentApi from '@/services/appointment'; @@ -13,8 +13,8 @@ import './index.scss'; const QUICK_SERVICES = [ { label: '预约挂号', char: '约', path: '/pages/appointment/create/index' }, - { label: '健康录入', char: '录', path: '/pages/health/input/index' }, - { label: '健康趋势', char: '势', path: '/pages/health/trend/index' }, + { label: '健康录入', char: '录', path: '/pages/pkg-health/input/index' }, + { label: '健康趋势', char: '势', path: '/pages/pkg-health/trend/index' }, { label: '资讯文章', char: '文', path: '/pages/article/index' }, { label: 'AI 报告', char: 'AI', path: '/pages/ai-report/list/index' }, ]; @@ -123,6 +123,20 @@ export default function Index() { {new Date().toLocaleDateString('zh-CN', { month: 'long', day: 'numeric', weekday: 'short' })} + {/* 设备快捷入口 */} + + + + + {/* 今日健康 */} 今日健康 @@ -132,7 +146,7 @@ export default function Index() { 今天还没录入数据 - Taro.navigateTo({ url: '/pages/health/input/index' })}> + Taro.navigateTo({ url: '/pages/pkg-health/input/index' })}> 点击开始记录 @@ -142,7 +156,7 @@ export default function Index() { {healthItems.map((item) => { const tag = getStatusTag(item.status); return ( - Taro.navigateTo({ url: `/pages/health/trend/index?indicator=${item.label === '血压' ? 'blood_pressure_systolic' : item.label === '心率' ? 'heart_rate' : item.label === '血糖' ? 'blood_sugar_fasting' : 'weight'}` })}> + Taro.navigateTo({ url: `/pages/pkg-health/trend/index?indicator=${item.label === '血压' ? 'blood_pressure_systolic' : item.label === '心率' ? 'heart_rate' : item.label === '血糖' ? 'blood_sugar_fasting' : 'weight'}` })}> {item.label} {item.value}