diff --git a/api/setting.js b/api/setting.js
index 4a6dfda..2eeb2c3 100644
--- a/api/setting.js
+++ b/api/setting.js
@@ -5,7 +5,52 @@ import request from '../utils/request'
// 获取锁设置
export function getLockSettingRequest(data) {
return request({
- url: '/lockSetting/getLockSetting',
+ url: '/lock/getLockSettingData',
+ method: 'POST',
+ data
+ })
+}
+
+// 更新锁名称
+export function updateLockNameRequest(data) {
+ return request({
+ url: '/lock/updateLockName',
+ method: 'POST',
+ data
+ })
+}
+
+// 修改管理员密码
+export function updateAdminPasswordRequest(data) {
+ return request({
+ url: '/room/modifyPwd',
+ method: 'POST',
+ data
+ })
+}
+
+// 获取分组列表
+export function getGroupListRequest(data) {
+ return request({
+ url: '/authorizedAdmin/listGroup',
+ method: 'POST',
+ data
+ })
+}
+
+// 创建分组
+export function createGroupRequest(data) {
+ return request({
+ url: '/keyGroup/add',
+ method: 'POST',
+ data
+ })
+}
+
+// 设置分组
+export function setGroupRequest(data) {
+ return request({
+ url: '/keyGroup/setGroup',
method: 'POST',
data
})
diff --git a/pages.json b/pages.json
index 2232296..4dbaf30 100644
--- a/pages.json
+++ b/pages.json
@@ -337,6 +337,27 @@
"navigationBarTitleText": "修改有效期",
"disableScroll": true
}
+ },
+ {
+ "path": "pages/lockInfo/lockInfo",
+ "style": {
+ "navigationBarTitleText": "基本信息",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/syncElec/syncElec",
+ "style": {
+ "navigationBarTitleText": "电量",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/selectGroup/selectGroup",
+ "style": {
+ "navigationBarTitleText": "选择分组",
+ "disableScroll": true
+ }
}
],
"globalStyle": {
diff --git a/pages/lockInfo/lockInfo.vue b/pages/lockInfo/lockInfo.vue
new file mode 100644
index 0000000..662ed1f
--- /dev/null
+++ b/pages/lockInfo/lockInfo.vue
@@ -0,0 +1,269 @@
+
+
+
+ 锁编号
+ {{ $bluetooth.currentLockSetting.lockBasicInfo.lockName }}
+
+
+ MAC/ID
+ {{ $bluetooth.currentLockSetting.lockBasicInfo.mac }}/{{
+ $bluetooth.currentLockSetting.lockBasicInfo.lockId
+ }}
+
+
+ 电量
+
+ {{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantity }}%
+
+
+
+
+ 有效期
+
+ {{ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.startDate, 'yyyy-mm-dd') }}~{{
+ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.endDate, 'yyyy-mm-dd')
+ }}
+
+ {{
+ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.startDate, 'yyyy-mm-dd h:M')
+ }}
+ {{
+ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.endDate, 'yyyy-mm-dd h:M')
+ }}
+
+ 单次
+ 永久
+
+
+
+ 有效日
+
+ {{
+ $lock.convertWeekDaysToChineseString($bluetooth.currentLockSetting.lockBasicInfo.weekDays)
+ }}
+
+
+
+ 有效时间
+
+ {{ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.startDate, 'h:M') }}~{{
+ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.endDate, 'h:M')
+ }}
+
+
+ $refs.modalInput.open()"
+ >
+ 名称
+
+ {{
+ $bluetooth.currentLockSetting.lockBasicInfo.lockAlias
+ }}
+
+
+
+
+ 锁分组
+
+ {{
+ $bluetooth.currentLockSetting.lockBasicInfo.groupName
+ }}
+
+
+
+ $refs.modalPassword.open()"
+ >
+ 管理员开锁密码
+
+ {{ $bluetooth.currentLockSetting.lockBasicInfo.adminPwd }}
+
+
+
+
+ 位置信息
+
+ {{ $bluetooth.currentLockSetting.lockBasicInfo.address }}
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/selectGroup/selectGroup.vue b/pages/selectGroup/selectGroup.vue
new file mode 100644
index 0000000..71364b3
--- /dev/null
+++ b/pages/selectGroup/selectGroup.vue
@@ -0,0 +1,140 @@
+
+
+
+
+
+ {{ item.keyGroupName }}
+
+
+
+
+
+
+ $refs.modalInput.open()"
+ class="bg-#63b8af text-white pos-fixed bottom-[calc(env(safe-area-inset-bottom)+48rpx)] rounded-44rpx w-686 ml-4 h-88 line-height-88rpx text-lg font-bold text-center"
+ >创建新分组
+
+
+
+
+
+
+
diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue
index a97ba60..1b8d259 100644
--- a/pages/setting/setting.vue
+++ b/pages/setting/setting.vue
@@ -1,98 +1,153 @@
-
-
-
- 名称
-
- {{
- currentLockInfo.lockAlias
- }}
-
-
-
-
- 锁编号
-
- {{ currentLockInfo.name }}
-
-
-
-
- MAC/ID
-
- {{ currentLockInfo.mac }}/{{ currentLockInfo.lockId }}
-
-
-
-
- 电量
-
- {{ currentLockInfo.electricQuantity }}%
+
+
+ 基本信息
+
+
+
+ 自动闭锁
+
+
+ {{
+ $bluetooth.currentLockSetting.lockSettingInfo.autoLock === 1
+ ? $bluetooth.currentLockSetting.lockSettingInfo.autoLockSecond + 's'
+ : '已关闭'
+ }}
+
-
-
- 开锁时是否需联网
-
-
+
+ 锁声音
+
+
+ {{
+ $bluetooth.currentLockSetting.lockSettingInfo.lockSound === 1
+ ? volumeList[$bluetooth.currentLockSetting.lockSettingInfo.lockSoundVolume - 1]
+ : '已关闭'
+ }}
+
-
-
-
- 有效期
-
- {{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd') }}~{{
- timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd')
- }}
-
-
-
-
- 有效日
-
- {{ convertWeekDaysToChineseString(currentLockInfo.weekDays) }}
-
-
-
-
- 有效时间
-
- {{ timeFormat(currentLockInfo.startDate, 'h:M') }}~{{
- timeFormat(currentLockInfo.endDate, 'h:M')
- }}
-
-
-
-
-
- 有效期
-
-
- {{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd h:M') }}
- {{ timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd h:M') }}
-
- 单次
- 永久
-
+
+ 防撬报警
+
+
+ {{
+ $bluetooth.currentLockSetting.lockSettingInfo.antiPrySwitch === 1 ? '已开启' : '已关闭'
+ }}
+
- 删除
+
+ 远程开锁
+
+
+ {{
+ $bluetooth.currentLockSetting.lockSettingInfo.remoteUnlock === 1 ? '已开启' : '已关闭'
+ }}
+
+
+
+
+
+ 重置键
+
+
+ {{
+ $bluetooth.currentLockSetting.lockSettingInfo.resetSwitch === 1 ? '已开启' : '已关闭'
+ }}
+
+
+
+
+
+ 面容开锁
+
+
+
+ 消息提醒
+
+
+
+ 考勤
+
+
+
+ 开锁提醒
+
+
+
+ 开锁时是否需联网
+
+
+
+ 锁时间
+
+
+
+ 上传数据
+
+
+
+ 锁升级
+
+
+ 删除
-
@@ -300,61 +335,3 @@
background-color: $uni-bg-color-grey;
}
-
-
diff --git a/pages/syncElec/syncElec.vue b/pages/syncElec/syncElec.vue
new file mode 100644
index 0000000..64b44ca
--- /dev/null
+++ b/pages/syncElec/syncElec.vue
@@ -0,0 +1,108 @@
+
+
+
+ 电量信息可以通过网关远程更新,或通过手机蓝牙在锁旁边更新
+ 电池1电量:{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantity }}%
+ 电池2电量:{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantityStandby }}%
+
+ 电量更新时间:{{
+ timeFormat(
+ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantityDate,
+ 'yyyy-mm-dd h:M'
+ )
+ }}
+
+ 更新
+
+
+
+
+
diff --git a/stores/basic.js b/stores/basic.js
index c6b3f23..1f4e064 100644
--- a/stores/basic.js
+++ b/stores/basic.js
@@ -251,6 +251,21 @@ const pages = [
name: 'temporaryDate',
path: '/pages/temporaryDate/temporaryDate',
tabBar: false
+ },
+ {
+ name: 'lockInfo',
+ path: '/pages/lockInfo/lockInfo',
+ tabBar: false
+ },
+ {
+ name: 'syncElec',
+ path: '/pages/syncElec/syncElec',
+ tabBar: false
+ },
+ {
+ name: 'selectGroup',
+ path: '/pages/selectGroup/selectGroup',
+ tabBar: false
}
]
diff --git a/stores/bluetooth.js b/stores/bluetooth.js
index 1b1d313..a4dc7e0 100644
--- a/stores/bluetooth.js
+++ b/stores/bluetooth.js
@@ -84,7 +84,9 @@ const subCmdIds = {
// 注册掌纹取消
registerPalmVeinCancel: 44,
// 同步操作记录
- syncRecord: 41
+ syncRecord: 41,
+ // 更新管理员密码
+ updateAdminPassword: 2
}
export const useBluetoothStore = defineStore('ble', {
@@ -103,6 +105,8 @@ export const useBluetoothStore = defineStore('ble', {
deviceList: [],
// 当前锁信息
currentLockInfo: {},
+ // 当前锁设置信息
+ currentLockSetting: null,
// 消息序号
messageCount: 1,
// 是否初始化蓝牙
@@ -354,11 +358,16 @@ export const useBluetoothStore = defineStore('ble', {
),
lockConfig
})
+ characteristicValueCallback({
+ code: decrypted[2],
+ data: { lockConfig }
+ })
console.log('获取锁状态成功', that.currentLockInfo.lockConfig)
+ } else {
+ characteristicValueCallback({
+ code: decrypted[2]
+ })
}
- characteristicValueCallback({
- code: decrypted[2]
- })
break
case cmdIds.addUser:
that.updateCurrentLockInfo({
@@ -505,6 +514,15 @@ export const useBluetoothStore = defineStore('ble', {
characteristicValueCallback({ code: decrypted[2] })
}
break
+ case subCmdIds.updateAdminPassword:
+ that.updateCurrentLockInfo({
+ ...that.currentLockInfo,
+ token: decrypted.slice(5, 9)
+ })
+ characteristicValueCallback({
+ code: decrypted[2]
+ })
+ break
default:
break
}
@@ -512,7 +530,9 @@ export const useBluetoothStore = defineStore('ble', {
case cmdIds.openDoor:
that.updateCurrentLockInfo({
...that.currentLockInfo,
- token: decrypted.slice(2, 6)
+ token: decrypted.slice(2, 6),
+ electricQuantity: decrypted[7],
+ electricQuantityStandby: decrypted[9]
})
console.log('开门', decrypted[6], that.currentLockInfo.token)
log.info({
@@ -884,6 +904,11 @@ export const useBluetoothStore = defineStore('ble', {
console.log('更新当前锁信息', lockInfo)
this.currentLockInfo = lockInfo
},
+ // 更新当前锁设置信息
+ updateCurrentLockSetting(lockSetting) {
+ console.log('更新当前锁设置信息', lockSetting)
+ this.currentLockSetting = lockSetting
+ },
// 订阅设备特征值改变
notifyBluetoothCharacteristicValueChange() {
const that = this
@@ -2612,6 +2637,102 @@ export const useBluetoothStore = defineStore('ble', {
await this.writeBLECharacteristicValue(packageArray)
return this.getWriteResult(this.syncSingleRecord, data)
+ },
+ // 更新管理员密码
+ async updateAdminPassword(data) {
+ // 确认蓝牙状态正常
+ if (this.bluetoothStatus !== 0) {
+ console.log('写入未执行', this.bluetoothStatus)
+ this.getBluetoothStatus()
+ return {
+ code: -1
+ }
+ }
+
+ // 确认设备连接正常
+ if (!this.currentLockInfo.connected) {
+ const searchResult = await this.searchAndConnectDevice()
+ if (searchResult.code !== 0) {
+ return searchResult
+ }
+ this.updateCurrentLockInfo({
+ ...this.currentLockInfo,
+ deviceId: searchResult.data.deviceId
+ })
+ console.log('设备ID:', this.currentLockInfo.deviceId)
+ const result = await this.connectBluetoothDevice()
+ console.log('连接结果', result)
+ if (!result) {
+ return {
+ code: -1
+ }
+ }
+ }
+
+ // 检查是否已添加为用户
+ const checkResult = await this.checkLockUser()
+ if (!checkResult) {
+ return {
+ code: -1
+ }
+ }
+
+ let { keyId, uid, adminPwd, userCountLimit, startDate, endDate } = data
+
+ const length = 2 + 1 + 1 + 40 + 20 + 2 + 20 + 2 + 4 + 4 + 4 + 1 + 16
+ const headArray = this.createPackageHeader(3, length)
+ const contentArray = new Uint8Array(length)
+
+ contentArray[0] = cmdIds.expandCmd / 256
+ contentArray[1] = cmdIds.expandCmd % 256
+
+ contentArray[2] = subCmdIds.updateAdminPassword
+
+ contentArray[3] = length - 3
+
+ for (let i = 0; i < keyId.length; i++) {
+ contentArray[i + 4] = keyId.charCodeAt(i)
+ }
+
+ for (let i = 0; i < uid.length; i++) {
+ contentArray[i + 44] = uid.charCodeAt(i)
+ }
+
+ contentArray[64] = 1 / 256
+ contentArray[65] = 1 % 256
+
+ for (let i = 0; i < adminPwd.length; i++) {
+ contentArray[i + 66] = adminPwd.charCodeAt(i)
+ }
+
+ contentArray[86] = (userCountLimit || 0xffff) / 256
+ contentArray[87] = (userCountLimit || 0xffff) % 256
+
+ contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 88)
+
+ contentArray.set(this.timestampToArray(startDate), 92)
+ contentArray.set(this.timestampToArray(endDate), 96)
+
+ contentArray[100] = 16
+
+ const md5Array = this.md5Encrypte(
+ keyId + uid,
+ this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
+ this.currentLockInfo.signKey
+ )
+
+ contentArray.set(md5Array, 101)
+
+ const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
+ mode: 'ecb',
+ output: 'array'
+ })
+
+ const packageArray = this.createPackageEnd(headArray, cebArray)
+
+ await this.writeBLECharacteristicValue(packageArray)
+
+ return this.getWriteResult(this.updateAdminPassword, data)
}
}
})