From db02e0795990e5aa40cc44df09e9fdd75de74165 Mon Sep 17 00:00:00 2001
From: lzp <1747191978@qq.com>
Date: Thu, 19 Jun 2025 12:18:22 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E8=AF=B7=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/index/index.vue | 78 ++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 41 deletions(-)
diff --git a/pages/index/index.vue b/pages/index/index.vue
index fe1df5f..eb41ac6 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -11,7 +11,7 @@
{{ deviceInfo.temperature }}°C
+ >{{ deviceInfo.temperature || "-" }}°C
@@ -20,7 +20,7 @@
{{ deviceInfo.humidity }}%RH
+ >{{ deviceInfo.humidity || "-" }}%RH
@@ -29,7 +29,7 @@
{{ deviceInfo.Co2 }}ppm
+ >{{ deviceInfo.Co2 || "-" }}ppm
@@ -41,14 +41,18 @@
mode="widthFix"
>
- 27ppb
+ {{ deviceInfo.Tvoc || "-" }}ppb
+
- 27%LEL
+ {{ deviceInfo.smoke || "-" }}%LEL
+
@@ -56,7 +60,7 @@
{{ deviceInfo.light }}Lux
+ >{{ deviceInfo.light || "-" }}Lux
@@ -64,7 +68,9 @@
- 有人
+ {{
+ deviceInfo.person == 1 ? "有人" : "没人"
+ }}
@@ -83,7 +89,7 @@
- LED({{ deviceInfo.LED }}%)
+ LED({{ deviceInfo.LED || "-" }}%)
窗帘
- {{ deviceInfo.curtain == 0 ? "OFF" : "NO" }}
+ {{ deviceInfo.curtain == 0 ? "OFF" : "ON" }}
加湿器
- {{ deviceInfo.humidifier == 0 ? "OFF" : "NO" }}
+ {{ deviceInfo.humidifier == 0 ? "OFF" : "ON" }}
风扇
- {{ deviceInfo.fan == 0 ? "OFF" : "NO" }}
+ {{ deviceInfo.fan == 0 ? "OFF" : "ON" }}
空气净化器
- {{ deviceInfo.airCleaner == 0 ? "OFF" : "NO" }}
+ {{ deviceInfo.airCleaner == 0 ? "OFF" : "ON" }}
@@ -202,16 +208,8 @@ export default {
value: 30,
deviceId: "", // 设备id
// 温度、湿度、Co2、Tvoc、烟雾浓度、光照强度、是否有人、声光报警状态
- deviceInfo: {
- temperature: 27, // 温度
- humidity: 27, // 湿度
- co: 27, // CO
- tvoc: 27, // Tvoc
- smoke: 27, // 烟雾浓度
- light: 27, // 光照强度
- person: 27, // 是否有人
- alarm: 27, // 声光报警状态
- },
+ deviceInfo: {},
+ falt: false,
};
},
@@ -300,23 +298,6 @@ export default {
if (code == 200) {
this.loading = false;
let deviceAttributesList = data.deviceAttributesList;
- // {id: 448053828969475, belongType: "1", attributeName: "C02", attributeType: "1",},
- // {id: 448053828969476, belongType: "1", attributeName: "CO", attributeType: "1",},
- // {id: 448053828969473, belongType: "1", attributeName: "湿度", attributeType: "1",},
- // {id: 448058657266432, belongType: "1", attributeName: "湿度上限阈值", attributeType: "2",},
- // {id: 448058581624832, belongType: "1", attributeName: "湿度下限阈值", attributeType: "2",},
- // {id: 448053828969477, belongType: "1", attributeName: "光照", attributeType: "1",},
- // {id: 448058556146688, belongType: "1", attributeName: "光照阈值", attributeType: "2",},
- // {id: 448053828969484, belongType: "1", attributeName: "空气净化器开关", attributeType: "1",},
- // {id: 448053828969478, belongType: "1", attributeName: "报警器", attributeType: "1",},
- // {id: 448053828969483, belongType: "1", attributeName: "除湿器开关", attributeType: "1",},
- // {id: 448053828969482, belongType: "1", attributeName: "加湿器开关", attributeType: "1",},
- // {id: 448053828969479, belongType: "1", attributeName: "红外", attributeType: "1",},
- // {id: 448053828969480, belongType: "1", attributeName: "LED", attributeType: "1",},
- // {id: 448053828969481, belongType: "1", attributeName: "窗帘开关", attributeType: "1",},
- // {id: 448053828969472, belongType: "1", attributeName: "温度", attributeType: "1",},
- // {id: 448053828969474, belongType: "1", attributeName: "空气质量", attributeType: "1",},
- // {id: 448058718225664, belongType: "1", attributeName: "空气质量阈值", attributeType: "2",},
// ------ 显示 ------
// 温度、湿度、Co2、Tvoc、烟雾浓度、光照强度、是否有人、声光报警状态
// 温度
@@ -332,15 +313,22 @@ export default {
(row) => row.id === 448053828969475
)?.attributeValue;
// Tvoc
-
+ let Tvoc = deviceAttributesList.find(
+ (row) => row.id === 448053828969474
+ )?.attributeValue;
// 烟雾浓度
+ let smoke = deviceAttributesList.find(
+ (row) => row.id === 448053828969476
+ )?.attributeValue;
// 光照强度
let light = deviceAttributesList.find(
(row) => row.id === 448053828969477
)?.attributeValue;
// 是否有人
-
+ let person = deviceAttributesList.find(
+ (row) => row.id === 448053828969479
+ )?.attributeValue;
// 声光报警状态
let alarm = deviceAttributesList.find(
(row) => row.id === 448053828969478
@@ -390,7 +378,10 @@ export default {
temperature, // 温度
humidity, // 湿度
Co2, // Co2
+ Tvoc, // Tvoc
+ smoke, // 烟雾浓度
light, // 光照强度
+ person, // 是否有人
alarm, // 声光报警状态
LED, // LED
curtain, // 窗帘开关
@@ -402,6 +393,11 @@ export default {
humidityUpperThreshold, // 湿度上限阈值
airQualityThreshold, // 空气质量阈值
};
+ console.log("this.deviceInfo", this.deviceInfo);
+ // 定时请求接口,每次结束后等待10秒再请求
+ setTimeout(() => {
+ this.getAttributes(this.deviceId); // 根据设备id查找设备信息
+ }, 30000);
}
},
},