feat: 1. 添加获取锁支持项方法 2. 获取离线密码入参添加 lockId
This commit is contained in:
parent
d1914a3eff
commit
cc84733f9a
@ -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({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
list: [],
|
list: [],
|
||||||
@ -7,9 +7,9 @@ Page({
|
|||||||
},
|
},
|
||||||
async onLoad () {
|
async onLoad () {
|
||||||
init({
|
init({
|
||||||
clientId: 'wWdVGYOHGD2Xj3TIl8v7DfeIgnnCZ6K8',
|
clientId: 'Tmj4XoB9dkXjD7t7OHKHl564rJdmvPm9',
|
||||||
clientSecret: '8TmY144P9uf0A1FDykeebEwzCJh3o0qh',
|
clientSecret: 'g1VvSbN0Ya3IqPkA8j9Xn54PE1L8zGiy',
|
||||||
env: 'XHJ',
|
env: 'SKY',
|
||||||
isReportLog: true
|
isReportLog: true
|
||||||
})
|
})
|
||||||
const result = await register()
|
const result = await register()
|
||||||
@ -19,9 +19,11 @@ Page({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 搜索设备
|
||||||
searchDevice() {
|
searchDevice() {
|
||||||
searchDevice(this.searchDeviceCallback)
|
searchDevice(this.searchDeviceCallback)
|
||||||
},
|
},
|
||||||
|
// 搜索设备回调
|
||||||
searchDeviceCallback(result) {
|
searchDeviceCallback(result) {
|
||||||
if(result.code === Result.Success.code) {
|
if(result.code === Result.Success.code) {
|
||||||
this.setData({
|
this.setData({
|
||||||
@ -29,6 +31,7 @@ Page({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 绑定设备
|
||||||
bindDevice(e) {
|
bindDevice(e) {
|
||||||
const { device } = e.currentTarget.dataset
|
const { device } = e.currentTarget.dataset
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
@ -54,6 +57,7 @@ Page({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 开门
|
||||||
async openDoor () {
|
async openDoor () {
|
||||||
await selectLock({
|
await selectLock({
|
||||||
accountInfo: this.data.accountInfo,
|
accountInfo: this.data.accountInfo,
|
||||||
@ -72,6 +76,7 @@ Page({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 删除锁
|
||||||
async deleteLock () {
|
async deleteLock () {
|
||||||
await selectLock({
|
await selectLock({
|
||||||
accountInfo: this.data.accountInfo,
|
accountInfo: this.data.accountInfo,
|
||||||
@ -90,5 +95,30 @@ Page({
|
|||||||
icon: 'none',
|
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)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5,4 +5,6 @@
|
|||||||
</view>
|
</view>
|
||||||
<button wx:if="{{lock}}" bind:tap="openDoor">开门</button>
|
<button wx:if="{{lock}}" bind:tap="openDoor">开门</button>
|
||||||
<button wx:if="{{lock}}" bind:tap="deleteLock">删除设备</button>
|
<button wx:if="{{lock}}" bind:tap="deleteLock">删除设备</button>
|
||||||
|
<button wx:if="{{lock}}" bind:tap="getLockSupportFeatures">获取锁支持项</button>
|
||||||
|
<button wx:if="{{lock}}" bind:tap="getOfflinePassword">获取锁离线密码</button>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@ -133,5 +133,13 @@ module.exports = {
|
|||||||
async getServerTime() {
|
async getServerTime() {
|
||||||
const starCloud = getStarCloudStore()
|
const starCloud = getStarCloudStore()
|
||||||
return await starCloud.getServerTimestamp()
|
return await starCloud.getServerTimestamp()
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 获取锁支持的功能
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
async getLockSupportFeatures (params) {
|
||||||
|
const starCloud = getStarCloudStore()
|
||||||
|
return await starCloud.getLockSupportFeatures(params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user