From aa7229e21b00d3a12c96a950b4c18e723cdcb105 Mon Sep 17 00:00:00 2001
From: fengerli <528575642@qq.com>
Date: Mon, 13 Oct 2025 17:01:11 +0800
Subject: [PATCH] =?UTF-8?q?6170=E6=8E=A7=E5=88=B6=E9=9D=A2=E6=9D=BF?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/controlCenter/6170/index.vue | 11 ++++-------
src/views/equipmentManagement/devices/index.vue | 2 +-
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/views/controlCenter/6170/index.vue b/src/views/controlCenter/6170/index.vue
index 3d8e87a..e10d8af 100644
--- a/src/views/controlCenter/6170/index.vue
+++ b/src/views/controlCenter/6170/index.vue
@@ -592,17 +592,15 @@ const getMainLightModeLabel = (mode: any) => {
// 处理设备消息
const handleDeviceMessage = (msg: any) => {
try {
- // 解析设备消息(假设格式为 { state: [类型, 模式值, 亮度, 续航...] })
const payloadObj = JSON.parse(msg.payload.toString());
const deviceState = payloadObj.state; // 设备状态数组
if (!Array.isArray(deviceState)) {
return;
}
- // 用switch处理不同的消息类型(deviceState[0])
switch (deviceState[0]) {
case 1:
// 类型1灯光主键
- const lightModeId = getMainLightModeLabel(deviceState[1]); // 获取模式ID(如'strong')
+ const lightModeId = getMainLightModeLabel(deviceState[1]);
const brightness = deviceState[2]; // 亮度值
const batteryTime = deviceState[3]; // 续航时间
console.log('灯光模式消息:', { 模式ID: lightModeId, 亮度: brightness, 续航: batteryTime });
@@ -625,7 +623,7 @@ const handleDeviceMessage = (msg: any) => {
break;
case 12:
// 灯光主键
- const lightModeIdA = getMainLightModeLabel(deviceState[1]); // 获取模式ID(如'strong')
+ const lightModeIdA = getMainLightModeLabel(deviceState[1]);
if (lightModeIdA !== 'unknown') {
lightModes.value.forEach(mode => {
const isActive = mode.id === lightModeIdA;
@@ -650,7 +648,6 @@ const handleDeviceMessage = (msg: any) => {
break;
default:
- // 其他类型消息(不处理,仅打印)
console.log('未处理的消息类型:', deviceState[0]);
break;
}
@@ -658,7 +655,7 @@ const handleDeviceMessage = (msg: any) => {
}
};
onMounted(async () => {
- await getList(); // 先获取设备信息
+ await getList();
// 连接mqtt
onConnect(async () => {
const deviceImei = deviceDetail.value.deviceImei;
@@ -684,7 +681,7 @@ onMounted(async () => {
handleDeviceMessage(msg);
});
onError((err) => {
- console.error('MQTT连接失败原因:', err.message); // 关键:打印连接失败的具体原因
+ console.error('MQTT连接失败原因:', err.message);
});
connect();
});
diff --git a/src/views/equipmentManagement/devices/index.vue b/src/views/equipmentManagement/devices/index.vue
index 2f20e8b..d4bcf06 100644
--- a/src/views/equipmentManagement/devices/index.vue
+++ b/src/views/equipmentManagement/devices/index.vue
@@ -112,7 +112,7 @@
{{ scope.row.bindingStatus === 1 ? '已绑定' : '未绑定' }}
-
+