From cc84733f9abcbbb54cef39276d20cae8c5771bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Mon, 9 Dec 2024 13:48:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201.=20=E6=B7=BB=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=94=81=E6=94=AF=E6=8C=81=E9=A1=B9=E6=96=B9=E6=B3=95?= =?UTF-8?q?=202.=20=E8=8E=B7=E5=8F=96=E7=A6=BB=E7=BA=BF=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=85=A5=E5=8F=82=E6=B7=BB=E5=8A=A0=20lockId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/miniprogram/pages/index/index.js | 40 ++++++++++++++++--- .../miniprogram/pages/index/index.wxml | 2 + src/index.js | 8 ++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/miniprogram/miniprogram/pages/index/index.js b/miniprogram/miniprogram/pages/index/index.js index 75bc19f..8e426d0 100644 --- a/miniprogram/miniprogram/pages/index/index.js +++ b/miniprogram/miniprogram/pages/index/index.js @@ -1,4 +1,4 @@ -const { init, Result, searchDevice, bindDevice, register, openDoor, deleteLock, stopSearchDevice, selectLock } = requirePlugin('starCloud') +const { init, Result, searchDevice, bindDevice, register, openDoor, deleteLock, stopSearchDevice, selectLock, getLockSupportFeatures, getOfflinePassword } = requirePlugin('starCloud') Page({ data: { list: [], @@ -7,9 +7,9 @@ Page({ }, async onLoad () { init({ - clientId: 'wWdVGYOHGD2Xj3TIl8v7DfeIgnnCZ6K8', - clientSecret: '8TmY144P9uf0A1FDykeebEwzCJh3o0qh', - env: 'XHJ', + clientId: 'Tmj4XoB9dkXjD7t7OHKHl564rJdmvPm9', + clientSecret: 'g1VvSbN0Ya3IqPkA8j9Xn54PE1L8zGiy', + env: 'SKY', isReportLog: true }) const result = await register() @@ -19,9 +19,11 @@ Page({ }) } }, + // 搜索设备 searchDevice() { searchDevice(this.searchDeviceCallback) }, + // 搜索设备回调 searchDeviceCallback(result) { if(result.code === Result.Success.code) { this.setData({ @@ -29,6 +31,7 @@ Page({ }) } }, + // 绑定设备 bindDevice(e) { const { device } = e.currentTarget.dataset wx.showModal({ @@ -54,6 +57,7 @@ Page({ } }) }, + // 开门 async openDoor () { await selectLock({ accountInfo: this.data.accountInfo, @@ -72,6 +76,7 @@ Page({ }) } }, + // 删除锁 async deleteLock () { await selectLock({ accountInfo: this.data.accountInfo, @@ -90,5 +95,30 @@ Page({ icon: 'none', }) } - } + }, + // 获取锁支持项 + async getLockSupportFeatures() { + const result = await getLockSupportFeatures({ + accountInfo: this.data.accountInfo, + lockId: this.data.lock.lockId + }) + console.log('锁支持项',result) + }, + // 获取锁离线密码 + async getOfflinePassword() { + const result = await getOfflinePassword({ + accountInfo: this.data.accountInfo, + password: { + lockId: this.data.lock.lockId, + keyboardPwdName: `单次密码${new Date().getTime()}`, + keyboardPwdType: 1, + isCoerced: 2, + startDate: 0, + endDate: 0, + hoursStart: 0, + hoursEnd: 0, + } + }) + console.log('锁离线密码',result) + }, }) diff --git a/miniprogram/miniprogram/pages/index/index.wxml b/miniprogram/miniprogram/pages/index/index.wxml index 2477c81..b60c3dd 100644 --- a/miniprogram/miniprogram/pages/index/index.wxml +++ b/miniprogram/miniprogram/pages/index/index.wxml @@ -5,4 +5,6 @@ + + diff --git a/src/index.js b/src/index.js index 4941906..7c16f33 100644 --- a/src/index.js +++ b/src/index.js @@ -133,5 +133,13 @@ module.exports = { async getServerTime() { const starCloud = getStarCloudStore() return await starCloud.getServerTimestamp() + }, + /** + * 获取锁支持的功能 + * @returns Result + */ + async getLockSupportFeatures (params) { + const starCloud = getStarCloudStore() + return await starCloud.getLockSupportFeatures(params) } }