35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
const API_BASE_URL = ''
|
|
|
|
const wait = (duration: number) => new Promise<void>((resolve) => { setTimeout(() => resolve(), duration) })
|
|
|
|
// API_BASE_URL 为空时使用本地演示数据;接入后端后仅需替换各方法内部实现。
|
|
export async function requestSmsCode(phone: string): Promise<boolean> {
|
|
if (API_BASE_URL.length == 0) { await wait(350); return phone.length >= 11 }
|
|
return true
|
|
}
|
|
|
|
export async function submitAssessment(payload: UTSJSONObject): Promise<string> {
|
|
if (API_BASE_URL.length == 0) {
|
|
await wait(650)
|
|
uni.setStorageSync('latestAssessment', payload)
|
|
return 'ASSESSMENT-DEMO-001'
|
|
}
|
|
return ''
|
|
}
|
|
|
|
export async function fetchMatches(): Promise<UTSJSONObject[]> {
|
|
await wait(320)
|
|
return [
|
|
{ rank: 1, bank: '招商银行·闪电贷', amount: '50万', rate: '3.85%', term: '12-36期', score: 96 },
|
|
{ rank: 2, bank: '平安银行·新一贷', amount: '30万', rate: '4.20%', term: '12-60期', score: 91 },
|
|
{ rank: 3, bank: '建设银行·快e贷', amount: '20万', rate: '4.35%', term: '12-36期', score: 88 }
|
|
]
|
|
}
|
|
|
|
export async function sendAssistantMessage(message: string): Promise<string> {
|
|
await wait(600)
|
|
return '结合您的评估结果,建议优先选择年化利率较低、可随借随还的产品,并重点确认提前还款规则。'
|
|
}
|
|
|
|
export { API_BASE_URL }
|