1
0
forked from dyf/APP

修复蓝牙连接锁未释放的问题

This commit is contained in:
liub
2026-04-30 11:23:28 +08:00
parent 677586e51c
commit 6d9df4c945
24 changed files with 1225 additions and 759 deletions

View File

@ -39,7 +39,7 @@
</view>
</view>
@ -112,7 +112,7 @@
</view>
</view>
</view>
<view class="warnnig" :class="formData.sta_ShakeBit!=0 ?'':'displayNone'">
<view class="warnnig" :class="formData.sta_ShakeBit!=0 ?'':'displayNone'">
<view>{{formData.sta_ShakeBit==3?'设备疑似受到外力碰撞':'设备声光报警中'}}</view>
<view @click.stop="SOSToggle()">
<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
@ -223,7 +223,7 @@
<text class="lbl">职位</text>
<input class="value" v-model="formData.job" placeholder="请输入职位" placeholder-class="usrplace" />
</view>
</view>
</view>
@ -243,7 +243,7 @@
</view>
</view>
<ProParams :id="device.id"></ProParams>
<ProParams :id="device.id"></ProParams>
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
@ -278,17 +278,17 @@
import MqttClient from '@/utils/mqtt.js';
import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
import SendBatchData from '@/utils/SendBatchData.js';
var batchTool=null;
var batchTool = null;
var eventChannel = null;
var these = null;
var ble = null;
var recei = null;
var mq = null;
var pagePath = "pages/6075J/BJQ6075J";
var brightnessTimer = null;
var reGeoTime=null;
var reGeoTime = null;
export default {
components: {
TextToHexV1
@ -460,7 +460,7 @@
}
},
created() {
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 20;
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
},
onUnload() {
console.log("页面卸载,释放资源");
@ -487,10 +487,10 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
});;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
});;
}
},
onHide: function() {
@ -558,10 +558,12 @@
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
});;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
});
these.getDetail();
});
@ -648,14 +650,14 @@
let f = this.getDevice();
if(!f){
if (!f) {
this.showBleUnConnect();
return;
}
if(!batchTool){
batchTool=new SendBatchData(these,f,ble);
}
if (!batchTool) {
batchTool = new SendBatchData(these, f, ble);
}
batchTool.SendVideo(504);
},
sendImg() {
@ -666,20 +668,20 @@
}
let f = this.getDevice();
if(!f){
if (!f) {
this.showBleUnConnect();
return;
}
if(!batchTool){
batchTool=new SendBatchData(these,f,ble);
if (!batchTool) {
batchTool = new SendBatchData(these, f, ble);
}
batchTool.SendImg();
return ;
return;
},
sliderChanging(e) {
this.formData.sta_brightness = e.detail.value;
@ -853,11 +855,11 @@
];
let item3 = Object.assign({}, json);
item3.textAlign='center';
item3.textAlign = 'center';
item3.name = 'media';
item3.title = '选择媒体';
item3.menuItems = [{
text: '照片',
text: '照片',
value: 'img',
key: 'media'
},
@ -967,7 +969,7 @@
let sendLaser = () => {
this.sendData(json, null, 'string').then(res => {
this.formData.sta_laser = val;
this.formData.sta_LightGrade=6;
this.formData.sta_LightGrade = 6;
this.setBleFormData();
}).catch(ex => {
console.error("出现错误", ex)
@ -1004,8 +1006,8 @@
this.sendData(json, null, 'string').then((res) => {
let key = li.key.replace(/ins_/g, 'sta_');
this.formData[key] = li.value;
if(li.value!=6){
this.formData.sta_laser=0;
if (li.value != 6) {
this.formData.sta_laser = 0;
}
this.setBleFormData();
this.formData.sta_brightness = 100;
@ -1028,9 +1030,9 @@
}
if(!batchTool){
batchTool=new SendBatchData(these,f,ble);
}
if (!batchTool) {
batchTool = new SendBatchData(these, f, ble);
}
batchTool.SendUsr(3);
},
sendMsg() {
@ -1106,7 +1108,13 @@
if (combinedData.length === curr - 1) {
Common.saveDeviceLog({
deviceId: this.device.id,
name: '发送紧急通知',
sendMsg: this.formData.sendMsg.trim()
}).catch(ex => {
});
holdHand('transmit complete', 200).then(res => {
MsgSuccess("消息发送成功", "确定", these);
@ -1124,12 +1132,14 @@
this.sendData(json, '4g', 'string').then(
res => {
curr++;
console.log("发送成功", curr)
setTimeout(sendPacket, 500);
console.log("发送成功", curr);
setTimeout(sendPacket, 1000);
}).catch(err => {
if (err.code == '10007') {
setTimeout(sendPacket, 500);
setTimeout(sendPacket, 1000);
} else {
console.log("err:", err);
MsgError('发送失败' + (err.msg || err.code), '确定', these);
@ -1291,7 +1301,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#FFFFFFde',
showCancel: true,
okCallback: function() {
console.log("1111");
@ -1361,37 +1371,37 @@
}
this.setBleFormData();
},
reGeo() {
console.log("经纬度发生变化,执行逆地理")
let task = () => {
if (this.formData.sta_longitude && this.formData.sta_latitude) {
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData
.sta_latitude);
promise.then(lnglat => {
this.device.longitude = lnglat[0];
this.device.latitude = lnglat[1];
this.formData.sta_longitude=lnglat[0];
this.formData.sta_latitude=lnglat[1];
Common.regeo(lnglat[0], lnglat[1]).then(res => {
reGeo() {
console.log("经纬度发生变化,执行逆地理")
let task = () => {
if (this.formData.sta_longitude && this.formData.sta_latitude) {
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData
.sta_latitude);
promise.then(lnglat => {
this.device.longitude = lnglat[0];
this.device.latitude = lnglat[1];
this.formData.sta_longitude = lnglat[0];
this.formData.sta_latitude = lnglat[1];
Common.regeo(lnglat[0], lnglat[1]).then(res => {
this.formData.address = res.regeocode.formatted_address
this.setBleFormData();
}).catch(ex => {
console.error("逆地理失败了")
});
}).catch(err => {
console.error("坐标转换失败了");
});
} else {
console.error("经纬度缺失");
}
}
clearTimeout(reGeoTime);
reGeoTime = setTimeout(task, 500);
this.setBleFormData();
}).catch(ex => {
console.error("逆地理失败了")
});
}).catch(err => {
console.error("坐标转换失败了");
});
} else {
console.error("经纬度缺失");
}
}
clearTimeout(reGeoTime);
reGeoTime = setTimeout(task, 500);
},
setBleFormData() {
if (!ble) {
@ -1416,8 +1426,8 @@
}
if (res.deviceId == these.formData.deviceId) {
this.formData.bleStatu = true;
batchTool=new SendBatchData(this,res,ble);
batchTool = new SendBatchData(this, res, ble);
setTimeout(() => {
hideLoading(these, 1000);
});
@ -1433,7 +1443,7 @@
// return;
// }
if (res.deviceId == these.formData.deviceId) {
batchTool=null;
batchTool = null;
if (res.device) {
these.formData.bleStatu = 'connecting';
} else {
@ -1481,7 +1491,7 @@
updateLoading(these, {
text: ex.msg
});
these.formData.bleStatu = 'err';
these.formData.bleStatu = 'err';
}).finally(() => {
setTimeout(() => {
hideLoading(these);
@ -1509,7 +1519,7 @@
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
MsgError("连接错误:" + ex.msg, "确定", these);
});
return;
}
@ -1517,7 +1527,8 @@
},
gotoMap() {
let promise =Promise.resolve([this.formData.sta_longitude, this.formData.sta_latitude]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
let promise = Promise.resolve([this.formData.sta_longitude, this.formData
.sta_latitude]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
promise.then(lnglat => {
this.detailData.longitude = lnglat[0];
@ -1536,7 +1547,7 @@
});
},
prevPage() {
uni.navigateBack({
@ -1941,7 +1952,7 @@
text-align: left;
}
.slider-container {
padding: 0px;