diff --git a/manifest.json b/manifest.json index 59874e5..43e3978 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "appid" : "__UNI__933D519", "description" : "", "versionName" : "1.0.0", - "versionCode" : "5", + "versionCode" : "6", "transformPx" : false, /* 小程序特有相关 */ "mp-weixin" : { diff --git a/pages/bindLock/bindLock.vue b/pages/bindLock/bindLock.vue index ed1d3fe..9aa85ee 100644 --- a/pages/bindLock/bindLock.vue +++ b/pages/bindLock/bindLock.vue @@ -33,7 +33,8 @@ export default { console.log(this.name) }, methods: { - ...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection', 'updateBindedDeviceName']), + ...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection', 'updateBindedDeviceName', + 'closeAllBluetooth', 'initAndListenBluetooth']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useBasicStore, ['backAndToast']), uopdateName(data) { @@ -75,6 +76,8 @@ export default { if(addUserCode === 0) { this.closeBluetoothConnection() this.updateBindedDeviceName(this.currentLockInfo.name) + this.closeAllBluetooth() + this.initAndListenBluetooth() } else if(addUserCode === -1) { uni.hideLoading() this.backAndToast('添加失败,请重试') diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 39d8b65..3ab4424 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -107,6 +107,15 @@ export const useBluetoothStore = defineStore('ble', { } return { code, data, message } }, + // 关闭全部蓝牙监听并关闭蓝牙模拟 + closeAllBluetooth() { + uni.offBluetoothAdapterStateChange() + uni.closeBluetoothAdapter({ + success(res) { + console.log('关闭蓝牙模块', res) + } + }) + }, // 初始化并监听 async initAndListenBluetooth(tipFlag) { // 初始化蓝牙