feat: 接入积分服务端真实接口并完成隔离联调

新增积分服务端接口封装、积分中心页面,支持登录回跳、签到恢复、积分明细等功能。清理缓存时保留未确认签到键,新增ApiRequestError错误类型区分业务状态,更新开发文档记录积分页面联调完成情况。
This commit is contained in:
hujun
2026-10-04 08:29:53 +08:00
parent 2a9ff403c4
commit 6b16d4fd55
9 changed files with 555 additions and 150 deletions
+13 -1
View File
@@ -6,6 +6,16 @@ export { API_BASE_URL, API_DEMO_ENABLED } from './config.uts'
const REQUEST_TIMEOUT = 10000
const SESSION_KEY = 'aiFinanceSession'
export class ApiRequestError extends Error {
status: number
errorCode: string
constructor(message: string, status: number, errorCode: string) {
super(message)
this.status = status
this.errorCode = errorCode
}
}
const wait = (duration: number) => new Promise<void>((resolve) => { setTimeout(() => resolve(), duration) })
export function saveSession(token: string, phone: string, userId: string, expiresAt: string): void {
@@ -74,7 +84,9 @@ const requestJson = (path: string, method: RequestMethod, payload: UTSJSONObject
const message = body['msg'] as string | null
if (response.statusCode < 200 || response.statusCode >= 300 || code != 1) {
if (code == 401 && sentToken.length > 0) clearSession()
reject(new Error(message != null && message.length > 0 ? message : '请求失败,请稍后重试')); return
const details = body['data']
const errorCode = details != null && typeof details == 'object' ? (details as UTSJSONObject).getString('errorCode') ?? '' : ''
reject(new ApiRequestError(message != null && message.length > 0 ? message : '请求失败,请稍后重试', response.statusCode, errorCode)); return
}
const data = body['data']
if (data == null) resolve(new UTSJSONObject())