- 迁移内容数据到服务端接口,移除本地模拟数据 - 首页新增推荐课程加载与未读消息检查 - 资讯、课程、搜索页面支持分页加载与错误重试 - 登录页新增恢复课程、消息、帮助页的路由逻辑 - 评估分析页新增处理中状态动效与阶段提示 - API 环境切换到正式域名 airz.hqling.cloud
32 lines
1.8 KiB
Plaintext
32 lines
1.8 KiB
Plaintext
import { requestJson } from '@/services/api.uts'
|
|
|
|
export type FeedbackItem = { id: string, content: string, status: string, reply: string, createdAt: string, updatedAt: string }
|
|
export type FeedbackPage = { items: FeedbackItem[], page: number, total: number, hasMore: boolean }
|
|
|
|
function feedbackView(data: UTSJSONObject): FeedbackItem {
|
|
const id = data.getString('id') ?? ''; const content = data.getString('content') ?? ''
|
|
if (id.length == 0) throw new Error('反馈响应不完整')
|
|
return { id, content, status: data.getString('status') ?? 'pending', reply: data.getString('reply') ?? '',
|
|
createdAt: data.getString('createdAt') ?? '', updatedAt: data.getString('updatedAt') ?? '' }
|
|
}
|
|
|
|
export function feedbackKey(): string { return 'feedback_' + Date.now().toString() + '_' + Math.floor(Math.random() * 1000000000).toString() }
|
|
export function feedbackStatus(status: string): string {
|
|
if (status == 'pending') return '待处理'
|
|
if (status == 'processing') return '处理中'
|
|
if (status == 'resolved') return '已回复'
|
|
if (status == 'closed') return '已关闭'
|
|
return '待核对'
|
|
}
|
|
export async function submitFeedback(content: string, requestId: string): Promise<FeedbackItem> {
|
|
const attachmentIds: string[] = []
|
|
return feedbackView(await requestJson('/feedback', 'POST', { content, requestId, attachmentIds }))
|
|
}
|
|
export async function fetchFeedback(page: number): Promise<FeedbackPage> {
|
|
const data = await requestJson('/feedback', 'GET', { page: page.toString(), pageSize: '20' })
|
|
const rows = data['items'] as UTSJSONObject[] | null
|
|
if (rows == null) throw new Error('反馈记录加载失败')
|
|
return { items: rows.map((item: UTSJSONObject): FeedbackItem => feedbackView(item)), page: data.getNumber('page') ?? page,
|
|
total: data.getNumber('total') ?? 0, hasMore: data.getBoolean('hasMore') ?? false }
|
|
}
|