.
This commit is contained in:
parent
24c280b8db
commit
2ea711903e
13
App.vue
13
App.vue
@ -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 = {};
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
});
|
||||
},
|
||||
|
@ -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 || "田间";
|
||||
|
Loading…
Reference in New Issue
Block a user