From 7eff56b2a0ab7d6c16e600a5bd68fec6e9f8450f Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 18 Apr 2025 09:23:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=B0=83=E6=95=B4weekDay=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=B6=E7=9A=84=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E6=8D=A2=E3=80=81=E5=A2=9E=E5=8A=A0=E5=BC=80?= =?UTF-8?q?=E9=94=81=E6=97=B6=E7=9A=84=E6=97=B6=E9=97=B4=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env.js | 4 ++-- format.js | 12 +++++++----- star-cloud/lock.js | 3 ++- star-cloud/other.js | 2 ++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/env.js b/env.js index df9420a..0afa5f8 100644 --- a/env.js +++ b/env.js @@ -1,7 +1,7 @@ // uni版本号 -export const uniVersion = '1.0.12' +export const uniVersion = '1.0.13' // uni构建号 -export const uniBuildNumber = 13 +export const uniBuildNumber = 14 // web版本号 export const webVersion = '1.0.1' diff --git a/format.js b/format.js index a6444b0..deb0fab 100644 --- a/format.js +++ b/format.js @@ -133,15 +133,17 @@ export function convertWeekdayBitToArray(weekdayBit) { /** * 十进制数字数组转为二进制字符串 - * 例如 将 [1,2,3,4,5] 转换回 '0111110' - * @param weekdays - * @returns {string} + * 例如 将 [1,2,3,4,5] 转换回 '0111110'(表示周一到周五) + * @param {number[]} weekdays - 周几数组,1-7 分别代表周一到周日 + * @returns {string} - 7位二进制字符串,从右到左分别代表周一到周日 */ export function convertWeekdayArrayToBit(weekdays) { const bits = new Array(7).fill('0'); weekdays.forEach(day => { - if (day >= 0 && day < 7) { - bits[day] = '1'; + if (day >= 1 && day <= 7) { + // 将1-7转换为0-6的数组索引 + const index = day === 7 ? 0 : day - 1; + bits[index] = '1'; } }); return bits.join(''); diff --git a/star-cloud/lock.js b/star-cloud/lock.js index 6c90371..d926751 100644 --- a/star-cloud/lock.js +++ b/star-cloud/lock.js @@ -1,7 +1,7 @@ import {sm4} from 'sm-crypto' import {cmdIds, Result} from '../constant' import {searchAndConnectDevice, writeBLECharacteristicValue} from '../uni/basic' -import {createPackageEnd, md5Encrypt, timestampToArray,checkRequiredFields} from '../format' +import {createPackageEnd, md5Encrypt, timestampToArray, checkRequiredFields} from '../format' import {getLockDetailRequest, getLockSettingDataRequest, remoteUnLockRequest} from '../api' import {getStorage, setStorage} from '../export' import log from '../log' @@ -199,6 +199,7 @@ export async function openDoor(params) { contentArray.set(timestampToArray(openTime), 63) console.log('开门时token', this.lockInfo.token) + console.log('开门时同步的时间', Array.from(timestampToArray(openTime)), openTime) contentArray.set(this.lockInfo.token || timestampToArray(openTime), 67) diff --git a/star-cloud/other.js b/star-cloud/other.js index 01e14e4..cc4619d 100644 --- a/star-cloud/other.js +++ b/star-cloud/other.js @@ -41,6 +41,8 @@ export async function getServerTimestamp() { if (code === Result.Success.code) { this.serverTimestamp = Math.ceil(data.date / 1000) this.timeDifference = Math.ceil((data.date - new Date().getTime()) / 1000) + console.log('服务器时差:', this.timeDifference) + console.log('服务器时间:', data) } return new Result(code, data, message) }