Files
cz-web/src/api/message.ts
2026-10-01 17:24:57 +08:00

147 lines
8.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { PageResult } from '@/types/api'
import type { Message, MessageQuery } from '@/types/business/message'
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用
const MOCK_MESSAGES: Message[] = [
{
id: 'msg-001',
type: '系统通知',
title: '【新功能】物联网全案"整机联调"看板正式上线',
summary: '整机联调看板已上线,支持联调进度、问题闭环与交付物一览。',
content: '尊敬的用户:\n\n为了提升物联网全案项目的交付透明度,平台已正式上线"整机联调"看板功能。\n\n一、功能亮点\n1、联调进度实时同步:设备接入、协议联调、场景验证各阶段进度一目了然;\n2、问题闭环跟踪:联调过程中产生的缺陷与阻塞项统一登记、分派、闭环;\n3、交付物一览:联调报告、测试记录、验收文档集中展示,随时查阅下载。\n\n二、使用方式\n进入「项目中心 → 项目详情 → 整机联调」即可查看对应看板。已有进行中的物联网全案项目将自动迁移历史数据,无需重新配置。\n\n三、温馨提示\n如在使用过程中遇到问题,可通过「在线客服」联系我们,或联系专属项目经理协助处理。\n\n智联智造平台产品团队\n2026年8月',
publishTime: '2026-08-06 10:00',
isRead: false,
attachments: [
{ name: '物联网全案服务介绍.pdf', size: 2.5 * 1024 * 1024, uploadTime: '2026-08-06 10:00', url: '' },
],
},
{
id: 'msg-002',
type: '系统通知',
title: '平台 v2.6 版本更新公告',
summary: '新增需求提报模板、案例库对比功能,并优化了消息中心体验。',
content: '尊敬的用户:\n\n平台 v2.6 版本已于近日发布,本次更新内容如下:\n\n一、新增功能\n1、需求提报模板:常用需求类型支持保存为模板,一键复用;\n2、案例库对比:最多选择 4 个案例进行横向对比,辅助决策;\n3、消息中心改版:分类标签、关键词搜索、全部已读一站式处理。\n\n二、体验优化\n1、列表页加载性能提升约 40%;\n2、移动端适配细节修复;\n3、附件上传支持 1GB 大文件。\n\n感谢您一直以来的支持,祝使用愉快!',
publishTime: '2026-07-15 14:30',
isRead: false,
attachments: [],
},
{
id: 'msg-003',
type: '系统通知',
title: '关于平台服务时间调整的通知',
summary: '自 2026-09-01 起,在线客服服务时间调整为 9:00-21:00。',
content: '尊敬的用户:\n\n为进一步提升服务质量,自 2026 年 9 月 1 日起,在线客服服务时间调整如下:\n\n服务时间:每日 9:00 - 21:00(法定节假日照常服务)\n非服务时段提交的留言,我们将在下一个服务时段内尽快回复。\n\n紧急事务可通过专属项目经理电话联系。\n\n感谢您的理解与支持!',
publishTime: '2026-08-28 09:00',
isRead: true,
attachments: [],
},
{
id: 'msg-004',
type: '状态通知',
title: '合同生效通知',
summary: '您的合同已正式生效,合同编号 CZ-2026-0815 已开始生效。',
content: '您好:\n\n您的合同已正式生效。\n\n合同编号:CZ-2026-0815\n合同名称:智能园区综合管理平台开发合同\n生效日期:2026-08-15\n\n合同已开始生效,可随时在「合同中心」查看详情及履约进度。\n\n如有疑问,请联系您的专属项目经理。',
publishTime: '2026-08-15 16:42',
isRead: false,
attachments: [],
},
{
id: 'msg-005',
type: '状态通知',
title: '项目进度更新:需求确认阶段已完成',
summary: '「智能工厂物联网整体解决方案」需求确认已完成,即将进入方案设计。',
content: '您好:\n\n您的项目进度已更新:\n\n项目名称:智能工厂物联网整体解决方案\n当前阶段:需求确认 ✅ 已完成\n下一阶段:方案设计\n\n项目组将于 3 个工作日内提交初步方案,届时会再次通知您。您也可以前往「项目中心」查看详细进度与里程碑。\n\n感谢您的配合!',
publishTime: '2026-08-20 11:05',
isRead: false,
attachments: [],
},
{
id: 'msg-006',
type: '状态通知',
title: '账单待办提醒',
summary: '您有一笔待付款账单,账单编号 BILL-202608-023,请及时处理。',
content: '您好:\n\n您有一笔待付款账单,请及时处理:\n\n账单编号:BILL-202608-023\n关联项目:电商中台系统定制开发\n账单金额:150,000.00 元\n到期日期:2026-09-10\n\n请前往「财务中心 → 账单管理」完成支付。如对账单有疑问,请通过在线客服联系我们。\n\n温馨提示:逾期支付可能影响项目排期,请留意处理时间。',
publishTime: '2026-08-25 10:00',
isRead: true,
attachments: [],
},
{
id: 'msg-007',
type: '在线客服',
title: '您好,请问有什么可以帮您的?',
summary: '专属客服小助手已收到您的咨询,将尽快为您答复。',
content: '您好,欢迎咨询智联智造平台!\n\n我是您的专属客服小助手,请问有什么可以帮您的?\n\n您可以咨询:\n1、物联网全案开发的流程与周期\n2、项目进度查询\n3、合同与账单相关问题\n4、平台操作指引\n\n我们将在服务时间内尽快回复您。',
publishTime: '2026-08-21 10:25',
isRead: false,
attachments: [],
},
{
id: 'msg-008',
type: '在线客服',
title: '您的咨询已有回复',
summary: '关于"整机联调周期"的咨询已回复,点击查看详细内容。',
content: '您好:\n\n关于您咨询的"整机联调周期"问题,客服回复如下:\n\n一般物联网全案项目的整机联调周期为 2-4 周,具体取决于设备数量、协议复杂度与场景验证范围。常规智能家居类项目约 2 周,工业场景多设备联调约 3-4 周。\n\n详细排期以项目计划为准,您可在「项目中心」查看最新里程碑。\n\n如还有其他问题,欢迎继续咨询!',
publishTime: '2026-08-19 15:40',
isRead: true,
attachments: [],
},
{
id: 'msg-009',
type: '在线客服',
title: '会话满意度回访',
summary: '您上次的会话已结束,欢迎对本次服务进行评价。',
content: '您好:\n\n您于 2026-08-18 的会话已结束,感谢您的咨询!\n\n欢迎对本次服务进行评价,您的反馈将帮助我们持续改进。如问题未得到解决,可直接回复本条消息,我们将重新为您跟进。\n\n祝您使用愉快!',
publishTime: '2026-08-18 17:00',
isRead: false,
attachments: [],
},
]
function applyFilters(query: MessageQuery): Message[] {
return MOCK_MESSAGES.filter((item) => {
if (query.type !== 'all' && item.type !== query.type) return false
if (query.keyword && !item.title.includes(query.keyword) && !item.summary.includes(query.keyword)) return false
return true
})
}
export function getMessageList(query: MessageQuery): Promise<PageResult<Message>> {
const filtered = applyFilters(query)
const start = (query.page - 1) * query.pageSize
return Promise.resolve({
list: filtered.slice(start, start + query.pageSize),
total: filtered.length,
})
}
export function getMessageDetail(id: string): Promise<Message | null> {
const found = MOCK_MESSAGES.find((item) => item.id === id) ?? null
return Promise.resolve(found ? { ...found } : null)
}
export function markAllRead(): Promise<void> {
for (const item of MOCK_MESSAGES) {
item.isRead = true
}
return Promise.resolve()
}
export function markRead(id: string): Promise<void> {
const found = MOCK_MESSAGES.find((item) => item.id === id)
if (found) found.isRead = true
return Promise.resolve()
}
export function getTabCounts(): Promise<{ all: number; 在线客服: number; 状态通知: number; 系统通知: number }> {
const counts = { all: MOCK_MESSAGES.length, 在线客服: 0, 状态通知: 0, 系统通知: 0 }
for (const item of MOCK_MESSAGES) {
counts[item.type] += 1
}
return Promise.resolve(counts)
}
export function getUnreadCount(): Promise<number> {
return Promise.resolve(MOCK_MESSAGES.filter((item) => !item.isRead).length)
}