From 8304eac2a45a32b00563c03a2f3fd303ecd5872a Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期五, 22 八月 2025 13:54:36 +0800
Subject: [PATCH] 1.解决微信小程序真机MQTT无法连接问题

---
 pages/tabBar/device.vue |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/pages/tabBar/device.vue b/pages/tabBar/device.vue
index b1c0a83..70339eb 100644
--- a/pages/tabBar/device.vue
+++ b/pages/tabBar/device.vue
@@ -182,7 +182,7 @@
 						</view>
 						<view class="right" style="min-width: 240rpx;">
 							<view class="title text-sm">鏇存柊鏃堕棿:</view>
-							<view class="title text-sm text-gray">{{ refreshTime}}</view>
+							<view class="title text-sm text-gray">{{ item.refreshTime}}</view>
 						</view>
 					</view>
 
@@ -205,8 +205,7 @@
 				isProcessing: false,
 				// key->璁惧绉熸埛+code 
 				dataMap: new Map(),
-				// 鏇存柊鏃堕棿
-				refreshTime: '',
+
 				alarmEquCount: 0,
 				faultEquCount: 0,
 				timer: null
@@ -242,6 +241,7 @@
 			},
 			// 璁惧鏁版嵁鍜宮tqq瀹炴椂鏁版嵁鍚堝苟
 			mergeMqttRealData(mqttData) {
+
 				const {
 					tenantid,
 					machineid
@@ -251,11 +251,15 @@
 				const targetItem = this.dataList.find(item =>
 					item.tenantId === tenantid && item.code === machineid
 				);
+				if (targetItem && !targetItem.online) {
+					mqttData = {};
+				}
 				if (targetItem) {
 					const updatedItem = {
 						...targetItem,
 						realData: mqttData
 					};
+					updatedItem.refreshTime = dayjs().format('HH:mm:ss');
 					this.$set(this.dataList, this.dataList.indexOf(targetItem), updatedItem);
 
 				}
@@ -318,7 +322,7 @@
 							case topics.realData:
 								this.mergeMqttRealData(wdata);
 								break;
-							case topics.realFaultTopic:
+							case topics.realFaultTopic:
 							case topics.oneceFaultTopic:
 								this.handleFaultData(wdata);
 								break;
@@ -401,14 +405,18 @@
 					const [tenantId, equCode] = key.split("_");
 					const targetItem = this.dataList.find(i =>
 						i.tenantId == tenantId && i.code == equCode
-					);
-
+					);
+					
 					if (targetItem) {
 						const updatedItem = {
 							...targetItem,
-							errorData: faults.filter(f => f.faultType === 1).map(n => n.faultName),
-							warnData: faults.filter(f => f.faultType === 2).map(n => n.faultName),
-						};
+							errorData: targetItem.online ? faults.filter(f => f.faultType === 1).map(n => n.faultName) : [],
+							warnData: targetItem.online ? faults.filter(f => f.faultType === 2).map(n => n.faultName) : [],
+						};
+						if(targetItem.online){
+							updatedItem.refreshTime = dayjs().format('HH:mm:ss');
+						}
+						
 						this.$set(this.dataList, this.dataList.indexOf(targetItem), updatedItem);
 					}
 				});

--
Gitblit v1.9.3