Merge branch 'fanpeng' into 'develop'
Fanpeng See merge request StarlockTeam/starcloud-sdk-miniprogram!1
This commit is contained in:
commit
3799c16c64
4
.gitignore
vendored
4
.gitignore
vendored
@ -18,4 +18,6 @@ dist
|
|||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
|
miniprogram/plugin
|
||||||
|
|||||||
@ -1,15 +1,585 @@
|
|||||||
# 插件文档标题
|
# 说明
|
||||||
|
星云SDK是一款专为微信小程序开发者打造的智能锁插件,旨在简化与智能锁与星云平台的交互。通过封装底层操作,使接入者无需关注锁的操作逻辑,能够将更多精力集中在业务开发中。
|
||||||
|
|
||||||
## 二级标题
|
# 版本
|
||||||
|
当前最新版本 1.1.0
|
||||||
|
|
||||||
### 三级标题
|
# 引用
|
||||||
|
APPID: **wxf2c491f734bbf82f**
|
||||||
|
1. 登录小程序后台-选择设置->第三方设置->插件管理->点击“添加插件”->搜索对应APPID->添加插件->等待审核通过
|
||||||
|
2. 项目中引用需在app.json文件中添加
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"starCloud": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"provider": "wxf2c491f734bbf82f"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
3. 页面中引用
|
||||||
|
```javascript
|
||||||
|
// 引用插件
|
||||||
|
const plugin = requirePlugin('starCloud')
|
||||||
|
```
|
||||||
|
|
||||||
这个文件用于书写插件文档,引用图片时必须以**相对路径**引用 ***doc*** 目录下的本地图片,不能使用网络图片或非 ***doc*** 目录下的图片。以下是相对路径的引用示例:
|
# 公共参数
|
||||||
|
|
||||||

