From ff194611a9e67c8e8ec5c08808cac566b2f53e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Tue, 7 Jan 2025 18:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83uniapp1.0.4+5=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 18 ++++++-------- common.js | 5 ++-- env.js | 4 +-- format.js | 11 +++++++++ package.json | 4 +-- uni.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ uni/index.js | 34 +++++++++++++++++++++++++ 7 files changed, 130 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 0e32a02..c511a0b 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,14 @@ ``` ## 调试方法 -1. 在测试项目中执行以下命令,将星云SDK项目作为子项目添加到测试项目中,直接调用对应平台的index.js文件中的方法 +1. 执行想要调试的平台命令 + ```shell + npm run web-build + npm run uni-build ``` - git subtree add --prefix=starCloud git@code.star-lock.cn:StarlockTeam/starcloud-sdk-uniapp.git master - ``` -2. 更新子项目 - ``` - git subtree pull --prefix=starCloud git@code.star-lock.cn:StarlockTeam/starcloud-sdk-uniapp.git master - ``` -3. 推送子项目 - ``` - git subtree push --prefix=starCloud git@code.star-lock.cn:StarlockTeam/starcloud-sdk-uniapp.git master +2. 将项目与调试项目放在同级目录下,在调试项目中执行npm命令 + ```shell + npm install ../[项目名称] ``` +3. 即可在调试项目中用调用正式版npm包方法进行调试 diff --git a/common.js b/common.js index d3c9dc2..4c58cdf 100644 --- a/common.js +++ b/common.js @@ -4,6 +4,7 @@ import { convertWeekdaysToNumber, createPackageEnd, md5Encrypt, + removeTrailingZeros, timestampToArray, uint8ArrayToString } from './format' @@ -787,9 +788,9 @@ export async function parsingCharacteristicValue(binaryData) { 176 + decrypted[174] + decrypted[175 + decrypted[174]] ) ), - featureSettingParams: Array.from( + featureSettingParams: removeTrailingZeros(Array.from( decrypted.slice(176 + decrypted[174] + decrypted[175 + decrypted[174]]) - ), + )), lockConfig }) console.log('获取锁状态成功', this.lockInfo.lockConfig) diff --git a/env.js b/env.js index 2417b42..92cdae2 100644 --- a/env.js +++ b/env.js @@ -1,7 +1,7 @@ // uni版本号 -export const uniVersion = '1.0.3' +export const uniVersion = '1.0.4' // uni构建号 -export const uniBuildNumber = 4 +export const uniBuildNumber = 5 // web版本号 export const webVersion = '1.0.1' diff --git a/format.js b/format.js index b5afceb..008ca87 100644 --- a/format.js +++ b/format.js @@ -77,3 +77,14 @@ export function uint8ArrayToString(uint8Array) { } return str } + +// 去除特征值尾部0 +export function removeTrailingZeros(data) { + const featureCount = data[0] + let currentIndex = 1 + for (let i = 0; i < featureCount; i++) { + const length = data[currentIndex + 1] + currentIndex += 2 + length + } + return data.slice(0, currentIndex) +} diff --git a/package.json b/package.json index 13dd336..e15156b 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "star-cloud-uni", - "version": "1.0.3", + "version": "1.0.4", "type": "module", - "main": "./web/index.js", + "main": "./uni/index.js", "author": "zzc059", "scripts": { "web-build": "node obfuscate-web.js", diff --git a/uni.md b/uni.md index 64d0b75..23b0ef0 100644 --- a/uni.md +++ b/uni.md @@ -607,3 +607,73 @@ removeBadLock(params) **返回** 无 + + +# 电表 + +## 更新电表信息 + +**调用方法** + +```javascript +import { refreshElecInfo } from 'star-cloud-web' + +refreshElecInfo(params) +``` + +**入参** + +| 参数名称 | 数据类型 | 必须 | 描述 | +|--------|--------|----|-------| +| uid | Number | N | 用户uid | +| elecId | Number | Y | 电表ID | + +**返回** +无 + + +# 冷水表 + +## 更新冷水表信息 + +**调用方法** + +```javascript +import { refreshColdWaterInfo } from 'star-cloud-web' + +refreshColdWaterInfo(params) +``` + +**入参** + +| 参数名称 | 数据类型 | 必须 | 描述 | +|---------|--------|----|-------| +| uid | Number | N | 用户uid | +| waterId | Number | Y | 冷水表ID | + +**返回** +无 + + + +# 热水表 + +## 更新热水表信息 + +**调用方法** + +```javascript +import { refreshHotWaterInfo } from 'star-cloud-web' + +refreshHotWaterInfo(params) +``` + +**入参** + +| 参数名称 | 数据类型 | 必须 | 描述 | +|---------|--------|----|-------| +| uid | Number | N | 用户uid | +| waterId | Number | Y | 热水表ID | + +**返回** +无 diff --git a/uni/index.js b/uni/index.js index 5ba159d..185df89 100644 --- a/uni/index.js +++ b/uni/index.js @@ -228,3 +228,37 @@ export const getServerTime = async () => { export const getLockSupportFeatures = async params => { return await starCloudInstance.getLockSupportFeatures(params) } + +/** + * 电表-刷新电表信息 + * @param params + * @param {Number} [params.uid] 用户ID + * @param {Number} params.elecId 用户ID + * @returns Result + */ +export const refreshElecInfo = async params => { + return await starCloudInstance.refreshElecInfo(params) +} + +/** + * 冷水表-刷新水表信息 + * @param params + * @param {Number} [params.uid] 用户ID + * @param {Number} params.waterId 冷水表ID + * @returns Result + */ +export const refreshColdWaterInfo = async params => { + return await starCloudInstance.refreshColdWaterInfo(params) +} + + +/** + * 热水表-刷新水表信息 + * @param params + * @param {Number} [params.uid] 用户ID + * @param {Number} params.waterId 热水表ID + * @returns Result + */ +export const refreshHotWaterInfo = async params => { + return await starCloudInstance.refreshHotWaterInfo(params) +}