Files
hujun dcf12a4471 refactor: 重构存储与接口适配,统一金额单位与会话管理
- 新增配置、存储、金额转换工具服务
- 按userId隔离本地缓存,替换旧设备级存储
- 统一移动端金额单位为万元,新增转换适配逻辑
- 重构认证与请求逻辑,支持真实后端会话
- 调整搜索、帮助、融资模块的模拟开关与数据适配
- 更新文档说明开发状态与配置规则
2026-09-22 17:25:52 +08:00

29 lines
2.4 KiB
Plaintext
Raw Permalink 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 { yuanToWan } from '@/services/money.uts'
export type FinanceProduct = {
id: string, bank: string, initials: string, color: string,
amount: number, rate: number, term: string, score: number,
advantages: string[], age: string, work: string, credit: string, materials: string
}
// 列表和详情共用产品标识;正式数据由 API 适配层提供。
export const demoProducts: FinanceProduct[] = [
{ id: '1', bank: '招商银行·闪电贷', initials: '招', color: '#c93547', amount: 50, rate: 3.85, term: '12–36个月', score: 96, advantages: ['线上申请', '无需抵押', '额度循环', '还款灵活'], age: '22–55周岁', work: '现单位工作满6个月', credit: '近两年无严重逾期', materials: '身份证 · 银行卡 · 收入证明' },
{ id: '2', bank: '平安银行·新一贷', initials: '平', color: '#ed7924', amount: 30, rate: 4.20, term: '12–60个月', score: 91, advantages: ['信用融资', '期限可选', '在线预审', '无需担保'], age: '23–55周岁', work: '有稳定工作或经营收入', credit: '征信记录良好', materials: '身份证 · 收入证明 · 居住证明' },
{ id: '3', bank: '建设银行·快e贷', initials: '建', color: '#2869b7', amount: 20, rate: 4.35, term: '12–36个月', score: 88, advantages: ['线上办理', '便捷用款', '信用授信', '支持提前还款'], age: '22–60周岁', work: '有稳定收入来源', credit: '符合机构信用要求', materials: '身份证 · 银行卡 · 资产或收入证明' }
]
export function parseProduct(item: UTSJSONObject): FinanceProduct {
// 接口额度使用元的十进制字符串,视图模型始终使用万元。
const amountYuan = item['amountYuan'] as string | null
return {
id: item['id'] as string ?? '', bank: item['bank'] as string ?? '融资产品',
initials: item['initials'] as string ?? '融', color: item['color'] as string ?? '#2869b7',
amount: amountYuan != null ? parseFloat(yuanToWan(amountYuan)) : (item['amount'] as number ?? 0), rate: item['rate'] as number ?? 0,
term: item['term'] as string ?? '以审批为准', score: item['score'] as number ?? 0,
advantages: item['advantages'] as string[] ?? [], age: item['age'] as string ?? '以机构要求为准',
work: item['work'] as string ?? '以机构要求为准', credit: item['credit'] as string ?? '以机构要求为准',
materials: item['materials'] as string ?? '以机构要求为准'
}
}