feat: 完成水电充值功能

This commit is contained in:
范鹏 2024-11-13 14:36:51 +08:00
parent 904c0bf247
commit a254039d5e
2 changed files with 9 additions and 12 deletions

View File

@ -257,21 +257,12 @@ function openBluetoothAdapter() {
}
// 关闭蓝牙模块
function closeBluetoothAdapter() {
return new Promise(resolve => {
uni.closeBluetoothAdapter({
success() {
resolve(Result.Success)
},
async fail(err) {
resolve(await handleError(err))
}
})
})
export function closeBluetoothAdapter() {
uni.closeBluetoothAdapter()
}
// 移除蓝牙适配器的全部监听
function offBluetoothAdapterStateChange() {
export function offBluetoothAdapterStateChange() {
uni.offBluetoothAdapterStateChange()
}

View File

@ -18,8 +18,10 @@ import {
import { getStorage, removeStorage, setStorage } from '@/starCloud/storage'
import {
closeBLEConnection,
closeBluetoothAdapter,
createBLEConnection,
getBluetoothDevices,
offBluetoothAdapterStateChange,
onBLECharacteristicValueChange,
Result,
searchAndConnectDevice,
@ -659,6 +661,10 @@ export const useStarCloudStore = defineStore('starCloud', {
if (addUserResult.code !== Result.Success.code) {
return addUserResult
}
offBluetoothAdapterStateChange()
closeBluetoothAdapter()
const params = {
lockAlias: this.lockInfo.bluetooth.bluetoothDeviceName,
lockInfo: {