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)
}
}