关闭按钮

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({
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() {