feat(融资): 新增产品对比页面及相关接口实现
新增产品对比页面 compare/compare,支持同一评估下最多3个产品的横向对比,展示额度、期限、利率、适用条件等核心指标及匹配详情。 新增 matches.uts 服务层,封装匹配列表、详情、公共产品查询接口。 新增 account 分包的 latest-report.uts 服务,用于查找用户最新成功报告。 调整个人中心页面,将“评估记录”改为“开始评估”,新增最近报告直达功能。 更新文档,标记匹配相关接口及原型07、09页面已实现,调整页面数量至26页。 移除 finance 分包中旧的 fetchMatches、fetchProduct 模拟数据接口,统一使用正式API。
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { requestJson } from '@/services/api.uts'
|
||||
|
||||
export type LatestReportEntry = { id: string, status: string }
|
||||
|
||||
async function latestAssessment(status: string): Promise<LatestReportEntry | null> {
|
||||
const result = await requestJson('/assessments', 'GET', { status, limit: '1' })
|
||||
const items = result['items'] as UTSJSONObject[] | null
|
||||
if (items == null) throw new Error('评估记录响应不完整')
|
||||
if (items.length == 0) return null
|
||||
const id = items[0].getString('assessmentId') ?? ''
|
||||
if (!/^[1-9][0-9]{0,9}$/.test(id) || items[0].getString('status') != status) throw new Error('评估记录格式错误,请稍后重试')
|
||||
return { id, status }
|
||||
}
|
||||
|
||||
// 服务端先按成功状态筛选再取最新提交,避免最近一页中的处理中任务遮住更早的报告。
|
||||
// 账户分包只读取共享API,不导入融资分包代码,也不缓存报告或个人资料。
|
||||
export async function findLatestReportEntry(): Promise<LatestReportEntry | null> {
|
||||
const report = await latestAssessment('succeeded')
|
||||
return report != null ? report : await latestAssessment('processing')
|
||||
}
|
||||
Reference in New Issue
Block a user