diff --git a/api/lockSetting.js b/api/lockSetting.js
deleted file mode 100644
index 3a04683..0000000
--- a/api/lockSetting.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import request from '../utils/request'
-
-// lockSetting 锁设置模块
-
-// 更新锁设置
-export function updateLockSettingRequest(data) {
- return request({
- url: '/lockSetting/updateLockSetting',
- method: 'POST',
- data
- })
-}
diff --git a/api/setting.js b/api/setting.js
index 4a6dfda..f8c8a62 100644
--- a/api/setting.js
+++ b/api/setting.js
@@ -5,7 +5,70 @@ import request from '../utils/request'
// 获取锁设置
export function getLockSettingRequest(data) {
return request({
- url: '/lockSetting/getLockSetting',
+ url: '/lock/getLockSettingData',
+ method: 'POST',
+ data
+ })
+}
+
+// 更新锁设置
+export function updateLockSettingRequest(data) {
+ return request({
+ url: '/lockSetting/updateLockSetting',
+ 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
+ })
+}
+
+// 上传锁数据
+export function lockDataUploadRequest(data) {
+ return request({
+ url: '/lockRecords/lockDataUpload',
method: 'POST',
data
})
diff --git a/manifest.json b/manifest.json
index 4228f74..20de3bb 100644
--- a/manifest.json
+++ b/manifest.json
@@ -2,8 +2,8 @@
"name" : "wx-starlock",
"appid" : "__UNI__933D519",
"description" : "",
- "versionName" : "1.1.3",
- "versionCode" : "30",
+ "versionName" : "1.2.0",
+ "versionCode" : "31",
"transformPx" : false,
/* 小程序特有相关 */
"mp-weixin" : {
diff --git a/pages.json b/pages.json
index 2232296..b5b8379 100644
--- a/pages.json
+++ b/pages.json
@@ -337,6 +337,69 @@
"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
+ }
+ },
+ {
+ "path": "pages/updateSetting/updateSetting",
+ "style": {
+ "navigationBarTitleText": "设置",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/lockSound/lockSound",
+ "style": {
+ "navigationBarTitleText": "锁声音",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/autoLock/autoLock",
+ "style": {
+ "navigationBarTitleText": "自动闭锁",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/faceSetting/faceSetting",
+ "style": {
+ "navigationBarTitleText": "面容开锁设置",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/lockDate/lockDate",
+ "style": {
+ "navigationBarTitleText": "锁时间",
+ "disableScroll": true
+ }
+ },
+ {
+ "path": "pages/uploadLockData/uploadLockData",
+ "style": {
+ "navigationBarTitleText": "上传数据",
+ "disableScroll": true
+ }
}
],
"globalStyle": {
diff --git a/pages/LockDate/LockDate.vue b/pages/LockDate/LockDate.vue
new file mode 100644
index 0000000..c427167
--- /dev/null
+++ b/pages/LockDate/LockDate.vue
@@ -0,0 +1,112 @@
+
+
+
+ {{
+ timeFormat($bluetooth.currentLockInfo.lockConfig.indate, 'yyyy-mm-dd hh:MM')
+ }}
+
+
+ 校准
+
+
+
+
+
+
+
diff --git a/pages/adminDetail/adminDetail.vue b/pages/adminDetail/adminDetail.vue
index 87506bf..f0bf2a0 100644
--- a/pages/adminDetail/adminDetail.vue
+++ b/pages/adminDetail/adminDetail.vue
@@ -4,7 +4,7 @@
$refs.modalInput.open()">
姓名
- {{ info.keyName }}
+ {{ info.keyName }}
@@ -88,7 +88,7 @@
{{
info.keyRight === 1
? '取消授权会在用户APP连网后生效'
- : '授权用户拥有管理员的大部分权限,比如发送要是、发送密码'
+ : '授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码'
}}
diff --git a/pages/autoLock/autoLock.vue b/pages/autoLock/autoLock.vue
new file mode 100644
index 0000000..36c5590
--- /dev/null
+++ b/pages/autoLock/autoLock.vue
@@ -0,0 +1,199 @@
+
+
+
+ 自动闭锁
+
+
+
+ 延迟时间
+
+ {{ custom ? '自定义' : value + 's' }}
+
+
+
+
+
+
+
+ 经过以上设定的时间,锁会自动关闭。开启或修改设置后,请先开一次锁,使时间生效。
+
+
+ 保存
+
+
+
+
+
+
+
+
diff --git a/pages/bindCard/bindCard.vue b/pages/bindCard/bindCard.vue
index cace36a..ad9b4ef 100644
--- a/pages/bindCard/bindCard.vue
+++ b/pages/bindCard/bindCard.vue
@@ -39,13 +39,6 @@
onLoad(async options => {
if (options.card) {
const params = JSON.parse(options.card)
- const { code } = await $bluetooth.registerAuthentication(params)
-
- if (code === 0) {
- text.value = '已连接到锁,请将卡靠近锁的读卡区'
- } else {
- $basic.backAndToast('操作失败,请重试')
- }
uni.$on('registerCardConfirm', async data => {
if (data.status === 0) {
@@ -67,27 +60,18 @@
})
if (code === 0) {
eventChannel.emit('refresherList', {})
- $basic.backAndToast('绑卡成功', 2)
+ $basic.backAndToast('添加成功', 2)
} else {
$basic.backAndToast(message)
}
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
- uni.showToast({
- title: '管理员已满',
- icon: 'none'
- })
+ $basic.backAndToast('管理员已满')
} else if (data.status === 0xfd) {
- uni.showToast({
- title: '用户已满',
- icon: 'none'
- })
+ $basic.backAndToast('用户已满')
} else if (data.status === 0xfc) {
- uni.showToast({
- title: '卡片已满',
- icon: 'none'
- })
+ $basic.backAndToast('卡片已满')
} else if (data.status === 0xfb) {
uni.showToast({
title: '卡片已存在',
@@ -95,6 +79,14 @@
})
}
})
+
+ const { code } = await $bluetooth.registerAuthentication(params)
+
+ if (code === 0) {
+ text.value = '已连接到锁,请将卡靠近锁的读卡区'
+ } else if (code === -21) {
+ $basic.backAndToast('请先打开蓝牙')
+ }
}
})
diff --git a/pages/bindFace/bindFace.vue b/pages/bindFace/bindFace.vue
index cd25ba4..6fa3055 100644
--- a/pages/bindFace/bindFace.vue
+++ b/pages/bindFace/bindFace.vue
@@ -76,20 +76,11 @@
if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
- uni.showToast({
- title: '管理员已满',
- icon: 'none'
- })
+ $basic.backAndToast('管理员已满')
} else if (data.status === 0xfd) {
- uni.showToast({
- title: '用户已满',
- icon: 'none'
- })
+ $basic.backAndToast('用户已满')
} else if (data.status === 0xfc) {
- uni.showToast({
- title: '人脸已满',
- icon: 'none'
- })
+ $basic.backAndToast('人脸已满')
} else if (data.status === 0xfb) {
uni.showToast({
title: '人脸已存在',
@@ -103,13 +94,16 @@
const ready = async () => {
showProcess.value = true
const { code } = await $bluetooth.registerAuthentication(params.value)
- if (code !== 0) {
- $basic.backAndToast('操作失败,请重试')
+ if (code === 0) {
+ /* empty */
+ } else if (code === -21) {
+ $basic.backAndToast('请先打开蓝牙')
}
}
onUnmounted(() => {
uni.$off('registerFaceConfirm')
+ uni.$off('registerFaceProcess')
if (!bindFlag.value) {
$bluetooth.registerAuthenticationCancel({
type: 'face',
diff --git a/pages/bindFingerprint/bindFingerprint.vue b/pages/bindFingerprint/bindFingerprint.vue
index fb20e38..567fe60 100644
--- a/pages/bindFingerprint/bindFingerprint.vue
+++ b/pages/bindFingerprint/bindFingerprint.vue
@@ -40,16 +40,6 @@
onLoad(async options => {
if (options.info) {
const params = JSON.parse(options.info)
- const { code, data } = await $bluetooth.registerAuthentication(params)
-
- if (code === 0) {
- text.value = '请将您的手指按下'
- maxProcess.value = data.maxProcess
- showProcess.value = true
- } else {
- $basic.backAndToast('操作失败,请重试')
- }
-
uni.$on('registerFingerprintConfirm', async data => {
if (data.status === 0) {
bindFlag.value = true
@@ -82,20 +72,11 @@
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
- uni.showToast({
- title: '管理员已满',
- icon: 'none'
- })
+ $basic.backAndToast('管理员已满')
} else if (data.status === 0xfd) {
- uni.showToast({
- title: '用户已满',
- icon: 'none'
- })
+ $basic.backAndToast('用户已满')
} else if (data.status === 0xfc) {
- uni.showToast({
- title: '指纹已满',
- icon: 'none'
- })
+ $basic.backAndToast('指纹已满')
} else if (data.status === 0xfb) {
uni.showToast({
title: '指纹已存在',
@@ -103,11 +84,21 @@
})
}
})
+ const { code, data } = await $bluetooth.registerAuthentication(params)
+
+ if (code === 0) {
+ text.value = '请将您的手指按下'
+ maxProcess.value = data.maxProcess
+ showProcess.value = true
+ } else if (code === -21) {
+ $basic.backAndToast('请先打开蓝牙')
+ }
}
})
onUnmounted(() => {
uni.$off('registerFingerprintConfirm')
+ uni.$off('registerFingerprintProcess')
if (!bindFlag.value) {
$bluetooth.registerAuthenticationCancel({
type: 'fingerprint',
diff --git a/pages/bindPalmVein/bindPalmVein.vue b/pages/bindPalmVein/bindPalmVein.vue
index d272254..fe25956 100644
--- a/pages/bindPalmVein/bindPalmVein.vue
+++ b/pages/bindPalmVein/bindPalmVein.vue
@@ -36,13 +36,6 @@
onLoad(async options => {
if (options.info) {
const params = JSON.parse(options.info)
- const { code } = await $bluetooth.registerAuthentication(params)
-
- if (code === 0) {
- text.value = '已连接到锁,请自然张开手掌,掌心对准摄像头'
- } else {
- $basic.backAndToast('操作失败,请重试')
- }
uni.$on('registerPalmVeinConfirm', async data => {
if (data.status === 0) {
@@ -64,27 +57,18 @@
})
if (code === 0) {
eventChannel.emit('refresherList', {})
- $basic.backAndToast('绑卡成功', 2)
+ $basic.backAndToast('添加成功', 2)
} else {
$basic.backAndToast(message)
}
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
- uni.showToast({
- title: '管理员已满',
- icon: 'none'
- })
+ $basic.backAndToast('管理员已满')
} else if (data.status === 0xfd) {
- uni.showToast({
- title: '用户已满',
- icon: 'none'
- })
+ $basic.backAndToast('用户已满')
} else if (data.status === 0xfc) {
- uni.showToast({
- title: '掌静脉已满',
- icon: 'none'
- })
+ $basic.backAndToast('掌静脉已满')
} else if (data.status === 0xfb) {
uni.showToast({
title: '掌静脉已存在',
@@ -92,6 +76,14 @@
})
}
})
+
+ const { code } = await $bluetooth.registerAuthentication(params)
+
+ if (code === 0) {
+ text.value = '已连接到锁,请自然张开手掌,掌心对准摄像头'
+ } else if (code === -21) {
+ $basic.backAndToast('请先打开蓝牙')
+ }
}
})
diff --git a/pages/bindRemote/bindRemote.vue b/pages/bindRemote/bindRemote.vue
index 3e9c442..77b740b 100644
--- a/pages/bindRemote/bindRemote.vue
+++ b/pages/bindRemote/bindRemote.vue
@@ -39,13 +39,6 @@
onLoad(async options => {
if (options.info) {
const params = JSON.parse(options.info)
- const { code } = await $bluetooth.registerAuthentication(params)
-
- if (code === 0) {
- text.value = '已连接到锁,请按遥控'
- } else {
- $basic.backAndToast('操作失败,请重试')
- }
uni.$on('registerRemoteConfirm', async data => {
if (data.status === 0) {
@@ -74,20 +67,11 @@
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
- uni.showToast({
- title: '管理员已满',
- icon: 'none'
- })
+ $basic.backAndToast('管理员已满')
} else if (data.status === 0xfd) {
- uni.showToast({
- title: '用户已满',
- icon: 'none'
- })
+ $basic.backAndToast('用户已满')
} else if (data.status === 0xfc) {
- uni.showToast({
- title: '遥控已满',
- icon: 'none'
- })
+ $basic.backAndToast('遥控已满')
} else if (data.status === 0xfb) {
uni.showToast({
title: '遥控已存在',
@@ -95,6 +79,14 @@
})
}
})
+
+ const { code } = await $bluetooth.registerAuthentication(params)
+
+ if (code === 0) {
+ text.value = '已连接到锁,请按遥控'
+ } else if (code === -21) {
+ $basic.backAndToast('请先打开蓝牙')
+ }
}
})
diff --git a/pages/cardDetail/cardDetail.vue b/pages/cardDetail/cardDetail.vue
index e45fe34..54a9cca 100644
--- a/pages/cardDetail/cardDetail.vue
+++ b/pages/cardDetail/cardDetail.vue
@@ -8,7 +8,7 @@
$refs.modalInput.open()">
姓名
- {{ info.cardName }}
+ {{ info.cardName }}
@@ -192,6 +192,10 @@
}
const changeCoerced = async () => {
+ const netWork = await $basic.getNetworkType()
+ if (!netWork) {
+ return
+ }
if (pending.value) return
pending.value = true
uni.showLoading({
diff --git a/pages/cardList/cardList.vue b/pages/cardList/cardList.vue
index d6a8af2..e83df99 100644
--- a/pages/cardList/cardList.vue
+++ b/pages/cardList/cardList.vue
@@ -291,7 +291,7 @@
}
if (data.list[i].cardType === 1) {
- data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
+ data.list[i].timeText = timeFormat(data.list[i].createDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].cardType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
diff --git a/pages/createAdmin/createAdmin.vue b/pages/createAdmin/createAdmin.vue
index ba08013..d08fcd1 100644
--- a/pages/createAdmin/createAdmin.vue
+++ b/pages/createAdmin/createAdmin.vue
@@ -43,6 +43,9 @@
@change="changeAdmin('permanent', $event)"
>
+
+ 授权管理员拥有操作这把锁的重要权限,请确保只发给你信任的人
+
发送
@@ -50,13 +53,13 @@
:value="temporaryAccount"
title="接收者"
placeholder="请输入手机号或者邮箱"
- @change-input="changeAccount('permanent', $event)"
+ @change-input="changeAccount('temporary', $event)"
>
@@ -74,7 +76,6 @@
:value="temporaryEndTime"
:minDate="minDate"
:maxDate="maxDate"
- type="datehour"
@change-time="changeDate('temporaryEndTime', $event)"
>
@@ -83,9 +84,12 @@
:value="temporaryManageSelf"
title="仅管理自己创建的用户"
:tip="tip"
- @change="changeAdmin('permanent', $event)"
+ @change="changeAdmin('temporary', $event)"
>
+
+ 授权管理员拥有操作这把锁的重要权限,请确保只发给你信任的人
+
发送
diff --git a/pages/createCard/createCard.vue b/pages/createCard/createCard.vue
index 8bef323..043c19c 100644
--- a/pages/createCard/createCard.vue
+++ b/pages/createCard/createCard.vue
@@ -29,7 +29,7 @@
placeholder="请输入"
@change-input="changeName('permanent', $event)"
>
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
- 单次钥匙有效期为1小时,只能使用一次
+ 单次钥匙有效期为1小时,只能使用一次
+
+ 小程序暂不支持邮箱登录,若接收者账号为邮箱可先使用星星锁APP登录,绑定手机号后可使用小程序登录
+
发送
@@ -108,7 +111,10 @@
- 接收者可以在有效期内的固定时间段里,不限次数使用
+ 接收者可以在有效期内的固定时间段里,不限次数使用
+ 小程序暂不支持邮箱登录,若接收者账号为邮箱可先使用星星锁APP登录,绑定手机号后可使用小程序登录
发送
diff --git a/pages/createPalmVein/createPalmVein.vue b/pages/createPalmVein/createPalmVein.vue
index fa7e295..134e4be 100644
--- a/pages/createPalmVein/createPalmVein.vue
+++ b/pages/createPalmVein/createPalmVein.vue
@@ -29,7 +29,7 @@
placeholder="请输入"
@change-input="changeName('permanent', $event)"
>
-
+
-
+
-
+
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
+ import { timeFormat } from 'uview-plus'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { useBluetoothStore } from '@/stores/bluetooth'
import { checkPalmVeinNameRequest } from '@/api/palmVein'
- import { timeFormat } from 'uview-plus'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
diff --git a/pages/createPassword/createPassword.vue b/pages/createPassword/createPassword.vue
index 121dceb..77be4d1 100644
--- a/pages/createPassword/createPassword.vue
+++ b/pages/createPassword/createPassword.vue
@@ -98,7 +98,7 @@
@change-time="changeDate('customEndTime', $event)"
>
-
+
$refs.modalInput.open()">
姓名
- {{ info.faceName }}
+ {{ info.faceName }}
diff --git a/pages/faceList/faceList.vue b/pages/faceList/faceList.vue
index fd466a4..faaecb4 100644
--- a/pages/faceList/faceList.vue
+++ b/pages/faceList/faceList.vue
@@ -292,7 +292,7 @@
}
if (data.list[i].faceType === 1) {
- data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
+ data.list[i].timeText = timeFormat(data.list[i].createDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].faceType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
diff --git a/pages/faceSetting/faceSetting.vue b/pages/faceSetting/faceSetting.vue
new file mode 100644
index 0000000..3a5d219
--- /dev/null
+++ b/pages/faceSetting/faceSetting.vue
@@ -0,0 +1,200 @@
+
+
+
+ 面容开锁
+
+
+
+
+ 感应距离
+ {{ distanceColumns[0][distanceIndex].text }}
+
+
+ {{ distanceColumns[0][distanceIndex].name }}
+
+
+
+
+
+ 防误开
+ {{ enErrUnlockColumns[0][enErrUnlock].text }}
+
+
+ {{ enErrUnlockColumns[0][enErrUnlock].name }}
+
+
+
+
+ 添加和使用面容开锁时:
+ 1、请尽量保持单人在门前操作;
+ 2、请站立在门锁正前方约0.5~0.8米,面向门锁;
+ 3、请保持脸部无遮挡,露出五官;
+ 4、面容识别异常时,可触摸数字键盘任意按键,手动重启人脸识别。
+
+
+
+
+
+
+
+
+
diff --git a/pages/fingerprintDetail/fingerprintDetail.vue b/pages/fingerprintDetail/fingerprintDetail.vue
index dd98602..a92bb14 100644
--- a/pages/fingerprintDetail/fingerprintDetail.vue
+++ b/pages/fingerprintDetail/fingerprintDetail.vue
@@ -8,7 +8,7 @@
$refs.modalInput.open()">
姓名
- {{ info.fingerprintName }}
+ {{ info.fingerprintName }}
@@ -134,6 +134,10 @@
}
const changeCoerced = async () => {
+ const netWork = await $basic.getNetworkType()
+ if (!netWork) {
+ return
+ }
if (pending.value) return
pending.value = true
uni.showLoading({
diff --git a/pages/fingerprintList/fingerprintList.vue b/pages/fingerprintList/fingerprintList.vue
index 2c4b910..4b08c85 100644
--- a/pages/fingerprintList/fingerprintList.vue
+++ b/pages/fingerprintList/fingerprintList.vue
@@ -291,7 +291,7 @@
}
if (data.list[i].fingerprintType === 1) {
- data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
+ data.list[i].timeText = timeFormat(data.list[i].createDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].fingerprintType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
diff --git a/pages/home/home.vue b/pages/home/home.vue
index 5135757..6e35b2c 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -518,6 +518,13 @@
this.getBluetoothStatus()
return
}
+ if (lock.keyStatus === 110403) {
+ uni.showToast({
+ title: '您的钥匙未生效',
+ icon: 'none'
+ })
+ return
+ }
if (lock.keyStatus === 110412) {
uni.showToast({
title: '钥匙已过期',
diff --git a/pages/keyDetail/keyDetail.vue b/pages/keyDetail/keyDetail.vue
index f0e8dd3..361cfd1 100644
--- a/pages/keyDetail/keyDetail.vue
+++ b/pages/keyDetail/keyDetail.vue
@@ -3,7 +3,9 @@
$refs.modalInput.open()">
姓名
- {{ $lock.currentKeyInfo.keyName }}
+ {{
+ $lock.currentKeyInfo.keyName
+ }}
@@ -91,11 +93,17 @@
{{ $lock.currentKeyInfo.keyStatus === 110405 ? '解冻' : '冻结' }}
{{ $lock.currentKeyInfo.keyRight === 1 ? '取消授权管理员' : '授权管理员' }}{{
$lock.currentKeyInfo.keyRight === 1
? '取消授权会在用户APP连网后生效'
- : '授权用户拥有管理员的大部分权限,比如发送要是、发送密码'
+ : '授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码'
}}
diff --git a/pages/keyList/keyList.vue b/pages/keyList/keyList.vue
index 0d4584f..c178da9 100644
--- a/pages/keyList/keyList.vue
+++ b/pages/keyList/keyList.vue
@@ -176,7 +176,7 @@
mask: true
})
const that = this
- const { code } = await deleteKeyRequest({
+ const { code, message } = await deleteKeyRequest({
keyId: that.deleteKeyId,
includeUnderlings: that.checked ? 1 : 0
})
@@ -195,7 +195,7 @@
} else {
uni.hideLoading()
uni.showToast({
- title: 'message',
+ title: message,
icon: 'none'
})
}
diff --git a/pages/lockDetail/lockDetail.vue b/pages/lockDetail/lockDetail.vue
index cf7ce48..7dda053 100644
--- a/pages/lockDetail/lockDetail.vue
+++ b/pages/lockDetail/lockDetail.vue
@@ -46,7 +46,7 @@
-
-
+
是否为管理员
-
+
操作记录
+
+ 密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。
+
删除
日期:
-
+
事件:
-
+
+
+
+
-
- 清空记录
- 同步记录
+
+ 清空记录
+
+ 同步记录
@@ -138,6 +157,15 @@
videoContext.requestFullScreen({ direction: 0 })
}
+ const tip = () => {
+ uni.showModal({
+ title: '操作记录未显示',
+ content: '锁未联网,开门记录无法实时上传,可以点击同步记录进行读取',
+ showCancel: false,
+ confirmText: '我知道了'
+ })
+ }
+
const previewImage = url => {
uni.previewImage({
urls: [url]
@@ -305,6 +333,10 @@
}
const syncRecord = async () => {
+ const netWork = await $basic.getNetworkType()
+ if (!netWork) {
+ return
+ }
uni.showLoading({
title: '同步中'
})
diff --git a/pages/remoteDetail/remoteDetail.vue b/pages/remoteDetail/remoteDetail.vue
index 722efad..cf7a967 100644
--- a/pages/remoteDetail/remoteDetail.vue
+++ b/pages/remoteDetail/remoteDetail.vue
@@ -8,7 +8,7 @@
$refs.modalInput.open()">
姓名
- {{ info.remoteName }}
+ {{ info.remoteName }}
diff --git a/pages/remoteList/remoteList.vue b/pages/remoteList/remoteList.vue
index ed6ab92..b5b9860 100644
--- a/pages/remoteList/remoteList.vue
+++ b/pages/remoteList/remoteList.vue
@@ -294,7 +294,7 @@
}
if (data.list[i].remoteType === 1) {
- data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
+ data.list[i].timeText = timeFormat(data.list[i].createDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].remoteType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
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..c79845f 100644
--- a/pages/setting/setting.vue
+++ b/pages/setting/setting.vue
@@ -1,98 +1,178 @@
-
-
-
- 名称
-
- {{
- 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 ? '已开启' : '已关闭'
+ }}
+
+
+
+
+
+
+ 面容开锁
+
+
+
+
+
+
+
+
+ 开锁提醒
+
+
+
+ 开锁时是否需联网
+
+
+
+ 锁时间
+
+
+
+ 上传数据
+
+
+
+
+
+
+ 删除
-
-
-
diff --git a/pages/syncElec/syncElec.vue b/pages/syncElec/syncElec.vue
new file mode 100644
index 0000000..3260f22
--- /dev/null
+++ b/pages/syncElec/syncElec.vue
@@ -0,0 +1,115 @@
+
+
+
+ 电量信息可以通过网关远程更新,或通过手机蓝牙在锁旁边更新
+ 电池1电量:{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantity }}%
+ 电池2电量:{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantityStandby }}%
+
+ 电量更新时间:{{
+ timeFormat(
+ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantityDate,
+ 'yyyy-mm-dd h:M'
+ )
+ }}
+
+ 更新
+
+
+
+
+
diff --git a/pages/temporaryDate/temporaryDate.vue b/pages/temporaryDate/temporaryDate.vue
index 3474f30..ca4f7b8 100644
--- a/pages/temporaryDate/temporaryDate.vue
+++ b/pages/temporaryDate/temporaryDate.vue
@@ -133,6 +133,19 @@
return
}
+ if (endDate.value <= new Date().getTime()) {
+ uni.showToast({
+ title: '失效时间需晚于当前时间',
+ icon: 'none'
+ })
+ return
+ }
+
+ const netWork = await $basic.getNetworkType()
+ if (!netWork) {
+ return
+ }
+
if (pending.value) {
return
}
diff --git a/pages/typeRecordList/typeRecordList.vue b/pages/typeRecordList/typeRecordList.vue
index 93a9a72..bda52ee 100644
--- a/pages/typeRecordList/typeRecordList.vue
+++ b/pages/typeRecordList/typeRecordList.vue
@@ -1,5 +1,8 @@
+ 锁未联网,开门记录无法实时上传,可以点击同步记录进行读取
+
{
+ const netWork = await $basic.getNetworkType()
+ if (!netWork) {
+ return
+ }
uni.showLoading({
title: '同步中'
})
diff --git a/pages/updateSetting/updateSetting.vue b/pages/updateSetting/updateSetting.vue
new file mode 100644
index 0000000..36c3de8
--- /dev/null
+++ b/pages/updateSetting/updateSetting.vue
@@ -0,0 +1,66 @@
+
+
+
+
+
+ 功能开启后,你将可以通过网关远程开锁。此功能的开启和关闭只能在锁附近通过手机蓝牙进行。
+
+
+ 开启后,可通过长按锁上的设置键重新上电,用APP重新添加
+
+
+ 关闭后,重置键无效,锁要通过app删除后才能重新添加
+
+ 开启后,锁被撬动时,会发出报警声
+ 当前模式:{{
+ $bluetooth.currentLockSetting.lockSettingInfo[type] === 1 ? '已开启' : '已关闭'
+ }}
+
+ {{ $bluetooth.currentLockSetting.lockSettingInfo[type] === 1 ? '关闭' : '开启' }}
+
+
+
+
+
+
diff --git a/pages/uploadLockData/uploadLockData.vue b/pages/uploadLockData/uploadLockData.vue
new file mode 100644
index 0000000..4f70b59
--- /dev/null
+++ b/pages/uploadLockData/uploadLockData.vue
@@ -0,0 +1,116 @@
+
+
+
+
+ 本操作将上传锁内数据到服务器,过程可能需要几分钟,请耐心等待
+
+
+ 开始
+
+
+
+
+
+
+
+
diff --git a/static/images/icon_admin_black.png b/static/images/icon_admin_black.png
index 825bc88..25c8961 100644
Binary files a/static/images/icon_admin_black.png and b/static/images/icon_admin_black.png differ
diff --git a/static/images/icon_card.png b/static/images/icon_card.png
index 1355daf..fd4f81c 100644
Binary files a/static/images/icon_card.png and b/static/images/icon_card.png differ
diff --git a/static/images/icon_face.png b/static/images/icon_face.png
index ce6b9fd..70b7034 100644
Binary files a/static/images/icon_face.png and b/static/images/icon_face.png differ
diff --git a/static/images/icon_fingerprint.png b/static/images/icon_fingerprint.png
index 6ec6147..bce2eae 100644
Binary files a/static/images/icon_fingerprint.png and b/static/images/icon_fingerprint.png differ
diff --git a/static/images/icon_key.png b/static/images/icon_key.png
new file mode 100644
index 0000000..d97edf8
Binary files /dev/null and b/static/images/icon_key.png differ
diff --git a/static/images/icon_palm_vein.png b/static/images/icon_palm_vein.png
index 018050b..4ff12ad 100644
Binary files a/static/images/icon_palm_vein.png and b/static/images/icon_palm_vein.png differ
diff --git a/static/images/icon_password_green.png b/static/images/icon_password_green.png
new file mode 100644
index 0000000..9175277
Binary files /dev/null and b/static/images/icon_password_green.png differ
diff --git a/static/images/icon_record.png b/static/images/icon_record.png
index 3050172..ff18169 100644
Binary files a/static/images/icon_record.png and b/static/images/icon_record.png differ
diff --git a/static/images/icon_remote.png b/static/images/icon_remote.png
index 3bf9398..7dc223b 100644
Binary files a/static/images/icon_remote.png and b/static/images/icon_remote.png differ
diff --git a/static/images/icon_setting.png b/static/images/icon_setting.png
index 6834c06..c3a28a6 100644
Binary files a/static/images/icon_setting.png and b/static/images/icon_setting.png differ
diff --git a/stores/basic.js b/stores/basic.js
index c6b3f23..eddeaac 100644
--- a/stores/basic.js
+++ b/stores/basic.js
@@ -251,6 +251,51 @@ 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
+ },
+ {
+ name: 'updateSetting',
+ path: '/pages/updateSetting/updateSetting',
+ tabBar: false
+ },
+ {
+ name: 'lockSound',
+ path: '/pages/lockSound/lockSound',
+ tabBar: false
+ },
+ {
+ name: 'autoLock',
+ path: '/pages/autoLock/autoLock',
+ tabBar: false
+ },
+ {
+ name: 'faceSetting',
+ path: '/pages/faceSetting/faceSetting',
+ tabBar: false
+ },
+ {
+ name: 'lockDate',
+ path: '/pages/lockDate/lockDate',
+ tabBar: false
+ },
+ {
+ name: 'uploadLockData',
+ path: '/pages/uploadLockData/uploadLockData',
+ tabBar: false
}
]
diff --git a/stores/bluetooth.js b/stores/bluetooth.js
index 1b1d313..8800d12 100644
--- a/stores/bluetooth.js
+++ b/stores/bluetooth.js
@@ -40,7 +40,23 @@ const cmdIds = {
// 清理用户
cleanUser: 0x300c,
// 扩展命令
- expandCmd: 0x3030
+ expandCmd: 0x3030,
+ // 校准时间
+ calibrationTime: 0x30f0,
+ // 锁密码列表
+ lockPasswordList: 0x3021,
+ // 锁卡片列表
+ lockCardList: 0x3022,
+ // 锁指纹列表
+ lockFingerprintList: 0x3023,
+ // 锁人脸列表
+ lockFaceList: 0x3024,
+ // 锁掌静脉列表
+ lockPalmVeinList: 0x3025,
+ // 锁遥控列表
+ lockRemoteList: 0x3026,
+ // 锁设置列表
+ lockSettingList: 0x302a
}
// 子命令ID
@@ -84,7 +100,13 @@ const subCmdIds = {
// 注册掌纹取消
registerPalmVeinCancel: 44,
// 同步操作记录
- syncRecord: 41
+ syncRecord: 41,
+ // 更新管理员密码
+ updateAdminPassword: 2,
+ // 修改设置
+ updateSetting: 70,
+ // 修改设置带参数
+ updateSettingWithParams: 72
}
export const useBluetoothStore = defineStore('ble', {
@@ -103,6 +125,8 @@ export const useBluetoothStore = defineStore('ble', {
deviceList: [],
// 当前锁信息
currentLockInfo: {},
+ // 当前锁设置信息
+ currentLockSetting: null,
// 消息序号
messageCount: 1,
// 是否初始化蓝牙
@@ -315,6 +339,7 @@ export const useBluetoothStore = defineStore('ble', {
mode: 'ecb',
output: 'array'
})
+ const length = binaryData[10] * 256 + binaryData[11]
console.log('ecb解密后的数据', decrypted)
const cmdId = decrypted[0] * 256 + decrypted[1]
@@ -354,11 +379,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 +535,33 @@ 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
+ case subCmdIds.updateSetting:
+ that.updateCurrentLockInfo({
+ ...that.currentLockInfo,
+ token: decrypted.slice(5, 9)
+ })
+ characteristicValueCallback({
+ code: decrypted[2]
+ })
+ break
+ case subCmdIds.updateSettingWithParams:
+ that.updateCurrentLockInfo({
+ ...that.currentLockInfo,
+ token: decrypted.slice(5, 9)
+ })
+ characteristicValueCallback({
+ code: decrypted[2]
+ })
+ break
default:
break
}
@@ -512,7 +569,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({
@@ -568,6 +627,40 @@ export const useBluetoothStore = defineStore('ble', {
})
}
break
+ case cmdIds.calibrationTime:
+ characteristicValueCallback({
+ code: decrypted[2]
+ })
+ break
+ case cmdIds.lockPasswordList:
+ case cmdIds.lockCardList:
+ case cmdIds.lockFingerprintList:
+ case cmdIds.lockFaceList:
+ case cmdIds.lockPalmVeinList:
+ case cmdIds.lockRemoteList:
+ case cmdIds.lockSettingList:
+ that.updateCurrentLockInfo({
+ ...that.currentLockInfo,
+ token: decrypted.slice(3, 7)
+ })
+ let data
+ if (cmdId === cmdIds.lockSettingList) {
+ data = {
+ list: decrypted.slice(7, length)
+ }
+ } else {
+ data = {
+ page: decrypted[7],
+ size: decrypted[8],
+ list: decrypted.slice(9, length)
+ }
+ }
+ console.log(1234, cmdId, data)
+ characteristicValueCallback({
+ code: decrypted[2],
+ data
+ })
+ break
default:
that.updateCurrentLockInfo({
...that.currentLockInfo,
@@ -884,6 +977,11 @@ export const useBluetoothStore = defineStore('ble', {
console.log('更新当前锁信息', lockInfo)
this.currentLockInfo = lockInfo
},
+ // 更新当前锁设置信息
+ updateCurrentLockSetting(lockSetting) {
+ console.log('更新当前锁设置信息', lockSetting)
+ this.currentLockSetting = lockSetting
+ },
// 订阅设备特征值改变
notifyBluetoothCharacteristicValueChange() {
const that = this
@@ -2306,7 +2404,7 @@ export const useBluetoothStore = defineStore('ble', {
console.log('写入未执行', this.bluetoothStatus)
this.getBluetoothStatus()
return {
- code: -1
+ code: -21
}
}
@@ -2494,26 +2592,6 @@ export const useBluetoothStore = defineStore('ble', {
},
// 获取操作记录
async syncRecord(params) {
- const { uid, keyId } = params
-
- const { code, data, message } = await this.syncSingleRecord({
- uid,
- keyId
- })
-
- if (code === 0) {
- if (data?.count === 10) {
- return await this.syncSingleRecord({
- uid,
- keyId
- })
- }
- return { code, data, message }
- }
- return { code, data, message }
- },
- // 获取单次操作记录
- async syncSingleRecord(data) {
// 确认蓝牙状态正常
if (this.bluetoothStatus !== 0) {
console.log('写入未执行', this.bluetoothStatus)
@@ -2551,6 +2629,26 @@ export const useBluetoothStore = defineStore('ble', {
}
}
+ const { uid, keyId } = params
+
+ const { code, data, message } = await this.syncSingleRecord({
+ uid,
+ keyId
+ })
+
+ if (code === 0) {
+ if (data?.count === 10) {
+ return await this.syncSingleRecord({
+ uid,
+ keyId
+ })
+ }
+ return { code, data, message }
+ }
+ return { code, data, message }
+ },
+ // 获取单次操作记录
+ async syncSingleRecord(data) {
const { keyId, uid } = data
const logsCount = 10
@@ -2612,6 +2710,393 @@ 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)
+ },
+ // 更新设置
+ async updateSetting(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, featureBit, featureEnable, withParams, params } = data
+
+ let length = 2 + 1 + 1 + 40 + 20 + 4 + 1 + 16
+ if (withParams) {
+ length += 2 + params.length
+ } else {
+ length += 2
+ }
+ const headArray = this.createPackageHeader(3, length)
+ const contentArray = new Uint8Array(length)
+
+ contentArray[0] = cmdIds.expandCmd / 256
+ contentArray[1] = cmdIds.expandCmd % 256
+
+ contentArray[2] = withParams ? subCmdIds.updateSettingWithParams : subCmdIds.updateSetting
+
+ 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] = featureBit
+
+ if (withParams) {
+ contentArray[65] = params.length
+ contentArray.set(new Uint8Array(params), 66)
+ } else {
+ contentArray[65] = featureEnable
+ }
+
+ contentArray.set(
+ this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
+ withParams ? 66 + params.length : 66
+ )
+
+ contentArray[withParams ? 70 + params.length : 70] = 16
+
+ const md5Array = this.md5Encrypte(
+ keyId + uid,
+ this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
+ this.currentLockInfo.signKey
+ )
+
+ contentArray.set(md5Array, withParams ? 71 + params.length : 71)
+
+ 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.updateSetting, data)
+ },
+ // 校准时间
+ async calibrationTime(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 { lockId, uid, nowTime } = data
+ const length = 2 + 40 + 20 + 4 + 4 + 1 + 16
+ const headArray = this.createPackageHeader(3, length)
+ const contentArray = new Uint8Array(length)
+
+ contentArray[0] = cmdIds.calibrationTime / 256
+ contentArray[1] = cmdIds.calibrationTime % 256
+
+ for (let i = 0; i < lockId.length; i++) {
+ contentArray[i + 2] = lockId.charCodeAt(i)
+ }
+
+ for (let i = 0; i < uid.length; i++) {
+ contentArray[i + 42] = uid.charCodeAt(i)
+ }
+
+ contentArray.set(this.timestampToArray(nowTime), 62)
+
+ contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 66)
+ contentArray[70] = 16
+
+ const md5Array = this.md5Encrypte(
+ lockId + uid,
+ this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
+ this.currentLockInfo.signKey
+ )
+
+ contentArray.set(md5Array, 71)
+
+ const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
+ mode: 'ecb',
+ output: 'array'
+ })
+
+ const packageArray = this.createPackageEnd(headArray, cebArray)
+ this.writeBLECharacteristicValue(packageArray)
+
+ return this.getWriteResult(this.calibrationTime, data)
+ },
+ // 获取锁数据列表
+ async getLockDataList(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 { lockId, uid, page, countReq, type } = data
+ let length = 2 + 40 + 20 + 4 + 1 + 16
+ if (type !== 'setting') {
+ length += 2
+ }
+ const headArray = this.createPackageHeader(3, length)
+ const contentArray = new Uint8Array(length)
+
+ let id
+
+ if (type === 'password') {
+ id = cmdIds.lockPasswordList
+ } else if (type === 'card') {
+ id = cmdIds.lockCardList
+ } else if (type === 'fingerprint') {
+ id = cmdIds.lockFingerprintList
+ } else if (type === 'face') {
+ id = cmdIds.lockFaceList
+ } else if (type === 'remote') {
+ id = cmdIds.lockRemoteList
+ } else if (type === 'palmVein') {
+ id = cmdIds.lockPalmVeinList
+ } else if (type === 'setting') {
+ id = cmdIds.lockSettingList
+ }
+
+ contentArray[0] = id / 256
+ contentArray[1] = id % 256
+
+ for (let i = 0; i < lockId.length; i++) {
+ contentArray[i + 2] = lockId.charCodeAt(i)
+ }
+
+ for (let i = 0; i < uid.length; i++) {
+ contentArray[i + 42] = uid.charCodeAt(i)
+ }
+
+ if (type !== 'setting') {
+ contentArray[62] = page
+ contentArray[63] = countReq
+
+ contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 64)
+ contentArray[68] = 16
+
+ const md5Array = this.md5Encrypte(
+ lockId + uid,
+ this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
+ this.currentLockInfo.signKey
+ )
+
+ contentArray.set(md5Array, 69)
+ } else {
+ contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62)
+ contentArray[66] = 16
+
+ const md5Array = this.md5Encrypte(
+ lockId + uid,
+ this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
+ this.currentLockInfo.signKey
+ )
+
+ contentArray.set(md5Array, 67)
+ }
+
+ const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
+ mode: 'ecb',
+ output: 'array'
+ })
+
+ const packageArray = this.createPackageEnd(headArray, cebArray)
+ this.writeBLECharacteristicValue(packageArray)
+
+ return this.getWriteResult(this.getLockDataList, data)
}
}
})