|
## Result 方法的统一返回结构
|
||||||
|
|
||||||
使用编辑器下方的上传按钮可以上传插件文档,上传的内容包括 doc 目录下的 README.md 和图片。
|
```javascript
|
||||||
|
// Result 类是所有有返回结果的方法,统一的返回结构
|
||||||
|
const { Result } = requirePlugin('starCloud')
|
||||||
|
// code对应报错码有三部分组合构成,锁端报错码+星云服务端报错码+自定义报错码
|
||||||
|
const { code, data, message } = Result.Success
|
||||||
|
// 常用判断方式
|
||||||
|
if (code === Result.Success.code) {
|
||||||
|
// 逻辑代码
|
||||||
|
} else {
|
||||||
|
// 错误处理
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|code|变量名|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|0|Success|成功|
|
||||||
|
|-1|Fail|失败|
|
||||||
|
|-10|NotMoreData|没有更多数据|
|
||||||
|
|-20|NotAvailableBluetooth|蓝牙尚未打开,请先打开蓝牙|
|
||||||
|
|-21|NotAvailableBluetoothPermission|小程序蓝牙功能被禁用,请打开小程序蓝牙权限|
|
||||||
|
|-22|NotAvailableWeChatNearbyDevicesPermission|蓝牙功能需要附近设备权限,请前往设置开启微信的附近设备权限后再试|
|
||||||
|
|-23|NotAvailableWeChatLocationPermission|蓝牙功能需要定位权限,请前往设置开启微信的定位权限后再试|
|
||||||
|
|-24|NotAvailableWeChatNearbyDevicesEmpty|蓝牙功能需要定位服务,请前往设置开启定位服务后再试|
|
||||||
|
|-25|NotAvailableWeChatBluetoothPermission|微信的蓝牙权限被禁用,请前往设置开启微信的蓝牙权限后再试|
|
||||||
|
|-30|DeviceHasBeenReset|设备已被重置|
|
||||||
|
|251|ReadyHasPassword|该密码已存在|
|
||||||
|
|
||||||
|
## AccountInfo 账号信息
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|uid|Number|用户uid|
|
||||||
|
|username|String|用户名|
|
||||||
|
|password|String|密码|
|
||||||
|
|
||||||
|
## LockInfo 锁信息
|
||||||
|
|
||||||
|
| 名称 | 类型 | 描述 |
|
||||||
|
|---------------------------|--------|----------------------------|
|
||||||
|
| deviceId | String | 设备 ID |
|
||||||
|
| serviceId | String | 服务 ID |
|
||||||
|
| notifyCharacteristicId | String | 通知特征值 ID |
|
||||||
|
| writeCharacteristicId | String | 写入特征值 ID |
|
||||||
|
| pwdTimestamp | Number | 密码时间戳(毫秒) |
|
||||||
|
| featureValue | String | 功能值 |
|
||||||
|
| featureSettingValue | String | 功能设置值 |
|
||||||
|
| featureSettingParams | Array.\<Number> | 功能设置参数 |
|
||||||
|
| lockUserNo | Number | 锁用户编号 |
|
||||||
|
| lockId | Number | 锁 ID |
|
||||||
|
| keyId | Number | 钥匙 ID |
|
||||||
|
| adminPwd | String | 管理密码 |
|
||||||
|
| bluetooth | Bluetooth | 蓝牙信息 |
|
||||||
|
| lockConfig | LockConfig | 锁配置信息 |
|
||||||
|
|
||||||
|
## Bluetooth 蓝牙信息
|
||||||
|
|
||||||
|
| 名称 | 类型 | 描述 |
|
||||||
|
|------------------------|--------|----------------|
|
||||||
|
| bluetoothDeviceId | String | 蓝牙设备 ID |
|
||||||
|
| bluetoothDeviceName | String | 蓝牙设备名称 |
|
||||||
|
| publicKey | Array.\<Number> | 公钥 |
|
||||||
|
| privateKey | Array.\<Number> | 私钥 |
|
||||||
|
| signKey | Array.\<Number> | 签名密钥 |
|
||||||
|
|
||||||
|
## LockConfig 锁配置信息
|
||||||
|
|
||||||
|
| 名称 | 类型 | 描述 |
|
||||||
|
|-----------------------|--------|----------------------------|
|
||||||
|
| vendor | String | 厂商 |
|
||||||
|
| product | Number | 产品号 |
|
||||||
|
| model | String | 型号 |
|
||||||
|
| fwVersion | String | 固件版本 |
|
||||||
|
| hwVersion | String | 硬件版本 |
|
||||||
|
| serialNum0 | String | 序列号 0 |
|
||||||
|
| serialNum1 | String | 序列号 1 |
|
||||||
|
| btDeviceName | String | 蓝牙设备名称 |
|
||||||
|
| electricQuantity | Number | 电量 |
|
||||||
|
| electricQuantityStandby | Number | 备用电量 |
|
||||||
|
| restoreCount | Number | 重置次数 |
|
||||||
|
| restoreDate | Number | 重置日期(时间戳秒) |
|
||||||
|
| icPartNo | String | 芯片型号 |
|
||||||
|
| indate | Number | 入网日期(时间戳秒) |
|
||||||
|
| mac | String | MAC 地址 |
|
||||||
|
| timezoneOffset | Number | 时区偏移(秒) |
|
||||||
|
|
||||||
|
|
||||||
|
# 初始化
|
||||||
|
|
||||||
|
## 初始化星云
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 初始化星云
|
||||||
|
*/
|
||||||
|
plugin.init(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|clientId|String|客户端Id|
|
||||||
|
|clientSecret|String|客户端密码|
|
||||||
|
|env|String|环境(SKY,XHJ)|
|
||||||
|
|isReportLog|Boolean|是否上报日志|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
# 用户
|
||||||
|
|
||||||
|
## 注册
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 注册
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.register()
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
无
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|username|String|用户名|
|
||||||
|
|password|String|密码|
|
||||||
|
|uid|Number|用户uid|
|
||||||
|
|
||||||
|
|
||||||
|
## 退出登录
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 退出登录
|
||||||
|
* @param params
|
||||||
|
* @param {int} params.uid 用户uid
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.logout(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|uid|Number|用户uid|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
# 设备
|
||||||
|
|
||||||
|
## 搜索设备
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 搜索蓝牙设备
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
plugin.searchDevice(callback)
|
||||||
|
const callback = async result => {
|
||||||
|
if(result.code === Result.Success.code) {
|
||||||
|
this.setData({
|
||||||
|
list: result.data.list
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
callback 回调方法
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|deviceId|String|蓝牙设备 id|
|
||||||
|
|RSSI|Number|当前蓝牙设备的信号强度,单位 dBm|
|
||||||
|
|connectable|Boolean|当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 )|
|
||||||
|
|advertisData|ArrayBuffer|当前蓝牙设备的广播数据段中的 ManufacturerData 数据段|
|
||||||
|
|advertisServiceUUIDs|Array.\<string\>|当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段|
|
||||||
|
|localName|String|当前蓝牙设备的广播数据段中的 LocalName 数据段|
|
||||||
|
|name|String|蓝牙设备名称,某些设备可能没有|
|
||||||
|
|
||||||
|
## 停止搜索设备
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 停止搜索
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await stopSearchDevice()
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
无
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
## 绑定设备
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 绑定设备
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {String} params.name 设备名称
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.bindDevice(params)
|
||||||
|
if(result.code === Result.Success.code) {
|
||||||
|
this.setData({
|
||||||
|
lock: result.data.lock
|
||||||
|
})
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|name|String|设备名称|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|lock|LockInfo|锁信息|
|
||||||
|
|
||||||
|
|
||||||
|
# 锁基本功能
|
||||||
|
## 选择锁(对锁进行操作前调用)
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 选择锁
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {Number} params.lockId 锁ID
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.selectLock(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|lockId|Number|锁ID|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
## 开关门
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 开门
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {String} params.type 开门方式 close: 关门 open: 开门
|
||||||
|
* @param {Boolean} params.disconnect 操作后是否断开连接
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.openDoor(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|type|String|开门方式|
|
||||||
|
|disconnect|Boolean|操作后是否断开连接|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
## 删除锁
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 删除锁
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.deleteLock(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
## 获取锁支持功能
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 获取锁支持项
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {Number} params.lockId 锁 Id
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.getLockSupportFeatures(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|lockId|Number|锁 Id|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
|
||||||
|
以下所有功能字段0代表不支持,1代表支持
|
||||||
|
|
||||||
|
| 名称 | 类型 | 描述 |
|
||||||
|
|---------------------------|--------|----------------------------|
|
||||||
|
| password | Number | 是否支持密码 |
|
||||||
|
| icCard | Number | 是否支持 IC 卡 |
|
||||||
|
| fingerprint | Number | 是否支持指纹 |
|
||||||
|
| fingerVein | Number | 是否支持指静脉 |
|
||||||
|
| palmVein | Number | 是否支持掌静脉 |
|
||||||
|
| d3Face | Number | 是否支持 3D 人脸 |
|
||||||
|
| qrCode | Number | 是否支持二维码 |
|
||||||
|
| bluetoothRemoteControl | Number | 是否支持蓝牙遥控器 |
|
||||||
|
| wirelessKey | Number | 是否支持无线钥匙 |
|
||||||
|
| gatewayUnlock | Number | 是否支持网关开锁 |
|
||||||
|
| lockCommand | Number | 是否支持闭锁指令 |
|
||||||
|
| firmwareUpgrade | Number | 是否支持固件升级设置指令 |
|
||||||
|
| passwordIssue | Number | 是否支持密码下发 |
|
||||||
|
| cardIssue | Number | 是否支持卡片下发 |
|
||||||
|
| fingerprintIssue | Number | 是否支持指纹下发 |
|
||||||
|
| fingerVeinIssue | Number | 是否支持指静脉下发 |
|
||||||
|
| palmVeinIssue | Number | 是否支持掌静脉下发 |
|
||||||
|
| d3FaceIssue | Number | 是否支持 3D 人脸下发 |
|
||||||
|
| lockFreeze | Number | 是否支持冻结/解冻锁 |
|
||||||
|
| readAdminPassword | Number | 是否支持读取管理员密码 |
|
||||||
|
| passwordManagement | Number | 是否支持密码管理功能 |
|
||||||
|
| passwordWithDelete | Number | 是否支持密码带删除功能 |
|
||||||
|
| remoteUnlock | Number | 是否支持配置远程开锁 |
|
||||||
|
| autoLock | Number | 是否支持自动闭锁设置 |
|
||||||
|
| antiPrySwitch | Number | 是否支持防撬开关配置 |
|
||||||
|
| resetSwitch | Number | 是否支持重置键配置 |
|
||||||
|
| lockSwitch | Number | 是否支持反锁功能配置 |
|
||||||
|
| lockSound | Number | 是否支持语音提示管理 |
|
||||||
|
| languageSetting | Number | 是否支持语言设置 |
|
||||||
|
| realTimeClock | Number | 是否支持实时时钟 |
|
||||||
|
| wifi | Number | 是否支持 WIFI |
|
||||||
|
| videoIntercom | Number | 是否支持可视对讲 |
|
||||||
|
| cyclePassword | Number | 是否支持循环密码 |
|
||||||
|
| cycleFingerprintCard | Number | 是否支持循环指纹/卡 |
|
||||||
|
| doubleAuthentication | Number | 是否支持双重认证 |
|
||||||
|
| openDirection | Number | 是否支持开门方向设置 |
|
||||||
|
| proximitySensing | Number | 是否支持接近感应 |
|
||||||
|
| doorStatus | Number | 是否支持门磁状态 |
|
||||||
|
| wiredDoorMagnet | Number | 是否支持有线门磁 |
|
||||||
|
| wirelessDoorMagnet | Number | 是否支持无线门磁 |
|
||||||
|
| doorNotClosedAlarm | Number | 是否支持门未关报警 |
|
||||||
|
| unlockReminder | Number | 是否支持开锁提醒 |
|
||||||
|
| wirelessKeyboard | Number | 是否支持无线键盘 |
|
||||||
|
| lightingTime | Number | 是否支持照明灯时间配置 |
|
||||||
|
| passageMode | Number | 是否支持常开模式 |
|
||||||
|
| hotelLockCardSystem | Number | 是否支持酒店锁卡系统 |
|
||||||
|
| appUnlockOnline | Number | 是否支持 APP 开锁需联网 |
|
||||||
|
| bluetoothBroadcast | Number | 是否支持蓝牙广播 |
|
||||||
|
| attendance | Number | 是否支持考勤 |
|
||||||
|
| motorTorsion | Number | 是否支持电机扭力 |
|
||||||
|
| stayWarn | Number | 是否支持逗留警告 |
|
||||||
|
| abnormalWarn | Number | 是否支持异常警告 |
|
||||||
|
| isSupportIris | Number | 是否支持虹膜识别 |
|
||||||
|
| isSupportCatEye | Number | 是否支持猫眼 |
|
||||||
|
| deviceEnMultiLanguage | Number | 是否支持设备支持的多国语言 |
|
||||||
|
| isNoSupportedBlueBroadcast | Number | 是否不支持蓝牙广播 |
|
||||||
|
| isSupportAutoLight | Number | 是否支持自动亮屏 |
|
||||||
|
| isSupportBackupBattery | Number | 是否支持备用电池 |
|
||||||
|
| isSupportForcedOpen | Number | 是否支持胁迫开门 |
|
||||||
|
| isSupportOpen | Number | 是否支持开门器开锁 |
|
||||||
|
| isSupportPush | Number | 是否支持推送 |
|
||||||
|
| offlinePasswordEncryption | Number | 是否支持密码算法 |
|
||||||
|
| offlinePasswordNumMax | Number | 是否支持离线密码最大个数 |
|
||||||
|
|
||||||
|
# 密码
|
||||||
|
## 获取离线密码
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 获取离线密码
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {OfflinePassword} params.password 密码信息
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.getOfflinePassword(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
OfflinePassword 密码信息
|
||||||
|
|
||||||
|
| 属性 | 类型 | 描述 |
|
||||||
|
|-------------------|----------|-------------------|
|
||||||
|
| lockId | Number | 锁 Id |
|
||||||
|
| keyboardPwdName | String | 密码名称 |
|
||||||
|
| keyboardPwdType | Number | 密码类型 |
|
||||||
|
| isCoerced | Number | 是否胁迫模式 1:胁迫 2:非胁迫 |
|
||||||
|
| startDate | Number | 开始日期时间戳(毫秒,永久默认为0) |
|
||||||
|
| endDate | Number | 结束日期时间戳(毫秒,永久默认为0) |
|
||||||
|
| hoursStart | Number | 开始时间(小时, 不需要时传0) |
|
||||||
|
| hoursEnd | Number | 结束时间(小时, 不需要时传0) |
|
||||||
|
|
||||||
|
keyboardPwdType 密码类型
|
||||||
|
| 状态 | 状态说明 |
|
||||||
|
|------|---------------|
|
||||||
|
| 1 | 单次 |
|
||||||
|
| 2 | 永久 |
|
||||||
|
| 3 | 限时 |
|
||||||
|
| 4 | 删除 |
|
||||||
|
| 5 | 周末循环 |
|
||||||
|
| 6 | 每日循环 |
|
||||||
|
| 7 | 工作日循环 |
|
||||||
|
| 8 | 周一循环 |
|
||||||
|
| 9 | 周二循环 |
|
||||||
|
| 10 | 周三循环 |
|
||||||
|
| 11 | 周四循环 |
|
||||||
|
| 12 | 周五循环 |
|
||||||
|
| 13 | 周六循环 |
|
||||||
|
| 14 | 周天循环 |
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
|
||||||
|
| 属性 | 类型 | 描述 |
|
||||||
|
|-------------------|----------|-------------------|
|
||||||
|
| keyboardPwd | Number | 密码 |
|
||||||
|
| keyboardPwdId | Number | 密码 |
|
||||||
|
|
||||||
|
|
||||||
|
## 修改超级管理员密码
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 修改管理员密码
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {String} params.adminPwd 管理员密码
|
||||||
|
* @param {Boolean} params.disconnect 操作后是否断开连接
|
||||||
|
* @returns {Promise<Result>}
|
||||||
|
*/
|
||||||
|
const result = await plugin.updateAdminPassword(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
| 属性 | 类型 | 描述 |
|
||||||
|
|-------------------|----------|-------------------|
|
||||||
|
| accountInfo | AccountInfo | 账号信息 |
|
||||||
|
| adminPwd | String | 管理员密码 |
|
||||||
|
| disconnect | Boolean | 操作后是否断开连接 |
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
# 记录
|
||||||
|
## 同步开门记录
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 同步全部开门记录
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {Boolean} params.disconnect 操作后是否断开连接
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.syncOpenDoorRecord()
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|disconnect|Boolean|操作后是否断开连接|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|
||||||
|
# 其他
|
||||||
|
## 获取服务器时间
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 获取服务器时间
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.getServerTime()
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
无
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|date|Number|时间戳(毫秒)|
|
||||||
|
|
||||||
|
## 移除坏锁
|
||||||
|
|
||||||
|
1. 调用方法
|
||||||
|
```javascript
|
||||||
|
/**
|
||||||
|
* 移除坏锁
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {List[int]} params.lockIds 锁Id列表
|
||||||
|
* @returns Result
|
||||||
|
*/
|
||||||
|
const result = await plugin.removeBadLock(params)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 入参
|
||||||
|
|
||||||
|
|名称|类型|描述|
|
||||||
|
| -- | -- | -- |
|
||||||
|
|accountInfo|AccountInfo|账号信息|
|
||||||
|
|lockIds|Array.\<Nmuber\>|锁Id列表|
|
||||||
|
|
||||||
|
3. 返回
|
||||||
|
无
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.1 KiB |
@ -1,11 +1,124 @@
|
|||||||
// const plugin = requirePlugin('starCloud')
|
const { init, Result, searchDevice, bindDevice, register, openDoor, deleteLock, stopSearchDevice, selectLock, getLockSupportFeatures, getOfflinePassword } = requirePlugin('starCloud')
|
||||||
Page({
|
Page({
|
||||||
onLoad() {
|
data: {
|
||||||
// plugin.initStarCloud({
|
list: [],
|
||||||
// clientId: 'clientId',
|
accountInfo: {},
|
||||||
// clientSecret: 'clientSecret',
|
lock: null
|
||||||
// env: 'env',
|
},
|
||||||
// isReportLog: true
|
async onLoad () {
|
||||||
// })
|
init({
|
||||||
}
|
clientId: 'Tmj4XoB9dkXjD7t7OHKHl564rJdmvPm9',
|
||||||
|
clientSecret: 'g1VvSbN0Ya3IqPkA8j9Xn54PE1L8zGiy',
|
||||||
|
env: 'SKY',
|
||||||
|
isReportLog: true
|
||||||
|
})
|
||||||
|
const result = await register()
|
||||||
|
if(result.code === Result.Success.code) {
|
||||||
|
this.setData({
|
||||||
|
accountInfo: result.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 搜索设备
|
||||||
|
searchDevice() {
|
||||||
|
searchDevice(this.searchDeviceCallback)
|
||||||
|
},
|
||||||
|
// 搜索设备回调
|
||||||
|
searchDeviceCallback(result) {
|
||||||
|
if(result.code === Result.Success.code) {
|
||||||
|
this.setData({
|
||||||
|
list: result.data.list
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 绑定设备
|
||||||
|
bindDevice(e) {
|
||||||
|
const { device } = e.currentTarget.dataset
|
||||||
|
wx.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定绑定${device.name}吗?`,
|
||||||
|
success: async (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
const result = await bindDevice({
|
||||||
|
accountInfo: this.data.accountInfo,
|
||||||
|
name: device.name,
|
||||||
|
})
|
||||||
|
if(result.code === Result.Success.code) {
|
||||||
|
stopSearchDevice()
|
||||||
|
this.setData({
|
||||||
|
lock: result.data.lock
|
||||||
|
})
|
||||||
|
wx.showToast({
|
||||||
|
title: '绑定成功',
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 开门
|
||||||
|
async openDoor () {
|
||||||
|
await selectLock({
|
||||||
|
accountInfo: this.data.accountInfo,
|
||||||
|
lockId: this.data.lock.lockId
|
||||||
|
})
|
||||||
|
const result = await openDoor({
|
||||||
|
accountInfo: this.data.accountInfo,
|
||||||
|
disconnect: true,
|
||||||
|
type: 'open'
|
||||||
|
})
|
||||||
|
console.log('开门结果',result)
|
||||||
|
if (result.code === Result.Success.code) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '开门成功',
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 删除锁
|
||||||
|
async deleteLock () {
|
||||||
|
await selectLock({
|
||||||
|
accountInfo: this.data.accountInfo,
|
||||||
|
lockId: this.data.lock.lockId
|
||||||
|
})
|
||||||
|
const result = await deleteLock({
|
||||||
|
accountInfo: this.data.accountInfo,
|
||||||
|
})
|
||||||
|
console.log('删除结果',result)
|
||||||
|
if (result.code === Result.Success.code) {
|
||||||
|
this.setData({
|
||||||
|
lock: null
|
||||||
|
})
|
||||||
|
wx.showToast({
|
||||||
|
title: '删除成功',
|
||||||
|
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)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1 +1,10 @@
|
|||||||
<view></view>
|
<view>
|
||||||
|
<button bind:tap="searchDevice">搜索设备</button>
|
||||||
|
<view wx:for="{{list}}" wx:for-item="device" class="device" bind:tap="bindDevice" data-device="{{device}}">
|
||||||
|
{{device.name}}
|
||||||
|
</view>
|
||||||
|
<button wx:if="{{lock}}" bind:tap="openDoor">开门</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>
|
||||||
|
|||||||
@ -1,12 +1,5 @@
|
|||||||
/* pages/index/index.wxss */
|
.device {
|
||||||
#nav {
|
padding: 32rpx;
|
||||||
text-align: center;
|
margin: 32rpx;
|
||||||
background: #eeeeee;
|
border: #2c405a 1px solid;
|
||||||
margin: 1em;
|
|
||||||
padding: 1em;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#add {
|
|
||||||
margin: 1em;
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./common/vendor.js");Math;const n={onLaunch:function(){console.log("App Launch")},onShow:function(){console.log("App Show")},onHide:function(){console.log("App Hide")}};function e(){const e=o.createSSRApp(n),t=o.createPinia();return e.use(t),{app:e}}e().app.mount("#app"),exports.createApp=e;
|
|
||||||
@ -1 +0,0 @@
|
|||||||
page::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(https://cdn1.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn1.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn1.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn1.dcloud.net.cn/img/shadow-grey.png)}}page{--status-bar-height:25px;--top-window-height:0px;--window-top:0px;--window-bottom:0px;--window-left:0px;--window-right:0px;--window-magin:0px}[data-c-h="true"]{display: none !important;}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
"use strict";exports._imports_0="/static/logo.png";
|
|
||||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./common/vendor.js"),t=require("./starCloud/starCloud.js"),r=e.createPinia();function o(){return t.useStarCloudStore(r)}module.exports={initStarCloud(e){o().initStarCloud(e)},async register(){const e=o();return await e.register()},logout:async e=>o().logout(e),async selectLock(e){const t=o();return await t.selectLock(e)},async openDoor(e){const t=o();return await t.openDoor(e)},async getOfflinePassword(e){const t=o();return await t.getOfflinePassword(e)},async customPassword(e){const t=o();return await t.customPassword(e)},async searchDevice(e){const t=o();return await t.searchDevice(e)},async stopSearchDevice(){const e=o();return await e.stopSearchDevice()},async bindDevice(e){const t=o();return await t.bindDevice(e)},async removeBadLock(e){const t=o();return await t.removeBadLock(e)},async deleteLock(e){const t=o();return await t.deleteLock(e)},async updateAdminPassword(e){const t=o();return await t.updateAdminPassword(e)},async syncOpenDoorRecord(e){const t=o();return await t.syncAllOpenRecord(e)},async getServerTime(){const e=o();return await e.getServerTimestamp()}},exports.getStarCloudStore=o;
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
require('../../app.js');
|
|
||||||
"use strict";const e=require("../../common/vendor.js"),t=require("../../common/assets.js"),o={data:()=>({title:"Hello"}),onLoad(){},methods:{}};const r=e._export_sfc(o,[["render",function(o,r,s,n,c,a){return{a:t._imports_0,b:e.t(c.title)}}]]);wx.createPage(r);
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"navigationBarTitleText": "uni-app",
|
|
||||||
"usingComponents": {}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
<view class="content"><image class="logo" src="{{a}}"></image><view class="text-area"><text class="title">{{b}}</text></view></view>
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
@import "../../app.wxss";
|
|
||||||
.content{display:flex;flex-direction:column;align-items:center;justify-content:center}.logo{height:200rpx;width:200rpx;margin-top:200rpx;margin-left:auto;margin-right:auto;margin-bottom:50rpx}.text-area{display:flex;justify-content:center}.title{font-size:36rpx;color:#8f8f94}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"main": "index.js"
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
"use strict";const e=require("./request.js");exports.addCustomPasswordRequest=function(t){return e.request({url:"/v1/keyboardPwd/add",method:"POST",data:t})},exports.bindLockRequest=function(t){return e.request({url:"/v1/lock/initialize",method:"POST",data:t})},exports.changeAdminKeyboardPwdRequest=function(t){return e.request({url:"/v1/lock/changeAdminKeyboardPwd",method:"POST",data:t})},exports.deleteLockRequest=function(t){return e.request({url:"/v1/lock/delete",method:"POST",data:t})},exports.deletePasswordRequest=function(t){return e.request({url:"/v1/keyboardPwd/delete",method:"POST",data:t})},exports.getLastRecordTimeRequest=function(t){return e.request({url:"/v1/lockRecord/getLastRecordTime",method:"POST",data:t})},exports.getLockDetailRequest=function(t){return e.request({url:"/v1/lock/detail",method:"POST",data:t})},exports.getLockNetTokenRequest=function(t){return e.request({url:"/v1/lock/getLockNetToken",method:"POST",data:t})},exports.getOfflinePasswordRequest=function(t){return e.request({url:"/v1/keyboardPwd/get",method:"POST",data:t})},exports.getServerDatetimeRequest=function(t){return e.request({url:"/v1/lock/queryDate",method:"POST",data:t})},exports.getStarCloudToken=function(t){return e.request({url:"/oauth2/token",method:"POST",data:t})},exports.getUserNoListRequest=function(t){return e.request({url:"/v1/key/getUserNoList",method:"POST",data:t})},exports.removeBadLockRequest=function(t){return e.request({url:"/v1/lock/removeBadLock",method:"POST",data:t})},exports.starCloudCreateUser=function(t){return e.request({url:"/createUser",method:"POST",data:t})},exports.updateElectricQuantityRequest=function(t){return e.request({url:"/v1/lock/updateElectricQuantity",method:"POST",data:t})},exports.updateLockUserNoRequest=function(t){return e.request({url:"/v1/key/updateLockUserNo",method:"POST",data:t})},exports.updatePasswordRequest=function(t){return e.request({url:"/v1/keyboardPwd/update",method:"POST",data:t})},exports.uploadRecordRequest=function(t){return e.request({url:"/v1/lockRecord/upload",method:"POST",data:t})};
|
|
||||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
"use strict";exports.buildNumber=1,exports.configs={DEV:{name:"DEV",baseUrl:"https://dev.cloud.star-lock.cn/sdk"},PRE:{name:"PRE",baseUrl:"https://pre.cloud.star-lock.cn/sdk"},PRE_SKY:{name:"PRE_SKY",baseUrl:"https://pre.cloud.star-lock.cn/sdk"},XHJ:{name:"XHJ",baseUrl:"https://cloud.xhjcn.ltd/sdk"},SKY:{name:"SKY",baseUrl:"https://cloud.skychip.top/sdk"}},exports.version="1.0.0";
|
|
||||||
@ -1 +0,0 @@
|
|||||||
"use strict";const t=require("../common/vendor.js");exports.arrayToTimestamp=function(t){return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0},exports.convertWeekdaysToNumber=function(t){let e="00000000";for(const r of t){const t=r%7;e=e.substring(0,t)+"1"+e.substring(t+1)}return e=e.split("").reverse().join(""),parseInt(e,2)},exports.createPackageEnd=function(e,r){let n=new Uint8Array(e.length+r.length);n.set(e),n.set(r,e.length);const o=t.crc.crc16kermit(n);let s=new Uint8Array(n.length+2);return s.set(n),s.set([o/256,o%256],n.length),s},exports.md5Encrypt=function(e,r,n){const o=e.length+4+16,s=new Uint8Array(o);for(let t=0;t<e.length;t++)s[t]=e.charCodeAt(t);s.set(r,e.length),s.set(n,e.length+4);const c=t.md5Exports.md5(s);return new Uint8Array(c.match(/.{1,2}/g).map((t=>parseInt(t,16))))},exports.timestampToArray=function(t){const e=new Uint8Array(4);return e[0]=(4278190080&t)>>24,e[1]=(16711680&t)>>16,e[2]=(65280&t)>>8,e[3]=255&t,e},exports.uint8ArrayToString=function(t){let e="";for(let r=0;r<t.length;r++)0!==t[r]&&(e+=String.fromCharCode(t[r]));return e};
|
|
||||||
@ -1 +0,0 @@
|
|||||||
"use strict";const r=require("../common/vendor.js"),e=require("./starCloud.js"),t=r.wx$1.getRealtimeLogManager?r.wx$1.getRealtimeLogManager():null,o={debug(){if(!t)return;e.useStarCloudStore().isReportLog&&t.debug.apply(t,arguments)},info(){if(!t)return;e.useStarCloudStore().isReportLog&&t.info.apply(t,arguments)},warn(){if(!t)return;e.useStarCloudStore().isReportLog&&t.warn.apply(t,arguments)},error(){if(!t)return;e.useStarCloudStore().isReportLog&&t.error.apply(t,arguments)},setFilterMsg(r){if(!t||!t.setFilterMsg)return;if("string"!=typeof r)return;e.useStarCloudStore().isReportLog&&t.setFilterMsg(r)},addFilterMsg(r){if(!t||!t.addFilterMsg)return;if("string"!=typeof r)return;e.useStarCloudStore().isReportLog&&t.addFilterMsg(r)}};exports.log=o;
|
|
||||||
@ -1 +0,0 @@
|
|||||||
"use strict";const e=require("../common/vendor.js"),o=require("./storage.js"),t=require("./starCloud.js"),s=require("./basic.js"),a=r=>{const l=t.useStarCloudStore();let n;return new Promise((async t=>{const u=l.getConfig(),d=(null==r?void 0:r.token)?r.token:o.getStorage("starCloudToken"),i=r.baseUrl?r.baseUrl+r.url:u.baseUrl+r.url,c={...{version:u.version+"+"+u.buildNumber},...r.header},m=r.method||"POST",g={...r.data,accessToken:d,clientId:l.clientId},v=(new Date).getTime();n=setTimeout((()=>{t(new s.Result(s.Result.Fail.code,{},"网络访问失败,请检查网络是否正常"))}),3200),e.index.request({url:i,method:m,header:c,data:g,timeout:3e3,async success(e){const{statusCode:u,data:d}=e;if(n&&clearTimeout(n),200===u){const e=d.errcode,n=d.errmsg;if(10003===e){o.removeStorage("starCloudToken"),o.removeStorage("starCloudUser");const{code:e}=await l.login({username:l.starCloudAccountInfo.username,password:l.starCloudAccountInfo.password,uid:l.starCloudAccountInfo.uid});e===s.Result.Success.code&&t(await a(r))}else t({code:e,data:d.data,message:n})}else t(new s.Result(s.Result.Fail.code,{},"网络访问失败,请检查网络是否正常"))},async fail(e){console.log("网络访问失败",e),n&&clearTimeout(n),t(new s.Result(s.Result.Fail.code,{},"网络访问失败,请检查网络是否正常"))},async complete(e){var o,t,s;console.log(i.substring(u.baseUrl.length+1),{env:u.name,url:i.substring(u.baseUrl.length+1),req:(null==r?void 0:r.data)||{},code:null==(o=null==e?void 0:e.data)?void 0:o.errcode,res:null==(t=null==e?void 0:e.data)?void 0:t.data,token:(null==c?void 0:c.authorization)||"",message:null==(s=null==e?void 0:e.data)?void 0:s.errmsg,duration:(new Date).getTime()-v})}})}))};exports.request=a;
|
|
||||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
"use strict";const e=require("../common/vendor.js"),r=require("./starCloud.js");function t(){return`${r.useStarCloudStore().envVersion}:`}exports.getStorage=function(r){return e.index.getStorageSync(t()+r)},exports.removeStorage=function(r){return e.index.removeStorageSync(t()+r)},exports.setStorage=function(r,n){return e.index.setStorageSync(t()+r,n)};
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB |
12
src/index.js
12
src/index.js
@ -1,5 +1,6 @@
|
|||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import { useStarCloudStore } from './starCloud/starCloud'
|
import { useStarCloudStore } from './starCloud/starCloud'
|
||||||
|
import { Result } from './starCloud/basic'
|
||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ export function getStarCloudStore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Result,
|
||||||
/**
|
/**
|
||||||
* 初始化星云
|
* 初始化星云
|
||||||
* @param params
|
* @param params
|
||||||
@ -16,7 +18,7 @@ module.exports = {
|
|||||||
* @param {String} params.env 环境
|
* @param {String} params.env 环境
|
||||||
* @param {Boolean} params.isReportLog 是否上报日志
|
* @param {Boolean} params.isReportLog 是否上报日志
|
||||||
*/
|
*/
|
||||||
initStarCloud(params) {
|
init(params) {
|
||||||
const starCloud = getStarCloudStore()
|
const starCloud = getStarCloudStore()
|
||||||
starCloud.initStarCloud(params)
|
starCloud.initStarCloud(params)
|
||||||
},
|
},
|
||||||
@ -131,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -166,4 +166,13 @@ const data = await $starCloud.syncAllOpenRecord(params)
|
|||||||
* @returns {Promise<Result>}
|
* @returns {Promise<Result>}
|
||||||
*/
|
*/
|
||||||
const data = await $starCloud.getServerTimestamp()
|
const data = await $starCloud.getServerTimestamp()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取锁支持项
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {Number} params.lockId 锁 Id
|
||||||
|
* @returns {Promise<Result>}
|
||||||
|
*/
|
||||||
|
const data = await $starCloud.getLockSupportFeatures(params)
|
||||||
```
|
```
|
||||||
|
|||||||
@ -161,3 +161,12 @@ export function uploadRecordRequest(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取锁应用设置
|
||||||
|
export function getLockSettingDataRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/v1/lock/getLockSettingData',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -7,44 +7,44 @@ export default {
|
|||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.debug.apply(log, arguments)
|
logger.info(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
info() {
|
info() {
|
||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.info.apply(log, arguments)
|
logger.info(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
warn() {
|
warn() {
|
||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.warn.apply(log, arguments)
|
logger.warn(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
error() {
|
error() {
|
||||||
if (!log) return
|
if (!log) return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
// eslint-disable-next-line prefer-spread,prefer-rest-params
|
const logger = log.tag(arguments[0].name)
|
||||||
log.error.apply(log, arguments)
|
logger.error(arguments[0].message, arguments[0])
|
||||||
},
|
},
|
||||||
setFilterMsg(msg) {
|
setFilterMsg(msg) {
|
||||||
// 从基础库2.7.3开始支持
|
|
||||||
if (!log || !log.setFilterMsg) return
|
if (!log || !log.setFilterMsg) return
|
||||||
if (typeof msg !== 'string') return
|
if (typeof msg !== 'string') return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
log.setFilterMsg(msg)
|
const logger = log.tag(arguments[0].name)
|
||||||
|
logger.setFilterMsg(JSON.stringify(arguments[0]))
|
||||||
},
|
},
|
||||||
addFilterMsg(msg) {
|
addFilterMsg(msg) {
|
||||||
// 从基础库2.8.1开始支持
|
|
||||||
if (!log || !log.addFilterMsg) return
|
if (!log || !log.addFilterMsg) return
|
||||||
if (typeof msg !== 'string') return
|
if (typeof msg !== 'string') return
|
||||||
const $starCloud = useStarCloudStore()
|
const $starCloud = useStarCloudStore()
|
||||||
if (!$starCloud.isReportLog) return
|
if (!$starCloud.isReportLog) return
|
||||||
log.addFilterMsg(msg)
|
const logger = log.tag(arguments[0].name)
|
||||||
|
logger.addFilterMsg(JSON.stringify(arguments[0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import {
|
|||||||
getLastRecordTimeRequest,
|
getLastRecordTimeRequest,
|
||||||
getLockDetailRequest,
|
getLockDetailRequest,
|
||||||
getLockNetTokenRequest,
|
getLockNetTokenRequest,
|
||||||
|
getLockSettingDataRequest,
|
||||||
getOfflinePasswordRequest,
|
getOfflinePasswordRequest,
|
||||||
getServerDatetimeRequest,
|
getServerDatetimeRequest,
|
||||||
getStarCloudToken,
|
getStarCloudToken,
|
||||||
@ -51,6 +52,7 @@ import log from '@/starCloud/log'
|
|||||||
* @typedef {Object} OfflinePassword
|
* @typedef {Object} OfflinePassword
|
||||||
* @property {String} keyboardPwdName - 密码名称
|
* @property {String} keyboardPwdName - 密码名称
|
||||||
* @property {Number} keyboardPwdType - 密码类型
|
* @property {Number} keyboardPwdType - 密码类型
|
||||||
|
* @property {Number} lockId - 锁 Id
|
||||||
* @property {Number} isCoerced - 胁迫 1:胁迫 2:非胁迫
|
* @property {Number} isCoerced - 胁迫 1:胁迫 2:非胁迫
|
||||||
* @property {Number} startDate - 开始时间
|
* @property {Number} startDate - 开始时间
|
||||||
* @property {Number} endDate - 结束时间
|
* @property {Number} endDate - 结束时间
|
||||||
@ -295,7 +297,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
lockList[accountInfo.uid] = [this.lockInfo]
|
lockList[accountInfo.uid] = [this.lockInfo]
|
||||||
setStorage('starLockList', lockList)
|
setStorage('starLockList', lockList)
|
||||||
}
|
}
|
||||||
} else {
|
} else if (code === Result.Fail.code) {
|
||||||
const lockList = getStorage('starLockList')
|
const lockList = getStorage('starLockList')
|
||||||
if (lockList[accountInfo.uid]) {
|
if (lockList[accountInfo.uid]) {
|
||||||
const index = lockList[accountInfo.uid].findIndex(item => item.lockId === lockId)
|
const index = lockList[accountInfo.uid].findIndex(item => item.lockId === lockId)
|
||||||
@ -318,8 +320,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
async openDoor(params) {
|
async openDoor(params) {
|
||||||
const { accountInfo, type } = params
|
const { accountInfo, type } = params
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
Result.Success.code,
|
Result.Success.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -328,8 +330,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`开始开门`
|
`开始开门`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 设置执行账号
|
// 设置执行账号
|
||||||
const result = await this.login(accountInfo)
|
const result = await this.login(accountInfo)
|
||||||
@ -337,8 +340,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
result.code,
|
result.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -347,16 +350,17 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`登录星云账号: ${result.message}`
|
`登录星云账号: ${result.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 确认设备连接正常
|
// 确认设备连接正常
|
||||||
if (!params.connected) {
|
if (!params.connected) {
|
||||||
const searchResult = await searchAndConnectDevice(
|
const searchResult = await searchAndConnectDevice(
|
||||||
this.lockInfo.bluetooth.bluetoothDeviceName
|
this.lockInfo.bluetooth.bluetoothDeviceName
|
||||||
)
|
)
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
searchResult.code,
|
searchResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -365,8 +369,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`连接设备: ${searchResult.message}`
|
`连接设备: ${searchResult.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
if (searchResult.code !== Result.Success.code) {
|
if (searchResult.code !== Result.Success.code) {
|
||||||
return searchResult
|
return searchResult
|
||||||
}
|
}
|
||||||
@ -379,8 +384,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return checkResult
|
return checkResult
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
checkResult.code,
|
checkResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -389,8 +394,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`确认是否为锁用户: ${checkResult.message}`
|
`确认是否为锁用户: ${checkResult.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 是否需要联网
|
// 是否需要联网
|
||||||
let onlineToken = ''
|
let onlineToken = ''
|
||||||
@ -403,8 +409,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
checkResult.code,
|
checkResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -413,8 +419,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`判断是否需要联网token: ${this.lockInfo.lockSetting.appUnlockOnline}`
|
`判断是否需要联网token: ${this.lockInfo.lockSetting.appUnlockOnline}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
// 开门方式
|
// 开门方式
|
||||||
let openMode
|
let openMode
|
||||||
@ -472,8 +479,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
|
|
||||||
const packageArray = createPackageEnd(headArray, cebArray)
|
const packageArray = createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
Result.Success.code,
|
Result.Success.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -482,8 +489,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`开始写入`
|
`开始写入`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
const writeResult = await writeBLECharacteristicValue(
|
const writeResult = await writeBLECharacteristicValue(
|
||||||
this.lockInfo.deviceId,
|
this.lockInfo.deviceId,
|
||||||
@ -496,8 +504,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return writeResult
|
return writeResult
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
writeResult.code,
|
writeResult.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -506,8 +514,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`写入完成:${writeResult.message}`
|
`写入完成:${writeResult.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
|
|
||||||
return this.getWriteResult(this.openDoor, params)
|
return this.getWriteResult(this.openDoor, params)
|
||||||
},
|
},
|
||||||
@ -525,10 +534,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
if (result.code !== Result.Success.code) {
|
if (result.code !== Result.Success.code) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
return await getOfflinePasswordRequest({
|
return await getOfflinePasswordRequest(password)
|
||||||
...password,
|
|
||||||
lockId: this.lockInfo.lockId
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 自定义密码
|
* 自定义密码
|
||||||
@ -1157,6 +1163,32 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
return new Result(code, data, message)
|
return new Result(code, data, message)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取锁支持项
|
||||||
|
* @param params
|
||||||
|
* @param {AccountInfo} params.accountInfo 账号信息
|
||||||
|
* @param {Number} params.lockId 锁 Id
|
||||||
|
* @returns {Promise<Result>}
|
||||||
|
*/
|
||||||
|
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<Result>}
|
* @returns {Promise<Result>}
|
||||||
@ -1570,8 +1602,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
characteristicValueCallback = async data => {
|
characteristicValueCallback = async data => {
|
||||||
// code 6 token过期,重新获取
|
// code 6 token过期,重新获取
|
||||||
if (data.code === Result.NotTokenLock.code) {
|
if (data.code === Result.NotTokenLock.code) {
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
data.code,
|
data.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -1579,8 +1611,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`token过期:${data.message}`
|
`token过期:${data.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
resolve(await request({ ...params, connected: true }))
|
resolve(await request({ ...params, connected: true }))
|
||||||
} else if (data.code === Result.NotRegisteredLock.code) {
|
} else if (data.code === Result.NotRegisteredLock.code) {
|
||||||
const checkResult = await this.checkLockUser(true)
|
const checkResult = await this.checkLockUser(true)
|
||||||
@ -1596,8 +1629,8 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
await this.disconnectDevice()
|
await this.disconnectDevice()
|
||||||
}
|
}
|
||||||
console.log('写入结果', data, request, params)
|
console.log('写入结果', data, request, params)
|
||||||
log.info(
|
log.info({
|
||||||
new Result(
|
...new Result(
|
||||||
data.code,
|
data.code,
|
||||||
{
|
{
|
||||||
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
lockName: this.lockInfo.bluetooth.bluetoothDeviceName,
|
||||||
@ -1605,8 +1638,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
time: new Date().getTime()
|
time: new Date().getTime()
|
||||||
},
|
},
|
||||||
`开门结果:${data.message}`
|
`开门结果:${data.message}`
|
||||||
)
|
),
|
||||||
)
|
name: 'openDoor'
|
||||||
|
})
|
||||||
resolve(data)
|
resolve(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1834,9 +1868,9 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
lockId: this.lockInfo.lockId
|
lockId: this.lockInfo.lockId
|
||||||
})
|
})
|
||||||
return characteristicValueCallback(new Result(result.code))
|
return characteristicValueCallback(new Result(result.code))
|
||||||
|
} else {
|
||||||
|
characteristicValueCallback(new Result(decrypted[2]))
|
||||||
}
|
}
|
||||||
characteristicValueCallback(new Result(decrypted[2]))
|
|
||||||
|
|
||||||
break
|
break
|
||||||
case subCmdIds.resetLockPassword:
|
case subCmdIds.resetLockPassword:
|
||||||
this.updateLockInfo({
|
this.updateLockInfo({
|
||||||
@ -1914,7 +1948,7 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
user: decrypted[8 + 17 * i] * 256 + decrypted[9 + 17 * i],
|
user: decrypted[8 + 17 * i] * 256 + decrypted[9 + 17 * i],
|
||||||
date: arrayToTimestamp(decrypted.slice(10 + 17 * i, 14 + 17 * i)) * 1000,
|
date: arrayToTimestamp(decrypted.slice(10 + 17 * i, 14 + 17 * i)) * 1000,
|
||||||
success: 1,
|
success: 1,
|
||||||
password
|
password: password
|
||||||
}
|
}
|
||||||
records.push(record)
|
records.push(record)
|
||||||
}
|
}
|
||||||
@ -1954,6 +1988,21 @@ export const useStarCloudStore = defineStore('starCloud', {
|
|||||||
}
|
}
|
||||||
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
||||||
break
|
break
|
||||||
|
case cmdIds.resetDevice:
|
||||||
|
this.updateLockInfo({
|
||||||
|
token: decrypted.slice(2, 6),
|
||||||
|
electricQuantity: decrypted[7],
|
||||||
|
electricQuantityStandby: decrypted[9]
|
||||||
|
})
|
||||||
|
if (decrypted[6] === Result.Success.code) {
|
||||||
|
updateElectricQuantityRequest({
|
||||||
|
lockId: this.lockInfo.lockId,
|
||||||
|
electricQuantity: decrypted[7],
|
||||||
|
electricQuantityStandby: decrypted[9]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
characteristicValueCallback(new Result(decrypted[6], { lock: this.lockInfo }))
|
||||||
|
break
|
||||||
case cmdIds.resetDevice:
|
case cmdIds.resetDevice:
|
||||||
this.updateLockInfo({
|
this.updateLockInfo({
|
||||||
token: decrypted.slice(2, 6)
|
token: decrypted.slice(2, 6)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user