diff --git a/pages/home/home.vue b/pages/home/home.vue index 426f241..ab414a2 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -185,7 +185,7 @@ authUid: that.userInfo.uid.toString(), keyId: that.keyId.toString() }) - if(resetDeviceCode === 0) { + if(resetDeviceCode === 0 || resetDeviceCode === -2) { const { code, message } = await deleteLockRequest({ lockId: that.currentLockInfo.lockId }) @@ -213,8 +213,6 @@ title: '删除失败,请保持在锁附近', icon: 'none' }) - } else { - uni.hideLoading() } } else { const { code } = await deleteKeyRequest({ diff --git a/pages/passwordDetail/passwordDetail.vue b/pages/passwordDetail/passwordDetail.vue index 6a7a0bc..ca9feb0 100644 --- a/pages/passwordDetail/passwordDetail.vue +++ b/pages/passwordDetail/passwordDetail.vue @@ -106,8 +106,6 @@ export default { title: '删除失败,请保持在锁附近', icon: 'none' }) - } else { - uni.hideLoading() } } } diff --git a/pages/passwordList/passwordList.vue b/pages/passwordList/passwordList.vue index 6e1330a..43e4ce6 100644 --- a/pages/passwordList/passwordList.vue +++ b/pages/passwordList/passwordList.vue @@ -151,8 +151,6 @@ export default { title: '删除失败,请保持在锁附近', icon: 'none' }) - } else { - uni.hideLoading() } } } @@ -211,8 +209,6 @@ export default { title: '重置密码失败,请保持在锁附近', icon: 'none' }) - } else { - uni.hideLoading() } } } diff --git a/pages/setting/setting.vue b/pages/setting/setting.vue index c94c940..18eb25a 100644 --- a/pages/setting/setting.vue +++ b/pages/setting/setting.vue @@ -38,7 +38,7 @@ - + 有效期 @@ -204,7 +204,7 @@ export default { authUid: that.userInfo.uid.toString(), keyId: that.keyId.toString() }) - if(resetDeviceCode === 0) { + if(resetDeviceCode === 0 || resetDeviceCode === -2) { const { code, message } = await deleteLockRequest({ lockId: that.currentLockInfo.lockId }) @@ -216,7 +216,6 @@ export default { }) that.getLockList(that.lockSearch) that.backAndToast('删除成功', 2) - uni.navigateBack() } else { uni.hideLoading() uni.showToast({ @@ -230,8 +229,6 @@ export default { title: '删除失败,请保持在锁附近', icon: 'none' }) - } else { - uni.hideLoading() } } else { const { code } = await deleteKeyRequest({ diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 3ab4424..784f5ce 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -609,7 +609,7 @@ export const useBluetoothStore = defineStore('ble', { }) }, // 连接蓝牙设备+获取设备服务+获取设备特征值 - connectBluetoothDevice() { + connectBluetoothDevice(number = 0) { const that = this return new Promise((resolve) => { if(that.bluetoothStatus !== 0) { @@ -681,11 +681,15 @@ export const useBluetoothStore = defineStore('ble', { } }) }, - fail(res) { + async fail(res) { if(res.errno === 1509007) { resolve(true) return } + if(res.errno === 1509001 && number < 1) { + // 重新连接 + resolve(await that.connectBluetoothDevice(number + 1)) + } uni.showToast({ title: '连接失败,请靠近设备并保持设备处于唤醒状态', icon: 'none' @@ -781,6 +785,7 @@ export const useBluetoothStore = defineStore('ble', { uni.stopBluetoothDevicesDiscovery() clearTimeout(timer2) clearInterval(timer1) + uni.hideLoading() uni.showToast({ title: '锁已被重置,请重新绑定', icon: 'none'