feat(miniprogram): 通知 Tab 对接 erp-message 消息 API — 替换空壳
This commit is contained in:
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro, { useDidShow } from '@tarojs/taro';
|
||||
import { listConsultations, ConsultationSession } from '../../services/consultation';
|
||||
import { notificationService } from '../../services/notification';
|
||||
import Loading from '../../components/Loading';
|
||||
import './index.scss';
|
||||
|
||||
@@ -32,9 +33,8 @@ export default function Messages() {
|
||||
const res = await listConsultations({ page: 1, page_size: 20 });
|
||||
setSessions(res.data || []);
|
||||
} else {
|
||||
// 通知目前从咨询中提取状态变化作为示例
|
||||
// 后续可对接独立通知 API
|
||||
setNotifications([]);
|
||||
const res = await notificationService.list<{ data: unknown[] }>({ page: 1, page_size: 20 });
|
||||
setNotifications((res as { data?: unknown[] })?.data || []);
|
||||
}
|
||||
} catch {
|
||||
if (tab === 'consultation') setSessions([]);
|
||||
|
||||
12
apps/miniprogram/src/services/notification.ts
Normal file
12
apps/miniprogram/src/services/notification.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { api } from './request';
|
||||
|
||||
export const notificationService = {
|
||||
list: (params?: { page?: number; page_size?: number }) =>
|
||||
api.get('/messages', params as Record<string, string | number | undefined>),
|
||||
markRead: (id: string) =>
|
||||
api.put(`/messages/${id}/read`),
|
||||
markAllRead: () =>
|
||||
api.put('/messages/read-all'),
|
||||
getUnreadCount: () =>
|
||||
api.get('/messages/unread-count'),
|
||||
};
|
||||
Reference in New Issue
Block a user