Browse Source

定时请求

znjjxt
lzp 3 months ago
parent
commit
db02e07959
  1. 78
      pages/index/index.vue

78
pages/index/index.vue

@ -11,7 +11,7 @@
<image class="data-item-img" src="./wd.png" mode="widthFix"></image> <image class="data-item-img" src="./wd.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>{{ deviceInfo.temperature }}<span>°C</span> >{{ deviceInfo.temperature || "-" }}<span>°C</span>
</view> </view>
</view> </view>
<!-- 湿度 --> <!-- 湿度 -->
@ -20,7 +20,7 @@
<image class="data-item-img" src="./sd.png" mode="widthFix"></image> <image class="data-item-img" src="./sd.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>{{ deviceInfo.humidity }}<span>%RH</span> >{{ deviceInfo.humidity || "-" }}<span>%RH</span>
</view> </view>
</view> </view>
<!-- Co2 --> <!-- Co2 -->
@ -29,7 +29,7 @@
<image class="data-item-img" src="./CO2.png" mode="widthFix"></image> <image class="data-item-img" src="./CO2.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>{{ deviceInfo.Co2 }}<span>ppm</span> >{{ deviceInfo.Co2 || "-" }}<span>ppm</span>
</view> </view>
</view> </view>
<!-- Tvoc --> <!-- Tvoc -->
@ -41,14 +41,18 @@
mode="widthFix" mode="widthFix"
></image> ></image>
</view> </view>
<view class="data-item-text">27<span>ppb</span> </view> <view class="data-item-text"
>{{ deviceInfo.Tvoc || "-" }}<span>ppb</span>
</view>
</view> </view>
<!-- 烟雾浓度 --> <!-- 烟雾浓度 -->
<view class="view-data-item"> <view class="view-data-item">
<view class="data-item-img-box"> <view class="data-item-img-box">
<image class="data-item-img" src="./ywnd.png" mode="widthFix"></image> <image class="data-item-img" src="./ywnd.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text">27<span>%LEL</span> </view> <view class="data-item-text"
>{{ deviceInfo.smoke || "-" }}<span>%LEL</span>
</view>
</view> </view>
<!-- 光照强度 --> <!-- 光照强度 -->
<view class="view-data-item"> <view class="view-data-item">
@ -56,7 +60,7 @@
<image class="data-item-img" src="./gzqd.png" mode="widthFix"></image> <image class="data-item-img" src="./gzqd.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>{{ deviceInfo.light }}<span>Lux</span> >{{ deviceInfo.light || "-" }}<span>Lux</span>
</view> </view>
</view> </view>
<!-- 是否有人 --> <!-- 是否有人 -->
@ -64,7 +68,9 @@
<view class="data-item-img-box"> <view class="data-item-img-box">
<image class="data-item-img" src="./sfyr.png" mode="widthFix"></image> <image class="data-item-img" src="./sfyr.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text">有人</view> <view class="data-item-text">{{
deviceInfo.person == 1 ? "有人" : "没人"
}}</view>
</view> </view>
<!-- 声光报警状态 --> <!-- 声光报警状态 -->
<view class="view-data-item"> <view class="view-data-item">
@ -83,7 +89,7 @@
<image class="data-item-img" src="./wd.png" mode="widthFix"></image> <image class="data-item-img" src="./wd.png" mode="widthFix"></image>
</view> </view>
<view class="data-item-text"> <view class="data-item-text">
LED{{ deviceInfo.LED }}% LED{{ deviceInfo.LED || "-" }}%
<u-slider <u-slider
style="width: 100%" style="width: 100%"
v-model="deviceInfo.LED" v-model="deviceInfo.LED"
@ -104,7 +110,7 @@
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>窗帘 >窗帘
<view>{{ deviceInfo.curtain == 0 ? "OFF" : "NO" }}</view> <view>{{ deviceInfo.curtain == 0 ? "OFF" : "ON" }}</view>
</view> </view>
</view> </view>
<view <view
@ -117,7 +123,7 @@
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>加湿器 >加湿器
<view>{{ deviceInfo.humidifier == 0 ? "OFF" : "NO" }}</view> <view>{{ deviceInfo.humidifier == 0 ? "OFF" : "ON" }}</view>
</view> </view>
</view> </view>
<view <view
@ -134,7 +140,7 @@
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>风扇 >风扇
<view>{{ deviceInfo.fan == 0 ? "OFF" : "NO" }}</view> <view>{{ deviceInfo.fan == 0 ? "OFF" : "ON" }}</view>
</view> </view>
</view> </view>
<view <view
@ -147,7 +153,7 @@
</view> </view>
<view class="data-item-text" <view class="data-item-text"
>空气净化器 >空气净化器
<view>{{ deviceInfo.airCleaner == 0 ? "OFF" : "NO" }}</view> <view>{{ deviceInfo.airCleaner == 0 ? "OFF" : "ON" }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -202,16 +208,8 @@ export default {
value: 30, value: 30,
deviceId: "", // id deviceId: "", // id
// 湿Co2Tvoc // 湿Co2Tvoc
deviceInfo: { deviceInfo: {},
temperature: 27, // falt: false,
humidity: 27, // 湿
co: 27, // CO
tvoc: 27, // Tvoc
smoke: 27, //
light: 27, //
person: 27, //
alarm: 27, //
},
}; };
}, },
@ -300,23 +298,6 @@ export default {
if (code == 200) { if (code == 200) {
this.loading = false; this.loading = false;
let deviceAttributesList = data.deviceAttributesList; 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",},
// ------ ------ // ------ ------
// 湿Co2Tvoc // 湿Co2Tvoc
// //
@ -332,15 +313,22 @@ export default {
(row) => row.id === 448053828969475 (row) => row.id === 448053828969475
)?.attributeValue; )?.attributeValue;
// Tvoc // Tvoc
let Tvoc = deviceAttributesList.find(
(row) => row.id === 448053828969474
)?.attributeValue;
// //
let smoke = deviceAttributesList.find(
(row) => row.id === 448053828969476
)?.attributeValue;
// //
let light = deviceAttributesList.find( let light = deviceAttributesList.find(
(row) => row.id === 448053828969477 (row) => row.id === 448053828969477
)?.attributeValue; )?.attributeValue;
// //
let person = deviceAttributesList.find(
(row) => row.id === 448053828969479
)?.attributeValue;
// //
let alarm = deviceAttributesList.find( let alarm = deviceAttributesList.find(
(row) => row.id === 448053828969478 (row) => row.id === 448053828969478
@ -390,7 +378,10 @@ export default {
temperature, // temperature, //
humidity, // 湿 humidity, // 湿
Co2, // Co2 Co2, // Co2
Tvoc, // Tvoc
smoke, //
light, // light, //
person, //
alarm, // alarm, //
LED, // LED LED, // LED
curtain, // curtain, //
@ -402,6 +393,11 @@ export default {
humidityUpperThreshold, // 湿 humidityUpperThreshold, // 湿
airQualityThreshold, // airQualityThreshold, //
}; };
console.log("this.deviceInfo", this.deviceInfo);
// 10
setTimeout(() => {
this.getAttributes(this.deviceId); // id
}, 30000);
} }
}, },
}, },

Loading…
Cancel
Save