关闭按钮

This commit is contained in:
WindowBird 2025-10-14 10:05:21 +08:00
parent 000395a22a
commit 48fcb58b7e

View File

@ -333,31 +333,47 @@ export default {
} }
}, },
// //
btngb() { async btngb() {
uni.showLoading({ uni.showLoading({
title: "设备关闭中...", title: "设备关闭中...",
}); });
this.$u
.put(`/app/device/admin/${this.id}/switch?open=false`) try {
.then((res) => { const res = await sendCommand({
if (res.code == 200) { command: "close",
// setTimeout(()=>{ mac: this.mac,
// this.btnsx() tryCount: "2",
// },1000) timeout: "10",
uni.showToast({ reason: "测试",
title: "关闭成功",
icon: "success",
duration: 2000,
});
this.powerStatus = "关闭";
} else {
uni.showToast({
title: "关闭失败",
icon: "none",
duration: 2000,
});
}
}); });
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() { btnsx() {