Files
airz-uniapp/packages/finance/services/api.uts
T
hujun dbfd637388 feat: 重构评估流程为内存状态管理并接入真实提交与报告接口
本次重构将评估草稿改为内存状态管理,移除本地存储草稿,新增评估流程内存状态模块;接入真实的账户资料获取、头像上传接口,新增账户缓存清理逻辑;重构评估提交逻辑,接入真实提交接口并返回评估ID;新增分析页和报告页的真实状态查询、报告获取功能;更新README文档,记录开发进度和接口状态。
2026-09-24 11:50:07 +08:00

40 lines
1.6 KiB
Plaintext

import { API_DEMO_ENABLED, API_BASE_URL, wait, requestJson } from '@/services/api.uts'
import { demoProducts, parseProduct, FinanceProduct } from './finance.uts'
import { createAssessment } from './records.uts'
export { API_BASE_URL } from '@/services/api.uts'
export async function submitAssessment(payload: UTSJSONObject): Promise<string> {
return await createAssessment(payload)
}
export async function fetchMatches(): Promise<FinanceProduct[]> {
if (API_DEMO_ENABLED) {
await wait(320)
return demoProducts.slice()
}
const result = await requestJson('/matches', 'GET', new UTSJSONObject())
const items = result['items'] as UTSJSONObject[] | null
return items == null ? [] : items.map((item: UTSJSONObject): FinanceProduct => parseProduct(item))
}
export async function fetchProduct(id: string): Promise<FinanceProduct | null> {
if (API_DEMO_ENABLED) {
await wait(180)
const products = demoProducts.filter((item: FinanceProduct): boolean => item.id == id)
return products.length > 0 ? products[0] : null
}
const result = await requestJson('/products/' + encodeURIComponent(id), 'GET', new UTSJSONObject())
return parseProduct(result)
}
export async function sendAssistantMessage(message: string): Promise<string> {
if (API_DEMO_ENABLED) {
await wait(600)
return '结合您的评估结果,建议优先选择年化利率较低、可随借随还的产品,并重点确认提前还款规则。'
}
const result = await requestJson('/assistant/messages', 'POST', { message })
const reply = result['reply'] as string | null
if (reply == null || reply.length == 0) throw new Error('助手暂时没有返回内容')
return reply
}