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() { export function closeBluetoothAdapter() {
return new Promise(resolve => { uni.closeBluetoothAdapter()
uni.closeBluetoothAdapter({
success() {
resolve(Result.Success)
},
async fail(err) {
resolve(await handleError(err))
}
})
})
} }
// 移除蓝牙适配器的全部监听 // 移除蓝牙适配器的全部监听
function offBluetoothAdapterStateChange() { export function offBluetoothAdapterStateChange() {
uni.offBluetoothAdapterStateChange() uni.offBluetoothAdapterStateChange()
} }

View File

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