蓝牙小优化,App隐藏时断开设备连接
This commit is contained in:
@ -519,7 +519,7 @@
|
||||
ble = BleTool.getBleTool();
|
||||
|
||||
this.$watch("formData.sta_battery", (newVal, oldVal) => {
|
||||
if (newVal <= 20 && this.formData.sta_system==2) {
|
||||
if (newVal <= 20 && this.formData.sta_system == 2) {
|
||||
this.showMsg("设备电量低");
|
||||
}
|
||||
});
|
||||
@ -595,6 +595,15 @@
|
||||
},
|
||||
onShow() {
|
||||
this.Status.pageHide = false;
|
||||
|
||||
let f = this.getDevice();
|
||||
if (f) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
getbleStatu() {
|
||||
@ -1197,9 +1206,9 @@
|
||||
|
||||
},
|
||||
deviceDispose(res) {
|
||||
if (this.Status.pageHide) {
|
||||
return;
|
||||
}
|
||||
// if (this.Status.pageHide) {
|
||||
// return;
|
||||
// }
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
if (res.device) {
|
||||
these.formData.bleStatu = 'connecting';
|
||||
|
||||
Reference in New Issue
Block a user