feat:增加获取锁列表接口;修复从服务器获取的时差属性为undefined时导致同步给锁的时间错误

This commit is contained in:
liyi 2025-04-18 15:34:08 +08:00
parent 7eff56b2a0
commit 013ffcfbe8
5 changed files with 50 additions and 6 deletions

16
api.js
View File

@ -778,4 +778,18 @@ export function updateLockSettingRequest(data) {
method: 'POST',
data
})
}
}
/**
* 获取名下锁列表
* @param data.lockId 锁id
* @returns {Promise<unknown>}
*/
export function getUserLockListRequest(data) {
return request({
url: '/v1/lock/list',
method: 'POST',
data
})
}

4
env.js
View File

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

View File

@ -1,6 +1,6 @@
{
"name": "star-cloud-uni",
"version": "1.0.12",
"version": "1.0.14",
"type": "module",
"main": "./uni/index.js",
"author": "zzc059",

View File

@ -2,7 +2,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 {getLockDetailRequest, getLockSettingDataRequest, remoteUnLockRequest} from '../api'
import {getLockDetailRequest, getLockSettingDataRequest, getUserLockListRequest, remoteUnLockRequest} from '../api'
import {getStorage, setStorage} from '../export'
import log from '../log'
@ -177,6 +177,10 @@ export async function openDoor(params) {
const name = this.lockInfo.bluetooth.bluetoothDeviceName
const uid = this.accountInfo.uid.toString()
if (this.timeDifference === null || this.timeDifference === undefined) {
this.timeDifference = 0;
}
const openTime = Math.ceil(new Date().getTime() / 1000) + this.timeDifference
const length = 2 + 40 + 20 + 1 + 4 + 4 + 1 + 16 + 16
@ -384,6 +388,21 @@ export async function remoteUnLock(params) {
})
}
/**
* 获取名下锁列表
* @param params
* @returns {Promise<*>}
*/
export async function getLockList(params) {
// 设置执行账号
const result = await this.login(params.uid)
if (result.code !== Result.Success.code) {
return result
}
return await getUserLockListRequest(params);
}
/**
* 搜索wifi列表
* @param params
@ -433,4 +452,6 @@ export async function searchWifiList(params) {
packageArray)
return this.getWriteResult(this.searchWifiList, params)
}
}

View File

@ -404,4 +404,13 @@ export const getRemoteList = async params => {
*/
export const remoteUnLock = async params => {
return await starCloudInstance.remoteUnLock(params)
}
/**
* 获取锁列表
* @param params
* @returns {Promise<*>}
*/
export const getLockList = async params => {
return await starCloudInstance.getLockList(params)
}