完成7305,添加在详情页去绑定蓝牙设备

This commit is contained in:
liub
2025-09-17 15:21:20 +08:00
parent ed8f02fb39
commit da9a9f4874
19 changed files with 5311 additions and 1523 deletions

View File

@ -44,7 +44,7 @@
</view>
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'">
<view>警告环境存在漏电电源</view>
<view>警告设备静止报警中</view>
<view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view>
@ -55,7 +55,7 @@
</view>
<view class="warnnig" v-bind:class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
@click="CloseWarn(true)">
<view>设备强制闪烁报警中</view>
<view>设备强制报警中</view>
<view class="netContent">
{{Status.staticWarn.time}}s
</view>
@ -90,7 +90,9 @@
:src="formData.SOS=='sg'?'/static/images/670/sgActive.png':'/static/images/670/sg.png'"
mode="aspectFit"></image>
</view>
<view class="txt">声光报警</view>
<view :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'">
报警中{{Status.staticWarn.time}}</view>
<view :class="(formData.qzwarn && Status.staticWarn.time)?'displayNone':''" class="txt">声光报警</view>
</view>
<view class="item" @click="sosSetting('rb')" :class="formData.SOS=='rb'?'active':''">
<view class="imgContent center">
@ -296,7 +298,8 @@
visiblePrompt: false,
promptTitle: '设备名称',
modelValue: '',
visibleClose: false
visibleClose: false,
},
BottomMenu: {
show: false,
@ -344,7 +347,7 @@
Lat: "", //纬度
address: "", //地址
modeCurr: "", //档位
SOS: "sg", //sos
SOS: "", //sos
lightCurr: "qiang", //照明模式
company: "", //单位
usrname: "", //姓名
@ -400,6 +403,7 @@
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
console.log("670")
ble.addReceiveCallback(these.bleValueNotify);
let eventChannel = this.getOpenerEventChannel();
@ -688,9 +692,9 @@
if (this.formData.imei) {
this.initMQ();
}
if (these.formData.staticWarn) { //有静止报警
if (this.formData.staticWarn) { //有静止报警
these.showPop({
message: "环境存在漏电电源",
message: "设备静止报警中",
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
@ -701,7 +705,7 @@
}
these.setBleFormData();
this.setBleFormData();
},
getDevice: function() {
@ -805,113 +809,97 @@
setTimeout(task, 0);
},
CloseWarn: function(ispop) {
CloseWarn: function(ispop) { //解除强制报警
let closeEvt = () => {
{
these.Status.Pop.showPop = false;
these.formData.qzwarn = false;
clearInterval(these.Status.staticWarn.inteval);
these.Status.Pop.showPop = false;
let closeSOS = () => {
let json = {
ins_SOSGrade: [0]
};
these.formData.qzwarn = false;
clearInterval(these.Status.staticWarn.inteval);
let requestCloseSOS = () => {
let json = {
ins_SOSGrade: [0]
};
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).finally(() => {
hideLoading(these);
these.setBleFormData();
});
}
let closeWarn = () => {
let json = {
ins_ShakeBit: [0]
};
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
these.setBleFormData();
});
}
let f = this.getDevice();
let buffer = null;
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x06); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x71); // 数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("关闭强制报警成功")
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x68);
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10)
.then(() => {
console.log("成功");
});
}).catch(ex => {
closeSOS();
// closeWarn();
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
} else {
closeSOS();
// closeWarn();
}
}).finally(() => {
hideLoading(these);
this.formData.SOS = 'close';
these.setBleFormData();
});
}
let f = this.getDevice();
let buffer = null;
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x6A); // 数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("关闭强制报警成功")
}).catch(ex => {
requestCloseSOS();
}).finally(() => {
this.formData.SOS = 'close';
these.setBleFormData();
});
} else {
requestCloseSOS();
}
}
if (!ispop) {
closeEvt();
return;
}
this.showQzWarn(closeEvt);
},
showQzWarn(callback) {
let message = '持续报警时间' + this.Status.staticWarn.time;
if (this.Status.Pop.clickEvt == 'time' && this.Status.Pop.showPop) {
this.Status.Pop.message = message
return;
}
this.showPop({
showHeader: true,
headerTxt: "强制报警",
message: '持续报警时间' + this.Status.staticWarn.time,
message: message,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: "解除报警",
okCallback: closeEvt
okCallback: callback,
clickEvt: 'time'
});
},
sosSetting: function(type) {
if (this.formData.SOS == type) {
@ -922,7 +910,7 @@
text: "请稍候..."
});
let task = () => {
this.formData.SOS = type;
let dic = {
ble: {
rb: 0x68,
@ -944,6 +932,8 @@
let requestSend = () => {
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
@ -961,7 +951,7 @@
}
let SendCmd = () => {
let bleSendCmd = () => {
let f = this.getDevice();
let buffer = null;
if (f) {
@ -979,21 +969,6 @@
() => {
console.log("蓝牙发送成功了");
// dic = {
// close: 0x71
// }
// if (type in dic) {
// dataView.setUint8(1, 0x06); // 帧类型
// dataView.setUint8(5, 0x71); // 数据
// } else {
// dataView.setUint8(1, 0x06); // 帧类型
// dataView.setUint8(5, 0x70); // 数据
// }
// ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
// 10).then(() => {
// console.log("蓝牙发送报警成功", type);
// })
hideLoading(these);
these.setBleFormData();
@ -1007,45 +982,70 @@
}
}
if (type !== 'sg') {
SendCmd();
} else {
let OpenSOS = () => {
these.formData.qzwarn = true; //标记为强制报警了
these.Status.staticWarn.time = 50;
this.formData.SOS = type;
let loopFunc = () => {
if (these.Status.staticWarn.inteval === null) {
return;
}
if (these.Status.staticWarn.time === 0) {
clearInterval(these.Status.staticWarn.inteval);
these.Status.staticWarn.inteval = null;
these.formData.qzwarn = false;
these.formData.SOS = 'close';
these.CloseWarn(false);
return;
}
these.Status.staticWarn.time = these.Status.staticWarn
.time - 1;
if (these.Status.Pop.clickEvt == 'time' && this.Status.Pop.showPop) {
console.log("111111");
this.showQzWarn(this.Status.Pop.okCallback);
}
}
these.Status.staticWarn.inteval = setInterval(() => {
loopFunc();
}, 1000)
bleSendCmd();
}
if (type == 'rb') { //红蓝报警
this.formData.SOS = type;
bleSendCmd();
return;
}
if (type == 'sg') //强制报警
{
this.showPop({
message: '确定开启声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: function() {
these.formData.qzwarn = true;
these.Status.staticWarn.time = 180;
let loopFunc = () => {
if (these.Status.staticWarn.inteval === null) {
return;
}
if (these.Status.staticWarn.time === 0) {
console.log("111111");
clearInterval(these.Status.staticWarn.inteval);
these.Status.staticWarn.inteval = null;
these.formData.qzwarn = false;
these.formData.SOS = 'close';
these.CloseWarn(false);
return;
}
these.Status.staticWarn.time = these.Status.staticWarn
.time - 1;
}
these.Status.staticWarn.inteval = setInterval(() => {
loopFunc();
}, 1000)
SendCmd();
}
okCallback: OpenSOS,
buttonText: "开启"
});
return;
}
if (type == 'close') {
if (this.formData.SOS = 'sg') { //解除声光报警
this.CloseWarn(true);
} else {
this.formData.SOS = type;
bleSendCmd();
}
}
}
@ -1522,7 +1522,30 @@
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
okCallback: function() {
console.log("1111");
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
}
});
return;
}
let uploadVideo = () => {
@ -1747,7 +1770,9 @@
buttonBgColor: '#BBE600',
okCallback: null,
cancelCallback: null,
popType: 'custom'
popType: 'custom',
buttonText: '确定',
clickEvt: ''
};
if (!option) {
@ -1755,7 +1780,7 @@
let keys = Object.keys(option);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
these.Status.Pop[key] = option[key];
this.Status.Pop[key] = option[key];
}
keys = Object.keys(defaultCfg);
for (var i = 0; i < keys.length; i++) {
@ -1763,10 +1788,10 @@
if (key in option) {
continue;
}
these.Status.Pop[key] = defaultCfg[key];
this.Status.Pop[key] = defaultCfg[key];
}
these.Status.Pop.showPop = true;
this.Status.Pop.showPop = true;
},
sendUsr: function(ReSendNo) {
@ -1873,7 +1898,7 @@
let json = {
deviceId: these.device.id,
deviceId: these.device.id,
name: these.formData.company,
position: these.formData.usrname,
unitName: these.formData.job,