This commit is contained in:
Iruka 2025-01-07 10:02:41 +08:00
parent 24c280b8db
commit 2ea711903e
11 changed files with 37 additions and 24 deletions

13
App.vue
View File

@ -42,7 +42,7 @@
},
methods: {
//
addMsgEvent(type, key, callBack) {
on(type, key, callBack) {
switch (type) {
case "land": //
this.landFun[key] = callBack;
@ -52,6 +52,17 @@
break;
}
},
//
off(type, key) {
switch (type) {
case "land": //
delete this.landFun[key]
break;
case "mqtt": //mqtt
delete this.mqttFun[key]
break;
}
},
//
sendMsgEvent(type, data) {
let func = {};

View File

@ -121,7 +121,7 @@
}
this.rolaFrequency.range = list;
const that = this;
getApp().addMsgEvent("mqtt", "mqtt_devOps_station", function(e) {
getApp().on("mqtt", "mqtt_devOps_station", function(e) {
if (e.type == "state") {
// that.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -142,7 +142,6 @@
})
}
that.dataObj[deviceCode] = obj;
console.error("this.dataObj:", that.dataObj);
}
}
});
@ -151,11 +150,11 @@
mounted() {},
onUnload() {
getApp().mqttUnsubscribes(this.topics);
getApp().off("mqtt", "mqtt_devOps_station")
},
methods: {
queryList(pageNo, pageSize) {
DevOpsApi.getStationList(this.landId).then(res => {
console.error("res:", res);
this.$refs.paging.completeByTotal(res.rows);
this.mqttSubscribes(res.rows);
});

View File

@ -138,7 +138,7 @@
}
this.rolaFrequency.range = list;
const that = this;
getApp().addMsgEvent("mqtt", "mqtt_devOps_valve", function(e) {
getApp().on("mqtt", "mqtt_devOps_valve", function(e) {
if (e.type == "state") {
// that.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -154,20 +154,13 @@
lf: e.data.data.lf,
})
}
that.dataObj[deviceCode] = obj;
console.error("this.dataObj:", that.dataObj);
}
if (e.topic.includes("jsy/iot/valveUpdateLoraRes/")) {
const arr = e.topic.split("/");
const deviceCode = arr[3];
let obj = that.dataObj[deviceCode] || {};
if (e.data.type == "vlf" && e.data.res == 1) {
obj = Object.assign(obj, {
lf: e.data.data,
})
}
that.dataObj[deviceCode] = obj;
console.error("this.dataObj:", that.dataObj);
}
}
});
@ -176,6 +169,7 @@
mounted() {},
onUnload() {
getApp().mqttUnsubscribes(this.topics);
getApp().off("mqtt", "mqtt_devOps_valve")
},
methods: {
queryList(pageNo, pageSize) {
@ -189,7 +183,6 @@
let topic = [];
rows.forEach(item => {
topic.push(`jsy/iot/deviceConfig/${item.device.deviceTypeId}/${item.device.deviceCode}`);//
topic.push(`jsy/iot/valveUpdateLoraRes/${item.device.deviceCode}`);//
});
this.topics = topic;
getApp().mqttSubscribes(this.topics);

View File

@ -253,7 +253,7 @@
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic);
this.mqttSubscribes(this.topics);
getApp().addMsgEvent("mqtt", "mqtt_head", function(e) {
getApp().on("mqtt", "mqtt_head", function(e) {
if (e.type == "state") {
this.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -265,6 +265,7 @@
},
onUnload() {
this.mqttUnSubscribes(this.topics);
getApp().off("mqtt", "mqtt_head")
},
methods: {
mqttSubscribes(topics) {

View File

@ -224,7 +224,7 @@
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic);
this.mqttSubscribes(this.topics);
getApp().addMsgEvent("mqtt", "mqtt_head", function(e) {
getApp().on("mqtt", "mqtt_head", function(e) {
if (e.type == "state") {
this.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -234,6 +234,9 @@
}
}
},
onUnload() {
getApp().off("mqtt", "mqtt_head")
},
methods: {
mqttSubscribes(topics) {
getApp().mqttSubscribes(topics);

View File

@ -213,7 +213,7 @@
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic);
this.mqttSubscribes(this.topics);
getApp().addMsgEvent("mqtt", "mqtt_head", function(e) {
getApp().on("mqtt", "mqtt_head", function(e) {
if (e.type == "state") {
this.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -223,6 +223,9 @@
}
}
},
onUnload() {
getApp().off("mqtt", "mqtt_head");
},
methods: {
mqttSubscribes(topics) {
getApp().mqttSubscribes(topics);

View File

@ -461,7 +461,7 @@
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic)
this.mqttSubscribes(this.topics);
getApp().addMsgEvent("mqtt", "mqtt_fertilizer", function(e) {
getApp().on("mqtt", "mqtt_fertilizer", function(e) {
if (e.type == "state") {
this.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -472,6 +472,7 @@
},
onUnload() {
this.mqttUnSubscribes(this.topics);
getApp().off("mqtt", "mqtt_fertilizer")
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary')
plus.navigator.setFullscreen(false);

View File

@ -405,7 +405,7 @@
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic)
this.mqttSubscribes(this.topics);
getApp().addMsgEvent("mqtt", "mqtt_fertilizerKL", function(e) {
getApp().on("mqtt", "mqtt_fertilizerKL", function(e) {
if (e.type == "state") {
this.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -416,6 +416,7 @@
},
onUnload() {
this.mqttUnSubscribes(this.topics);
getApp().off("mqtt", "mqtt_fertilizerKL")
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary')
plus.navigator.setFullscreen(false);

View File

@ -351,7 +351,7 @@
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic);
this.mqttSubscribes(this.topics);
getApp().addMsgEvent("mqtt", "mqtt_head", function(e) {
getApp().on("mqtt", "mqtt_head", function(e) {
if (e.type == "state") {
this.mqttConnected = e.connected;
} else if (e.type == "msg") {
@ -363,6 +363,7 @@
},
onUnload() {
this.mqttUnSubscribes(this.topics);
getApp().off("mqtt", "mqtt_head")
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary')
plus.navigator.setFullscreen(false);

View File

@ -450,14 +450,14 @@
},
onLoad() {
const that = this;
getApp().addMsgEvent("mqtt", "mqtt_map", function(e) {
getApp().on("mqtt", "mqtt_map", function(e) {
if (e.type == "state") {
that.mqttConnected = e.connected;
} else if (e.type == "msg") {
that.mapUpdateMarker(e.data);
}
});
getApp().addMsgEvent("land", "land_map", function(e) {
getApp().on("land", "land_map", function(e) {
this.mapOnload();
});
},

View File

@ -581,12 +581,12 @@
},
onLoad() {
const that = this;
getApp().addMsgEvent("mqtt", "mqtt_index", function(e) {
getApp().on("mqtt", "mqtt_index", function(e) {
if (e.type == "state") {
that.mqttConnected = e.connected;
} else if (e.type == "msg") {}
});
getApp().addMsgEvent("land", "land_index", function(e) {});
getApp().on("land", "land_index", function(e) {});
},
onShow() {
this.title = this.ijs?.land?.landName || "田间";