关闭按钮
This commit is contained in:
parent
000395a22a
commit
48fcb58b7e
|
|
@ -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() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user