feat(miniprogram): 医护端小程序页面 — 8 页面覆盖患者/咨询/随访/报告
Iteration 2 医护端前端核心页面: - 新增 doctor.ts service 层(仪表盘/患者/咨询/随访/报告 API) - 升级医生首页:接入真实仪表盘数据 + 快捷操作入口 - 患者管理:搜索 + 标签筛选 + 详情页(基本信息/过敏史/健康概览) - 咨询回复:会话列表 + 状态筛选 + 聊天详情 + 发送消息 + 关闭会话 - 随访管理:任务列表 + 状态筛选 + 详情 + 填写随访记录 - 报告解读:化验报告列表 + 异常高亮 + 指标表格 + 医生审核注释 - 修复 login 页面重复解构 - 注册 8 个新页面路由到 app.config.ts
This commit is contained in:
@@ -1,41 +1,101 @@
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { View, Text, ScrollView } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import * as doctorApi from '@/services/doctor';
|
||||
import Loading from '@/components/Loading';
|
||||
import './index.scss';
|
||||
|
||||
interface CardConfig {
|
||||
key: keyof doctorApi.DoctorDashboard;
|
||||
label: string;
|
||||
icon: string;
|
||||
route: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
const CARDS: CardConfig[] = [
|
||||
{ key: 'total_patients', label: '我的患者', icon: '👥', route: '/pages/doctor/patients/index', color: '#0891b2' },
|
||||
{ key: 'unread_messages', label: '未读消息', icon: '💬', route: '/pages/doctor/consultation/index', color: '#f59e0b' },
|
||||
{ key: 'pending_follow_ups', label: '待处理随访', icon: '📋', route: '/pages/doctor/followup/index', color: '#8b5cf6' },
|
||||
{ key: 'today_consultations', label: '今日咨询', icon: '🩺', route: '/pages/doctor/consultation/index', color: '#10b981' },
|
||||
];
|
||||
|
||||
export default function DoctorHome() {
|
||||
const { user, logout } = useAuthStore();
|
||||
const [dashboard, setDashboard] = useState<doctorApi.DoctorDashboard | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
loadDashboard();
|
||||
}, []);
|
||||
|
||||
const loadDashboard = async () => {
|
||||
try {
|
||||
const data = await doctorApi.getDashboard();
|
||||
setDashboard(data);
|
||||
} catch {
|
||||
// 静默失败,显示占位
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCardClick = (card: CardConfig) => {
|
||||
Taro.navigateTo({ url: card.route });
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
logout();
|
||||
Taro.redirectTo({ url: '/pages/login/index' });
|
||||
};
|
||||
|
||||
const getValue = (key: keyof doctorApi.DoctorDashboard): number | string => {
|
||||
if (!dashboard) return '-';
|
||||
return dashboard[key] ?? 0;
|
||||
};
|
||||
|
||||
if (loading) return <Loading />;
|
||||
|
||||
return (
|
||||
<View className='doctor-home'>
|
||||
<ScrollView scrollY className='doctor-home'>
|
||||
<View className='doctor-home__header'>
|
||||
<Text className='doctor-home__title'>医护工作台</Text>
|
||||
<Text className='doctor-home__greeting'>{user?.display_name || user?.username || '医生'},您好</Text>
|
||||
<Text className='doctor-home__greeting'>
|
||||
{user?.display_name || user?.username || '医生'},您好
|
||||
</Text>
|
||||
<Text className='doctor-home__date'>
|
||||
{new Date().toLocaleDateString('zh-CN', { month: 'long', day: 'numeric', weekday: 'long' })}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View className='doctor-home__section'>
|
||||
<Text className='doctor-home__section-title'>工作概览</Text>
|
||||
<View className='doctor-home__grid'>
|
||||
<View className='doctor-home__card' onClick={() => Taro.showToast({ title: '开发中', icon: 'none' })}>
|
||||
<Text className='doctor-home__card-num'>-</Text>
|
||||
<Text className='doctor-home__card-label'>待回复咨询</Text>
|
||||
{CARDS.map((card) => (
|
||||
<View
|
||||
key={card.key}
|
||||
className='doctor-home__card'
|
||||
style={`border-left: 6px solid ${card.color}`}
|
||||
onClick={() => handleCardClick(card)}
|
||||
>
|
||||
<Text className='doctor-home__card-icon'>{card.icon}</Text>
|
||||
<Text className='doctor-home__card-num'>{getValue(card.key)}</Text>
|
||||
<Text className='doctor-home__card-label'>{card.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className='doctor-home__section'>
|
||||
<Text className='doctor-home__section-title'>快捷操作</Text>
|
||||
<View className='doctor-home__quick-actions'>
|
||||
<View className='quick-action' onClick={() => Taro.navigateTo({ url: '/pages/doctor/report/index' })}>
|
||||
<Text className='quick-action__icon'>📊</Text>
|
||||
<Text className='quick-action__label'>化验审核</Text>
|
||||
</View>
|
||||
<View className='doctor-home__card' onClick={() => Taro.showToast({ title: '开发中', icon: 'none' })}>
|
||||
<Text className='doctor-home__card-num'>-</Text>
|
||||
<Text className='doctor-home__card-label'>待处理随访</Text>
|
||||
</View>
|
||||
<View className='doctor-home__card' onClick={() => Taro.showToast({ title: '开发中', icon: 'none' })}>
|
||||
<Text className='doctor-home__card-num'>-</Text>
|
||||
<Text className='doctor-home__card-label'>今日咨询</Text>
|
||||
</View>
|
||||
<View className='doctor-home__card' onClick={() => Taro.showToast({ title: '开发中', icon: 'none' })}>
|
||||
<Text className='doctor-home__card-num'>-</Text>
|
||||
<Text className='doctor-home__card-label'>我的患者</Text>
|
||||
<View className='quick-action' onClick={() => Taro.navigateTo({ url: '/pages/doctor/patients/index' })}>
|
||||
<Text className='quick-action__icon'>🔍</Text>
|
||||
<Text className='quick-action__label'>患者查询</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
@@ -43,6 +103,6 @@ export default function DoctorHome() {
|
||||
<View className='doctor-home__footer'>
|
||||
<Text className='doctor-home__logout' onClick={handleLogout}>退出登录</Text>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user