From 26066db3fdcd48d7079943df8fe3cad0515671d0 Mon Sep 17 00:00:00 2001 From: GGJ <357021191@qq.com> Date: Wed, 6 Nov 2024 09:17:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/mqtt.js | 2 +- manifest.json | 4 +- pages/device/APF/comp/xieBo.vue | 1 + pages/device/APF/detail.vue | 111 +++++++++++++++++--------------- pages/mine/setup.vue | 8 +-- 5 files changed, 67 insertions(+), 59 deletions(-) diff --git a/common/js/mqtt.js b/common/js/mqtt.js index 7b13a36..f344c48 100644 --- a/common/js/mqtt.js +++ b/common/js/mqtt.js @@ -1,5 +1,5 @@ -// export const MQTT_IP = '192.168.1.24:10215/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt export const MQTT_IP = 'pqmcn.com:8085/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt +// export const MQTT_IP = '192.168.1.24:8085/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt const MQTT_USERNAME = 't_user'//mqtt用户名 const MQTT_PASSWORD = 'njcnpqs'//密码 diff --git a/manifest.json b/manifest.json index bea1cd6..a9d26c2 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "灿能物联", "appid" : "__UNI__88BC25B", "description" : "", - "versionName" : "1.6.1", - "versionCode" : 161, + "versionName" : "1.6.3", + "versionCode" : 163, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/device/APF/comp/xieBo.vue b/pages/device/APF/comp/xieBo.vue index 29eea5b..a9197d5 100644 --- a/pages/device/APF/comp/xieBo.vue +++ b/pages/device/APF/comp/xieBo.vue @@ -298,6 +298,7 @@ barCateGoryGap:20, }, initEcharts() { setTimeout(() => { + if(this.renderData['电网侧']['Apf_HarmI'][Object.keys(this.renderData['电网侧']['Apf_HarmI'])[0]] == undefined) return let obj = JSON.parse( JSON.stringify( this.renderData['电网侧']['Apf_HarmI'][Object.keys(this.renderData['电网侧']['Apf_HarmI'])[0]], diff --git a/pages/device/APF/detail.vue b/pages/device/APF/detail.vue index 2a4b0eb..8adc38c 100644 --- a/pages/device/APF/detail.vue +++ b/pages/device/APF/detail.vue @@ -5,18 +5,10 @@ - - + + {{ item.label }} @@ -51,13 +43,9 @@ 设备状态 --> - {{ item.text }} + {{ item.text + }} @@ -80,7 +68,7 @@ - - + @@ -107,22 +95,10 @@ --> - - + + @@ -166,18 +142,22 @@ export default { navMenuList: [ { text: '基本', + id: 'fc8c86dbc3f2d9810f5cd8f53c295415' }, { text: '谐波', + id: '769f3db0bce070d35acf8fa92c998eb6' }, { text: '功率', + id: 'a16aceae7d1565bf9f94dd7410cf9bce' }, // { // text: '波形', // }, { text: '其他', + }, ], content: [ @@ -197,7 +177,7 @@ export default { iconPath: '/static/access.png', text: '接入', }, - + ], client: null, timer: null, @@ -209,7 +189,7 @@ export default { basicData: [], IOData: [], pageOptions: {}, - + } }, methods: { @@ -277,9 +257,9 @@ export default { } // this.$refs.fab.close() }, - clickItem(item) { - console.log(item); - }, + clickItem(item) { + console.log(item); + }, // 取消调试 cancelDebug() { this.dialogType = '取消调试' @@ -319,9 +299,20 @@ export default { }) } }, - navMenuClick(idx) { - this.navMenuActive = idx - uni.pageScrollTo({ scrollTop: 0, duration: 0 }) + async navMenuClick(idx) { + // console.log("🚀 ~ navMenuClick ~ idx:", idx) + if (idx != 3) { + await this.client.end() + await setTimeout(() => { + this.initMqtt(this.navMenuList[idx].id) + + },500) + + } + setTimeout(() => { + this.navMenuActive = idx + uni.pageScrollTo({ scrollTop: 0, duration: 0 }) + }, 500) }, downloadImg() { uni.downloadFile({ @@ -361,7 +352,7 @@ export default { if (this.client) { this.loading = false } else { - this.initMqtt() + this.initMqtt(this.navMenuList[0].id) } }) }, @@ -387,7 +378,7 @@ export default { }) } }, - initMqtt() { + initMqtt(id) { MQTT_OPTIONS.clientId = uni.getStorageSync('devCode') // #ifdef APP-PLUS this.client = mqtt.connect('wx://' + MQTT_IP, MQTT_OPTIONS) @@ -403,16 +394,22 @@ export default { console.log(`订阅成功:/zl/TemperData/${this.devId}`) } }) - this.client.subscribe(`/zl/devData/${this.devId}`, (err) => { + + this.client.subscribe(`/zl/devData/${this.devId}/${id}`, (err) => { if (!err) { - console.log(`订阅成功:/zl/devData/${this.devId}`) + console.log(`订阅成功:/zl/devData/${this.devId}/${id}`) // 默认推送 - this.client.publish(`/zl/askDevData/${this.devId}`) + this.client.publish(`/zl/askDevData/${this.devId}/${id}`) this.client.publish(`/zl/askTemperData/${this.devId}`) + if (this.timer) { + clearInterval(this.timer) + this.timer = null + } this.timer = setInterval(() => { + console.log('askDevData') - this.client.publish(`/zl/askDevData/${this.devId}`) + this.client.publish(`/zl/askDevData/${this.devId}/${id}`) this.client.publish(`/zl/askTemperData/${this.devId}`) }, 1000 * 60) } @@ -430,7 +427,9 @@ export default { }) .on('message', (topic, message) => { console.log('接收推送信息:', JSON.parse(message.toString()), topic) - if (topic === `/zl/devData/${this.devId}`) { + console.log("🚀 ~ .on ~ topic:", topic) + + if (topic === `/zl/devData/${this.devId}/${id}`) { if ((!message.toString() || message.toString().length < 10) && this.loading) { this.$util.toast('该设备暂无数据') } @@ -456,6 +455,7 @@ export default { } }) }, + handlerData(data) { this.basicData = data @@ -594,6 +594,7 @@ export default {