refactor: 重构项目分包结构与资源管理

1.  调整页面路由,将业务页面迁移到对应分包,主包仅保留首页
2.  拆分公共服务模块,将账户、融资相关逻辑移入对应分包
3.  统一资源路径,将专属静态资源放入各分包static目录,更新导航栏图标资源
4.  修复启动引导逻辑,实现仅首次冷启动显示引导页
5.  更新README文档,补充分包配置与开发规范说明
This commit is contained in:
hujun
2026-09-20 10:52:10 +08:00
parent 94a4558290
commit 69130d11e7
43 changed files with 278 additions and 180 deletions
+47
View File
@@ -0,0 +1,47 @@
import { API_BASE_URL, wait, requestJson } from '@/services/api.uts'
import { demoProducts, parseProduct, FinanceProduct } from './finance.uts'
export { API_BASE_URL } from '@/services/api.uts'
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'
}
const result = await requestJson('/assessments', 'POST', payload)
const id = result['id'] as string | null
if (id == null || id.length == 0) throw new Error('评估提交成功但未返回编号')
return id
}
export async function fetchMatches(): Promise<FinanceProduct[]> {
if (API_BASE_URL.length == 0) {
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_BASE_URL.length == 0) {
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_BASE_URL.length == 0) {
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
}
+24
View File
@@ -0,0 +1,24 @@
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 {
return {
id: item['id'] as string ?? '', bank: item['bank'] as string ?? '融资产品',
initials: item['initials'] as string ?? '融', color: item['color'] as string ?? '#2869b7',
amount: 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 ?? '以机构要求为准'
}
}