feat: 咨询消息轮询优化 — Web 自动刷新 + 患者端聊天详情页
Web 端: - ConsultationDetail 添加 10s 自动轮询新消息(after_id 增量拉取) - consultations API 补充 after_id 参数 小程序患者端: - 新增 consultation service 消息 API(listMessages/sendMessage/markSessionRead) - 新增聊天详情页(8s 轮询 + 发送消息 + 自动标记已读) - 咨询列表页点击跳转详情页(替换"即将上线"占位)
This commit is contained in:
@@ -13,6 +13,17 @@ export interface ConsultationSession {
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ConsultationMessage {
|
||||
id: string;
|
||||
session_id: string;
|
||||
sender_id: string;
|
||||
sender_role: string;
|
||||
content_type: string;
|
||||
content: string;
|
||||
is_read: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export async function listConsultations(params?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
@@ -22,3 +33,30 @@ export async function listConsultations(params?: {
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getSession(sessionId: string) {
|
||||
return api.get<ConsultationSession>(`/health/consultation-sessions/${sessionId}`);
|
||||
}
|
||||
|
||||
export async function listMessages(sessionId: string, params?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
after_id?: string;
|
||||
}) {
|
||||
return api.get<{ data: ConsultationMessage[]; total: number }>(
|
||||
`/health/consultation-sessions/${sessionId}/messages`,
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendMessage(sessionId: string, content: string, contentType = 'text') {
|
||||
return api.post<ConsultationMessage>('/health/consultation-messages', {
|
||||
session_id: sessionId,
|
||||
content_type: contentType,
|
||||
content,
|
||||
});
|
||||
}
|
||||
|
||||
export async function markSessionRead(sessionId: string) {
|
||||
return api.put<void>(`/health/consultation-sessions/${sessionId}/read`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user