From 5de0c69c949f220d9235c6b23e43d5d6e7534cf8 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Fri, 5 Jun 2026 14:10:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:API=E5=93=8D=E5=BA=94code=3D200=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BAmsg,=E9=9D=9E200=E6=8A=9B=E5=87=BAmsg?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 31d8d91..b7af3a9 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -2065,7 +2065,19 @@ export default { uni.hideLoading() if (res.statusCode !== 200) { - throw new Error('API返回: HTTP ' + res.statusCode + ' ' + JSON.stringify(res.data || '')) + throw new Error('API返回: HTTP ' + res.statusCode) + } + + // 解析 JSON 响应 + var respData = res.data + if (typeof respData === 'string') { + try { respData = JSON.parse(respData) } catch (e) { respData = { code: 500, msg: respData } } + } + + if (respData && respData.code === 200) { + uni.showToast({ title: respData.msg || '上传成功', icon: 'success' }) + } else { + throw new Error(respData && respData.msg || '上传失败') } // 保存上传记录到本地