This commit is contained in:
Iruka 2024-09-30 10:23:30 +08:00
parent 56f17f651d
commit 12f2d45ee4
4 changed files with 22 additions and 21 deletions

View File

@ -3,5 +3,5 @@ VITE_BASE_API = 'http://39.105.121.219'
#VITE_BASE_API = 'http://127.0.0.1' #VITE_BASE_API = 'http://127.0.0.1'
#VITE_BASE_API = 'http://api.jsyzhineng.com' #VITE_BASE_API = 'http://api.jsyzhineng.com'
VITE_BASE_MQTT = 'mqtt://39.105.121.219:8083/mqtt' VITE_BASE_MQTT = '39.105.121.219:8083/mqtt'
#VITE_BASE_MQTT = 'mqtt://8.130.77.146:8083/mqtt' #VITE_BASE_MQTT = '8.130.77.146:8083/mqtt'

View File

@ -1,5 +1,5 @@
ENV = 'production' ENV = 'production'
VITE_BASE_API = 'http://api.jsyzhineng.com' VITE_BASE_API = 'http://api.jsyzhineng.com'
VITE_BASE_MQTT = 'ws://39.105.121.219:8083/mqtt' #VITE_BASE_MQTT = '39.105.121.219:8083/mqtt'
#VITE_BASE_MQTT = 'ws://8.130.77.146:8083/mqtt' VITE_BASE_MQTT = '8.130.77.146:8083/mqtt'

32
App.vue
View File

@ -36,36 +36,35 @@
methods: { methods: {
//indexData //indexData
indexDataHandler(e, data) { indexDataHandler(e, data) {
// console.error("indexDataHandler_1", {
// e: e,
// data: data
// });
if (e == this.indexData.eventType.land) { if (e == this.indexData.eventType.land) {
// console.error(":", this.indexData.selectItem) // console.error(":", this.indexData.selectItem)
this.dc.setLandItem(this.indexData.selectItem, null); this.dc.setLandItem(this.indexData.selectItem, null);
} }
if (e == this.indexData.eventType.device) { if (e == this.indexData.eventType.device) {
// console.error(":", this.indexData.device) // console.error(":", this.indexData.device)
this.dc.setStations(this.indexData.device.stations); this.dc.setStations(this.indexData.device.stations);
this.dc.setFlapValves(this.indexData.device.flapValves); this.dc.setFlapValves(this.indexData.device.flapValves);
this.dc.setValves(this.indexData.selectItem.id, this.indexData.device.waterOutlets); this.dc.setValves(this.indexData.selectItem.id, this.indexData.device.waterOutlets);
} }
uni.hideLoading(); uni.hideLoading();
console.error("indexDataHandler_2:", { // console.error("indexDataHandler_2:", {
indexData: this.indexData, // e: e,
dc: this.dc, // data: data,
}) // indexData: this.indexData,
// dc: this.dc,
// })
}, },
//Mqtt //Mqtt
mqttLink(userId) { mqttLink(userId) {
console.error("mqttLink");
this.mqtt.link(userId); this.mqtt.link(userId);
}, },
//Mqtt //Mqtt
mqttEnd() { mqttSubscribes(topics) {
this.mqtt.over(); this.mqtt.subscribes(topics);
},
//Mqtt
mqttUnsubscribes(topics) {
this.mqtt.unsubscribes(topics);
}, },
//Mqtt //Mqtt
mqttMsgHandler(topic, data) { mqttMsgHandler(topic, data) {
@ -74,6 +73,11 @@
data: data, data: data,
}); });
}, },
//Mqtt
mqttEnd() {
this.mqtt.over();
},
} }
} }
</script> </script>

View File

@ -25,9 +25,6 @@ class MqttUtil {
static client; static client;
static connected = false; static connected = false;
static reconnectCount = 0; static reconnectCount = 0;
onCallback = (data) => {
console.error("onCallback:", data)
};
//接收创建来的数据 //接收创建来的数据
constructor(eventHandler) { constructor(eventHandler) {