feat: 实现协议全文与同意记录功能
新增协议全文后台管理、版本化发布及本人同意记录功能,支持可撤销授权;完善资料与授权相关边界提示,调整评估提交时的资料与授权校验逻辑,同步更新相关页面文案与路由。
This commit is contained in:
+4
-4
@@ -100,14 +100,14 @@ const requestJson = (path: string, method: RequestMethod, payload: UTSJSONObject
|
||||
|
||||
export { apiMessage, requestJson, wait }
|
||||
|
||||
export function uploadJson(path: string, filePath: string): Promise<UTSJSONObject> {
|
||||
export function uploadJson(path: string, filePath: string, formData: UTSJSONObject = {}, failureMessage: string = '头像上传失败'): Promise<UTSJSONObject> {
|
||||
return new Promise<UTSJSONObject>((resolve, reject) => {
|
||||
const sentToken = currentToken()
|
||||
if (sentToken.length == 0) { reject(new Error('请先登录')); return }
|
||||
if (API_BASE_URL.length == 0 || (APP_ENVIRONMENT == 'production' && !API_BASE_URL.startsWith('https://'))) {
|
||||
reject(new Error('服务地址尚未配置')); return
|
||||
}
|
||||
uni.uploadFile({ url: API_BASE_URL + path, filePath, name: 'file', timeout: REQUEST_TIMEOUT,
|
||||
uni.uploadFile({ url: API_BASE_URL + path, filePath, name: 'file', formData, timeout: REQUEST_TIMEOUT,
|
||||
header: { Authorization: 'Bearer ' + sentToken, 'X-Requested-With': 'XMLHttpRequest' },
|
||||
success: (response) => {
|
||||
if (currentToken() != sentToken) { reject(new Error('登录状态已变化,请重新操作')); return }
|
||||
@@ -117,13 +117,13 @@ export function uploadJson(path: string, filePath: string): Promise<UTSJSONObjec
|
||||
if (body == null) throw new Error('上传响应格式错误')
|
||||
if (response.statusCode < 200 || response.statusCode >= 300 || body['code'] != 1) {
|
||||
if (body['code'] == 401) clearSession()
|
||||
throw new Error((body['msg'] as string | null) ?? '头像上传失败')
|
||||
throw new Error((body['msg'] as string | null) ?? failureMessage)
|
||||
}
|
||||
const data = body['data'] as UTSJSONObject | null
|
||||
if (data == null) throw new Error('上传响应不完整')
|
||||
resolve(data)
|
||||
} catch (error) { reject(error) }
|
||||
}, fail: () => { reject(new Error('头像上传失败,请检查网络后重试')) }
|
||||
}, fail: () => { reject(new Error(failureMessage + ',请检查网络后手动重试')) }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user