From 48fcb58b7ec3693999e64887e5068e1b779cce2a Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Tue, 14 Oct 2025 10:05:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- page_user/luru/controlDevice.vue | 58 ++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/page_user/luru/controlDevice.vue b/page_user/luru/controlDevice.vue index 844efe1..6cc6902 100644 --- a/page_user/luru/controlDevice.vue +++ b/page_user/luru/controlDevice.vue @@ -333,31 +333,47 @@ export default { } }, // 关闭 - btngb() { + async btngb() { uni.showLoading({ title: "设备关闭中...", }); - this.$u - .put(`/app/device/admin/${this.id}/switch?open=false`) - .then((res) => { - if (res.code == 200) { - // setTimeout(()=>{ - // this.btnsx() - // },1000) - uni.showToast({ - title: "关闭成功", - icon: "success", - duration: 2000, - }); - this.powerStatus = "关闭"; - } else { - uni.showToast({ - title: "关闭失败", - icon: "none", - duration: 2000, - }); - } + + try { + const res = await sendCommand({ + command: "close", + mac: this.mac, + tryCount: "2", + timeout: "10", + reason: "测试", }); + + console.log("close-res", res); + uni.hideLoading(); + + if (res.code === 200 && res.data.code === "0") { + //0表示成功 + uni.showToast({ + title: "关闭成功", + icon: "success", + duration: 2000, + }); + this.powerStatus = "关闭"; + } else { + uni.showToast({ + title: res.msg || "关闭失败", + icon: "none", + duration: 2000, + }); + } + } catch (error) { + console.error("关闭设备失败:", error); + uni.hideLoading(); + uni.showToast({ + title: "关闭失败", + icon: "none", + duration: 2000, + }); + } }, // 刷新 btnsx() {