feat(融资): 新增产品对比页面及相关接口实现

新增产品对比页面 compare/compare,支持同一评估下最多3个产品的横向对比,展示额度、期限、利率、适用条件等核心指标及匹配详情。
新增 matches.uts 服务层,封装匹配列表、详情、公共产品查询接口。
新增 account 分包的 latest-report.uts 服务,用于查找用户最新成功报告。
调整个人中心页面,将“评估记录”改为“开始评估”,新增最近报告直达功能。
更新文档,标记匹配相关接口及原型07、09页面已实现,调整页面数量至26页。
移除 finance 分包中旧的 fetchMatches、fetchProduct 模拟数据接口,统一使用正式API。
This commit is contained in:
hujun
2026-09-28 14:56:46 +08:00
parent 26da91b337
commit 7c252fc730
20 changed files with 1605 additions and 403 deletions
+38
View File
@@ -0,0 +1,38 @@
import { getSession } from '@/services/api.uts'
import { validRecordId, MatchDetail, MatchReason } from './matches.uts'
let scope = ''
let selected: string[] = []
export function parseCompareIds(raw: string): string[] {
if (raw.length == 0) return []
const ids = raw.split(',')
if (ids.length > 3) throw new Error('每次最多对比3个产品,请返回重新选择。')
const seen: string[] = []
ids.forEach((id: string) => {
if (!validRecordId(id) || seen.includes(id)) throw new Error('对比产品编号无效或重复,请返回重新选择。')
seen.push(id)
})
return ids
}
// 只缓存少量选择ID,不持久化产品或个人事实;换账号、会话或评估后立即隔离。
export function compareSelection(assessmentId: string): string[] {
const session = getSession()
const key = session == null ? '' : (session.getString('userId') ?? '') + ':' + (session.getString('token') ?? '') + ':' + assessmentId
if (key != scope || key.length == 0) { scope = key; selected = [] }
return selected.slice()
}
export function saveCompareSelection(assessmentId: string, ids: string[]): void {
compareSelection(assessmentId)
selected = parseCompareIds(ids.join(','))
}
export function compareQuery(assessmentId: string, ids: string[]): string {
return '?assessmentId=' + encodeURIComponent(assessmentId) + '&productIds=' + ids.join(',')
}
export function sameMatchSnapshot(a: MatchDetail, b: MatchDetail): boolean {
return a.assessmentId == b.assessmentId && a.resultVersion == b.resultVersion && a.snapshotId == b.snapshotId && a.ruleVersion == b.ruleVersion && a.orderingVersion == b.orderingVersion
}
export function compareReasonText(reasons: MatchReason[], empty: string): string {
return reasons.length == 0 ? empty : reasons.map((r: MatchReason): string => r.text + '\n' + r.evidence.join('\n')).join('\n\n')
}