From bff152bedc9c2887f99302084a31310e1282bcb3 Mon Sep 17 00:00:00 2001 From: liyi Date: Thu, 27 Mar 2025 17:50:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E5=88=A4=E6=96=AD=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/common.js b/common.js index 3de41d0..593c6df 100644 --- a/common.js +++ b/common.js @@ -787,6 +787,16 @@ export async function parsingCharacteristicValue(binaryData) { const cmdId = decrypted[0] * 256 + decrypted[1] + // 处理时间戳 + if (this.requestParams.startDate) { + // 判断是否为秒级时间戳(10位) + this.requestParams.startDate = _convertToMilliseconds(this.requestParams.startDate) + } + if (this.requestParams.endDate) { + // 判断是否为秒级时间戳(10位) + this.requestParams.startDate = _convertToMilliseconds(this.requestParams.startDate) + } + switch (cmdId) { case cmdIds.getLockStatus: if (decrypted[2] === Result.Success.code) { @@ -1082,7 +1092,7 @@ export async function parsingCharacteristicValue(binaryData) { }) if (addResult.code === Result.Success.code) { // 增加返回一个指纹序号 - addResult.data.fingerprintNumber = decrypted[6] * 256 + decrypted[7]; + addResult.data.fingerprintNumber = decrypted[6] * 256 + decrypted[7]; } console.log('registerFingerprintConfirm', decrypted) // 触发指纹确认事件 @@ -1416,3 +1426,14 @@ export function createPackageHeader(encryptionType, originalLength) { export async function disconnectDevice() { return await closeBLEConnection(this.lockInfo.deviceId) } + +/** + * 用于判断时间戳是否是秒级别的,如果是的话则补充到毫秒级别 + * @param timestamp 时间戳 + * @returns {number|*} + * @private + */ +export function _convertToMilliseconds(timestamp) { + if (!timestamp) return timestamp; + return timestamp.toString().length === 10 ? timestamp * 1000 : timestamp; +} \ No newline at end of file