diff --git a/README.md b/README.md index a101af6..baf89da 100644 --- a/README.md +++ b/README.md @@ -166,4 +166,13 @@ const data = await $starCloud.syncAllOpenRecord(params) * @returns {Promise} */ const data = await $starCloud.getServerTimestamp() + +/** + * 获取锁支持项 + * @param params + * @param {AccountInfo} params.accountInfo 账号信息 + * @param {Number} params.lockId 锁 Id + * @returns {Promise} + */ +const data = await $starCloud.getLockSupportFeatures(params) ``` diff --git a/api.js b/api.js index 4d31d43..f2a5ad2 100644 --- a/api.js +++ b/api.js @@ -161,3 +161,12 @@ export function uploadRecordRequest(data) { data }) } + +// 获取锁应用设置 +export function getLockSettingDataRequest(data) { + return request({ + url: '/v1/lock/getLockSettingData', + method: 'POST', + data + }) +} diff --git a/starCloud.js b/starCloud.js index 4c29906..e698068 100644 --- a/starCloud.js +++ b/starCloud.js @@ -10,6 +10,7 @@ import { getLastRecordTimeRequest, getLockDetailRequest, getLockNetTokenRequest, + getLockSettingDataRequest, getOfflinePasswordRequest, getServerDatetimeRequest, getStarCloudToken, @@ -51,6 +52,7 @@ import log from '@/starCloud/log' * @typedef {Object} OfflinePassword * @property {String} keyboardPwdName - 密码名称 * @property {Number} keyboardPwdType - 密码类型 + * @property {Number} lockId - 锁 Id * @property {Number} isCoerced - 胁迫 1:胁迫 2:非胁迫 * @property {Number} startDate - 开始时间 * @property {Number} endDate - 结束时间 @@ -532,10 +534,7 @@ export const useStarCloudStore = defineStore('starCloud', { if (result.code !== Result.Success.code) { return result } - return await getOfflinePasswordRequest({ - ...password, - lockId: this.lockInfo.lockId - }) + return await getOfflinePasswordRequest(password) }, /** * 自定义密码 @@ -1164,6 +1163,32 @@ export const useStarCloudStore = defineStore('starCloud', { return new Result(code, data, message) }, + /** + * 获取锁支持项 + * @param params + * @param {AccountInfo} params.accountInfo 账号信息 + * @param {Number} params.lockId 锁 Id + * @returns {Promise} + */ + async getLockSupportFeatures(params) { + const { accountInfo, lockId } = params + + // 设置执行账号 + const result = await this.login(accountInfo) + if (result.code !== Result.Success.code) { + return result + } + + const { code, data, message } = await getLockSettingDataRequest({ + lockId: lockId + }) + if (code === Result.Success.code) { + return new Result(code, { ...data.lockFeature }, message) + } else { + return new Result(code, data, message) + } + }, + /** * 清理用户 * @returns {Promise}