From 9952275e592f5a35e8f12584b73e3d990f624879 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Wed, 21 Jan 2026 16:15:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=91=E5=AE=9A=E8=A7=A3=E7=BB=91?= =?UTF-8?q?=E5=A1=98=E5=8F=A3=E6=95=B0=E6=8D=AE=EF=BC=8Cbug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device.ts | 4 +++- src/pages/main/home.vue | 28 ++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/api/device.ts b/src/api/device.ts index 484628d..b807a3a 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -22,7 +22,9 @@ export function deviceUnbind(data){ } // 将设备及开关绑定到塘口 export function bandDeviceToPond(data){ - return httpService.put(API.POND.BIND_DEVICE(), {data}) + const store = useRootUserStore(); + const userId = store.getRootUserId || Taro.getStorageSync('UserId'); + return httpService.put(`${API.POND.BIND_DEVICE()}?rootUserId=${userId}`, {data}) } // 设备图表数据 export function deviceHistory(params){ diff --git a/src/pages/main/home.vue b/src/pages/main/home.vue index 94aaf72..695d5cf 100644 --- a/src/pages/main/home.vue +++ b/src/pages/main/home.vue @@ -1119,13 +1119,33 @@ function onconfirm(list) { if (res.code == 200) { state.show = true; state.msg = "操作成功"; - pond2(); - pond1(); - pondChildInfo.value.getDeviceList(); + // 先关闭弹窗 + bandDevShow.value = false; + // 延迟刷新数据,确保后端数据更新完成 + setTimeout(() => { + // 先刷新塘口列表(会自动选中当前塘口) + pond1(); + // 等待 pond1 完成后再刷新设备详情 + setTimeout(() => { + if (pondChildInfo.value && pondChildInfo.value.getDeviceList) { + pondChildInfo.value.getDeviceList(); + } + }, 500); + }, 500); + } else { + // 操作失败也关闭弹窗 + bandDevShow.value = false; + state.show = true; + state.msg = res.msg || "绑定失败,请重试"; + state.type = "fail"; } }) - .finally(() => { + .catch((error) => { + // 网络错误也关闭弹窗 bandDevShow.value = false; + state.show = true; + state.msg = "网络错误,请重试"; + state.type = "fail"; }); } else if (res.cancel) { bandDevShow.value = false;