feat: 通知分发器 DND 检查 + 咨询/报告事件 + 线下活动页面
Iteration 2 剩余工作: 通知分发器改进(erp-message module.rs): - 添加 should_skip_for_dnd() 免打扰检查(urgent 级别不受限) - DND 支持跨午夜窗口(如 22:00-08:00) - 新增 consultation.new_message 事件(患者发消息通知医生) - 新增 lab_report.reviewed 事件(报告审核完成通知患者) - 改进已有事件:预约确认含日期、随访逾期含患者名 积分前端补充: - points.ts 新增 OfflineEvent/EventRegistration 接口 + API - 新增线下活动列表页面(报名/人数/积分奖励) - 注册 events 页面路由
This commit is contained in:
@@ -38,6 +38,7 @@ export default defineAppConfig({
|
||||
'pages/doctor/followup/detail/index',
|
||||
'pages/doctor/report/index',
|
||||
'pages/doctor/report/detail/index',
|
||||
'pages/events/index',
|
||||
],
|
||||
tabBar: {
|
||||
color: '#94A3B8',
|
||||
|
||||
119
apps/miniprogram/src/pages/events/index.scss
Normal file
119
apps/miniprogram/src/pages/events/index.scss
Normal file
@@ -0,0 +1,119 @@
|
||||
.events-page {
|
||||
min-height: 100vh;
|
||||
background: #f0f4f8;
|
||||
padding-bottom: 120px;
|
||||
}
|
||||
|
||||
.events-header {
|
||||
background: linear-gradient(135deg, #0891b2, #06b6d4);
|
||||
padding: 40px 32px;
|
||||
color: #fff;
|
||||
|
||||
&__title {
|
||||
font-size: 40px;
|
||||
font-weight: 700;
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
font-size: 26px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
.event-list {
|
||||
padding: 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.event-card {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 28px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&__status {
|
||||
padding: 4px 14px;
|
||||
border-radius: 12px;
|
||||
font-size: 22px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__points {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 30px;
|
||||
font-weight: 600;
|
||||
color: #0f172a;
|
||||
display: block;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
&__desc {
|
||||
font-size: 26px;
|
||||
color: #64748b;
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
&__info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
&__date {
|
||||
font-size: 24px;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
&__location {
|
||||
font-size: 24px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
&__participants {
|
||||
font-size: 24px;
|
||||
color: #94a3b8;
|
||||
}
|
||||
|
||||
&__btn {
|
||||
background: #0891b2;
|
||||
border-radius: 12px;
|
||||
padding: 12px 28px;
|
||||
|
||||
&--disabled {
|
||||
background: #cbd5e1;
|
||||
}
|
||||
|
||||
&-text {
|
||||
font-size: 26px;
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
115
apps/miniprogram/src/pages/events/index.tsx
Normal file
115
apps/miniprogram/src/pages/events/index.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { View, Text, ScrollView } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import * as pointsApi from '@/services/points';
|
||||
import Loading from '@/components/Loading';
|
||||
import EmptyState from '@/components/EmptyState';
|
||||
import './index.scss';
|
||||
|
||||
const STATUS_MAP: Record<string, { label: string; color: string }> = {
|
||||
published: { label: '报名中', color: '#0891b2' },
|
||||
ongoing: { label: '进行中', color: '#10b981' },
|
||||
completed: { label: '已结束', color: '#94a3b8' },
|
||||
cancelled: { label: '已取消', color: '#ef4444' },
|
||||
};
|
||||
|
||||
export default function EventsPage() {
|
||||
const [events, setEvents] = useState<pointsApi.OfflineEvent[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [registering, setRegistering] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
loadEvents();
|
||||
}, []);
|
||||
|
||||
const loadEvents = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await pointsApi.listOfflineEvents({ page: 1, page_size: 50, status: 'published' });
|
||||
setEvents(res.data || []);
|
||||
} catch {
|
||||
Taro.showToast({ title: '加载失败', icon: 'none' });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRegister = async (event: pointsApi.OfflineEvent) => {
|
||||
setRegistering(event.id);
|
||||
try {
|
||||
await pointsApi.registerEvent(event.id);
|
||||
Taro.showToast({ title: '报名成功', icon: 'success' });
|
||||
loadEvents();
|
||||
} catch (err: any) {
|
||||
const msg = err?.message || '报名失败';
|
||||
Taro.showToast({ title: msg.substring(0, 20), icon: 'none' });
|
||||
} finally {
|
||||
setRegistering(null);
|
||||
}
|
||||
};
|
||||
|
||||
const formatDate = (d: string) => {
|
||||
return new Date(d).toLocaleDateString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
});
|
||||
};
|
||||
|
||||
if (loading) return <Loading />;
|
||||
|
||||
return (
|
||||
<ScrollView scrollY className='events-page'>
|
||||
<View className='events-header'>
|
||||
<Text className='events-header__title'>线下活动</Text>
|
||||
<Text className='events-header__subtitle'>参加活动赢取积分</Text>
|
||||
</View>
|
||||
|
||||
{events.length === 0 ? (
|
||||
<EmptyState text='暂无可报名的活动' />
|
||||
) : (
|
||||
<View className='event-list'>
|
||||
{events.map((event) => {
|
||||
const st = STATUS_MAP[event.status] || { label: event.status, color: '#94a3b8' };
|
||||
const isFull = event.max_participants != null && event.current_participants >= event.max_participants;
|
||||
const isRegistering = registering === event.id;
|
||||
|
||||
return (
|
||||
<View key={event.id} className='event-card'>
|
||||
<View className='event-card__header'>
|
||||
<View className='event-card__status' style={`background: ${st.color}20; color: ${st.color}`}>
|
||||
<Text>{st.label}</Text>
|
||||
</View>
|
||||
<Text className='event-card__points'>+{event.points_reward} 积分</Text>
|
||||
</View>
|
||||
<Text className='event-card__title'>{event.title}</Text>
|
||||
{event.description && (
|
||||
<Text className='event-card__desc'>{event.description}</Text>
|
||||
)}
|
||||
<View className='event-card__info'>
|
||||
<Text className='event-card__date'>{formatDate(event.event_date)}</Text>
|
||||
{event.location && (
|
||||
<Text className='event-card__location'>{event.location}</Text>
|
||||
)}
|
||||
</View>
|
||||
<View className='event-card__footer'>
|
||||
<Text className='event-card__participants'>
|
||||
{event.current_participants}{event.max_participants ? `/${event.max_participants}` : ''} 人已报名
|
||||
</Text>
|
||||
<View
|
||||
className={`event-card__btn ${isFull ? 'event-card__btn--disabled' : ''}`}
|
||||
onClick={() => !isFull && !isRegistering && handleRegister(event)}
|
||||
>
|
||||
<Text className='event-card__btn-text'>
|
||||
{isRegistering ? '报名中...' : isFull ? '已满' : '立即报名'}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
@@ -98,3 +98,40 @@ export async function listMyOrders(params?: { page?: number; page_size?: number
|
||||
export async function listMyTransactions(params?: { page?: number; page_size?: number }) {
|
||||
return api.get<{ data: PointsTransaction[]; total: number }>('/health/points/transactions', params);
|
||||
}
|
||||
|
||||
// ===== 线下活动 =====
|
||||
|
||||
export interface OfflineEvent {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
location: string | null;
|
||||
event_date: string;
|
||||
points_reward: number;
|
||||
max_participants: number | null;
|
||||
current_participants: number;
|
||||
status: string; // draft / published / ongoing / completed / cancelled
|
||||
image_url: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface EventRegistration {
|
||||
id: string;
|
||||
event_id: string;
|
||||
patient_id: string;
|
||||
status: string; // registered / checked_in / cancelled
|
||||
points_granted: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export async function listOfflineEvents(params?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
status?: string;
|
||||
}) {
|
||||
return api.get<{ data: OfflineEvent[]; total: number }>('/health/offline-events', params);
|
||||
}
|
||||
|
||||
export async function registerEvent(eventId: string) {
|
||||
return api.post<EventRegistration>(`/health/offline-events/${eventId}/register`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user