From 1c79f736a3c2db474952c2074c9eb237add30176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Wed, 4 Sep 2024 17:38:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=9C=A8=E9=83=A8=E5=88=86=E8=93=9D?= =?UTF-8?q?=E7=89=99=E6=93=8D=E4=BD=9C=E5=90=8E=E6=96=AD=E5=BC=80=E8=93=9D?= =?UTF-8?q?=E7=89=99=E8=BF=9E=E6=8E=A5=202.=20=E7=BB=91=E5=AE=9A=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=88=90=E5=8A=9F=E5=90=8E=E5=BB=B6=E8=BF=9F1?= =?UTF-8?q?=E7=A7=92=E9=80=80=E5=9B=9E=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/bindLock/bindLock.vue | 9 ++++++--- pages/lockDetail/lockDetail.vue | 3 ++- pages/passwordDetail/passwordDetail.vue | 3 ++- pages/passwordList/passwordList.vue | 4 +++- pages/setting/setting.vue | 2 +- stores/bluetooth.js | 1 + 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pages/bindLock/bindLock.vue b/pages/bindLock/bindLock.vue index df25b3a..03f3160 100644 --- a/pages/bindLock/bindLock.vue +++ b/pages/bindLock/bindLock.vue @@ -33,7 +33,7 @@ export default { console.log(this.name) }, methods: { - ...mapActions(useBluetoothStore, ['addLockUser']), + ...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useBasicStore, ['backAndToast']), uopdateName(data) { @@ -73,6 +73,7 @@ export default { password }) if(addUserCode === 0) { + this.closeBluetoothConnection() } else if(addUserCode === -1) { uni.hideLoading() this.backAndToast('添加失败,请重试') @@ -120,8 +121,10 @@ export default { pageNo: 1 }) this.getLockList(this.lockSearch) - uni.hideLoading() - this.backAndToast('添加成功') + setTimeout(() => { + uni.hideLoading() + this.backAndToast('添加成功') + }, 1000) } else { uni.hideLoading() uni.showToast({ diff --git a/pages/lockDetail/lockDetail.vue b/pages/lockDetail/lockDetail.vue index d4befbc..a63e467 100644 --- a/pages/lockDetail/lockDetail.vue +++ b/pages/lockDetail/lockDetail.vue @@ -86,7 +86,7 @@ export default { }, methods: { ...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']), - ...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp']), + ...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp', 'closeBluetoothConnection']), ...mapActions(useBasicStore, ['routeJump', 'backAndToast']), powerTip() { const that = this @@ -152,6 +152,7 @@ export default { onlineToken: this.onlineToken }) if(code === 0) { + this.closeBluetoothConnection() uni.showToast({ title: `${type === 'close' ? '关' : '开'}锁成功`, icon: 'none' diff --git a/pages/passwordDetail/passwordDetail.vue b/pages/passwordDetail/passwordDetail.vue index be596f9..6b0c72b 100644 --- a/pages/passwordDetail/passwordDetail.vue +++ b/pages/passwordDetail/passwordDetail.vue @@ -52,7 +52,7 @@ export default { }, methods: { timeFormat, - ...mapActions(useBluetoothStore, ['setLockPassword']), + ...mapActions(useBluetoothStore, ['setLockPassword', 'closeBluetoothConnection']), ...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']), ...mapActions(useBasicStore, ['backAndToast']), async deletePassword () { @@ -79,6 +79,7 @@ export default { endTime: timestamp }) if(code === 0) { + that.closeBluetoothConnection() const { code: requestCode, message } = await deletePsaawordRequest({ lockId: that.currentLockInfo.lockId, keyboardPwdId: that.currentPasswordInfo.keyboardPwdId, diff --git a/pages/passwordList/passwordList.vue b/pages/passwordList/passwordList.vue index bcf00a1..4917852 100644 --- a/pages/passwordList/passwordList.vue +++ b/pages/passwordList/passwordList.vue @@ -87,7 +87,7 @@ export default { methods: { ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']), ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch', 'getPasswordStatus']), - ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword']), + ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword', 'closeBluetoothConnection']), toPasswordDetail(password) { this.updateCurrentPasswordInfo(password) this.routeJump({ @@ -121,6 +121,7 @@ export default { endTime: timestamp }) if(code === 0) { + that.closeBluetoothConnection() const { code: requestCode, message } = await deletePsaawordRequest({ lockId: that.currentLockInfo.lockId, keyboardPwdId: password.keyboardPwdId, @@ -180,6 +181,7 @@ export default { keyId: that.currentLockInfo.keyId.toString() }) if(code === 0) { + that.closeBluetoothConnection() const { code: requestCode, message } = await resetPsaawordListRequest({ lockId: that.currentLockInfo.lockId, passwordKey: that.currentLockInfo.bluetooth.passwordKey diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue index 5ebb714..b9af61f 100644 --- a/pages/setting/setting.vue +++ b/pages/setting/setting.vue @@ -220,7 +220,7 @@ export default { icon: 'none' }) } - } else if(code === -1) { + } else if(resetDeviceCode === -1) { uni.hideLoading() uni.showToast({ title: '删除失败,请保持在锁附近', diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 3b111ff..a9e79b2 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -746,6 +746,7 @@ export const useBluetoothStore = defineStore('ble', { for(let i = 0; i < deviceList.length; i++) { if(deviceList[i]?.name === that.currentLockInfo.name) { const uuid = deviceList[i]?.advertisServiceUUIDs[0] + console.log('设备UUID', uuid, uuid.slice(2,8), uuid.slice(30,32)) if(uuid && uuid.slice(2,8)==='758824' && uuid.slice(30,32)==='01') { uni.stopBluetoothDevicesDiscovery() clearTimeout(timer2)