feat(miniprogram): 医护端小程序页面 — 8 页面覆盖患者/咨询/随访/报告
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

Iteration 2 医护端前端核心页面:

- 新增 doctor.ts service 层(仪表盘/患者/咨询/随访/报告 API)
- 升级医生首页:接入真实仪表盘数据 + 快捷操作入口
- 患者管理:搜索 + 标签筛选 + 详情页(基本信息/过敏史/健康概览)
- 咨询回复:会话列表 + 状态筛选 + 聊天详情 + 发送消息 + 关闭会话
- 随访管理:任务列表 + 状态筛选 + 详情 + 填写随访记录
- 报告解读:化验报告列表 + 异常高亮 + 指标表格 + 医生审核注释
- 修复 login 页面重复解构
- 注册 8 个新页面路由到 app.config.ts
This commit is contained in:
iven
2026-04-26 13:32:08 +08:00
parent a0b72b0f73
commit 3723cd93c0
21 changed files with 2795 additions and 28 deletions

View File

@@ -0,0 +1,140 @@
.chat-page {
display: flex;
flex-direction: column;
height: 100vh;
background: #f0f4f8;
}
.chat-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24px 32px;
background: #fff;
border-bottom: 1px solid #e2e8f0;
&__title {
font-size: 30px;
font-weight: 600;
color: #0f172a;
}
&__close {
font-size: 26px;
color: #ef4444;
padding: 8px 16px;
}
}
.chat-messages {
flex: 1;
padding: 24px;
overflow-y: auto;
}
.msg-row {
display: flex;
margin-bottom: 20px;
&--self {
justify-content: flex-end;
}
}
.msg-bubble {
max-width: 70%;
padding: 20px 24px;
border-radius: 16px;
position: relative;
&--other {
background: #fff;
border-top-left-radius: 4px;
}
&--self {
background: #0891b2;
border-top-right-radius: 4px;
}
}
.msg-text {
font-size: 28px;
color: #0f172a;
display: block;
line-height: 1.6;
word-break: break-all;
.msg-bubble--self & {
color: #fff;
}
}
.msg-time {
font-size: 20px;
color: #94a3b8;
display: block;
margin-top: 8px;
text-align: right;
.msg-bubble--self & {
color: rgba(255, 255, 255, 0.7);
}
}
.chat-empty {
text-align: center;
padding: 120px 32px;
&__text {
font-size: 26px;
color: #94a3b8;
}
}
.chat-input-bar {
display: flex;
align-items: center;
padding: 16px 24px;
background: #fff;
border-top: 1px solid #e2e8f0;
padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.chat-input {
flex: 1;
background: #f1f5f9;
border-radius: 12px;
padding: 16px 20px;
font-size: 28px;
margin-right: 16px;
}
.chat-send-btn {
background: #0891b2;
border-radius: 12px;
padding: 16px 28px;
flex-shrink: 0;
&--disabled {
opacity: 0.5;
}
&__text {
font-size: 28px;
color: #fff;
font-weight: 500;
}
}
.chat-closed-bar {
padding: 24px;
text-align: center;
background: #fff;
border-top: 1px solid #e2e8f0;
&__text {
font-size: 26px;
color: #94a3b8;
}
}

View File

@@ -0,0 +1,153 @@
import { useState, useEffect, useRef } from 'react';
import { View, Text, Input, ScrollView } from '@tarojs/components';
import Taro, { useRouter } from '@tarojs/taro';
import * as doctorApi from '@/services/doctor';
import Loading from '@/components/Loading';
import './index.scss';
export default function ConsultationDetail() {
const router = useRouter();
const sessionId = router.params.id || '';
const [session, setSession] = useState<doctorApi.ConsultationSession | null>(null);
const [messages, setMessages] = useState<doctorApi.ConsultationMessage[]>([]);
const [inputText, setInputText] = useState('');
const [sending, setSending] = useState(false);
const [loading, setLoading] = useState(true);
const scrollViewRef = useRef('');
useEffect(() => {
if (sessionId) {
loadData();
markRead();
}
}, [sessionId]);
const loadData = async () => {
setLoading(true);
try {
const [s, m] = await Promise.all([
doctorApi.getSession(sessionId),
doctorApi.listMessages(sessionId, { page: 1, page_size: 50 }),
]);
setSession(s);
setMessages(m.data || []);
scrollViewRef.current = `msg-${(m.data || []).length}`;
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
};
const markRead = async () => {
try {
await doctorApi.markSessionRead(sessionId);
} catch { /* ignore */ }
};
const handleSend = async () => {
const text = inputText.trim();
if (!text || sending) return;
setSending(true);
setInputText('');
try {
const msg = await doctorApi.sendMessage(sessionId, text);
setMessages((prev) => [...prev, msg]);
scrollViewRef.current = `msg-${messages.length + 1}`;
} catch {
Taro.showToast({ title: '发送失败', icon: 'none' });
setInputText(text);
} finally {
setSending(false);
}
};
const handleClose = () => {
Taro.showModal({
title: '确认关闭',
content: '关闭后将无法继续对话,确认关闭?',
success: async (res) => {
if (res.confirm) {
try {
await doctorApi.closeSession(sessionId);
Taro.showToast({ title: '已关闭', icon: 'success' });
loadData();
} catch {
Taro.showToast({ title: '操作失败', icon: 'none' });
}
}
},
});
};
const formatTime = (dateStr: string) => {
const d = new Date(dateStr);
return d.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
};
if (loading) return <Loading />;
const isOpen = session?.status !== 'closed';
return (
<View className='chat-page'>
{/* Header */}
<View className='chat-header'>
<Text className='chat-header__title'>{session?.subject || '在线咨询'}</Text>
{isOpen && (
<Text className='chat-header__close' onClick={handleClose}></Text>
)}
</View>
{/* Messages */}
<ScrollView
scrollY
className='chat-messages'
scrollIntoView={scrollViewRef.current}
scrollWithAnimation
>
{messages.map((msg, idx) => {
const isDoctor = msg.sender_role === 'doctor';
return (
<View key={msg.id} id={`msg-${idx + 1}`} className={`msg-row ${isDoctor ? 'msg-row--self' : ''}`}>
<View className={`msg-bubble ${isDoctor ? 'msg-bubble--self' : 'msg-bubble--other'}`}>
<Text className='msg-text'>{msg.content}</Text>
<Text className='msg-time'>{formatTime(msg.created_at)}</Text>
</View>
</View>
);
})}
{messages.length === 0 && (
<View className='chat-empty'>
<Text className='chat-empty__text'></Text>
</View>
)}
</ScrollView>
{/* Input */}
{isOpen ? (
<View className='chat-input-bar'>
<Input
className='chat-input'
placeholder='输入消息...'
value={inputText}
onInput={(e) => setInputText(e.detail.value)}
confirmType='send'
onConfirm={handleSend}
disabled={sending}
/>
<View
className={`chat-send-btn ${(!inputText.trim() || sending) ? 'chat-send-btn--disabled' : ''}`}
onClick={handleSend}
>
<Text className='chat-send-btn__text'>{sending ? '...' : '发送'}</Text>
</View>
</View>
) : (
<View className='chat-closed-bar'>
<Text className='chat-closed-bar__text'></Text>
</View>
)}
</View>
);
}