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 ? '已绑定' : '未绑定' }} - +