feat(miniprogram): 通知 Tab 对接 erp-message 消息 API — 替换空壳

This commit is contained in:
iven
2026-05-01 18:18:51 +08:00
parent f4b536accb
commit 0fb8b98c72
2 changed files with 15 additions and 3 deletions

View File

@@ -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([]);

View 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'),
};