diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue index 39a6abc..cdce4a3 100644 --- a/pages/670/HBY670.vue +++ b/pages/670/HBY670.vue @@ -53,6 +53,14 @@ + + 设备强制闪烁报警中! + + {{Status.staticWarn.time}}s + + + 档位 @@ -250,7 +258,7 @@ data() { return { Status: { - apiType:"listA", + apiType: "listA", navbar: { icons: [{ src: '/static/images/common/msg.png' @@ -393,7 +401,7 @@ console.log("收到父页面的参数:" + JSON.stringify(data)); var device = data.data; - these.Status.apiType=data.apiType; + these.Status.apiType = data.apiType; these.device = device; if (these.device.deviceImei) { these.initMQ(); @@ -438,7 +446,7 @@ methods: { getWarnStyle(index) { let className = ""; - + switch (this.formData.warnLevel) { case "none": break; @@ -463,7 +471,7 @@ } break; } - + return className; }, handleRightClick: function(s, e) { @@ -496,9 +504,9 @@ }, initMQ() { - + return new Promise((resolve, reject) => { - + if (mqttClient) { console.log("无需再次初始化") resolve(); @@ -606,14 +614,14 @@ }; warn = dic[json.sta_DetectResult]; - - let sosText =null; - if(json.sta_SOSGrade!==undefined){ - - - sosText=json.sta_SOSGrade === 2 ? 'rb' : - json.sta_SOSGrade === 1 ? "sg" : "close" - + + let sosText = null; + if (json.sta_SOSGrade !== undefined) { + + + sosText = json.sta_SOSGrade === 2 ? 'rb' : + json.sta_SOSGrade === 1 ? "sg" : "close" + receiveData.SOS = sosText; } let staticWarn = json.sta_ShakeBit === 1; @@ -622,7 +630,7 @@ receiveData.lightCurr = lightingLevelText; receiveData.xuhang = json.sta_PowerTime + "分钟"; receiveData.battary = json.sta_PowerPercent + "%"; - + receiveData.warnLevel = warn; receiveData.staticWarn = staticWarn; receiveData.fourGStrenth = json.sta_4gSinal; @@ -630,13 +638,13 @@ receiveData.Lon = json.sta_longitude; receiveData.Lat = json.sta_latitude; - this.refreshFormData(receiveData,'auto'); + this.refreshFormData(receiveData, 'auto'); return receiveData; }, bleValueNotify: function(receive, device, path) { //订阅消息 let data = recei.ReceiveData(receive, device, pagePath); - console.log("收到设备的数据", data) + console.log("收到设备的数据", data) if (data) { if ("staBlue_picture" in data) { //重发图片 @@ -659,11 +667,11 @@ } return; } - this.refreshFormData(data,'auto'); + this.refreshFormData(data, 'auto'); } }, - refreshFormData(data,type) { + refreshFormData(data, type) { let keys = Object.keys(data); for (var i = 0; i < keys.length; i++) { let key = keys[i]; @@ -683,15 +691,7 @@ buttonText: "确定", clickEvt: "staticWarn" }); - // this.Status.staticWarn.time=5; - // this.Status.staticWarn.inteval=setInterval(()=>{ - // if(this.Status.staticWarn.time===0){ - // clearInterval(this.Status.staticWarn.inteval); - // this.formData.staticWarn=false; - // return; - // } - // this.Status.staticWarn.time=this.Status.staticWarn.time-1; - // },1000) + } @@ -754,7 +754,7 @@ this.sendMQ(json).then((res) => { console.log("4g发送成功"); }).catch((ex) => { - console.log("ex=",ex); + console.log("ex=", ex); these.showPop({ message: "通信异常,请检查手机或设备网络", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -799,6 +799,112 @@ setTimeout(task, 0); }, + CloseWarn: function(ispop) { + let closeEvt=()=>{ + { + these.Status.Pop.showPop = false; + + these.formData.qzwarn = false; + clearInterval(these.Status.staticWarn.inteval); + + let closeSOS=()=>{ + 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", + }); + + }).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(); + }); + + } else { + closeSOS(); + closeWarn(); + } + } + } + if(!ispop){ + closeEvt(); + } + this.showPop({ + showHeader: true, + headerTxt: "强制报警", + message: '持续报警时间' + this.Status.staticWarn.time, + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + buttonText:"解除报警", + okCallback: closeEvt + }); + + }, sosSetting: function(type) { if (this.formData.SOS == type) { type = "close"; @@ -831,7 +937,7 @@ this.sendMQ(json).then((res) => { console.log("4g发送成功"); }).catch((ex) => { - console.log("ex=",ex); + console.log("ex=", ex); these.showPop({ message: "通信异常,请检查手机或设备网络", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -862,27 +968,28 @@ dataView.setUint8(5, dic.ble[type]); // 数据 ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then( - () => { - 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(); - }).catch((ex) => { + () => { + 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(); + }).catch((ex) => { //使用4G发送 console.log("蓝牙发送失败,转4g发送", ex); requestSend(); @@ -892,7 +999,35 @@ } } - SendCmd(); + if (type !== 'sg') { + SendCmd(); + } else { + + this.showPop({ + message: '确定开启声光报警模式?', + iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", + borderColor: "#e034344d", + buttonBgColor: "#E03434", + okCallback: function() { + these.formData.qzwarn = true; + + these.Status.staticWarn.time = 5; + these.Status.staticWarn.inteval = setInterval(() => { + if (these.Status.staticWarn.time === 0) { + clearInterval(these.Status.staticWarn.inteval); + these.formData.qzwarn = false; + these.CloseWarn(false); + return; + } + these.Status.staticWarn.time = these.Status.staticWarn + .time - 1; + }, 1000) + + SendCmd(); + } + }); + } + } setTimeout(task, 0); @@ -929,7 +1064,7 @@ this.sendMQ(json).then((res) => { console.log("4g发送成功"); }).catch((ex) => { - console.log("ex=",ex) + console.log("ex=", ex) these.showPop({ message: "通信异常,请检查手机或设备网络", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", @@ -1534,32 +1669,33 @@ // clearInterval(this.Status.staticWarn.inteval); // this.formData.staticWarn=false; } - if(this.Status.Pop.okCallback){ + if (this.Status.Pop.okCallback) { console.log("执行点击按钮回调"); this.Status.Pop.okCallback(); } - + this.Status.Pop.showPop = false; }, closePop: function() { this.Status.Pop.showPop = false; - - if(this.Status.Pop.cancelCallback){ + + if (this.Status.Pop.cancelCallback) { this.Status.Pop.cancelCallback(); } }, showPop: function(option) { hideLoading(this); - let defaultCfg = { - showCancel: false, - borderColor: '#BBE600', - buttonBgColor:'#BBE600', - okCallback:null, - cancelCallback:null, - popType: 'custom' - }; + let defaultCfg = { + showHeader: false, + showCancel: false, + borderColor: '#BBE600', + buttonBgColor: '#BBE600', + okCallback: null, + cancelCallback: null, + popType: 'custom' + }; if (!option) { - + } let keys = Object.keys(option); for (var i = 0; i < keys.length; i++) { @@ -1569,12 +1705,12 @@ keys = Object.keys(defaultCfg); for (var i = 0; i < keys.length; i++) { let key = keys[i]; - if(key in option){ + if (key in option) { continue; } these.Status.Pop[key] = defaultCfg[key]; } - + these.Status.Pop.showPop = true; }, sendUsr: function(ReSendNo) { @@ -2515,8 +2651,8 @@ width: 40rpx; height: 40rpx; } - - + + .netContent { display: flex; flex-direction: row; @@ -2526,32 +2662,32 @@ align-items: flex-end; width: 50rpx; } - + .net { width: 7rpx; background: rgba(255, 255, 255, 0.3); } - + .net.netone { height: 11rpx; } - + .net.nettwo { height: 17rpx; } - + .net.netsiri { height: 23rpx; } - + .net.netfour { height: 29rpx; } - + .net.netfive { height: 35rpx; } - + .net.active { background: #FFFFFF !important; }