From 9c7b0a23730097068f238d911e8d330ce619dd9d Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Mon, 17 Nov 2025 09:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=EF=BC=9A=E6=9C=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=20custom.catch:=20true=EF=BC=8C=E4=BC=9A=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=80=E4=B8=AA=E6=B0=B8=E8=BF=9C=20pending=20?= =?UTF-8?q?=E7=9A=84=20Promise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/task.js | 3 ++- pages/task/add/index.vue | 10 ++++------ utils/request/index.js | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/api/task.js b/api/task.js index 120eeb9..ea7c936 100644 --- a/api/task.js +++ b/api/task.js @@ -106,7 +106,8 @@ export const applyTaskDelay = (payload) => { export const createTask = (payload) => { return uni.$uv.http.post('/bst/task', payload, { custom: { - auth: true + auth: true, + catch: true // 允许在 catch 中处理错误 } }); }; diff --git a/pages/task/add/index.vue b/pages/task/add/index.vue index b4c3b03..1f6148b 100644 --- a/pages/task/add/index.vue +++ b/pages/task/add/index.vue @@ -862,7 +862,8 @@ const handleSubmit = async () => { }); try { - await createTask(payload); + const res = await createTask(payload); + console.log('@@@@@@@@@@',res); uni.hideLoading(); uni.showToast({ title: '创建成功', @@ -874,14 +875,11 @@ const handleSubmit = async () => { }, 1200); } catch (error) { uni.hideLoading(); - submitting.value = false; console.error('创建任务失败:', error); - uni.showToast({ - title: error.message || '创建失败,请重试', - icon: 'none' - }); + // 错误提示已在响应拦截器中统一处理,这里不需要重复显示 } finally { submitting.value = false; + console.log('submitting', submitting.value); } }; diff --git a/utils/request/index.js b/utils/request/index.js index 1a9501b..814ab9f 100644 --- a/utils/request/index.js +++ b/utils/request/index.js @@ -10,7 +10,7 @@ export const Request = () => { // 初始化请求配置 uni.$uv.http.setConfig((config) => { /* config 为默认全局配置*/ - config.baseURL = 'http://192.168.1.5:4001'; /* 根域名 */ + config.baseURL = 'http://192.168.1.9:4001'; /* 根域名 */ // config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */ return config })