fix(miniprogram): 删除重复页面 report/followup,修复 EmptyState 导入 bug
This commit is contained in:
@@ -6,48 +6,50 @@ import EmptyState from '../../components/EmptyState';
|
||||
import './index.scss';
|
||||
|
||||
export default function Index() {
|
||||
const { user, restore } = useAuthStore();
|
||||
const { user, currentPatient, restore: restoreAuth } = useAuthStore();
|
||||
const { todaySummary, refreshToday } = useHealthStore();
|
||||
|
||||
useDidShow(() => {
|
||||
restore();
|
||||
restoreAuth();
|
||||
refreshToday();
|
||||
});
|
||||
|
||||
const s = todaySummary || {};
|
||||
const hour = new Date().getHours();
|
||||
const greeting = hour < 12 ? '早上好' : hour < 18 ? '下午好' : '晚上好';
|
||||
const displayName = user?.display_name || currentPatient?.name || '访客';
|
||||
|
||||
const greeting = () => {
|
||||
const h = new Date().getHours();
|
||||
if (h < 6) return '凌晨好';
|
||||
if (h < 12) return '上午好';
|
||||
if (h < 14) return '中午好';
|
||||
if (h < 18) return '下午好';
|
||||
return '晚上好';
|
||||
const quickServices = [
|
||||
{ label: '预约挂号', icon: '📅', path: '/pages/appointment/create/index' },
|
||||
{ label: '健康录入', icon: '📊', path: '/pages/health/input/index' },
|
||||
{ label: '健康趋势', icon: '📈', path: '/pages/health/trend/index' },
|
||||
{ label: '资讯文章', icon: '📰', path: '/pages/article/index' },
|
||||
];
|
||||
|
||||
const handleServiceClick = (path: string) => {
|
||||
Taro.navigateTo({ url: path });
|
||||
};
|
||||
|
||||
const healthItems = [
|
||||
{ label: '血压', value: todaySummary?.blood_pressure ? `${todaySummary.blood_pressure.systolic}/${todaySummary.blood_pressure.diastolic}` : '--/--', unit: 'mmHg' },
|
||||
{ label: '心率', value: todaySummary?.heart_rate ? `${todaySummary.heart_rate.value}` : '--', unit: 'bpm' },
|
||||
{ label: '血糖', value: todaySummary?.blood_sugar ? `${todaySummary.blood_sugar.value}` : '--', unit: 'mmol/L' },
|
||||
{ label: '体重', value: todaySummary?.weight ? `${todaySummary.weight.value}` : '--', unit: 'kg' },
|
||||
];
|
||||
|
||||
return (
|
||||
<View className='index-page'>
|
||||
{/* 问候栏 */}
|
||||
<View className='greeting-bar'>
|
||||
<View className='greeting-text'>
|
||||
<Text className='greeting-hello'>{greeting()}</Text>
|
||||
<Text className='greeting-name'>{user?.display_name || '用户'}</Text>
|
||||
<Text className='greeting-hello'>{greeting},</Text>
|
||||
<Text className='greeting-name'>{displayName}</Text>
|
||||
</View>
|
||||
<Text className='greeting-date'>
|
||||
{new Date().toLocaleDateString('zh-CN', { month: 'long', day: 'numeric', weekday: 'short' })}
|
||||
</Text>
|
||||
<Text className='greeting-date'>{new Date().toLocaleDateString('zh-CN')}</Text>
|
||||
</View>
|
||||
|
||||
{/* 今日健康卡片 */}
|
||||
<View className='health-card'>
|
||||
<Text className='section-title'>今日健康</Text>
|
||||
<View className='health-grid'>
|
||||
{[
|
||||
{ label: '血压', value: s.blood_pressure ? `${s.blood_pressure.systolic}/${s.blood_pressure.diastolic}` : '--/--', unit: 'mmHg' },
|
||||
{ label: '心率', value: s.heart_rate ? `${s.heart_rate.value}` : '--', unit: 'bpm' },
|
||||
{ label: '血糖', value: s.blood_sugar ? `${s.blood_sugar.value}` : '--', unit: 'mmol/L' },
|
||||
{ label: '体重', value: s.weight ? `${s.weight.value}` : '--', unit: 'kg' },
|
||||
].map((item) => (
|
||||
{healthItems.map((item) => (
|
||||
<View className='health-item' key={item.label}>
|
||||
<Text className='health-label'>{item.label}</Text>
|
||||
<Text className='health-value'>{item.value}</Text>
|
||||
@@ -57,38 +59,21 @@ export default function Index() {
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 快捷服务 */}
|
||||
<View className='quick-services'>
|
||||
<Text className='section-title'>快捷服务</Text>
|
||||
<View className='service-grid'>
|
||||
{[
|
||||
{ label: '录数据', icon: '📝', path: '/pages/health/index', isTab: true },
|
||||
{ label: '预约', icon: '📅', path: '/pages/appointment/index', isTab: true },
|
||||
{ label: '报告', icon: '📋', path: '/pages/report/index', isTab: false },
|
||||
{ label: '随访', icon: '💬', path: '/pages/followup/index', isTab: false },
|
||||
].map((item) => (
|
||||
<View
|
||||
className='service-item'
|
||||
key={item.label}
|
||||
onClick={() => {
|
||||
if (item.isTab) {
|
||||
Taro.switchTab({ url: item.path });
|
||||
} else {
|
||||
Taro.navigateTo({ url: item.path });
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Text className='service-icon'>{item.icon}</Text>
|
||||
<Text className='service-label'>{item.label}</Text>
|
||||
{quickServices.map((svc) => (
|
||||
<View className='service-item' key={svc.label} onClick={() => handleServiceClick(svc.path)}>
|
||||
<Text className='service-icon'>{svc.icon}</Text>
|
||||
<Text className='service-label'>{svc.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 即将到来 */}
|
||||
<View className='upcoming'>
|
||||
<Text className='section-title'>即将到来</Text>
|
||||
<EmptyState text='暂无即将到来的预约' />
|
||||
<Text className='section-title'>待办事项</Text>
|
||||
<EmptyState icon='📋' text='暂无待办事项' hint='预约挂号后将在此显示' />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user