From 1835b6e4c8019f744b9d940a7d7bab854747846d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E8=90=8C?= <525441437@qq.com> Date: Wed, 24 Jan 2024 16:29:48 +0800 Subject: [PATCH] 1 --- src/views/page/realTime.vue | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/views/page/realTime.vue b/src/views/page/realTime.vue index ec5be2b..8e78d84 100644 --- a/src/views/page/realTime.vue +++ b/src/views/page/realTime.vue @@ -92,6 +92,8 @@
设备运行状态 +
日出:{{ sunrise }}
+
日落:{{ sunset }}
@@ -428,6 +430,8 @@ export default { }, data() { return { + sunrise: "00:00", + sunset: "00:00", statusList: [], time: null,//右上角时间 @@ -759,6 +763,25 @@ export default { } return num }, + + //16进制转为时间 16位无符号高字节是时,低字节是分 + convertToTimeMinutes(hexValue) { + // 将十进制数转换为16进制字符串 + let hexString = hexValue.toString(16); + + // 补零,确保结果是4位16进制数 + while (hexString.length < 4) { + hexString = "0" + hexString; + } + + return hexString; + }, + insertColonEveryTwoDigits(inputString) { + // 使用正则表达式将字符串每两位切割 + const chunks = inputString.match(/.{1,2}/g); + return chunks.join(":"); + // 使用join方法将切割后的数组元素用冒号连接起来 + }, //countType计算类型 //0是原数据 //1是原数据-400 @@ -1175,6 +1198,12 @@ export default { } this.api.getControlGetState(TargetValue).then(res => { if (res.data.code == 200) { + this.sunrise = this.insertColonEveryTwoDigits( + this.convertToTimeMinutes(res.data.data["1119"]) + ); + this.sunset = this.insertColonEveryTwoDigits( + this.convertToTimeMinutes(res.data.data["1120"]) + ); const statusList = [] this.nowDevicestatus.forEach((el, index) => { if (el.id == 1) { @@ -1273,7 +1302,7 @@ export default { statusList.push(statusData) } else if (el.id == 26 || el.id == 27 || el.id == 28 || el.id == 29) { //通风窗 - var statusData = { name: el.name, type: 15, id: el.id, open: res.data.data[(1102 + ((el.id - 26) * 2))], progress: res.data.data[(1104 + ((el.id - 26) * 2))], index: res.data.data[(1103 + ((el.id - 26) * 2))] } + var statusData = { name: el.name, type: 15, id: el.id, open: res.data.data[(1102 + ((el.id - 26) * 3))], progress: res.data.data[(1104 + ((el.id - 26) * 3))], index: res.data.data[(1103 + ((el.id - 26) * 3))] } statusList.push(statusData) }