绑定新设备后重新初始化蓝牙模块
This commit is contained in:
parent
4602f45dc6
commit
47cac685ab
@ -3,7 +3,7 @@
|
||||
"appid" : "__UNI__933D519",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "5",
|
||||
"versionCode" : "6",
|
||||
"transformPx" : false,
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
|
||||
@ -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('添加失败,请重试')
|
||||
|
||||
@ -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) {
|
||||
// 初始化蓝牙
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user