feat: 优化蓝牙连接和关闭逻辑,增加平台判断,提升代码可读性
This commit is contained in:
parent
e882aef71e
commit
5b12b5f198
@ -90,8 +90,10 @@
|
||||
})
|
||||
if (addUserCode === 0) {
|
||||
this.closeBluetoothConnection()
|
||||
// #ifdef MP
|
||||
this.closeAllBluetooth()
|
||||
this.initAndListenBluetooth()
|
||||
// #endif
|
||||
} else if (addUserCode === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
|
||||
@ -116,15 +116,15 @@
|
||||
|
||||
<style scoped lang="scss">
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -347,7 +347,9 @@
|
||||
lockId: $bluetooth.currentLockInfo.lockName.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
// #ifdef MP
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
// #endif
|
||||
if (code === 0) {
|
||||
const { code: resultCode } = await lockDataUploadRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
|
||||
@ -249,7 +249,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
}
|
||||
}
|
||||
// 蓝牙已经初始化
|
||||
if (err.errMsg === 'openBluetoothAdapter:fail already opened') {
|
||||
if (err.errMsg === 'openBluetoothAdapter:fail already opened' || err.code === -1) {
|
||||
resolve(true)
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user