diff --git a/pages/control/index.vue b/pages/control/index.vue index 9b32ecd..45f59de 100644 --- a/pages/control/index.vue +++ b/pages/control/index.vue @@ -477,6 +477,7 @@ export default { this.value=1; } this.reset(); + this.disconnectMqtt(); }, reset() { @@ -551,12 +552,13 @@ export default { this.message = JSON.stringify({[type]: status}) console.info("指令:"+this.message+";大棚:"+this.publishTopic) // 控制设备 - // this.publishMessage(); - // // 设备回执 - // this.deviceType=type; + this.publishMessage(); + // 设备回执 + this.deviceType=type; + //todo - this.status[type] = this.status[type] === 0 ? 1 : 0; - this.show[type] = this.status[type] === 0 ? "运行" : "暂停"; + // this.status[type] = this.status[type] === 0 ? 1 : 0; + // this.show[type] = this.status[type] === 0 ? "运行" : "暂停"; } } @@ -601,7 +603,7 @@ export default { }, disconnectMqtt() { - if (this.client) { + if (this.client && this.connected) { this.client.end() this.connected = false this.addMessage('已断开MQTT连接') @@ -652,6 +654,16 @@ export default { this.handleCommandAck(msgData,this.deviceType); } + if (this.value!==1) { + var arr=['jbk',"jbg","jm1k","jm1g","jm2k","jm2g","jm3k","jm3g"] + const allKeysNumeric = Object.keys(msgData).some(key => arr.includes(key)); + if (allKeysNumeric) { + console.info(msgData) + this.status={...msgData} + console.info("imei: "+this.publishTopic+"copy: ",this.status) + } + } + }, addMessage(content) {