feat(health+miniprogram): 预约/报告/随访/资讯/家庭管理 — Chunk 4-6
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

后端:
- 添加 articles 表迁移 + Entity + Service + Handler
- 健康数据趋势 API (get_mini_trend) 注册路由
- article CRUD (list/get) + DTO

前端 (11个新页面 + 5个服务):
- 预约挂号: 列表/创建向导/详情页
- 报告管理: 列表/详情页
- 随访管理: 任务列表/记录详情页
- 资讯文章: 文章详情页
- 个人中心: 就诊人管理/新增/我的报告/我的随访/用药提醒/设置
- 更新 app.config.ts 注册全部路由
- 更新 profile/article 页面为真实功能
This commit is contained in:
iven
2026-04-24 00:58:40 +08:00
parent ee9a5c4da1
commit 9ef65b9a9f
53 changed files with 6044 additions and 32 deletions

View File

@@ -5,8 +5,21 @@ export default defineAppConfig({
'pages/health/input/index',
'pages/health/trend/index',
'pages/appointment/index',
'pages/appointment/create/index',
'pages/appointment/detail/index',
'pages/article/index',
'pages/article/detail/index',
'pages/report/index',
'pages/report/detail/index',
'pages/followup/index',
'pages/followup/detail/index',
'pages/profile/index',
'pages/profile/family/index',
'pages/profile/family-add/index',
'pages/profile/reports/index',
'pages/profile/followups/index',
'pages/profile/medication/index',
'pages/profile/settings/index',
'pages/login/index',
],
tabBar: {

View File

@@ -0,0 +1,289 @@
@import '../../../styles/variables.scss';
.create-page {
min-height: 100vh;
background: $bg;
padding-bottom: 140px;
}
/* 步骤指示器 */
.step-bar {
display: flex;
justify-content: space-around;
padding: 32px 24px 0;
}
.step-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
opacity: 0.4;
transition: opacity 0.3s;
}
.step-item.step-active {
opacity: 1;
}
.step-item.step-done {
opacity: 0.8;
}
.step-dot {
width: 56px;
height: 56px;
border-radius: 50%;
background: $bd;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s;
}
.step-active .step-dot {
background: $pri;
}
.step-done .step-dot {
background: $acc;
}
.step-num {
font-size: 28px;
color: white;
font-weight: bold;
}
.step-check {
font-size: 28px;
color: white;
font-weight: bold;
}
.step-label {
font-size: 22px;
color: $tx2;
}
.step-active .step-label {
color: $pri;
font-weight: 500;
}
/* 步骤连接线 */
.step-line-wrapper {
padding: 12px 80px 0;
}
.step-line {
height: 4px;
background: $bd;
border-radius: 2px;
overflow: hidden;
}
.step-line-fill {
height: 100%;
background: linear-gradient(90deg, $acc, $pri);
border-radius: 2px;
transition: width 0.3s ease;
}
/* 步骤内容 */
.step-content {
padding: 32px 24px;
}
.step-title {
font-size: 32px;
font-weight: bold;
color: $tx;
margin-bottom: 28px;
display: block;
}
/* 选择器卡片 */
.picker-card {
background: $card;
border-radius: $r;
padding: 24px 28px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.picker-value {
font-size: 28px;
color: $tx;
}
.picker-value.placeholder {
color: $tx3;
}
.picker-arrow {
font-size: 24px;
color: $tx3;
}
/* 医生列表 */
.doctor-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.doctor-card {
background: $card;
border-radius: $r;
padding: 24px 28px;
display: flex;
align-items: center;
gap: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
border: 2px solid transparent;
transition: border-color 0.2s;
}
.doctor-card.doctor-selected {
border-color: $pri;
background: $pri-surface;
}
.doctor-avatar {
width: 80px;
height: 80px;
border-radius: 50%;
background: $pri-l;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.doctor-avatar-text {
font-size: 32px;
color: $pri;
font-weight: bold;
}
.doctor-detail {
flex: 1;
display: flex;
flex-direction: column;
gap: 4px;
}
.doctor-name {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.doctor-title {
font-size: 24px;
color: $tx2;
}
.doctor-specialty {
font-size: 22px;
color: $pri;
}
.doctor-check {
font-size: 32px;
color: $pri;
font-weight: bold;
}
/* 表单 */
.form-group {
margin-bottom: 28px;
}
.form-label {
font-size: 26px;
color: $tx2;
margin-bottom: 12px;
display: block;
}
.form-static {
background: $card;
border-radius: $r-sm;
padding: 24px 28px;
}
.form-static-text {
font-size: 28px;
color: $tx;
}
.form-input {
background: $card;
border-radius: $r-sm;
padding: 24px 28px;
font-size: 28px;
color: $tx;
width: 100%;
box-sizing: border-box;
}
/* 空状态 */
.empty-state {
padding: 80px 0;
text-align: center;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
/* 底部操作栏 */
.bottom-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
display: flex;
gap: 16px;
padding: 20px 24px;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
background: $card;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
.btn {
flex: 1;
padding: 24px 0;
border-radius: $r-sm;
text-align: center;
transition: opacity 0.2s;
}
.btn-prev {
background: $bd-l;
}
.btn-next,
.btn-submit {
background: linear-gradient(135deg, $pri 0%, $pri-d 100%);
}
.btn-disabled {
opacity: 0.5;
}
.btn-text {
font-size: 30px;
font-weight: bold;
color: $tx2;
}
.btn-text-white {
color: white;
}

View File

@@ -0,0 +1,268 @@
import React, { useState, useCallback } from 'react';
import { View, Text, Picker, Input } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { listDoctors, createAppointment } from '../../../services/appointment';
import { useAuthStore } from '../../../stores/auth';
import './index.scss';
const DEPARTMENTS = ['内科', '外科', '妇科', '儿科', '体检中心'];
interface DoctorItem {
id: string;
name: string;
title?: string;
department?: string;
specialty?: string;
}
export default function AppointmentCreate() {
const [currentStep, setCurrentStep] = useState(0);
const [department, setDepartment] = useState('');
const [deptPickerIndex, setDeptPickerIndex] = useState(0);
const [doctors, setDoctors] = useState<DoctorItem[]>([]);
const [selectedDoctor, setSelectedDoctor] = useState<DoctorItem | null>(null);
const [appointmentDate, setAppointmentDate] = useState('');
const [timeSlot, setTimeSlot] = useState('');
const [reason, setReason] = useState('');
const [loading, setLoading] = useState(false);
const currentPatient = useAuthStore((s) => s.currentPatient);
// Step 1: 选择科室后加载医生列表
const onDepartmentChange = useCallback(async (e: any) => {
const idx = e.detail.value;
const dept = DEPARTMENTS[idx];
setDeptPickerIndex(idx);
setDepartment(dept);
setSelectedDoctor(null);
try {
const res = await listDoctors(dept);
setDoctors(res.data || []);
} catch {
Taro.showToast({ title: '加载医生失败', icon: 'none' });
}
}, []);
// Step 2: 选择医生
const onSelectDoctor = useCallback((doctor: DoctorItem) => {
setSelectedDoctor(doctor);
}, []);
// Step 3: 日期变更
const onDateChange = useCallback((e: any) => {
setAppointmentDate(e.detail.value);
}, []);
// Step 3: 时段变更
const onTimeSlotChange = useCallback((e: any) => {
setTimeSlot(e.detail.value);
}, []);
// Step 3: 备注变更
const onReasonChange = useCallback((e: any) => {
setReason(e.detail.value);
}, []);
// 提交预约
const handleSubmit = useCallback(async () => {
if (!selectedDoctor) {
Taro.showToast({ title: '请选择医生', icon: 'none' });
return;
}
if (!appointmentDate) {
Taro.showToast({ title: '请选择日期', icon: 'none' });
return;
}
if (!timeSlot.trim()) {
Taro.showToast({ title: '请输入时段', icon: 'none' });
return;
}
if (!currentPatient) {
Taro.showToast({ title: '请先选择就诊人', icon: 'none' });
return;
}
setLoading(true);
try {
await createAppointment({
patient_id: currentPatient.id,
doctor_id: selectedDoctor.id,
schedule_id: '',
appointment_date: appointmentDate,
time_slot: timeSlot.trim(),
reason: reason.trim() || undefined,
});
Taro.showToast({ title: '预约成功', icon: 'success' });
setTimeout(() => {
Taro.navigateBack();
}, 1500);
} catch {
Taro.showToast({ title: '预约失败', icon: 'none' });
} finally {
setLoading(false);
}
}, [selectedDoctor, appointmentDate, timeSlot, reason, currentPatient]);
// 步骤切换
const goNext = () => {
if (currentStep === 0 && !department) {
Taro.showToast({ title: '请先选择科室', icon: 'none' });
return;
}
if (currentStep === 1 && !selectedDoctor) {
Taro.showToast({ title: '请选择医生', icon: 'none' });
return;
}
setCurrentStep(Math.min(currentStep + 1, 2));
};
const goPrev = () => {
setCurrentStep(Math.max(currentStep - 1, 0));
};
const stepLabels = ['选择科室', '选择医生', '选择日期与时段'];
return (
<View className='create-page'>
{/* 步骤指示器 */}
<View className='step-bar'>
{stepLabels.map((label, idx) => (
<View
className={`step-item ${idx <= currentStep ? 'step-active' : ''} ${idx < currentStep ? 'step-done' : ''}`}
key={label}
>
<View className='step-dot'>
{idx < currentStep ? (
<Text className='step-check'>&#10003;</Text>
) : (
<Text className='step-num'>{idx + 1}</Text>
)}
</View>
<Text className='step-label'>{label}</Text>
</View>
))}
</View>
{/* 步骤连接线 */}
<View className='step-line-wrapper'>
<View className='step-line'>
<View className='step-line-fill' style={{ width: `${(currentStep / 2) * 100}%` }} />
</View>
</View>
{/* Step 1: 选择科室 */}
{currentStep === 0 && (
<View className='step-content'>
<Text className='step-title'></Text>
<Picker mode='selector' range={DEPARTMENTS} value={deptPickerIndex} onChange={onDepartmentChange}>
<View className='picker-card'>
<Text className={`picker-value ${department ? '' : 'placeholder'}`}>
{department || '点击选择科室'}
</Text>
<Text className='picker-arrow'>&#9662;</Text>
</View>
</Picker>
</View>
)}
{/* Step 2: 选择医生 */}
{currentStep === 1 && (
<View className='step-content'>
<Text className='step-title'>{department} - </Text>
{doctors.length === 0 ? (
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
) : (
<View className='doctor-list'>
{doctors.map((doc) => (
<View
className={`doctor-card ${selectedDoctor?.id === doc.id ? 'doctor-selected' : ''}`}
key={doc.id}
onClick={() => onSelectDoctor(doc)}
>
<View className='doctor-avatar'>
<Text className='doctor-avatar-text'>{doc.name.charAt(0)}</Text>
</View>
<View className='doctor-detail'>
<Text className='doctor-name'>{doc.name}</Text>
<Text className='doctor-title'>{doc.title || '医生'}</Text>
{doc.specialty && <Text className='doctor-specialty'>{doc.specialty}</Text>}
</View>
{selectedDoctor?.id === doc.id && (
<Text className='doctor-check'>&#10003;</Text>
)}
</View>
))}
</View>
)}
</View>
)}
{/* Step 3: 选择日期和时段 */}
{currentStep === 2 && (
<View className='step-content'>
<Text className='step-title'></Text>
<View className='form-group'>
<Text className='form-label'></Text>
<View className='form-static'>
<Text className='form-static-text'>{selectedDoctor?.name} - {department}</Text>
</View>
</View>
<View className='form-group'>
<Text className='form-label'></Text>
<Picker mode='date' value={appointmentDate} onChange={onDateChange}>
<View className='picker-card'>
<Text className={`picker-value ${appointmentDate ? '' : 'placeholder'}`}>
{appointmentDate || '点击选择日期'}
</Text>
<Text className='picker-arrow'>&#9662;</Text>
</View>
</Picker>
</View>
<View className='form-group'>
<Text className='form-label'></Text>
<Input
className='form-input'
placeholder='例如: 09:00-10:00'
value={timeSlot}
onInput={onTimeSlotChange}
/>
</View>
<View className='form-group'>
<Text className='form-label'></Text>
<Input
className='form-input'
placeholder='请简要描述症状或就诊目的'
value={reason}
onInput={onReasonChange}
/>
</View>
</View>
)}
{/* 底部操作栏 */}
<View className='bottom-bar'>
{currentStep > 0 && (
<View className='btn btn-prev' onClick={goPrev}>
<Text className='btn-text'></Text>
</View>
)}
{currentStep < 2 ? (
<View className='btn btn-next' onClick={goNext}>
<Text className='btn-text btn-text-white'></Text>
</View>
) : (
<View className={`btn btn-submit ${loading ? 'btn-disabled' : ''}`} onClick={loading ? undefined : handleSubmit}>
<Text className='btn-text btn-text-white'>{loading ? '提交中...' : '确认预约'}</Text>
</View>
)}
</View>
</View>
);
}

View File

@@ -0,0 +1,216 @@
@import '../../../styles/variables.scss';
.detail-page {
min-height: 100vh;
background: $bg;
padding-bottom: 140px;
}
/* 顶部导航 */
.detail-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32px;
padding-top: 48px;
background: linear-gradient(135deg, $pri 0%, $pri-d 100%);
}
.back-btn {
padding: 8px 0;
}
.back-text {
font-size: 28px;
color: white;
}
.header-title {
font-size: 34px;
font-weight: bold;
color: white;
}
.header-placeholder {
width: 60px;
}
/* 状态卡片 */
.status-card {
background: $card;
border-radius: $r-lg;
padding: 40px 32px;
margin: -20px 24px 24px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.status-badge {
padding: 8px 32px;
border-radius: 24px;
margin-bottom: 12px;
.status-badge-text {
font-size: 28px;
font-weight: bold;
}
&.tag-pending {
background: $wrn-l;
.status-badge-text { color: $wrn; }
}
&.tag-confirmed {
background: $acc-l;
.status-badge-text { color: $acc; }
}
&.tag-cancelled {
background: $bd-l;
.status-badge-text { color: $tx3; }
}
&.tag-completed {
background: $pri-l;
.status-badge-text { color: $pri; }
}
}
.status-doctor {
font-size: 36px;
font-weight: bold;
color: $tx;
}
.status-dept {
font-size: 26px;
color: $tx2;
}
/* 详情信息 */
.info-section {
margin: 0 24px 24px;
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.section-title {
font-size: 30px;
font-weight: bold;
color: $tx;
margin-bottom: 24px;
display: block;
}
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 0;
border-bottom: 1px solid $bd-l;
}
.info-item:last-child {
border-bottom: none;
}
.info-label {
font-size: 26px;
color: $tx2;
}
.info-value {
font-size: 26px;
color: $tx;
font-weight: 500;
}
.info-id {
font-size: 22px;
color: $tx3;
word-break: break-all;
max-width: 400px;
text-align: right;
}
/* 温馨提示 */
.tips-card {
margin: 0 24px 24px;
background: $wrn-l;
border-radius: $r;
padding: 24px 28px;
}
.tips-title {
font-size: 26px;
font-weight: bold;
color: $wrn;
margin-bottom: 12px;
display: block;
}
.tips-text {
font-size: 24px;
color: $tx2;
line-height: 1.6;
}
/* 底部操作 */
.bottom-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20px 24px;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
background: $card;
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
.cancel-btn {
background: $dan-l;
border-radius: $r-sm;
padding: 24px 0;
text-align: center;
transition: opacity 0.2s;
}
.cancel-disabled {
opacity: 0.5;
}
.cancel-text {
font-size: 30px;
font-weight: bold;
color: $dan;
}
/* 空状态 */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120px 0;
}
.empty-icon {
font-size: 80px;
margin-bottom: 20px;
}
.empty-text {
font-size: 30px;
color: $tx2;
margin-bottom: 12px;
}
.empty-hint {
font-size: 24px;
color: $tx3;
}

View File

@@ -0,0 +1,158 @@
import React, { useState } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useRouter } from '@tarojs/taro';
import { cancelAppointment } from '../../../services/appointment';
import type { Appointment } from '../../../services/appointment';
import './index.scss';
const STATUS_MAP: Record<string, { label: string; className: string }> = {
pending: { label: '待确认', className: 'tag-pending' },
confirmed: { label: '已确认', className: 'tag-confirmed' },
cancelled: { label: '已取消', className: 'tag-cancelled' },
completed: { label: '已完成', className: 'tag-completed' },
};
export default function AppointmentDetail() {
const router = useRouter();
const id = router.params.id || '';
const [cancelling, setCancelling] = useState(false);
// 从页面参数或全局缓存获取预约数据
const encodedData = router.params.data || '';
let appointment: Appointment | null = null;
try {
if (encodedData) {
appointment = JSON.parse(decodeURIComponent(encodedData));
}
} catch {
// 解析失败则尝试从 Storage 获取
const cached = Taro.getStorageSync('appointment_detail_cache');
if (cached && cached.id === id) {
appointment = cached;
}
}
// 如果没有传数据,尝试从缓存获取
if (!appointment) {
const cached = Taro.getStorageSync('appointment_detail_cache');
if (cached && cached.id === id) {
appointment = cached;
}
}
const status = appointment ? (STATUS_MAP[appointment.status] || { label: appointment.status, className: 'tag-pending' }) : { label: '未知', className: 'tag-pending' };
const canCancel = appointment && (appointment.status === 'pending' || appointment.status === 'confirmed');
const handleCancel = async () => {
if (!appointment || cancelling) return;
const res = await Taro.showModal({
title: '确认取消',
content: '确定要取消此预约吗?取消后需重新预约。',
});
if (!res.confirm) return;
setCancelling(true);
try {
await cancelAppointment(appointment.id, appointment.version);
Taro.showToast({ title: '已取消预约', icon: 'success' });
setTimeout(() => {
Taro.navigateBack();
}, 1500);
} catch {
Taro.showToast({ title: '取消失败', icon: 'none' });
} finally {
setCancelling(false);
}
};
const goBack = () => {
Taro.navigateBack();
};
if (!appointment) {
return (
<View className='detail-page'>
<View className='detail-header'>
<View className='back-btn' onClick={goBack}>
<Text className='back-text'></Text>
</View>
<Text className='header-title'></Text>
<View className='header-placeholder' />
</View>
<View className='empty-state'>
<Text className='empty-icon'>📋</Text>
<Text className='empty-text'></Text>
<Text className='empty-hint'></Text>
</View>
</View>
);
}
return (
<View className='detail-page'>
{/* 顶部导航 */}
<View className='detail-header'>
<View className='back-btn' onClick={goBack}>
<Text className='back-text'></Text>
</View>
<Text className='header-title'></Text>
<View className='header-placeholder' />
</View>
{/* 状态卡片 */}
<View className='status-card'>
<View className={`status-badge ${status.className}`}>
<Text className='status-badge-text'>{status.label}</Text>
</View>
<Text className='status-doctor'>{appointment.doctor_name}</Text>
<Text className='status-dept'>{appointment.department}</Text>
</View>
{/* 详情信息 */}
<View className='info-section'>
<Text className='section-title'></Text>
<View className='info-item'>
<Text className='info-label'></Text>
<Text className='info-value'>{appointment.patient_name}</Text>
</View>
<View className='info-item'>
<Text className='info-label'></Text>
<Text className='info-value'>{appointment.appointment_date}</Text>
</View>
<View className='info-item'>
<Text className='info-label'></Text>
<Text className='info-value'>{appointment.time_slot}</Text>
</View>
<View className='info-item'>
<Text className='info-label'></Text>
<Text className='info-value info-id'>{appointment.id}</Text>
</View>
</View>
{/* 温馨提示 */}
{(appointment.status === 'pending' || appointment.status === 'confirmed') && (
<View className='tips-card'>
<Text className='tips-title'></Text>
<Text className='tips-text'>15</Text>
</View>
)}
{/* 底部操作 */}
{canCancel && (
<View className='bottom-bar'>
<View
className={`cancel-btn ${cancelling ? 'cancel-disabled' : ''}`}
onClick={cancelling ? undefined : handleCancel}
>
<Text className='cancel-text'>{cancelling ? '处理中...' : '取消预约'}</Text>
</View>
</View>
)}
</View>
);
}

View File

@@ -1 +1,176 @@
@import '../../styles/variables.scss';
.appointment-page {
min-height: 100vh;
background: $bg;
padding-bottom: 140px;
}
.page-header {
background: linear-gradient(135deg, $pri 0%, $pri-d 100%);
padding: 32px;
padding-top: 48px;
}
.page-title {
font-size: 36px;
font-weight: bold;
color: white;
}
.appointment-list {
padding: 0 24px;
margin-top: -16px;
}
.appointment-card {
background: $card;
border-radius: $r;
padding: 28px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.card-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.doctor-info {
display: flex;
align-items: center;
gap: 12px;
}
.doctor-name {
font-size: 32px;
font-weight: bold;
color: $tx;
}
.department {
font-size: 24px;
color: $pri;
background: $pri-l;
padding: 4px 16px;
border-radius: 20px;
}
.status-tag {
padding: 6px 20px;
border-radius: 20px;
.status-tag-text {
font-size: 22px;
font-weight: 500;
}
&.tag-pending {
background: $wrn-l;
.status-tag-text {
color: $wrn;
}
}
&.tag-confirmed {
background: $acc-l;
.status-tag-text {
color: $acc;
}
}
&.tag-cancelled {
background: $bd-l;
.status-tag-text {
color: $tx3;
}
}
&.tag-completed {
background: $pri-l;
.status-tag-text {
color: $pri;
}
}
}
.card-bottom {
display: flex;
flex-direction: column;
gap: 12px;
padding-top: 20px;
border-top: 1px solid $bd-l;
}
.info-row {
display: flex;
align-items: center;
gap: 8px;
}
.info-icon {
font-size: 26px;
}
.info-text {
font-size: 26px;
color: $tx2;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120px 0 80px;
}
.empty-icon {
font-size: 80px;
margin-bottom: 20px;
}
.empty-text {
font-size: 30px;
color: $tx2;
margin-bottom: 12px;
}
.empty-hint {
font-size: 24px;
color: $tx3;
}
.loading-tip {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}
.fab-btn {
position: fixed;
bottom: 60px;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, $pri 0%, $pri-d 100%);
padding: 24px 64px;
border-radius: 48px;
box-shadow: 0 8px 24px rgba($pri, 0.4);
z-index: 100;
}
.fab-text {
font-size: 30px;
color: white;
font-weight: bold;
}

View File

@@ -1,12 +1,141 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import '../health/index.scss';
import Taro, { useDidShow, useReachBottom, usePullDownRefresh } from '@tarojs/taro';
import { listAppointments, cancelAppointment } from '../../services/appointment';
import type { Appointment } from '../../services/appointment';
import './index.scss';
const STATUS_MAP: Record<string, { label: string; className: string }> = {
pending: { label: '待确认', className: 'tag-pending' },
confirmed: { label: '已确认', className: 'tag-confirmed' },
cancelled: { label: '已取消', className: 'tag-cancelled' },
completed: { label: '已完成', className: 'tag-completed' },
};
export default function AppointmentList() {
const [appointments, setAppointments] = useState<Appointment[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const [refreshing, setRefreshing] = useState(false);
const fetchData = useCallback(async (pageNum: number, isRefresh = false) => {
if (loading) return;
setLoading(true);
try {
const res = await listAppointments(pageNum);
const list = res.data || [];
if (isRefresh) {
setAppointments(list);
} else {
setAppointments((prev) => [...prev, ...list]);
}
setTotal(res.total);
setPage(pageNum);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
setRefreshing(false);
}
}, [loading]);
useDidShow(() => {
fetchData(1, true);
});
usePullDownRefresh(() => {
setRefreshing(true);
fetchData(1, true).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && appointments.length < total) {
fetchData(page + 1);
}
});
const goCreate = () => {
Taro.navigateTo({ url: '/pages/appointment/create/index' });
};
const goDetail = (id: string) => {
const item = appointments.find((a) => a.id === id);
if (item) {
Taro.setStorageSync('appointment_detail_cache', item);
}
Taro.navigateTo({ url: `/pages/appointment/detail/index?id=${id}` });
};
const getStatusTag = (status: string) => {
return STATUS_MAP[status] || { label: status, className: 'tag-pending' };
};
export default function Appointment() {
return (
<View className='placeholder-page'>
<Text className='placeholder-icon'>📅</Text>
<Text className='placeholder-title'></Text>
<Text className='placeholder-desc'></Text>
<View className='appointment-page'>
{/* 页面标题 */}
<View className='page-header'>
<Text className='page-title'></Text>
</View>
{/* 预约列表 */}
{appointments.length === 0 && !loading ? (
<View className='empty-state'>
<Text className='empty-icon'>📋</Text>
<Text className='empty-text'></Text>
<Text className='empty-hint'></Text>
</View>
) : (
<View className='appointment-list'>
{appointments.map((item) => {
const tag = getStatusTag(item.status);
return (
<View
className='appointment-card'
key={item.id}
onClick={() => goDetail(item.id)}
>
<View className='card-top'>
<View className='doctor-info'>
<Text className='doctor-name'>{item.doctor_name}</Text>
<Text className='department'>{item.department}</Text>
</View>
<View className={`status-tag ${tag.className}`}>
<Text className='status-tag-text'>{tag.label}</Text>
</View>
</View>
<View className='card-bottom'>
<View className='info-row'>
<Text className='info-icon'>📅</Text>
<Text className='info-text'>{item.appointment_date}</Text>
</View>
<View className='info-row'>
<Text className='info-icon'>🕐</Text>
<Text className='info-text'>{item.time_slot}</Text>
</View>
</View>
</View>
);
})}
{loading && (
<View className='loading-tip'>
<Text className='loading-text'>...</Text>
</View>
)}
{!loading && appointments.length >= total && total > 0 && (
<View className='loading-tip'>
<Text className='loading-text'></Text>
</View>
)}
</View>
)}
{/* 底部悬浮按钮 */}
<View className='fab-btn' onClick={goCreate}>
<Text className='fab-text'>+ </Text>
</View>
</View>
);
}

View File

@@ -0,0 +1,98 @@
@import '../../../styles/variables.scss';
.article-detail-page {
min-height: 100vh;
background: $bg;
padding-bottom: 40px;
}
.article-header {
background: $card;
padding: 32px;
margin-bottom: 2px;
}
.article-title {
font-size: 38px;
font-weight: bold;
color: $tx;
display: block;
line-height: 1.4;
margin-bottom: 16px;
}
.article-meta {
display: flex;
align-items: center;
gap: 16px;
flex-wrap: wrap;
}
.article-category {
font-size: 22px;
color: $pri;
background: $pri-l;
padding: 4px 12px;
border-radius: 12px;
}
.article-author {
font-size: 24px;
color: $tx2;
}
.article-date {
font-size: 24px;
color: $tx3;
}
.article-summary {
background: $card;
padding: 24px 32px;
margin-bottom: 2px;
}
.summary-text {
font-size: 26px;
color: $tx2;
line-height: 1.6;
}
.article-content {
background: $card;
padding: 32px;
// RichText 内部样式优化
h1, h2, h3 {
font-weight: bold;
color: #134E4A;
margin: 24px 0 12px;
}
p {
font-size: 28px;
color: #134E4A;
line-height: 1.8;
margin-bottom: 16px;
}
img {
max-width: 100%;
border-radius: 8px;
margin: 12px 0;
}
}
.loading-state,
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.loading-text,
.empty-text {
font-size: 28px;
color: $tx3;
}

View File

@@ -0,0 +1,76 @@
import React, { useState, useEffect } from 'react';
import { View, Text, RichText } from '@tarojs/components';
import Taro, { useRouter } from '@tarojs/taro';
import { getArticleDetail, Article } from '../../../services/article';
import './index.scss';
export default function ArticleDetail() {
const router = useRouter();
const id = router.params.id || '';
const [article, setArticle] = useState<Article | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (!id) return;
setLoading(true);
getArticleDetail(id)
.then((data) => setArticle(data))
.catch(() => Taro.showToast({ title: '加载失败', icon: 'none' }))
.finally(() => setLoading(false));
}, [id]);
if (loading) {
return (
<View className='article-detail-page'>
<View className='loading-state'>
<Text className='loading-text'>...</Text>
</View>
</View>
);
}
if (!article) {
return (
<View className='article-detail-page'>
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
</View>
);
}
return (
<View className='article-detail-page'>
{/* 文章头部 */}
<View className='article-header'>
<Text className='article-title'>{article.title}</Text>
<View className='article-meta'>
{article.category && (
<Text className='article-category'>{article.category}</Text>
)}
{article.author && (
<Text className='article-author'>{article.author}</Text>
)}
{article.published_at && (
<Text className='article-date'>{article.published_at.slice(0, 10)}</Text>
)}
</View>
</View>
{/* 摘要 */}
{article.summary && (
<View className='article-summary'>
<Text className='summary-text'>{article.summary}</Text>
</View>
)}
{/* 正文 */}
<View className='article-content'>
<RichText
nodes={article.content || ''}
/>
</View>
</View>
);
}

View File

@@ -1 +1,108 @@
@import '../../styles/variables.scss';
.article-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 40px;
}
.article-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.article-card {
display: flex;
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.article-card-body {
flex: 1;
display: flex;
flex-direction: column;
margin-right: 20px;
}
.article-card-title {
font-size: 30px;
font-weight: bold;
color: $tx;
line-height: 1.4;
display: block;
margin-bottom: 8px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.article-card-summary {
font-size: 26px;
color: $tx2;
line-height: 1.4;
display: block;
margin-bottom: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.article-card-meta {
display: flex;
align-items: center;
gap: 12px;
}
.article-card-tag {
font-size: 22px;
color: $pri;
background: $pri-l;
padding: 2px 12px;
border-radius: 12px;
}
.article-card-date {
font-size: 22px;
color: $tx3;
}
.article-card-cover {
width: 180px;
height: 120px;
border-radius: $r-sm;
overflow: hidden;
flex-shrink: 0;
}
.cover-img {
width: 100%;
height: 100%;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.loading-hint {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}

View File

@@ -1,12 +1,95 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import '../health/index.scss';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listArticles, Article } from '../../services/article';
import './index.scss';
export default function ArticleList() {
const [articles, setArticles] = useState<Article[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const fetchData = useCallback(async (p: number, append = false) => {
setLoading(true);
try {
const res = await listArticles(p);
const list = res.data || [];
setArticles(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total);
setPage(p);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchData(1);
}, [fetchData]);
usePullDownRefresh(() => {
fetchData(1).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && articles.length < total) {
fetchData(page + 1, true);
}
});
const goToDetail = (id: string) => {
Taro.navigateTo({ url: `/pages/article/detail/index?id=${id}` });
};
export default function Article() {
return (
<View className='placeholder-page'>
<Text className='placeholder-icon'>📰</Text>
<Text className='placeholder-title'></Text>
<Text className='placeholder-desc'></Text>
<View className='article-page'>
<View className='article-list'>
{articles.map((a) => (
<View
className='article-card'
key={a.id}
onClick={() => goToDetail(a.id)}
>
<View className='article-card-body'>
<Text className='article-card-title'>{a.title}</Text>
{a.summary && (
<Text className='article-card-summary'>{a.summary}</Text>
)}
<View className='article-card-meta'>
{a.category && (
<Text className='article-card-tag'>{a.category}</Text>
)}
{a.published_at && (
<Text className='article-card-date'>
{a.published_at.slice(0, 10)}
</Text>
)}
</View>
</View>
{a.cover_image && (
<View className='article-card-cover'>
<image className='cover-img' src={a.cover_image} mode='aspectFill' />
</View>
)}
</View>
))}
</View>
{articles.length === 0 && !loading && (
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
)}
{loading && (
<View className='loading-hint'>
<Text className='loading-text'>...</Text>
</View>
)}
</View>
);
}

View File

@@ -0,0 +1,118 @@
@import '../../../styles/variables.scss';
.detail-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 40px;
}
.detail-card {
background: $card;
border-radius: $r;
padding: 28px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.detail-title {
font-size: 34px;
font-weight: bold;
color: $tx;
display: block;
margin-bottom: 20px;
}
.detail-row {
display: flex;
justify-content: space-between;
padding: 12px 0;
border-bottom: 1px solid $bd-l;
&:last-child {
border-bottom: none;
}
}
.detail-label {
font-size: 26px;
color: $tx2;
}
.detail-value {
font-size: 26px;
color: $tx;
}
.detail-desc {
margin-top: 16px;
padding: 20px;
background: $bd-l;
border-radius: $r-sm;
}
.detail-desc-text {
font-size: 26px;
color: $tx;
line-height: 1.6;
}
.submit-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.section-title {
font-size: 30px;
font-weight: bold;
color: $tx;
display: block;
margin-bottom: 16px;
}
.submit-textarea {
width: 100%;
min-height: 200px;
font-size: 28px;
color: $tx;
background: $bd-l;
border-radius: $r-sm;
padding: 20px;
box-sizing: border-box;
border: none;
outline: none;
margin-bottom: 20px;
}
.submit-btn {
background: $pri;
border-radius: $r-sm;
padding: 24px;
text-align: center;
&.disabled {
opacity: 0.6;
}
}
.submit-btn-text {
font-size: 30px;
color: white;
font-weight: bold;
}
.loading-state,
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.loading-text,
.empty-text {
font-size: 28px;
color: $tx3;
}

View File

@@ -0,0 +1,119 @@
import React, { useState, useEffect } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useRouter } from '@tarojs/taro';
import { listTasks, submitRecord, FollowUpTask } from '../../../services/followup';
import './index.scss';
export default function FollowUpDetail() {
const router = useRouter();
const id = router.params.id || '';
const [task, setTask] = useState<FollowUpTask | null>(null);
const [content, setContent] = useState('');
const [submitting, setSubmitting] = useState(false);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (!id) return;
setLoading(true);
listTasks()
.then((res) => {
const found = (res.data || []).find((t) => t.id === id);
setTask(found || null);
})
.catch(() => Taro.showToast({ title: '加载失败', icon: 'none' }))
.finally(() => setLoading(false));
}, [id]);
const handleSubmit = async () => {
if (!content.trim()) {
Taro.showToast({ title: '请输入内容', icon: 'none' });
return;
}
setSubmitting(true);
try {
await submitRecord({
task_id: id,
content: { text: content.trim() },
});
Taro.showToast({ title: '提交成功', icon: 'success' });
setContent('');
} catch {
Taro.showToast({ title: '提交失败', icon: 'none' });
} finally {
setSubmitting(false);
}
};
const getStatusLabel = (status: string) => {
if (status === 'completed') return '已完成';
if (status === 'overdue') return '已过期';
return '待完成';
};
if (loading) {
return (
<View className='detail-page'>
<View className='loading-state'>
<Text className='loading-text'>...</Text>
</View>
</View>
);
}
if (!task) {
return (
<View className='detail-page'>
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
</View>
);
}
const isCompleted = task.status === 'completed';
return (
<View className='detail-page'>
{/* 任务详情 */}
<View className='detail-card'>
<Text className='detail-title'>{task.task_type}</Text>
<View className='detail-row'>
<Text className='detail-label'></Text>
<Text className='detail-value'>{getStatusLabel(task.status)}</Text>
</View>
<View className='detail-row'>
<Text className='detail-label'></Text>
<Text className='detail-value'>{task.due_date}</Text>
</View>
{task.description && (
<View className='detail-desc'>
<Text className='detail-desc-text'>{task.description}</Text>
</View>
)}
</View>
{/* 提交表单 */}
{!isCompleted && (
<View className='submit-card'>
<Text className='section-title'>访</Text>
<textarea
className='submit-textarea'
placeholder='请输入随访内容...'
value={content}
onInput={(e) => setContent(e.detail.value)}
maxlength={500}
/>
<View
className={`submit-btn ${submitting ? 'disabled' : ''}`}
onClick={submitting ? undefined : handleSubmit}
>
<Text className='submit-btn-text'>
{submitting ? '提交中...' : '提交'}
</Text>
</View>
</View>
)}
</View>
);
}

View File

@@ -0,0 +1,132 @@
@import '../../styles/variables.scss';
.followup-page {
min-height: 100vh;
background: $bg;
}
.tab-bar {
display: flex;
background: $card;
padding: 0;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.tab-item {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 24px 0;
position: relative;
&.active {
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 48px;
height: 4px;
background: $pri;
border-radius: 2px;
}
}
}
.tab-text {
font-size: 28px;
color: $tx2;
.tab-item.active & {
color: $pri;
font-weight: bold;
}
}
.task-list {
padding: 24px;
display: flex;
flex-direction: column;
gap: 20px;
}
.task-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.task-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.task-name {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.task-status {
font-size: 24px;
padding: 4px 16px;
border-radius: 20px;
&.pending {
color: $wrn;
background: $wrn-l;
}
&.completed {
color: $acc;
background: $acc-l;
}
&.overdue {
color: $dan;
background: $dan-l;
}
}
.task-desc {
font-size: 26px;
color: $tx2;
display: block;
margin-bottom: 8px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.task-due {
font-size: 24px;
color: $tx3;
display: block;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.loading-hint {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}

View File

@@ -0,0 +1,107 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow } from '@tarojs/taro';
import { listTasks, FollowUpTask } from '../../services/followup';
import './index.scss';
const TABS = [
{ key: 'pending', label: '待完成' },
{ key: 'completed', label: '已完成' },
{ key: 'overdue', label: '已过期' },
];
export default function FollowUpList() {
const [activeTab, setActiveTab] = useState('pending');
const [tasks, setTasks] = useState<FollowUpTask[]>([]);
const [loading, setLoading] = useState(false);
const fetchTasks = useCallback(async (status: string) => {
setLoading(true);
try {
const res = await listTasks(status);
setTasks(res.data || []);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchTasks(activeTab);
}, [activeTab, fetchTasks]);
const handleTabChange = (key: string) => {
setActiveTab(key);
setTasks([]);
fetchTasks(key);
};
const goToDetail = (id: string) => {
Taro.navigateTo({ url: `/pages/followup/detail/index?id=${id}` });
};
const getStatusClass = (status: string) => {
if (status === 'completed') return 'completed';
if (status === 'overdue') return 'overdue';
return 'pending';
};
const getStatusLabel = (status: string) => {
if (status === 'completed') return '已完成';
if (status === 'overdue') return '已过期';
return '待完成';
};
return (
<View className='followup-page'>
{/* Tab 栏 */}
<View className='tab-bar'>
{TABS.map((tab) => (
<View
className={`tab-item ${activeTab === tab.key ? 'active' : ''}`}
key={tab.key}
onClick={() => handleTabChange(tab.key)}
>
<Text className='tab-text'>{tab.label}</Text>
</View>
))}
</View>
{/* 任务列表 */}
<View className='task-list'>
{tasks.map((t) => (
<View
className='task-card'
key={t.id}
onClick={() => goToDetail(t.id)}
>
<View className='task-top'>
<Text className='task-name'>{t.task_type}</Text>
<Text className={`task-status ${getStatusClass(t.status)}`}>
{getStatusLabel(t.status)}
</Text>
</View>
<Text className='task-desc'>{t.description}</Text>
<Text className='task-due'>{t.due_date}</Text>
</View>
))}
</View>
{tasks.length === 0 && !loading && (
<View className='empty-state'>
<Text className='empty-text'>{(() => {
const tab = TABS.find((t) => t.key === activeTab);
return tab ? tab.label : '';
})()}</Text>
</View>
)}
{loading && (
<View className='loading-hint'>
<Text className='loading-text'>...</Text>
</View>
)}
</View>
);
}

View File

@@ -0,0 +1,82 @@
@import '../../../styles/variables.scss';
.family-add-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 140px;
}
.form-card {
background: $card;
border-radius: $r;
padding: 8px 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.form-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28px 0;
border-bottom: 1px solid $bd-l;
&:last-child {
border-bottom: none;
}
}
.form-label {
font-size: 28px;
color: $tx;
flex-shrink: 0;
width: 140px;
}
.form-input {
flex: 1;
font-size: 28px;
color: $tx;
text-align: right;
border: none;
background: transparent;
outline: none;
}
.form-picker {
display: flex;
align-items: center;
flex: 1;
justify-content: flex-end;
}
.form-picker-text {
font-size: 28px;
color: $tx;
margin-right: 8px;
}
.form-picker-arrow {
font-size: 32px;
color: $tx3;
}
.submit-btn {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: $pri;
padding: 28px;
text-align: center;
&.disabled {
opacity: 0.6;
}
}
.submit-text {
font-size: 32px;
color: white;
font-weight: bold;
}

View File

@@ -0,0 +1,111 @@
import React, { useState } from 'react';
import { View, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { Picker } from '@tarojs/components';
import { createPatient } from '../../../services/patient';
import './index.scss';
const RELATION_OPTIONS = ['本人', '配偶', '父母', '子女', '其他'];
const GENDER_OPTIONS = ['男', '女'];
export default function FamilyAdd() {
const [name, setName] = useState('');
const [relationIdx, setRelationIdx] = useState(0);
const [genderIdx, setGenderIdx] = useState(0);
const [birthDate, setBirthDate] = useState('');
const [submitting, setSubmitting] = useState(false);
const handleSubmit = async () => {
if (!name.trim()) {
Taro.showToast({ title: '请输入姓名', icon: 'none' });
return;
}
setSubmitting(true);
try {
await createPatient({
name: name.trim(),
gender: GENDER_OPTIONS[genderIdx] === '男' ? 'male' : 'female',
birthday: birthDate || undefined,
});
Taro.showToast({ title: '添加成功', icon: 'success' });
setTimeout(() => {
Taro.navigateBack();
}, 1000);
} catch {
Taro.showToast({ title: '添加失败', icon: 'none' });
} finally {
setSubmitting(false);
}
};
return (
<View className='family-add-page'>
<View className='form-card'>
{/* 姓名 */}
<View className='form-item'>
<Text className='form-label'></Text>
<input
className='form-input'
placeholder='请输入姓名'
value={name}
onInput={(e) => setName(e.detail.value)}
/>
</View>
{/* 关系 */}
<View className='form-item'>
<Text className='form-label'></Text>
<Picker
mode='selector'
range={RELATION_OPTIONS}
value={relationIdx}
onChange={(e) => setRelationIdx(Number(e.detail.value))}
>
<View className='form-picker'>
<Text className='form-picker-text'>{RELATION_OPTIONS[relationIdx]}</Text>
<Text className='form-picker-arrow'></Text>
</View>
</Picker>
</View>
{/* 性别 */}
<View className='form-item'>
<Text className='form-label'></Text>
<Picker
mode='selector'
range={GENDER_OPTIONS}
value={genderIdx}
onChange={(e) => setGenderIdx(Number(e.detail.value))}
>
<View className='form-picker'>
<Text className='form-picker-text'>{GENDER_OPTIONS[genderIdx]}</Text>
<Text className='form-picker-arrow'></Text>
</View>
</Picker>
</View>
{/* 出生日期 */}
<View className='form-item'>
<Text className='form-label'></Text>
<Picker
mode='date'
value={birthDate || '2000-01-01'}
onChange={(e) => setBirthDate(e.detail.value)}
>
<View className='form-picker'>
<Text className='form-picker-text'>{birthDate || '请选择'}</Text>
<Text className='form-picker-arrow'></Text>
</View>
</Picker>
</View>
</View>
<View
className={`submit-btn ${submitting ? 'disabled' : ''}`}
onClick={submitting ? undefined : handleSubmit}
>
<Text className='submit-text'>{submitting ? '提交中...' : '确认添加'}</Text>
</View>
</View>
);
}

View File

@@ -0,0 +1,97 @@
@import '../../../styles/variables.scss';
.family-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 140px;
}
.family-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.family-item {
display: flex;
align-items: center;
justify-content: space-between;
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
border: 2px solid transparent;
&.active {
border-color: $pri;
background: $pri-surface;
}
}
.family-info {
display: flex;
flex-direction: column;
}
.family-name {
font-size: 30px;
font-weight: bold;
color: $tx;
margin-bottom: 8px;
}
.family-meta {
display: flex;
gap: 16px;
}
.family-tag {
font-size: 24px;
color: $pri;
background: $pri-l;
padding: 2px 12px;
border-radius: 12px;
}
.family-gender {
font-size: 24px;
color: $tx2;
}
.family-check {
font-size: 24px;
color: $pri;
background: $pri-l;
padding: 6px 16px;
border-radius: 16px;
font-weight: bold;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.family-add-btn {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: $pri;
padding: 28px;
text-align: center;
}
.family-add-text {
font-size: 32px;
color: white;
font-weight: bold;
}

View File

@@ -0,0 +1,85 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow } from '@tarojs/taro';
import { listPatients, Patient } from '../../../services/patient';
import { useAuthStore } from '../../../stores/auth';
import './index.scss';
export default function FamilyList() {
const [patients, setPatients] = useState<Patient[]>([]);
const [loading, setLoading] = useState(false);
const { currentPatient, setCurrentPatient } = useAuthStore();
const fetchPatients = useCallback(async () => {
setLoading(true);
try {
const res = await listPatients();
setPatients(res.data || []);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchPatients();
}, [fetchPatients]);
const handleSelect = (patient: Patient) => {
setCurrentPatient({
id: patient.id,
name: patient.name,
gender: patient.gender,
birthday: patient.birthday,
relation: patient.relation || '本人',
});
Taro.showToast({ title: `已切换为 ${patient.name}`, icon: 'success' });
};
const goToAdd = () => {
Taro.navigateTo({ url: '/pages/profile/family-add/index' });
};
const genderText = (g?: string) => {
if (g === 'male') return '男';
if (g === 'female') return '女';
return '未知';
};
return (
<View className='family-page'>
<View className='family-list'>
{patients.map((p) => {
const isActive = currentPatient?.id === p.id;
return (
<View
className={`family-item ${isActive ? 'active' : ''}`}
key={p.id}
onClick={() => handleSelect(p)}
>
<View className='family-info'>
<Text className='family-name'>{p.name}</Text>
<View className='family-meta'>
<Text className='family-tag'>{p.relation || '本人'}</Text>
<Text className='family-gender'>{genderText(p.gender)}</Text>
</View>
</View>
{isActive && <Text className='family-check'></Text>}
</View>
);
})}
</View>
{patients.length === 0 && !loading && (
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
)}
<View className='family-add-btn' onClick={goToAdd}>
<Text className='family-add-text'>+ </Text>
</View>
</View>
);
}

View File

@@ -0,0 +1,132 @@
@import '../../../styles/variables.scss';
.my-followups-page {
min-height: 100vh;
background: $bg;
}
.tab-bar {
display: flex;
background: $card;
padding: 0;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.tab-item {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 24px 0;
position: relative;
&.active {
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 48px;
height: 4px;
background: $pri;
border-radius: 2px;
}
}
}
.tab-text {
font-size: 28px;
color: $tx2;
.tab-item.active & {
color: $pri;
font-weight: bold;
}
}
.task-list {
padding: 24px;
display: flex;
flex-direction: column;
gap: 20px;
}
.task-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.task-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.task-name {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.task-status {
font-size: 24px;
padding: 4px 16px;
border-radius: 20px;
&.pending {
color: $wrn;
background: $wrn-l;
}
&.completed {
color: $acc;
background: $acc-l;
}
&.overdue {
color: $dan;
background: $dan-l;
}
}
.task-desc {
font-size: 26px;
color: $tx2;
display: block;
margin-bottom: 8px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.task-due {
font-size: 24px;
color: $tx3;
display: block;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.loading-hint {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}

View File

@@ -0,0 +1,105 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow } from '@tarojs/taro';
import { listTasks, FollowUpTask } from '../../../services/followup';
import './index.scss';
const TABS = [
{ key: 'pending', label: '待完成' },
{ key: 'completed', label: '已完成' },
{ key: 'overdue', label: '已过期' },
];
export default function MyFollowUps() {
const [activeTab, setActiveTab] = useState('pending');
const [tasks, setTasks] = useState<FollowUpTask[]>([]);
const [loading, setLoading] = useState(false);
const fetchTasks = useCallback(async (status: string) => {
setLoading(true);
try {
const res = await listTasks(status);
setTasks(res.data || []);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchTasks(activeTab);
}, [activeTab, fetchTasks]);
const handleTabChange = (key: string) => {
setActiveTab(key);
setTasks([]);
fetchTasks(key);
};
const goToDetail = (id: string) => {
Taro.navigateTo({ url: `/pages/followup/detail/index?id=${id}` });
};
const getStatusClass = (status: string) => {
if (status === 'completed') return 'completed';
if (status === 'overdue') return 'overdue';
return 'pending';
};
const getStatusLabel = (status: string) => {
if (status === 'completed') return '已完成';
if (status === 'overdue') return '已过期';
return '待完成';
};
return (
<View className='my-followups-page'>
<View className='tab-bar'>
{TABS.map((tab) => (
<View
className={`tab-item ${activeTab === tab.key ? 'active' : ''}`}
key={tab.key}
onClick={() => handleTabChange(tab.key)}
>
<Text className='tab-text'>{tab.label}</Text>
</View>
))}
</View>
<View className='task-list'>
{tasks.map((t) => (
<View
className='task-card'
key={t.id}
onClick={() => goToDetail(t.id)}
>
<View className='task-top'>
<Text className='task-name'>{t.task_type}</Text>
<Text className={`task-status ${getStatusClass(t.status)}`}>
{getStatusLabel(t.status)}
</Text>
</View>
<Text className='task-desc'>{t.description}</Text>
<Text className='task-due'>{t.due_date}</Text>
</View>
))}
</View>
{tasks.length === 0 && !loading && (
<View className='empty-state'>
<Text className='empty-text'>{(() => {
const tab = TABS.find((t) => t.key === activeTab);
return tab ? tab.label : '';
})()}</Text>
</View>
)}
{loading && (
<View className='loading-hint'>
<Text className='loading-text'>...</Text>
</View>
)}
</View>
);
}

View File

@@ -1,10 +1,35 @@
import React from 'react';
import { View, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useAuthStore } from '../../stores/auth';
import '../health/index.scss';
import './index.scss';
const MENU_ITEMS = [
{ label: '就诊人管理', icon: '👥', path: '/pages/profile/family/index' },
{ label: '我的报告', icon: '📋', path: '/pages/profile/reports/index' },
{ label: '我的随访', icon: '💬', path: '/pages/profile/followups/index' },
{ label: '用药提醒', icon: '💊', path: '/pages/profile/medication/index' },
{ label: '设置', icon: '⚙️', path: '/pages/profile/settings/index' },
];
export default function Profile() {
const { user, logout } = useAuthStore();
const handleMenuClick = (path: string) => {
Taro.navigateTo({ url: path });
};
const handleLogout = () => {
Taro.showModal({
title: '退出登录',
content: '确定要退出登录吗?',
}).then((res) => {
if (res.confirm) {
logout();
}
});
};
return (
<View className='profile-page'>
<View className='profile-header'>
@@ -18,14 +43,12 @@ export default function Profile() {
</View>
<View className='profile-menu'>
{[
{ label: '就诊人管理', icon: '👥' },
{ label: '我的报告', icon: '📋' },
{ label: '我的随访', icon: '💬' },
{ label: '用药提醒', icon: '💊' },
{ label: '设置', icon: '⚙️' },
].map((item) => (
<View className='menu-item' key={item.label}>
{MENU_ITEMS.map((item) => (
<View
className='menu-item'
key={item.label}
onClick={() => handleMenuClick(item.path)}
>
<Text className='menu-icon'>{item.icon}</Text>
<Text className='menu-label'>{item.label}</Text>
<Text className='menu-arrow'></Text>
@@ -33,7 +56,7 @@ export default function Profile() {
))}
</View>
<View className='profile-logout' onClick={logout}>
<View className='profile-logout' onClick={handleLogout}>
<Text className='logout-text'>退</Text>
</View>
</View>

View File

@@ -0,0 +1,196 @@
@import '../../../styles/variables.scss';
.medication-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 140px;
}
.reminder-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.reminder-card {
display: flex;
align-items: center;
justify-content: space-between;
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.reminder-left {
display: flex;
flex-direction: column;
}
.reminder-name {
font-size: 30px;
font-weight: bold;
color: $tx;
margin-bottom: 4px;
}
.reminder-dosage {
font-size: 24px;
color: $tx2;
}
.reminder-actions {
display: flex;
align-items: center;
gap: 16px;
}
.toggle {
width: 80px;
height: 44px;
border-radius: 22px;
padding: 4px;
position: relative;
transition: background 0.3s;
&.on {
background: $pri;
}
&.off {
background: $bd;
}
}
.toggle-dot {
width: 36px;
height: 36px;
border-radius: 50%;
background: white;
position: absolute;
top: 4px;
transition: left 0.3s;
.toggle.on & {
left: 40px;
}
.toggle.off & {
left: 4px;
}
}
.delete-btn {
font-size: 24px;
color: $dan;
padding: 4px 12px;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.form-card {
background: $card;
border-radius: $r;
padding: 28px;
margin-top: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.form-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid $bd-l;
&:last-of-type {
border-bottom: none;
}
}
.form-label {
font-size: 28px;
color: $tx;
flex-shrink: 0;
width: 140px;
}
.form-input {
flex: 1;
font-size: 28px;
color: $tx;
text-align: right;
border: none;
background: transparent;
outline: none;
}
.time-picker-wrap {
flex: 1;
text-align: right;
}
.time-value {
font-size: 28px;
color: $tx;
}
.form-actions {
display: flex;
gap: 16px;
margin-top: 20px;
}
.form-cancel {
flex: 1;
background: $bd-l;
border-radius: $r-sm;
padding: 20px;
text-align: center;
}
.form-cancel-text {
font-size: 28px;
color: $tx2;
}
.form-confirm {
flex: 1;
background: $pri;
border-radius: $r-sm;
padding: 20px;
text-align: center;
}
.form-confirm-text {
font-size: 28px;
color: white;
font-weight: bold;
}
.add-btn {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: $pri;
padding: 28px;
text-align: center;
}
.add-text {
font-size: 32px;
color: white;
font-weight: bold;
}

View File

@@ -0,0 +1,158 @@
import React, { useState, useEffect } from 'react';
import { View, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import './index.scss';
interface MedicationReminder {
id: string;
name: string;
dosage: string;
time: string;
enabled: boolean;
}
const STORAGE_KEY = 'medication_reminders';
function loadReminders(): MedicationReminder[] {
return Taro.getStorageSync(STORAGE_KEY) || [];
}
function saveReminders(reminders: MedicationReminder[]) {
Taro.setStorageSync(STORAGE_KEY, reminders);
}
export default function MedicationReminder() {
const [reminders, setReminders] = useState<MedicationReminder[]>([]);
const [showForm, setShowForm] = useState(false);
const [formName, setFormName] = useState('');
const [formDosage, setFormDosage] = useState('');
const [formTime, setFormTime] = useState('08:00');
useEffect(() => {
setReminders(loadReminders());
}, []);
const updateReminders = (updated: MedicationReminder[]) => {
setReminders(updated);
saveReminders(updated);
};
const handleToggle = (id: string) => {
const updated = reminders.map((r) =>
r.id === id ? { ...r, enabled: !r.enabled } : r
);
updateReminders(updated);
};
const handleDelete = (id: string) => {
Taro.showModal({
title: '确认删除',
content: '确定要删除这个提醒吗?',
}).then((res) => {
if (res.confirm) {
updateReminders(reminders.filter((r) => r.id !== id));
}
});
};
const handleAdd = () => {
if (!formName.trim()) {
Taro.showToast({ title: '请输入药品名称', icon: 'none' });
return;
}
const newReminder: MedicationReminder = {
id: Date.now().toString(),
name: formName.trim(),
dosage: formDosage.trim(),
time: formTime,
enabled: true,
};
updateReminders([...reminders, newReminder]);
setFormName('');
setFormDosage('');
setFormTime('08:00');
setShowForm(false);
Taro.showToast({ title: '添加成功', icon: 'success' });
};
return (
<View className='medication-page'>
<View className='reminder-list'>
{reminders.map((r) => (
<View className='reminder-card' key={r.id}>
<View className='reminder-left'>
<Text className='reminder-name'>{r.name}</Text>
<Text className='reminder-dosage'>
{r.dosage} | {r.time}
</Text>
</View>
<View className='reminder-actions'>
<View
className={`toggle ${r.enabled ? 'on' : 'off'}`}
onClick={() => handleToggle(r.id)}
>
<View className='toggle-dot' />
</View>
<Text
className='delete-btn'
onClick={() => handleDelete(r.id)}
>
</Text>
</View>
</View>
))}
</View>
{reminders.length === 0 && (
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
)}
{/* 添加表单 */}
{showForm && (
<View className='form-card'>
<View className='form-item'>
<Text className='form-label'></Text>
<input
className='form-input'
placeholder='请输入药品名称'
value={formName}
onInput={(e) => setFormName(e.detail.value)}
/>
</View>
<View className='form-item'>
<Text className='form-label'></Text>
<input
className='form-input'
placeholder='如1片、10ml'
value={formDosage}
onInput={(e) => setFormDosage(e.detail.value)}
/>
</View>
<View className='form-item'>
<Text className='form-label'></Text>
<View className='time-picker-wrap'>
<Text className='time-value'>{formTime}</Text>
</View>
</View>
<View className='form-actions'>
<View className='form-cancel' onClick={() => setShowForm(false)}>
<Text className='form-cancel-text'></Text>
</View>
<View className='form-confirm' onClick={handleAdd}>
<Text className='form-confirm-text'></Text>
</View>
</View>
</View>
)}
{!showForm && (
<View className='add-btn' onClick={() => setShowForm(true)}>
<Text className='add-text'>+ </Text>
</View>
)}
</View>
);
}

View File

@@ -0,0 +1,78 @@
@import '../../../styles/variables.scss';
.my-reports-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 40px;
}
.report-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.report-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.report-card-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.report-type {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.report-status {
font-size: 24px;
padding: 4px 16px;
border-radius: 20px;
&.normal {
color: $acc;
background: $acc-l;
}
&.abnormal {
color: $dan;
background: $dan-l;
}
}
.report-date {
font-size: 26px;
color: $tx2;
display: block;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.loading-hint {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}

View File

@@ -0,0 +1,94 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listReports, LabReport } from '../../../services/report';
import './index.scss';
const PAGE_SIZE = 20;
export default function MyReports() {
const [reports, setReports] = useState<LabReport[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const patientId = Taro.getStorageSync('current_patient_id') || '';
const fetchData = useCallback(async (p: number, append = false) => {
if (!patientId) return;
setLoading(true);
try {
const res = await listReports(patientId, p);
const list = res.data || [];
setReports(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total);
setPage(p);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, [patientId]);
useDidShow(() => {
fetchData(1);
}, [fetchData]);
usePullDownRefresh(() => {
fetchData(1).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && reports.length < total) {
fetchData(page + 1, true);
}
});
const goToDetail = (id: string) => {
Taro.navigateTo({ url: `/pages/report/detail/index?id=${id}` });
};
const formatStatus = (report: LabReport) => {
const indicators = report.indicators;
if (!indicators || typeof indicators !== 'object') return '未知';
const vals = Object.values(indicators) as Array<{ status?: string }>;
const hasAbnormal = vals.some((v) => v.status === 'high' || v.status === 'low');
return hasAbnormal ? '异常' : '正常';
};
return (
<View className='my-reports-page'>
<View className='report-list'>
{reports.map((r) => (
<View
className='report-card'
key={r.id}
onClick={() => goToDetail(r.id)}
>
<View className='report-card-top'>
<Text className='report-type'>{r.report_type}</Text>
<Text className={`report-status ${formatStatus(r) === '正常' ? 'normal' : 'abnormal'}`}>
{formatStatus(r)}
</Text>
</View>
<Text className='report-date'>{r.report_date}</Text>
</View>
))}
</View>
{reports.length === 0 && !loading && (
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
)}
{loading && (
<View className='loading-hint'>
<Text className='loading-text'>...</Text>
</View>
)}
</View>
);
}

View File

@@ -0,0 +1,50 @@
@import '../../../styles/variables.scss';
.settings-page {
min-height: 100vh;
background: $bg;
padding: 24px;
}
.settings-group {
background: $card;
border-radius: $r;
overflow: hidden;
margin-bottom: 24px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.settings-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28px 24px;
border-bottom: 1px solid $bd-l;
&:last-child {
border-bottom: none;
}
&.logout-item {
justify-content: center;
}
}
.settings-label {
font-size: 30px;
color: $tx;
.logout-item & {
color: $dan;
font-weight: bold;
}
}
.logout-label {
color: $dan;
}
.settings-arrow {
font-size: 32px;
color: $tx3;
}

View File

@@ -0,0 +1,90 @@
import React from 'react';
import { View, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useAuthStore } from '../../../stores/auth';
import './index.scss';
export default function Settings() {
const { logout } = useAuthStore();
const handleClearCache = () => {
Taro.showModal({
title: '清除缓存',
content: '确定要清除本地缓存数据吗?不会影响账号信息。',
}).then((res) => {
if (res.confirm) {
// 保留登录态和核心设置
const token = Taro.getStorageSync('access_token');
const refreshToken = Taro.getStorageSync('refresh_token');
const user = Taro.getStorageSync('user');
const currentPatient = Taro.getStorageSync('current_patient');
const currentPatientId = Taro.getStorageSync('current_patient_id');
const tenantId = Taro.getStorageSync('tenant_id');
Taro.clearStorageSync();
// 恢复登录态
if (token) Taro.setStorageSync('access_token', token);
if (refreshToken) Taro.setStorageSync('refresh_token', refreshToken);
if (user) Taro.setStorageSync('user', user);
if (currentPatient) Taro.setStorageSync('current_patient', currentPatient);
if (currentPatientId) Taro.setStorageSync('current_patient_id', currentPatientId);
if (tenantId) Taro.setStorageSync('tenant_id', tenantId);
Taro.showToast({ title: '缓存已清除', icon: 'success' });
}
});
};
const handleAbout = () => {
Taro.showModal({
title: '关于我们',
content: 'HMS 健康管理平台 v1.0.0\n为您的健康保驾护航',
showCancel: false,
});
};
const handlePrivacy = () => {
Taro.showModal({
title: '隐私政策',
content: '我们重视您的隐私保护。所有健康数据均经过加密存储,仅用于为您提供健康管理服务,不会向第三方分享。',
showCancel: false,
});
};
const handleLogout = () => {
Taro.showModal({
title: '退出登录',
content: '确定要退出登录吗?',
}).then((res) => {
if (res.confirm) {
logout();
}
});
};
return (
<View className='settings-page'>
<View className='settings-group'>
<View className='settings-item' onClick={handleClearCache}>
<Text className='settings-label'></Text>
<Text className='settings-arrow'></Text>
</View>
<View className='settings-item' onClick={handleAbout}>
<Text className='settings-label'></Text>
<Text className='settings-arrow'></Text>
</View>
<View className='settings-item' onClick={handlePrivacy}>
<Text className='settings-label'></Text>
<Text className='settings-arrow'></Text>
</View>
</View>
<View className='settings-group'>
<View className='settings-item logout-item' onClick={handleLogout}>
<Text className='settings-label logout-label'>退</Text>
</View>
</View>
</View>
);
}

View File

@@ -0,0 +1,142 @@
@import '../../../styles/variables.scss';
.detail-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 40px;
}
.detail-card {
background: $card;
border-radius: $r;
padding: 28px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.detail-title {
font-size: 34px;
font-weight: bold;
color: $tx;
display: block;
margin-bottom: 20px;
}
.detail-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
padding: 12px 0;
border-bottom: 1px solid $bd-l;
&:last-child {
border-bottom: none;
}
}
.detail-label {
font-size: 26px;
color: $tx2;
flex-shrink: 0;
}
.detail-value {
font-size: 26px;
color: $tx;
text-align: right;
flex: 1;
margin-left: 24px;
}
.indicators-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.section-title {
font-size: 30px;
font-weight: bold;
color: $tx;
display: block;
margin-bottom: 16px;
}
.indicator-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 0;
border-bottom: 1px solid $bd-l;
&:last-child {
border-bottom: none;
}
}
.indicator-left {
display: flex;
flex-direction: column;
}
.indicator-name {
font-size: 26px;
color: $tx2;
margin-bottom: 4px;
}
.indicator-value {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.indicator-right {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.indicator-ref {
font-size: 22px;
color: $tx3;
margin-bottom: 4px;
}
.indicator-status {
font-size: 24px;
font-weight: bold;
padding: 4px 12px;
border-radius: 16px;
&.normal {
color: $tx3;
background: $bd-l;
}
&.high {
color: $dan;
background: $dan-l;
}
&.low {
color: $dan;
background: $dan-l;
}
}
.loading-state,
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.loading-text,
.empty-text {
font-size: 28px;
color: $tx3;
}

View File

@@ -0,0 +1,118 @@
import React, { useState, useEffect } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useRouter } from '@tarojs/taro';
import { getReportDetail, LabReport } from '../../../services/report';
import './index.scss';
interface IndicatorItem {
name: string;
value: number;
unit?: string;
reference_min?: number;
reference_max?: number;
status?: string;
}
export default function ReportDetail() {
const router = useRouter();
const id = router.params.id || '';
const patientId = Taro.getStorageSync('current_patient_id') || '';
const [report, setReport] = useState<LabReport | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (!id || !patientId) return;
setLoading(true);
getReportDetail(patientId, id)
.then((data) => setReport(data))
.catch(() => Taro.showToast({ title: '加载失败', icon: 'none' }))
.finally(() => setLoading(false));
}, [id, patientId]);
const indicators: IndicatorItem[] = React.useMemo(() => {
if (!report?.indicators || typeof report.indicators !== 'object') return [];
return Object.entries(report.indicators).map(([name, val]: [string, any]) => ({
name,
value: val.value,
unit: val.unit,
reference_min: val.reference_min,
reference_max: val.reference_max,
status: val.status,
}));
}, [report]);
const getStatusInfo = (status?: string) => {
if (status === 'high') return { text: '偏高', icon: '', className: 'high' };
if (status === 'low') return { text: '偏低', icon: '', className: 'low' };
return { text: '正常', icon: '', className: 'normal' };
};
if (loading) {
return (
<View className='detail-page'>
<View className='loading-state'>
<Text className='loading-text'>...</Text>
</View>
</View>
);
}
if (!report) {
return (
<View className='detail-page'>
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
</View>
);
}
return (
<View className='detail-page'>
{/* 基本信息 */}
<View className='detail-card'>
<Text className='detail-title'>{report.report_type}</Text>
<View className='detail-row'>
<Text className='detail-label'></Text>
<Text className='detail-value'>{report.report_date}</Text>
</View>
{report.doctor_interpretation && (
<View className='detail-row'>
<Text className='detail-label'></Text>
<Text className='detail-value'>{report.doctor_interpretation}</Text>
</View>
)}
</View>
{/* 指标列表 */}
<View className='indicators-card'>
<Text className='section-title'></Text>
{indicators.map((item) => {
const statusInfo = getStatusInfo(item.status);
return (
<View className='indicator-item' key={item.name}>
<View className='indicator-left'>
<Text className='indicator-name'>{item.name}</Text>
<Text className='indicator-value'>
{item.value}
{item.unit ? ` ${item.unit}` : ''}
</Text>
</View>
<View className='indicator-right'>
{item.reference_min != null && item.reference_max != null && (
<Text className='indicator-ref'>
{item.reference_min}~{item.reference_max}
</Text>
)}
<Text className={`indicator-status ${statusInfo.className}`}>
{statusInfo.icon} {statusInfo.text}
</Text>
</View>
</View>
);
})}
</View>
</View>
);
}

View File

@@ -0,0 +1,88 @@
@import '../../styles/variables.scss';
.report-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 40px;
}
.report-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.report-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.report-card-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.report-type {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.report-status {
font-size: 24px;
padding: 4px 16px;
border-radius: 20px;
&.normal {
color: $acc;
background: $acc-l;
}
&.abnormal {
color: $dan;
background: $dan-l;
}
}
.report-date {
font-size: 26px;
color: $tx2;
display: block;
margin-bottom: 8px;
}
.report-note {
font-size: 24px;
color: $tx3;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.loading-hint {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}

View File

@@ -0,0 +1,97 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listReports, LabReport } from '../../services/report';
import './index.scss';
const PAGE_SIZE = 20;
export default function ReportList() {
const [reports, setReports] = useState<LabReport[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const patientId = Taro.getStorageSync('current_patient_id') || '';
const fetchData = useCallback(async (p: number, append = false) => {
if (!patientId) return;
setLoading(true);
try {
const res = await listReports(patientId, p);
const list = res.data || [];
setReports(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total);
setPage(p);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, [patientId]);
useDidShow(() => {
fetchData(1);
});
usePullDownRefresh(() => {
fetchData(1).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && reports.length < total) {
fetchData(page + 1, true);
}
});
const goToDetail = (id: string) => {
Taro.navigateTo({ url: `/pages/report/detail/index?id=${id}` });
};
const formatStatus = (report: LabReport) => {
const indicators = report.indicators;
if (!indicators || typeof indicators !== 'object') return '未知';
const vals = Object.values(indicators) as Array<{ status?: string }>;
const hasAbnormal = vals.some((v) => v.status === 'high' || v.status === 'low');
return hasAbnormal ? '异常' : '正常';
};
return (
<View className='report-page'>
<View className='report-list'>
{reports.map((r) => (
<View
className='report-card'
key={r.id}
onClick={() => goToDetail(r.id)}
>
<View className='report-card-top'>
<Text className='report-type'>{r.report_type}</Text>
<Text className={`report-status ${formatStatus(r) === '正常' ? 'normal' : 'abnormal'}`}>
{formatStatus(r)}
</Text>
</View>
<Text className='report-date'>{r.report_date}</Text>
{r.doctor_interpretation && (
<Text className='report-note'>{r.doctor_interpretation}</Text>
)}
</View>
))}
</View>
{reports.length === 0 && !loading && (
<View className='empty-state'>
<Text className='empty-text'></Text>
</View>
)}
{loading && (
<View className='loading-hint'>
<Text className='loading-text'>...</Text>
</View>
)}
</View>
);
}

View File

@@ -0,0 +1,50 @@
import { api } from './request';
export interface Appointment {
id: string;
patient_name: string;
doctor_name: string;
department: string;
appointment_date: string;
time_slot: string;
status: string;
version: number;
}
export async function listAppointments(page = 1) {
return api.get<{ data: Appointment[]; total: number }>(`/health/appointments?page=${page}&page_size=20`);
}
export async function createAppointment(data: {
patient_id: string;
doctor_id: string;
schedule_id: string;
appointment_date: string;
time_slot: string;
reason?: string;
}) {
return api.post<Appointment>('/health/appointments', data);
}
export async function cancelAppointment(id: string, version: number) {
return api.put(`/health/appointments/${id}/status`, {
status: 'cancelled',
version,
});
}
export async function getDoctorSchedules(doctorId: string, startDate: string, endDate: string) {
return api.get<{ data: any[]; total: number }>(
`/health/doctor-schedules?doctor_id=${doctorId}&start_date=${startDate}&end_date=${endDate}&page_size=50`
);
}
export async function listDoctors(department?: string) {
const deptParam = department ? `&department=${department}` : '';
return api.get<{ data: any[]; total: number }>(`/health/doctors?page_size=100${deptParam}`);
}
export async function calendarView(startDate: string, endDate: string, doctorId?: string) {
const docParam = doctorId ? `&doctor_id=${doctorId}` : '';
return api.get<any[]>(`/health/doctor-schedules/calendar?start_date=${startDate}&end_date=${endDate}${docParam}`);
}

View File

@@ -0,0 +1,19 @@
import { api } from './request';
export interface Article {
id: string;
title: string;
summary?: string;
content?: string;
cover_image?: string;
category?: string;
published_at?: string;
}
export async function listArticles(page = 1) {
return api.get<{ data: Article[]; total: number }>(`/health/articles?page=${page}&page_size=20`);
}
export async function getArticleDetail(id: string) {
return api.get<Article>(`/health/articles/${id}`);
}

View File

@@ -0,0 +1,36 @@
import { api } from './request';
export interface FollowUpTask {
id: string;
patient_name: string;
task_type: string;
description: string;
status: string;
due_date: string;
version: number;
}
export interface FollowUpRecord {
id: string;
task_id: string;
content: any;
created_at: string;
}
export async function listTasks(status?: string) {
const statusParam = status ? `&status=${status}` : '';
return api.get<{ data: FollowUpTask[]; total: number }>(
`/health/follow-up-tasks?page=1&page_size=50${statusParam}`
);
}
export async function submitRecord(data: { task_id: string; content: any }) {
return api.post<FollowUpRecord>('/health/follow-up-records', data);
}
export async function listRecords(taskId?: string) {
const taskParam = taskId ? `&task_id=${taskId}` : '';
return api.get<{ data: FollowUpRecord[]; total: number }>(
`/health/follow-up-records?page=1&page_size=50${taskParam}`
);
}

View File

@@ -0,0 +1,30 @@
import { api } from './request';
export interface Patient {
id: string;
name: string;
gender?: string;
birthday?: string;
phone?: string;
id_number?: string;
relation?: string;
version: number;
}
export async function listPatients() {
return api.get<{ data: Patient[]; total: number }>('/health/patients?page=1&page_size=100');
}
export async function createPatient(data: {
name: string;
gender?: string;
birthday?: string;
phone?: string;
id_number?: string;
}) {
return api.post<Patient>('/health/patients', data);
}
export async function updatePatient(id: string, data: any, version: number) {
return api.put<Patient>(`/health/patients/${id}`, { ...data, version });
}

View File

@@ -0,0 +1,21 @@
import { api } from './request';
export interface LabReport {
id: string;
report_date: string;
report_type: string;
indicators: any;
doctor_interpretation?: string;
image_urls?: string[];
version: number;
}
export async function listReports(patientId: string, page = 1) {
return api.get<{ data: LabReport[]; total: number }>(
`/health/patients/${patientId}/lab-reports?page=${page}&page_size=20`
);
}
export async function getReportDetail(patientId: string, id: string) {
return api.get<LabReport>(`/health/patients/${patientId}/lab-reports/${id}`);
}

View File

@@ -0,0 +1,36 @@
use serde::{Deserialize, Serialize};
use utoipa::{IntoParams, ToSchema};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ArticleResp {
pub id: Uuid,
pub title: String,
pub summary: Option<String>,
pub content: Option<String>,
pub cover_image: Option<String>,
pub category: Option<String>,
pub author: Option<String>,
pub published_at: Option<chrono::DateTime<chrono::Utc>>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub version: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct ArticleListItem {
pub id: Uuid,
pub title: String,
pub summary: Option<String>,
pub cover_image: Option<String>,
pub category: Option<String>,
pub author: Option<String>,
pub published_at: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(Debug, Clone, Deserialize, IntoParams)]
pub struct ArticleListParams {
pub page: Option<u64>,
pub page_size: Option<u64>,
pub category: Option<String>,
}

View File

@@ -65,6 +65,15 @@ pub struct CreateLabReportReq {
pub doctor_interpretation: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct UpdateLabReportReq {
pub report_date: Option<NaiveDate>,
pub report_type: Option<String>,
pub indicators: Option<serde_json::Value>,
pub image_urls: Option<serde_json::Value>,
pub doctor_interpretation: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct LabReportResp {
pub id: Uuid,
@@ -89,6 +98,16 @@ pub struct CreateHealthRecordReq {
pub notes: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct UpdateHealthRecordReq {
pub record_type: Option<String>,
pub record_date: Option<NaiveDate>,
pub source: Option<String>,
pub overall_assessment: Option<String>,
pub report_file_url: Option<String>,
pub notes: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct HealthRecordResp {
pub id: Uuid,

View File

@@ -1,4 +1,5 @@
pub mod appointment_dto;
pub mod article_dto;
pub mod consultation_dto;
pub mod doctor_dto;
pub mod follow_up_dto;

View File

@@ -0,0 +1,36 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "article")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub tenant_id: Uuid,
pub title: String,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub summary: Option<String>,
pub content: String,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub cover_image: Option<String>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub category: Option<String>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub author: Option<String>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub published_at: Option<DateTimeUtc>,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub created_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub updated_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub deleted_at: Option<DateTimeUtc>,
pub version: i32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -1,4 +1,5 @@
pub mod appointment;
pub mod article;
pub mod consultation_message;
pub mod consultation_session;
pub mod doctor_profile;

View File

@@ -41,6 +41,9 @@ pub enum HealthError {
#[error("会话不存在")]
ConsultationNotFound,
#[error("文章不存在")]
ArticleNotFound,
#[error("状态转换无效: {0}")]
InvalidStatusTransition(String),
@@ -65,7 +68,8 @@ impl From<HealthError> for AppError {
| HealthError::FamilyMemberNotFound
| HealthError::TagNotFound
| HealthError::FollowUpTaskNotFound
| HealthError::ConsultationNotFound => AppError::NotFound(err.to_string()),
| HealthError::ConsultationNotFound
| HealthError::ArticleNotFound => AppError::NotFound(err.to_string()),
HealthError::ScheduleFull => AppError::Validation(err.to_string()),
HealthError::InvalidStatusTransition(s) => AppError::Validation(s),
HealthError::VersionMismatch => AppError::VersionMismatch,

View File

@@ -0,0 +1,43 @@
use axum::Extension;
use axum::extract::{FromRef, Json, Path, Query, State};
use erp_core::error::AppError;
use erp_core::rbac::require_permission;
use erp_core::types::{ApiResponse, PaginatedResponse, TenantContext};
use crate::dto::article_dto::{ArticleListItem, ArticleListParams, ArticleResp};
use crate::service::article_service;
use crate::state::HealthState;
pub async fn list_articles<S>(
State(state): State<HealthState>,
Extension(ctx): Extension<TenantContext>,
Query(params): Query<ArticleListParams>,
) -> Result<Json<ApiResponse<PaginatedResponse<ArticleListItem>>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
require_permission(&ctx, "health.articles.list")?;
let page = params.page.unwrap_or(1);
let page_size = params.page_size.unwrap_or(20);
let result = article_service::list_articles(
&state, ctx.tenant_id, page, page_size, params.category,
)
.await?;
Ok(Json(ApiResponse::ok(result)))
}
pub async fn get_article<S>(
State(state): State<HealthState>,
Extension(ctx): Extension<TenantContext>,
Path(id): Path<uuid::Uuid>,
) -> Result<Json<ApiResponse<ArticleResp>>, AppError>
where
HealthState: FromRef<S>,
S: Clone + Send + Sync + 'static,
{
require_permission(&ctx, "health.articles.list")?;
let result = article_service::get_article(&state, ctx.tenant_id, id).await?;
Ok(Json(ApiResponse::ok(result)))
}

View File

@@ -357,13 +357,13 @@ pub struct UpdateVitalSignsWithVersion {
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
pub struct UpdateLabReportWithVersion {
#[serde(flatten)]
pub data: CreateLabReportReq,
pub data: UpdateLabReportReq,
pub version: i32,
}
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
pub struct UpdateHealthRecordWithVersion {
#[serde(flatten)]
pub data: CreateHealthRecordReq,
pub data: UpdateHealthRecordReq,
pub version: i32,
}

View File

@@ -1,4 +1,5 @@
pub mod appointment_handler;
pub mod article_handler;
pub mod consultation_handler;
pub mod doctor_handler;
pub mod follow_up_handler;

View File

@@ -6,7 +6,7 @@ use erp_core::events::EventBus;
use erp_core::module::{ErpModule, PermissionDescriptor};
use crate::handler::{
appointment_handler, consultation_handler, doctor_handler, follow_up_handler,
appointment_handler, article_handler, consultation_handler, doctor_handler, follow_up_handler,
health_data_handler, patient_handler,
};
@@ -193,6 +193,15 @@ impl HealthModule {
.put(doctor_handler::update_doctor)
.delete(doctor_handler::delete_doctor),
)
// 健康资讯
.route(
"/health/articles",
axum::routing::get(article_handler::list_articles),
)
.route(
"/health/articles/{id}",
axum::routing::get(article_handler::get_article),
)
}
}
@@ -319,6 +328,18 @@ impl ErpModule for HealthModule {
description: "创建、编辑医护档案、排班".into(),
module: "health".into(),
},
PermissionDescriptor {
code: "health.articles.list".into(),
name: "查看资讯".into(),
description: "查看健康资讯文章列表和详情".into(),
module: "health".into(),
},
PermissionDescriptor {
code: "health.articles.manage".into(),
name: "管理资讯".into(),
description: "创建、编辑、删除健康资讯文章".into(),
module: "health".into(),
},
]
}

View File

@@ -282,7 +282,7 @@ pub async fn update_lab_report(
patient_id: Uuid,
report_id: Uuid,
operator_id: Option<Uuid>,
req: CreateLabReportReq,
req: UpdateLabReportReq,
expected_version: i32,
) -> HealthResult<LabReportResp> {
let model = lab_report::Entity::find()
@@ -297,11 +297,11 @@ pub async fn update_lab_report(
.map_err(|_| HealthError::VersionMismatch)?;
let mut active: lab_report::ActiveModel = model.into();
active.report_date = Set(req.report_date);
active.report_type = Set(req.report_type);
active.indicators = Set(req.indicators);
active.image_urls = Set(req.image_urls);
active.doctor_interpretation = Set(req.doctor_interpretation);
if let Some(v) = req.report_date { active.report_date = Set(v); }
if let Some(v) = req.report_type { active.report_type = Set(v); }
if let Some(v) = req.indicators { active.indicators = Set(Some(v)); }
if let Some(v) = req.image_urls { active.image_urls = Set(Some(v)); }
if let Some(v) = req.doctor_interpretation { active.doctor_interpretation = Set(Some(v)); }
active.updated_at = Set(Utc::now());
active.updated_by = Set(operator_id);
active.version = Set(next_ver);

View File

@@ -1,4 +1,5 @@
pub mod appointment_service;
pub mod article_service;
pub mod consultation_service;
pub mod doctor_service;
pub mod follow_up_service;

View File

@@ -43,6 +43,7 @@ mod m20260419_000040_plugin_market;
mod m20260419_000041_plugin_user_views;
mod m20260423_000042_create_health_tables;
mod m20260423_000043_create_wechat_users;
mod m20260423_000044_create_articles;
pub struct Migrator;
@@ -93,6 +94,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260419_000041_plugin_user_views::Migration),
Box::new(m20260423_000042_create_health_tables::Migration),
Box::new(m20260423_000043_create_wechat_users::Migration),
Box::new(m20260423_000044_create_articles::Migration),
]
}
}

View File

@@ -0,0 +1,104 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Article::Table)
.if_not_exists()
.col(ColumnDef::new(Article::Id).uuid().not_null().primary_key())
.col(ColumnDef::new(Article::TenantId).uuid().not_null())
.col(ColumnDef::new(Article::Title).string_len(200).not_null())
.col(ColumnDef::new(Article::Summary).text().null())
.col(ColumnDef::new(Article::Content).text().not_null())
.col(ColumnDef::new(Article::CoverImage).string_len(500).null())
.col(ColumnDef::new(Article::Category).string_len(50).null())
.col(ColumnDef::new(Article::Author).string_len(100).null())
.col(ColumnDef::new(Article::PublishedAt).timestamp_with_time_zone().null())
.col(
ColumnDef::new(Article::CreatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.col(
ColumnDef::new(Article::UpdatedAt)
.timestamp_with_time_zone()
.not_null()
.default(Expr::current_timestamp()),
)
.col(ColumnDef::new(Article::CreatedBy).uuid().null())
.col(ColumnDef::new(Article::UpdatedBy).uuid().null())
.col(ColumnDef::new(Article::DeletedAt).timestamp_with_time_zone().null())
.col(
ColumnDef::new(Article::Version)
.integer()
.not_null()
.default(1),
)
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.if_not_exists()
.name("idx_article_tenant_category")
.table(Article::Table)
.col(Article::TenantId)
.col(Article::Category)
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.if_not_exists()
.name("idx_article_tenant_published")
.table(Article::Table)
.col(Article::TenantId)
.col(Article::PublishedAt)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(Index::drop().name("idx_article_tenant_published").to_owned())
.await?;
manager
.drop_index(Index::drop().name("idx_article_tenant_category").to_owned())
.await?;
manager
.drop_table(Table::drop().table(Article::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
enum Article {
Table,
Id,
TenantId,
Title,
Summary,
Content,
CoverImage,
Category,
Author,
PublishedAt,
CreatedAt,
UpdatedAt,
CreatedBy,
UpdatedBy,
DeletedAt,
Version,
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,509 @@
# HMS 患者小程序设计规格
> **版本**: v1.0
> **日期**: 2026-04-23
> **状态**: 草案
> **关联**: 健康模块设计规格 `2026-04-23-health-management-module-design.md`
---
## 1. 概述
### 1.1 产品定位
HMS 患者小程序是**综合健康管理入口**,面向体检中心/医疗机构的患者。覆盖体检预约、报告查询、健康数据长期监测、随访管理、家庭健康管理等场景。
医护端以 PC 管理后台(`apps/web/`)为主力,小程序聚焦患者体验。医护端小程序可在后续按需补一个轻量版(随访提醒、排班查看),不在本规格范围内。
### 1.2 核心决策
| 维度 | 决策 | 原因 |
|------|------|------|
| 技术选型 | Taro 4 + React 19 | 与 Web 端 React 技能复用,支持多端编译 |
| 架构方案 | 直连后端 | MVP 阶段最务实,复用 erp-server API |
| 登录方式 | 微信授权 + 手机号补充 | 降低门槛 + 确保身份可靠 |
| 代码位置 | `apps/miniprogram/`Monorepo | 方便接口同步,共享类型定义 |
| 目标平台 | 微信小程序优先 | 覆盖最广泛用户,后续可扩展 |
| 数据录入 | 手动 + 蓝牙预留接口 | MVP 快速交付,后续对接设备 |
| 视觉风格 | 医疗清新(青色主调) | 专业可靠,沿用现有 HTML 原型风格 |
### 1.3 MVP 功能范围
**MVP 包含7 个功能模块):**
1. 登录 + 个人中心
2. 健康数据录入 + 趋势图
3. 预约挂号
4. 报告查询
5. 随访管理
6. 家庭健康管理(就诊人切换)
7. 健康资讯 + 用药提醒
**后续版本:**
- 在线咨询即时通讯WebSocket 长连接)
---
## 2. 项目结构
```
apps/miniprogram/
├── config/ # Taro 编译配置
│ ├── index.ts # 通用配置
│ ├── dev.ts # 开发环境
│ └── prod.ts # 生产环境
├── project.config.json # 微信小程序项目配置
├── src/
│ ├── app.config.ts # Taro 全局配置TabBar、页面路由
│ ├── app.tsx # 入口组件
│ ├── app.scss # 全局样式(医疗清新主题变量)
│ ├── components/ # 通用组件
│ │ ├── HealthCard/ # 健康指标卡片(血压/血糖/体重)
│ │ ├── AppointmentCard/ # 预约卡片
│ │ ├── ReportItem/ # 报告列表项
│ │ ├── FamilyPicker/ # 就诊人切换器
│ │ ├── EmptyState/ # 空状态占位
│ │ └── TrendChart/ # 趋势图echarts-taro3-react
│ ├── pages/
│ │ ├── index/ # 首页(今日健康+快捷入口+待办)
│ │ ├── health/ # 健康数据(录入+趋势图)
│ │ ├── appointment/ # 预约(列表+新建预约)
│ │ ├── report/ # 报告(体检报告+化验单)
│ │ ├── followup/ # 随访(任务+问卷填写)
│ │ ├── article/ # 健康资讯(文章列表+详情)
│ │ ├── profile/ # 我的(个人信息+就诊人管理+设置)
│ │ └── login/ # 登录(微信授权+手机号)
│ ├── services/ # API 调用层
│ │ ├── request.ts # 封装 Taro.requestJWT 注入、错误处理)
│ │ ├── auth.ts # 登录/刷新 token
│ │ ├── health.ts # 健康数据 CRUD
│ │ ├── appointment.ts # 预约 CRUD
│ │ ├── report.ts # 报告查询
│ │ ├── followup.ts # 随访任务/记录
│ │ └── article.ts # 资讯/科普
│ ├── stores/ # Zustand 状态管理
│ │ ├── auth.ts # 登录态、用户信息、就诊人列表
│ │ └── health.ts # 健康数据缓存
│ ├── utils/
│ │ ├── bluetooth.ts # 蓝牙接口预留MVP 不实现)
│ │ ├── format.ts # 日期/数值格式化
│ │ └── constants.ts # 常量定义
│ └── styles/
│ ├── variables.scss # 主题变量(青色主调)
│ └── mixins.scss # 常用样式混入
├── package.json
└── tsconfig.json
```
**设计原则:**
- services 层与 Web 端 `apps/web/src/api/` 职责对齐,用 Taro.request 替代 fetch
- stores 复用 Zustand 模式,与 Web 端保持一致的状态管理风格
- 组件命名 PascalCase 目录,与 Web 端风格统一
- MVP 阶段不强抽取 `packages/shared/`,等两端跑起来后根据重复度决定
---
## 3. 认证流程
### 3.1 整体流程
```
用户打开小程序
检查本地 storage 有无有效 JWT
├── 有且未过期 → 直接进入首页
└── 无或已过期 ↓
Step 1: 微信静默登录
wx.login() → code
→ POST /api/v1/auth/wechat/login { code }
→ 后端用 code 换 openid查找绑定用户
├── 已绑定 → 签发 JWT { token, user }
└── 未绑定 → 返回 { need_bind: true, openid }
Step 2: 手机号绑定(仅新用户)
wx.getPhoneNumber 按钮组件 → encryptedData + iv
→ POST /api/v1/auth/wechat/bind-phone { openid, encryptedData, iv }
→ 后端解密手机号,创建/关联 user + patient 档案
→ 签发 JWT { token, user, patient }
Step 3: 补充档案(首次绑定后)
→ 引导填写姓名、性别、出生日期、身份证号(可选)
→ PUT /api/v1/health/patients/me { name, gender, birthday }
```
### 3.2 后端新增内容
**`erp-auth` 新增:**
| 新增 | 说明 |
|------|------|
| `wechat_users` 表 | `id, openid, union_id, user_id, phone, created_at, updated_at` |
| `POST /api/v1/auth/wechat/login` | code → openid 查询,返回绑定状态 |
| `POST /api/v1/auth/wechat/bind-phone` | 绑定手机号,创建 user + patient |
| `GET /api/v1/auth/wechat/qrcode` | 生成带参数小程序码PC 端扫码登录场景) |
`wechat_users` 表必须包含 `tenant_id`(多租户隔离)和标准审计字段(`created_at`, `updated_at`, `deleted_at`)。
### 3.3 Token 策略
| Token | 有效期 | 存储 |
|-------|--------|------|
| Access Token (JWT) | 15 分钟 | 内存 + Taro.setStorage |
| Refresh Token | 7 天 | Taro.setStorage |
自动刷新机制:`services/request.ts` 拦截 401 → 调用 `POST /auth/refresh` → 重试原请求。刷新失败则跳转登录页。
### 3.4 多就诊人
- 一个微信账号可管理多个 patient本人 + 家人)
- 切换就诊人时请求 header 带 `X-Patient-Id`
- 后端校验该 patient 属于当前 user
---
## 4. 页面结构与导航
### 4.1 Tab Bar
底部导航栏 5 个入口:
| Tab | 图标 | 页面路径 |
|-----|------|----------|
| 首页 | 🏠 | /pages/index/index |
| 健康 | 📊 | /pages/health/index |
| 预约 | 📅 | /pages/appointment/index |
| 资讯 | 📰 | /pages/article/index |
| 我的 | 👤 | /pages/profile/index |
### 4.2 页面层级
```
Tab: 首页 /pages/index
├── /pages/notifications/index # 通知列表
└── /pages/followup/detail/index # 随访任务详情
Tab: 健康 /pages/health
├── /pages/health/input/index # 录入数据
├── /pages/health/trend/index # 指标趋势
└── /pages/health/history/index # 历史记录
Tab: 预约 /pages/appointment
├── /pages/appointment/create/index # 新建预约
└── /pages/appointment/detail/index # 预约详情
Tab: 资讯 /pages/article
└── /pages/article/detail/index # 文章详情
Tab: 我的 /pages/profile
├── /pages/profile/family/index # 就诊人管理
├── /pages/profile/family-add/index # 添加就诊人
├── /pages/profile/reports/index # 我的报告
├── /pages/profile/followups/index # 我的随访
├── /pages/profile/medication/index # 用药提醒
└── /pages/profile/settings/index # 设置
独立页面(不在 Tab 内):
├── /pages/login/index # 登录
└── /pages/login/profile/index # 档案补全
```
### 4.3 首页布局
```
┌─────────────────────────────┐
│ 问候栏(渐变青色背景) │ 用户名 + 日期 + 通知铃铛
├─────────────────────────────┤
│ 今日健康卡片(上浮 -20px │ 血压/心率/血糖/体重 2×2 网格
├─────────────────────────────┤
│ 快捷服务4 宫格) │ 录数据/预约/报告/随访
├─────────────────────────────┤
│ 即将到来 │ 最近 1 条预约卡片
├─────────────────────────────┤
│ 待办随访 │ 最多 2 条待办 + 查看全部
├─────────────────────────────┤
│ [ 首页 ] [ 健康 ] [ 预约 ] [ 资讯 ] [ 我的 ] │
└─────────────────────────────┘
```
---
## 5. 核心功能数据流
### 5.1 健康数据录入
```
选择指标类型 → 输入数值 + 测量时间 → 添加备注(可选)→ POST /vital-signs
成功 → 更新首页卡片 + 趋势缓存
失败 → Toast + 本地暂存
```
**MVP 支持的指标类型:**
| 指标 | 单位 | 输入控件 |
|------|------|---------|
| 收缩压 / 舒张压 | mmHg | 两个数字输入框 |
| 心率 | bpm | 数字输入框 |
| 空腹血糖 | mmol/L | 数字输入框 |
| 餐后血糖 | mmol/L | 数字输入框 |
| 体重 | kg | 数字输入框1 位小数) |
| 体温 | ℃ | 数字输入框1 位小数) |
每次可同时填多项或只填一项。录入时间默认当前,可手动调整为当天任意时间。
### 5.2 预约挂号
```
选择科室 → 选择医生 → 选择日期(排班日历)→ 选择时段 → 确认预约
POST /appointments
成功 → 订阅消息通知 + 日历同步
满员 → 提示"该时段已满"
```
**关键交互:**
- 排班日历用周视图,有排班的日期标绿点
- 点击日期后展示该日可用时段
- 时段显示"剩余 X 位"
- 预约成功后支持微信订阅消息提醒
### 5.3 报告查询
```
报告列表(分页,时间倒序)
↓ 点击某份报告
报告详情 → 基本信息卡 + 指标列表 + PDF/图片附件预览
```
**指标状态标记:**
- 异常偏高:红色 + ↑ 箭头
- 异常偏低:红色 + ↓ 箭头
- 正常范围:灰色
### 5.4 随访管理
```
待办列表(按截止日期排序)
↓ 支持"待完成/已完成/已过期"筛选
点击任务 → 动态表单(后端定义字段)→ 提交 → 标记完成
```
问卷由 PC 端医护创建follow_up_task小程序负责展示和填写。提交后创建 follow_up_record。
### 5.5 家庭健康管理
```
就诊人列表(本人 + 已添加家属)
↓ 点击头像或下拉切换
切换就诊人 → 全局 X-Patient-Id 更新 → 所有页面数据刷新
↓ 添加家属
填写信息 → 姓名 + 关系 + 身份证号(可选)→ POST /patients
```
切换就诊人通过全局 store 更新,所有 service 请求自动携带新 `X-Patient-Id`
### 5.6 健康资讯 + 用药提醒
**资讯:**
- `GET /articles` → 分页列表(缩略图 + 标题 + 摘要 + 时间)
- 文章详情使用 Taro `RichText` 组件渲染富文本
**用药提醒MVP**
- 小程序本地 storage 存储提醒规则(药品名 + 频率 + 时间)
- 每日触发检查
- 通过微信订阅消息推送提醒
- 不依赖后端新表
---
## 6. API 集成与状态管理
### 6.1 请求层封装
`services/request.ts` 职责:
| 拦截点 | 行为 |
|--------|------|
| 请求拦截 | 自动注入 `Authorization: Bearer {token}` |
| 请求拦截 | 自动注入 `X-Patient-Id`(当前选中就诊人) |
| 请求拦截 | 自动注入 `X-Tenant-Id`(从登录信息获取) |
| 响应拦截 | 401 → 静默刷新 token → 重试原请求 |
| 响应拦截 | 刷新失败 → 跳转登录页 |
| 错误处理 | 网络错误 / 业务错误 / 超时统一处理 |
多租户处理:患者只属于一个租户。登录时后端返回 `tenant_id`,前端每次请求带上。不走 `tenant_id` 中间件自动注入。
### 6.2 Zustand Stores
**auth store**
```typescript
interface AuthState {
token: string | null
refreshToken: string | null
user: { id: string; name: string; phone: string; avatar: string } | null
currentPatient: Patient | null
patients: Patient[]
setCurrentPatient: (id: string) => void
login: (code: string) => Promise<void>
bindPhone: (data: BindPhoneData) => Promise<void>
logout: () => void
}
```
**health store**
```typescript
interface HealthState {
todaySummary: VitalSigns | null
trendData: Record<string, TrendPoint[]>
refreshToday: () => Promise<void>
getTrend: (type: string, range: '7d' | '30d' | '90d') => Promise<TrendPoint[]>
}
```
### 6.3 API 端点对应表
| 小程序 service | 后端端点 | 方法 |
|----------------|----------|------|
| `auth.login(code)` | `/api/v1/auth/wechat/login` | POST |
| `auth.bindPhone(data)` | `/api/v1/auth/wechat/bind-phone` | POST |
| `auth.refresh()` | `/api/v1/auth/refresh` | POST |
| `health.getToday()` | `/api/v1/health/vital-signs?date=today` | GET |
| `health.input(data)` | `/api/v1/health/vital-signs` | POST |
| `health.getTrend(type, range)` | `/api/v1/health/vital-signs/trend` | GET |
| `appointment.list()` | `/api/v1/health/appointments` | GET |
| `appointment.create(data)` | `/api/v1/health/appointments` | POST |
| `appointment.cancel(id)` | `/api/v1/health/appointments/:id/cancel` | PUT |
| `schedule.getByDoctor(id)` | `/api/v1/health/doctor-schedules` | GET |
| `report.list()` | `/api/v1/health/lab-reports` | GET |
| `report.detail(id)` | `/api/v1/health/lab-reports/:id` | GET |
| `followup.list()` | `/api/v1/health/follow-up-tasks` | GET |
| `followup.submit(id, data)` | `/api/v1/health/follow-up-records` | POST |
| `patient.list()` | `/api/v1/health/patients` | GET |
| `patient.create(data)` | `/api/v1/health/patients` | POST |
| `patient.update(id, data)` | `/api/v1/health/patients/:id` | PUT |
**后端需新增的端点(尚未实现):**
| 端点 | 说明 |
|------|------|
| `POST /auth/wechat/login` | 微信登录 |
| `POST /auth/wechat/bind-phone` | 手机号绑定 |
| `GET /vital-signs/trend` | 趋势聚合查询 |
| `GET /doctor-schedules` | 按科室/医生查询排班 |
| `GET /articles` | 健康资讯列表 |
| `GET /articles/:id` | 资讯详情 |
---
## 7. 视觉设计
### 7.1 主题色
沿用现有 HTML 原型的医疗清新风格:
| 用途 | 色值 | 说明 |
|------|------|------|
| 主色 | `#0891B2` | 青色,按钮、导航、强调 |
| 主色浅 | `#E0F7FA` | 背景、卡片高亮 |
| 主色深 | `#065A73` | 渐变、按压态 |
| 辅助色 | `#059669` | 绿色,成功、正常指标 |
| 危险色 | `#DC2626` | 红色,异常指标、删除 |
| 警告色 | `#D97706` | 琥珀,待办、提醒 |
| 背景色 | `#F0FDFA` | 页面底色 |
| 卡片色 | `#FFFFFF` | 卡片背景 |
| 主文字 | `#134E4A` | 标题、正文 |
| 副文字 | `#6B7280` | 说明、标签 |
| 轻文字 | `#94A3B8` | 时间戳、占位符 |
### 7.2 圆角规范
| 元素 | 圆角 |
|------|------|
| 卡片 | 12px |
| 按钮 | 8px |
| 输入框 | 8px |
| 头像 | 50% |
| 快捷图标 | 14px |
### 7.3 阴影规范
| 层级 | 值 |
|------|---|
| 轻阴影 | `0 1px 3px rgba(0,0,0,.04)` |
| 标准阴影 | `0 2px 8px rgba(0,0,0,.06)` |
| 中阴影 | `0 4px 16px rgba(0,0,0,.08)` |
| 重阴影 | `0 8px 32px rgba(0,0,0,.12)` |
---
## 8. 开发工作流
### 8.1 开发环境
```bash
# 安装依赖
cd apps/miniprogram && pnpm install
# 开发模式(需配合微信开发者工具)
pnpm dev:weapp # Taro 编译 + watch → dist/
# 用微信开发者工具打开 dist/ 目录预览
# 生产构建
pnpm build:weapp # 压缩 + tree-shaking
# 后端联调
# 需同时运行 erp-server (port 3000)
# 小程序开发设置中关闭域名校验(开发阶段)
```
### 8.2 与 Web 端的代码复用
| 复用内容 | 方式 | 说明 |
|---------|------|------|
| TypeScript 类型 | 按需引用 Web 端 DTO 类型 | API 请求/响应结构一致 |
| 主题变量值 | Web CSS 变量 → SCSS 变量 | 青色主调色值保持一致 |
| Zustand 模式 | 相同 store 设计模式 | 各自独立实现 |
| API 接口定义 | service 层函数签名对齐 | Web 用 fetch小程序用 Taro.request |
### 8.3 后端需同步开发的内容
| 优先级 | 内容 | 涉及 crate |
|--------|------|-----------|
| P0 | `wechat_users` 表 + 微信登录/绑定 API | erp-auth |
| P0 | `vital_signs` 趋势查询 API | erp-health |
| P0 | `doctor_schedules` 按科室/医生查询 API | erp-health |
| P1 | `lab_reports` 指标异常标注字段 | erp-health |
| P1 | `follow_up_tasks` 动态问卷字段扩展 | erp-health |
| P2 | `articles` 表 + CRUD | erp-health |
| P2 | 微信订阅消息模板注册 | erp-server |
---
## 9. 分期交付计划
| 阶段 | 内容 | 目标 |
|------|------|------|
| Phase 1 | 项目骨架 + 登录流程 + 首页(静态数据) | 基础搭建 |
| Phase 2 | 健康数据录入 + 趋势图 | 核心功能 |
| Phase 3 | 预约挂号 + 排班日历 | 核心功能 |
| Phase 4 | 报告查询 + 家庭管理 | 扩展功能 |
| Phase 5 | 随访 + 资讯 + 用药提醒 | 扩展功能 |
| Phase 6 | 打磨 + 真机测试 + 提审 | 上线准备 |
每个 Phase 内部遵循:先对接后端 API → 再实现 UI → 真机验证 → 提交。
---
## 10. 约束与风险
| 约束/风险 | 应对策略 |
|-----------|---------|
| 小程序包体积限制2MB 主包) | 按功能分包加载,图表库按需引入 |
| 微信审核周期3-7 天) | Phase 6 预留充足审核时间 |
| 后端 API 部分未实现 | 小程序开发与后端同步推进,优先实现 P0 端点 |
| 微信订阅消息需用户主动触发 | 在预约成功、随访提交等场景引导用户订阅 |
| 蓝牙设备适配复杂 | MVP 预留接口不实现,后续按设备型号逐一对接 |
| 多就诊人数据隔离 | 后端严格校验 user-patient 归属关系 |