feat:调整weekDay提交服务器时的格式转换、增加开锁时的时间同步日志

This commit is contained in:
liyi 2025-04-18 09:23:00 +08:00
parent 6ab9990961
commit 7eff56b2a0
4 changed files with 13 additions and 8 deletions

4
env.js
View File

@ -1,7 +1,7 @@
// uni版本号 // uni版本号
export const uniVersion = '1.0.12' export const uniVersion = '1.0.13'
// uni构建号 // uni构建号
export const uniBuildNumber = 13 export const uniBuildNumber = 14
// web版本号 // web版本号
export const webVersion = '1.0.1' export const webVersion = '1.0.1'

View File

@ -133,15 +133,17 @@ export function convertWeekdayBitToArray(weekdayBit) {
/** /**
* 十进制数字数组转为二进制字符串 * 十进制数字数组转为二进制字符串
* 例如 [1,2,3,4,5] 转换回 '0111110' * 例如 [1,2,3,4,5] 转换回 '0111110'表示周一到周五
* @param weekdays * @param {number[]} weekdays - 周几数组1-7 分别代表周一到周日
* @returns {string} * @returns {string} - 7位二进制字符串从右到左分别代表周一到周日
*/ */
export function convertWeekdayArrayToBit(weekdays) { export function convertWeekdayArrayToBit(weekdays) {
const bits = new Array(7).fill('0'); const bits = new Array(7).fill('0');
weekdays.forEach(day => { weekdays.forEach(day => {
if (day >= 0 && day < 7) { if (day >= 1 && day <= 7) {
bits[day] = '1'; // 将1-7转换为0-6的数组索引
const index = day === 7 ? 0 : day - 1;
bits[index] = '1';
} }
}); });
return bits.join(''); return bits.join('');

View File

@ -1,7 +1,7 @@
import {sm4} from 'sm-crypto' import {sm4} from 'sm-crypto'
import {cmdIds, Result} from '../constant' import {cmdIds, Result} from '../constant'
import {searchAndConnectDevice, writeBLECharacteristicValue} from '../uni/basic' 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 {getLockDetailRequest, getLockSettingDataRequest, remoteUnLockRequest} from '../api'
import {getStorage, setStorage} from '../export' import {getStorage, setStorage} from '../export'
import log from '../log' import log from '../log'
@ -199,6 +199,7 @@ export async function openDoor(params) {
contentArray.set(timestampToArray(openTime), 63) contentArray.set(timestampToArray(openTime), 63)
console.log('开门时token', this.lockInfo.token) console.log('开门时token', this.lockInfo.token)
console.log('开门时同步的时间', Array.from(timestampToArray(openTime)), openTime)
contentArray.set(this.lockInfo.token || timestampToArray(openTime), 67) contentArray.set(this.lockInfo.token || timestampToArray(openTime), 67)

View File

@ -41,6 +41,8 @@ export async function getServerTimestamp() {
if (code === Result.Success.code) { if (code === Result.Success.code) {
this.serverTimestamp = Math.ceil(data.date / 1000) this.serverTimestamp = Math.ceil(data.date / 1000)
this.timeDifference = Math.ceil((data.date - new Date().getTime()) / 1000) this.timeDifference = Math.ceil((data.date - new Date().getTime()) / 1000)
console.log('服务器时差:', this.timeDifference)
console.log('服务器时间:', data)
} }
return new Result(code, data, message) return new Result(code, data, message)
} }