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}