From 28aac335f949a864d51780f7e56062031755a0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Fri, 11 Apr 2025 10:04:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8D=E8=85=BE?= =?UTF-8?q?=E8=AE=AF=E9=94=81=E6=B7=BB=E5=8A=A0=E5=8F=91=E9=80=81=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E9=92=A5=E5=8C=99=E5=90=8E=E5=9C=A8=E9=94=81=E6=9D=BF?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=94=A8=E6=88=B7=EF=BC=8C=E5=BC=80=E9=97=A8?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E9=80=82=E9=85=8Dwifi=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/feature/createAdmin.vue | 41 ++++++++++++++++++------ pages/feature/createCard.vue | 49 ++++++++++++++++++----------- pages/feature/createFace.vue | 49 ++++++++++++++++++----------- pages/feature/createFingerprint.vue | 49 ++++++++++++++++++----------- pages/feature/createKey.vue | 43 +++++++++++++++++++------ pages/feature/createPalmVein.vue | 49 ++++++++++++++++++----------- pages/feature/createRemote.vue | 49 ++++++++++++++++++----------- stores/bluetooth.js | 2 +- 8 files changed, 221 insertions(+), 110 deletions(-) diff --git a/pages/feature/createAdmin.vue b/pages/feature/createAdmin.vue index d08fcd1..078007e 100644 --- a/pages/feature/createAdmin.vue +++ b/pages/feature/createAdmin.vue @@ -103,6 +103,7 @@ import { useBasicStore } from '@/stores/basic' import { createKeyRequest } from '@/api/key' import { useBluetoothStore } from '@/stores/bluetooth' + import { transportType } from '@/utils/constants' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -246,10 +247,32 @@ params.receiverUsername = permanentAccount.value params.isOnlyManageSelf = permanentManageSelf.value ? 1 : 0 } - const { code, message } = await createKeyRequest(params) + const { code, data, message } = await createKeyRequest(params) if (code === 0) { eventChannel.emit('refresherList', {}) $basic.backAndToast('添加成功') + if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + $bluetooth.addLockUser({ + name: $bluetooth.currentLockInfo.name, + keyId: $bluetooth.keyId, + authUid: $bluetooth.currentLockInfo.uid.toString(), + uid: data.receiverUid.toString(), + openMode: 1, + keyType: params.keyType, + startDate: params.startDate.toString(), + expireDate: params.endDate.toString(), + useCountLimit: params.keyType === '3' ? 1 : 0xffff, + isRound: params.keyType === '4' ? 1 : 0, + weekRound: + params.keyType === '4' ? $bluetooth.convertWeekdaysToNumber(params.weekDays) : 0, + startHour: params.keyType === '4' ? new Date(params.startDate).getHours() : 0, + startMin: params.keyType === '4' ? new Date(params.startDate).getMinutes() : 0, + endHour: params.keyType === '4' ? new Date(params.endDate).getHours() : 0, + endMin: params.keyType === '4' ? new Date(params.endDate).getMinutes() : 0, + role: 1, + password: (Math.floor(Math.random() * 900000) + 100000).toString() + }) + } } else if (code === 425) { pending.value = false uni.showModal({ @@ -324,23 +347,23 @@ } .text { + padding: 0 32rpx; margin-top: 40rpx; margin-bottom: 50rpx; - color: #262626; font-size: 26rpx; - padding: 0 32rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/pages/feature/createCard.vue b/pages/feature/createCard.vue index cc5925e..d1bcbf1 100644 --- a/pages/feature/createCard.vue +++ b/pages/feature/createCard.vue @@ -127,6 +127,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkCardNameRequest } from '@/api/card' + import { transportType } from '@/utils/constants' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -306,17 +307,29 @@ cardName: params.cardName }) if (code === 0) { - $basic.routeJump({ - name: 'bindCard', - params: { - card: JSON.stringify(params) - }, - events: { - refresherList() { - eventChannel.emit('refresherList', {}) - } + if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + const { code } = await $bluetooth.registerAuthentication(params) + if (code === 0) { + $basic.backAndToast('请在锁端添加卡片') + } else { + uni.showToast({ + title: '添加卡片命令下达失败,请重试', + icon: 'none' + }) } - }) + } else { + $basic.routeJump({ + name: 'bindCard', + params: { + card: JSON.stringify(params) + }, + events: { + refresherList() { + eventChannel.emit('refresherList', {}) + } + } + }) + } } else { uni.showToast({ title: message, @@ -385,23 +398,23 @@ } .text { + padding: 0 32rpx; margin-top: 40rpx; margin-bottom: 50rpx; - color: #262626; font-size: 26rpx; - padding: 0 32rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/pages/feature/createFace.vue b/pages/feature/createFace.vue index 8c1be34..36a9d6c 100644 --- a/pages/feature/createFace.vue +++ b/pages/feature/createFace.vue @@ -104,6 +104,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkFaceNameRequest } from '@/api/face' + import { transportType } from '@/utils/constants' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -275,17 +276,29 @@ faceName: params.faceName }) if (code === 0) { - $basic.routeJump({ - name: 'bindFace', - params: { - info: JSON.stringify(params) - }, - events: { - refresherList() { - eventChannel.emit('refresherList', {}) - } + if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + const { code } = await $bluetooth.registerAuthentication(params) + if (code === 0) { + $basic.backAndToast('请在锁端添加人脸') + } else { + uni.showToast({ + title: '添加人脸命令下达失败,请重试', + icon: 'none' + }) } - }) + } else { + $basic.routeJump({ + name: 'bindFace', + params: { + info: JSON.stringify(params) + }, + events: { + refresherList() { + eventChannel.emit('refresherList', {}) + } + } + }) + } } else { uni.showToast({ title: message, @@ -344,23 +357,23 @@ } .text { + padding: 0 32rpx; margin-top: 40rpx; margin-bottom: 50rpx; - color: #262626; font-size: 26rpx; - padding: 0 32rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/pages/feature/createFingerprint.vue b/pages/feature/createFingerprint.vue index 9c7116a..8d035c4 100644 --- a/pages/feature/createFingerprint.vue +++ b/pages/feature/createFingerprint.vue @@ -127,6 +127,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkFingerprintNameRequest } from '@/api/fingerprint' + import { transportType } from '@/utils/constants' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -306,17 +307,29 @@ fingerprintName: params.fingerprintName }) if (code === 0) { - $basic.routeJump({ - name: 'bindFingerprint', - params: { - info: JSON.stringify(params) - }, - events: { - refresherList() { - eventChannel.emit('refresherList', {}) - } + if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + const { code } = await $bluetooth.registerAuthentication(params) + if (code === 0) { + $basic.backAndToast('请在锁端添加指纹') + } else { + uni.showToast({ + title: '添加指纹命令下达失败,请重试', + icon: 'none' + }) } - }) + } else { + $basic.routeJump({ + name: 'bindFingerprint', + params: { + info: JSON.stringify(params) + }, + events: { + refresherList() { + eventChannel.emit('refresherList', {}) + } + } + }) + } } else { uni.showToast({ title: message, @@ -385,23 +398,23 @@ } .text { + padding: 0 32rpx; margin-top: 40rpx; margin-bottom: 50rpx; - color: #262626; font-size: 26rpx; - padding: 0 32rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/pages/feature/createKey.vue b/pages/feature/createKey.vue index 54a19a6..afbea1c 100644 --- a/pages/feature/createKey.vue +++ b/pages/feature/createKey.vue @@ -130,6 +130,7 @@ import { useBluetoothStore } from '@/stores/bluetooth' import { useLockStore } from '@/stores/lock' import { createKeyRequest } from '@/api/key' + import { transportType } from '@/constant/transportType' export default { components: { @@ -173,7 +174,7 @@ } }, computed: { - ...mapState(useBluetoothStore, ['currentLockInfo']), + ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useLockStore, ['keySearch']) }, async onLoad() { @@ -182,6 +183,7 @@ methods: { ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast', 'getNetworkType']), ...mapActions(useLockStore, ['getKeyList', 'updateKeySearch']), + ...mapActions(useBluetoothStore, ['addLockUser', 'convertWeekdaysToNumber']), changeCycle(data) { this.cycleStartTime = data.startDate this.cycleEndTime = data.endDate @@ -271,7 +273,7 @@ params.startTime = this.cycleStartTime params.endTime = this.cycleEndTime } - const { code, message } = await createKeyRequest(params) + const { code, data, message } = await createKeyRequest(params) if (code === 0) { uni.reportEvent('create_key', {}) this.updateKeySearch({ @@ -280,6 +282,27 @@ }) this.getKeyList(this.keySearch) this.backAndToast('钥匙已发送') + if (this.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + this.addLockUser({ + name: this.currentLockInfo.name, + keyId: this.keyId, + authUid: this.currentLockInfo.uid.toString(), + uid: data.receiverUid.toString(), + openMode: 1, + keyType: params.keyType, + startDate: params.startDate.toString(), + expireDate: params.endDate.toString(), + useCountLimit: params.keyType === '3' ? 1 : 0xffff, + isRound: params.keyType === '4' ? 1 : 0, + weekRound: params.keyType === '4' ? this.convertWeekdaysToNumber(params.weekDays) : 0, + startHour: params.keyType === '4' ? new Date(params.startDate).getHours() : 0, + startMin: params.keyType === '4' ? new Date(params.startDate).getMinutes() : 0, + endHour: params.keyType === '4' ? new Date(params.endDate).getHours() : 0, + endMin: params.keyType === '4' ? new Date(params.endDate).getMinutes() : 0, + role: 0, + password: (Math.floor(Math.random() * 900000) + 100000).toString() + }) + } } else if (code === 425) { this.pending = false uni.showModal({ @@ -350,21 +373,21 @@ } .text { - color: #262626; - font-size: 26rpx; padding: 0 32rpx; + font-size: 26rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/pages/feature/createPalmVein.vue b/pages/feature/createPalmVein.vue index 458a0e9..9bf176c 100644 --- a/pages/feature/createPalmVein.vue +++ b/pages/feature/createPalmVein.vue @@ -128,6 +128,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkPalmVeinNameRequest } from '@/api/palmVein' + import { transportType } from '@/utils/constants' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -307,17 +308,29 @@ palmVeinName: params.palmVeinName }) if (code === 0) { - $basic.routeJump({ - name: 'bindPalmVein', - params: { - info: JSON.stringify(params) - }, - events: { - refresherList() { - eventChannel.emit('refresherList', {}) - } + if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + const { code } = await $bluetooth.registerAuthentication(params) + if (code === 0) { + $basic.backAndToast('请在锁端添加掌静脉') + } else { + uni.showToast({ + title: '添加掌静脉命令下达失败,请重试', + icon: 'none' + }) } - }) + } else { + $basic.routeJump({ + name: 'bindPalmVein', + params: { + info: JSON.stringify(params) + }, + events: { + refresherList() { + eventChannel.emit('refresherList', {}) + } + } + }) + } } else { uni.showToast({ title: message, @@ -386,23 +399,23 @@ } .text { + padding: 0 32rpx; margin-top: 40rpx; margin-bottom: 50rpx; - color: #262626; font-size: 26rpx; - padding: 0 32rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/pages/feature/createRemote.vue b/pages/feature/createRemote.vue index 787e32b..fc2f954 100644 --- a/pages/feature/createRemote.vue +++ b/pages/feature/createRemote.vue @@ -83,6 +83,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkRemoteNameRequest } from '@/api/remote' + import { transportType } from '@/utils/constants' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() @@ -248,17 +249,29 @@ remoteName: params.remoteName }) if (code === 0) { - $basic.routeJump({ - name: 'bindRemote', - params: { - info: JSON.stringify(params) - }, - events: { - refresherList() { - eventChannel.emit('refresherList', {}) - } + if ($bluetooth.currentLockInfo.transport_type === transportType.TRANSPORT_TENCENT_YUN) { + const { code } = await $bluetooth.registerAuthentication(params) + if (code === 0) { + $basic.backAndToast('请在锁端添加远程') + } else { + uni.showToast({ + title: '添加远程命令下达失败,请重试', + icon: 'none' + }) } - }) + } else { + $basic.routeJump({ + name: 'bindRemote', + params: { + info: JSON.stringify(params) + }, + events: { + refresherList() { + eventChannel.emit('refresherList', {}) + } + } + }) + } } else { uni.showToast({ title: message, @@ -307,23 +320,23 @@ } .text { + padding: 0 32rpx; margin-top: 40rpx; margin-bottom: 50rpx; - color: #262626; font-size: 26rpx; - padding: 0 32rpx; + color: #262626; } .button { - border-radius: 64rpx; width: 686rpx; - margin-left: 32rpx; height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #63b8af; - color: #fff; + margin-left: 32rpx; font-size: 32rpx; font-weight: bold; + line-height: 100rpx; + color: #fff; + text-align: center; + background-color: #63b8af; + border-radius: 64rpx; } diff --git a/stores/bluetooth.js b/stores/bluetooth.js index b5c5610..126ec6e 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -1275,7 +1275,7 @@ export const useBluetoothStore = defineStore('ble', { this.currentLockInfo.keyType === 4 ? new Date(this.currentLockInfo.endDate).getMinutes() : 0, - role: 0, + role: Number(this.currentLockInfo.keyRight), password } const { code: addUserCode } = await this.addLockUser(addUserParams) From 5af784a18d9a070a833b54afd6c5628491eb5b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Fri, 11 Apr 2025 14:04:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E5=BC=95?= =?UTF-8?q?=E7=94=A8bug+=E4=BC=98=E5=8C=96=E7=9B=91=E6=8E=A7=E5=92=8C?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E6=97=B6=E7=9A=84UI=E5=8F=8A=E6=96=87?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/feature/createAdmin.vue | 2 +- pages/feature/createCard.vue | 2 +- pages/feature/createFace.vue | 2 +- pages/feature/createFingerprint.vue | 2 +- pages/feature/createPalmVein.vue | 2 +- pages/feature/createRemote.vue | 2 +- pages/p2p/authorizeWechat.vue | 19 ++-- pages/p2p/p2pPlayer.vue | 131 ++++++++++++++++++++++++++-- 8 files changed, 142 insertions(+), 20 deletions(-) diff --git a/pages/feature/createAdmin.vue b/pages/feature/createAdmin.vue index 078007e..e526422 100644 --- a/pages/feature/createAdmin.vue +++ b/pages/feature/createAdmin.vue @@ -103,7 +103,7 @@ import { useBasicStore } from '@/stores/basic' import { createKeyRequest } from '@/api/key' import { useBluetoothStore } from '@/stores/bluetooth' - import { transportType } from '@/utils/constants' + import { transportType } from '@/constant/transportType' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() diff --git a/pages/feature/createCard.vue b/pages/feature/createCard.vue index d1bcbf1..c4dc32c 100644 --- a/pages/feature/createCard.vue +++ b/pages/feature/createCard.vue @@ -127,7 +127,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkCardNameRequest } from '@/api/card' - import { transportType } from '@/utils/constants' + import { transportType } from '@/constant/transportType' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() diff --git a/pages/feature/createFace.vue b/pages/feature/createFace.vue index 36a9d6c..6a06ad4 100644 --- a/pages/feature/createFace.vue +++ b/pages/feature/createFace.vue @@ -104,7 +104,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkFaceNameRequest } from '@/api/face' - import { transportType } from '@/utils/constants' + import { transportType } from '@/constant/transportType' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() diff --git a/pages/feature/createFingerprint.vue b/pages/feature/createFingerprint.vue index 8d035c4..fbad371 100644 --- a/pages/feature/createFingerprint.vue +++ b/pages/feature/createFingerprint.vue @@ -127,7 +127,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkFingerprintNameRequest } from '@/api/fingerprint' - import { transportType } from '@/utils/constants' + import { transportType } from '@/constant/transportType' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() diff --git a/pages/feature/createPalmVein.vue b/pages/feature/createPalmVein.vue index 9bf176c..d44d15c 100644 --- a/pages/feature/createPalmVein.vue +++ b/pages/feature/createPalmVein.vue @@ -128,7 +128,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkPalmVeinNameRequest } from '@/api/palmVein' - import { transportType } from '@/utils/constants' + import { transportType } from '@/constant/transportType' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() diff --git a/pages/feature/createRemote.vue b/pages/feature/createRemote.vue index fc2f954..d17dd86 100644 --- a/pages/feature/createRemote.vue +++ b/pages/feature/createRemote.vue @@ -83,7 +83,7 @@ import { useUserStore } from '@/stores/user' import { useBluetoothStore } from '@/stores/bluetooth' import { checkRemoteNameRequest } from '@/api/remote' - import { transportType } from '@/utils/constants' + import { transportType } from '@/constant/transportType' const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel() diff --git a/pages/p2p/authorizeWechat.vue b/pages/p2p/authorizeWechat.vue index 75d6808..6d3c9bd 100644 --- a/pages/p2p/authorizeWechat.vue +++ b/pages/p2p/authorizeWechat.vue @@ -1,19 +1,20 @@ diff --git a/pages/p2p/p2pPlayer.vue b/pages/p2p/p2pPlayer.vue index 0a07bbc..3ae152b 100644 --- a/pages/p2p/p2pPlayer.vue +++ b/pages/p2p/p2pPlayer.vue @@ -54,9 +54,9 @@ - + - + - 长按说话 + 长按说话 - 挂断 + 挂断 @@ -99,7 +99,7 @@ class="w-60 h-60" > - 开锁 + 开锁 @@ -123,13 +123,23 @@ import { onUnload } from '@dcloudio/uni-app' import { useBluetoothStore } from '@/stores/bluetooth' import { useBasicStore } from '@/stores/basic' + import { useUserStore } from '@/stores/user' import { passthrough } from '@/api/sdk' + import { getLockNetTokenRequest } from '@/api/lock' const $bluetooth = useBluetoothStore() const $basic = useBasicStore() - + const $user = useUserStore() const buttonInfo = ref(null) + const onlineToken = ref('0') + + const lockId = ref() + + const time = ref(0) + + const pending = ref(false) + const index = ref(1) const range = ref([ { name: '标清', value: 'standard' }, @@ -166,6 +176,8 @@ } else { $basic.backAndToast(message) } + + await getServeTime() }) onUnload(() => { @@ -213,7 +225,110 @@ } const handleLock = () => { - console.log('handleLock') + uni.showModal({ + title: '提示', + content: '是否确认开锁?', + success: res => { + if (res.confirm) { + openDoorOperate() + } + } + }) + } + + const getServeTime = async () => { + const { code, data } = await $bluetooth.updateServerTimestamp() + if (code === 0) { + time.value = parseInt((data.date - new Date().getTime()) / 1000, 10) + } + } + + const openDoorOperate = async () => { + const timestamp = new Date().getTime() + if (pending.value) { + return + } + + const netWork = await $basic.getNetworkType() + if (!netWork) { + return + } + + if ($bluetooth.currentLockInfo.appUnlockOnline) { + const result = await getNetToken() + if (!result) { + pending.value = false + return + } + } + + uni.showLoading({ + title: '开锁中' + }) + uni.vibrateLong() + pending.value = true + const openMode = $bluetooth.currentLockInfo.appUnlockOnline ? 1 : 0 + + const { code } = await $bluetooth.openDoor({ + name: $bluetooth.currentLockInfo.lockName, + uid: $user.userInfo.uid.toString(), + openMode, + openTime: parseInt(new Date().getTime() / 1000, 10) + time.value, + onlineToken: onlineToken.value + }) + + $bluetooth + .syncRecord({ + keyId: $bluetooth.keyId.toString(), + uid: $user.userInfo.uid.toString() + }) + .then(() => { + $bluetooth.closeBluetoothConnection() + }) + + uni.reportEvent('open_door', { + result: code, + duration: new Date().getTime() - timestamp + }) + + if (code === 0) { + uni.showToast({ + title: `开门成功`, + icon: 'none' + }) + } else if (code === 7) { + uni.showToast({ + title: `钥匙过期`, + icon: 'none' + }) + } else if (code === 13) { + uni.showToast({ + title: `钥匙当前不可用`, + icon: 'none' + }) + } else if (code === -1) { + uni.showToast({ + title: `开锁失败`, + icon: 'none' + }) + } + uni.hideLoading() + pending.value = false + } + + const getNetToken = async () => { + const { code, data, message } = await getLockNetTokenRequest({ + lockId: lockId.value + }) + if (code === 0) { + onlineToken.value = data.token + return true + } + uni.showToast({ + title: message, + icon: 'none' + }) + return false } const startVoice = () => { From f34f3aa14ac205e65a0d33eb05554097bbd0f1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Tue, 29 Apr 2025 16:43:12 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E8=85=BE=E8=AE=AF=E9=94=81?= =?UTF-8?q?=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constant/transportType.js | 16 ++-- pages/addDevice/addLockGuid.vue | 25 +----- pages/addDevice/distributionNetwork.vue | 107 +++++++++++------------- pages/addDevice/searchDevice.vue | 6 +- pages/feature/createAdmin.vue | 2 +- pages/feature/createCard.vue | 2 +- pages/feature/createFace.vue | 2 +- pages/feature/createFingerprint.vue | 2 +- pages/feature/createKey.vue | 2 +- pages/feature/createPalmVein.vue | 2 +- pages/feature/createRemote.vue | 2 +- stores/bluetooth.js | 100 +++++++++++++--------- 12 files changed, 136 insertions(+), 132 deletions(-) diff --git a/constant/transportType.js b/constant/transportType.js index 7effc3f..acfa808 100644 --- a/constant/transportType.js +++ b/constant/transportType.js @@ -1,7 +1,13 @@ export const transportType = { - TRANSPORT_BLUETOOTH: 0, - TRANSPORT_OFFLINE: 10, - TRANSPORT_GATEWAY: 20, - TRANSPORT_WIFI: 30, - TRANSPORT_TENCENT_YUN: 40 + TRANSPORT_BLUETOOTH: 10, + TRANSPORT_OFFLINE: 20, + TRANSPORT_GATEWAY: 30, + TRANSPORT_WIFI: 40, + TRANSPORT_TENCENT_YUN: 50, + TRANSPORT_WIFI_PRIORITY: 60, + TRANSPORT_BLUETOOTH_PRIORITY: 70 +} + +export const model = { + TENCENT_YUN_LOCK: 'XB007' } diff --git a/pages/addDevice/addLockGuid.vue b/pages/addDevice/addLockGuid.vue index b3accef..7c85489 100644 --- a/pages/addDevice/addLockGuid.vue +++ b/pages/addDevice/addLockGuid.vue @@ -12,22 +12,12 @@