蓝牙模块添加在web平台默认成功方便调试功能,4877功能完成

This commit is contained in:
liub
2025-10-27 10:52:17 +08:00
parent d37ccfeabc
commit 61ed91695f
13 changed files with 575 additions and 318 deletions

View File

@ -2,7 +2,8 @@
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'" mode="aspectFit"></image>
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'"
mode="aspectFit"></image>
</view>
<view class="rightTxt">
<view class="row">
@ -36,7 +37,8 @@
</view>
</view>
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop="showUnWarn('sos_off')">
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view>
<view class="netContent">
{{formData.warnTime}}s
@ -47,7 +49,7 @@
<view class="lamp">
<view class="title">
<text>SOS</text>
<view @click.stop="sosSetting({val:'sos_off'})">
<view @click.stop="sosSetting({val:'sos_off'},-1)">
<image class="img" src="/static/images/common/close.png" mode="aspectFit"></image>
</view>
</view>
@ -245,12 +247,12 @@
var ble = null;
var these = null;
var recei = null;
var interval=null;
var interval = null;
export default {
data() {
return {
Status: {
pageHide: false,
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
@ -323,7 +325,7 @@
sta_SOSType: '', //sos
sta_GroupType: '', //配组
sta_ArrowType: '', //箭头方向
warnTime:0
warnTime: 0
},
dic: {
SOS: [{
@ -398,11 +400,11 @@
ble = BleTool.getBleTool();
ble.addReceiveCallback(these.bleValueNotify, pagePath);
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
ble.addDisposeCallback(these.deviceDispose, pagePath);
ble.addRecoveryCallback(these.deviceRecovry, pagePath);
ble.addReceiveCallback(this.bleValueNotify, pagePath);
ble.addStateBreakCallback(this.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(this.bleStateRecovry, pagePath);
ble.addDisposeCallback(this.deviceDispose, pagePath);
ble.addRecoveryCallback(this.deviceRecovry, pagePath);
let eventChannel = this.getOpenerEventChannel();
@ -438,7 +440,7 @@
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu=false;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
@ -467,19 +469,18 @@
return;
}
if (this.formData.sta_ArrowType === val) {
this.formData.sta_ArrowType = 'arrow_off';
} else {
this.formData.sta_ArrowType = val;
val = 'arrow_off';
}
var json = {
ins_ArrowType: this.formData.sta_ArrowType
ins_ArrowType: val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
.catch(ex => {
this.showMsg(ex.msg);
});
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.formData.sta_ArrowType = val;
}).catch(ex => {
this.showMsg(ex.msg);
});
},
groupSetting(item, index) {
let f = this.getDevice();
@ -510,7 +511,7 @@
buttonBgColor: "#E03434",
okCallback: () => {
clearInterval(interval);
this.sosSetting({
val: val
});
@ -528,30 +529,31 @@
return;
}
let task = () => {
var json = {
ins_SOSType: this.formData.sta_SOSType==item.val?'sos_off':item.val
ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
if(this.formData.sta_SOSType=='sos'){
this.formData.warnTime=0;
clearInterval(interval);
interval=setInterval(()=>{
this.formData.warnTime+=1;
},1000)
}
})
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
if (this.formData.sta_SOSType == 'sos') {
this.formData.warnTime = 0;
clearInterval(interval);
interval = setInterval(() => {
this.formData.warnTime += 1;
}, 1000)
}
})
.catch(ex => {
this.showMsg(ex.msg);
});
@ -569,12 +571,12 @@
});
} else {
if(index!==undefined && this.formData.sta_SOSType=='sos'){
if (index !== undefined && this.formData.sta_SOSType == 'sos') {
this.showUnWarn(item.val);
}else{
task();
} else {
task();
}
}
@ -688,6 +690,9 @@
return className;
},
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("处理后的数据:", data);
@ -754,7 +759,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#232323de',
okCallback: function() {
uni.navigateTo({
@ -826,7 +831,7 @@
}
},
showPop: function(option) {
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',