From 12f2d45ee476f623185ab32f72a04439e97f3219 Mon Sep 17 00:00:00 2001 From: Iruka <1017819588@qq.com> Date: Mon, 30 Sep 2024 10:23:30 +0800 Subject: [PATCH] . --- .env.development | 4 ++-- .env.production | 4 ++-- App.vue | 32 ++++++++++++++++++-------------- utils/mqttUtil.js | 3 --- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.env.development b/.env.development index e76a246..d4bfd55 100644 --- a/.env.development +++ b/.env.development @@ -3,5 +3,5 @@ VITE_BASE_API = 'http://39.105.121.219' #VITE_BASE_API = 'http://127.0.0.1' #VITE_BASE_API = 'http://api.jsyzhineng.com' -VITE_BASE_MQTT = 'mqtt://39.105.121.219:8083/mqtt' -#VITE_BASE_MQTT = 'mqtt://8.130.77.146:8083/mqtt' \ No newline at end of file +VITE_BASE_MQTT = '39.105.121.219:8083/mqtt' +#VITE_BASE_MQTT = '8.130.77.146:8083/mqtt' \ No newline at end of file diff --git a/.env.production b/.env.production index f567bac..fc17867 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ ENV = 'production' VITE_BASE_API = 'http://api.jsyzhineng.com' -VITE_BASE_MQTT = 'ws://39.105.121.219:8083/mqtt' -#VITE_BASE_MQTT = 'ws://8.130.77.146:8083/mqtt' \ No newline at end of file +#VITE_BASE_MQTT = '39.105.121.219:8083/mqtt' +VITE_BASE_MQTT = '8.130.77.146:8083/mqtt' \ No newline at end of file diff --git a/App.vue b/App.vue index 3012b6a..7ce68f6 100644 --- a/App.vue +++ b/App.vue @@ -36,36 +36,35 @@ methods: { //监听indexData的回调 indexDataHandler(e, data) { - // console.error("indexDataHandler_1:", { - // e: e, - // data: data - // }); if (e == this.indexData.eventType.land) { // console.error("地块更新通知:", this.indexData.selectItem) - this.dc.setLandItem(this.indexData.selectItem, null); } if (e == this.indexData.eventType.device) { // console.error("设备更新通知:", this.indexData.device) - this.dc.setStations(this.indexData.device.stations); this.dc.setFlapValves(this.indexData.device.flapValves); this.dc.setValves(this.indexData.selectItem.id, this.indexData.device.waterOutlets); } uni.hideLoading(); - console.error("indexDataHandler_2:", { - indexData: this.indexData, - dc: this.dc, - }) + // console.error("indexDataHandler_2:", { + // e: e, + // data: data, + // indexData: this.indexData, + // dc: this.dc, + // }) }, //Mqtt连接 mqttLink(userId) { - console.error("mqttLink"); this.mqtt.link(userId); }, - //Mqtt断开连接 - mqttEnd() { - this.mqtt.over(); + //Mqtt连接 + mqttSubscribes(topics) { + this.mqtt.subscribes(topics); + }, + //Mqtt连接 + mqttUnsubscribes(topics) { + this.mqtt.unsubscribes(topics); }, //Mqtt消息回调 mqttMsgHandler(topic, data) { @@ -74,6 +73,11 @@ data: data, }); }, + //Mqtt断开连接 + mqttEnd() { + this.mqtt.over(); + }, + } } diff --git a/utils/mqttUtil.js b/utils/mqttUtil.js index 2c33c41..bbded71 100644 --- a/utils/mqttUtil.js +++ b/utils/mqttUtil.js @@ -25,9 +25,6 @@ class MqttUtil { static client; static connected = false; static reconnectCount = 0; - onCallback = (data) => { - console.error("onCallback:", data) - }; //接收创建来的数据 constructor(eventHandler) {