优化蓝牙订阅在首页的弹窗
This commit is contained in:
@ -58,6 +58,12 @@
|
|||||||
{{getbleStatu}}
|
{{getbleStatu}}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
|
||||||
|
<text class="info-label">充电状态</text>
|
||||||
|
<text class="info-value status-running" >
|
||||||
|
{{deviceInfo.chargeState != 0?'充电中':'未充电'}}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
<text class="info-label" style="display: flex; align-items: center;">定位信息</text>
|
<text class="info-label" style="display: flex; align-items: center;">定位信息</text>
|
||||||
<view class="info-value status-running" @click="gpsPosition(deviceInfo)">
|
<view class="info-value status-running" @click="gpsPosition(deviceInfo)">
|
||||||
@ -73,7 +79,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="callpolice" v-if="deviceInfo.onlineStatus == 1 && deviceInfo.alarmStatus == 1">
|
<view class="callpolice" v-if="deviceInfo.alarmStatus == 1">
|
||||||
<view class="">设备强制报警中</view>
|
<view class="">设备强制报警中</view>
|
||||||
<view>
|
<view>
|
||||||
<uni-icons type="closeempty" size="15" color="rgba(255, 255, 255, 0.9)"
|
<uni-icons type="closeempty" size="15" color="rgba(255, 255, 255, 0.9)"
|
||||||
@ -436,6 +442,52 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onReceive(deviceState){//蓝牙/Mq通用消息处理
|
||||||
|
switch (deviceState[0]) {
|
||||||
|
// 1设备切换灯光实时返回
|
||||||
|
case 1:
|
||||||
|
this.currentMainMode = this.getMainLightModeLabel(
|
||||||
|
deviceState[
|
||||||
|
1]);
|
||||||
|
this.sliderValue = deviceState[2];
|
||||||
|
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
||||||
|
break;
|
||||||
|
// 12为设备实时上报
|
||||||
|
case 12:
|
||||||
|
this.currentMainMode = this.getMainLightModeLabel(
|
||||||
|
deviceState[
|
||||||
|
1]);
|
||||||
|
this.isLaserOn = deviceState[2] === 1; //第3位表示当时激光灯档位
|
||||||
|
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
||||||
|
if (this.deviceInfo) {
|
||||||
|
this.deviceInfo.batteryPercentage = deviceState[3]; //第4位电量百分比
|
||||||
|
this.deviceInfo.chargeState = deviceState[4]; //第5位为充电状态(0没有充电,1正在充电,2为已充满)
|
||||||
|
this.deviceInfo.batteryRemainingTime = deviceState[5]; //第6位200代表电池剩余续航时间200分钟
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||||
|
this.deviceInfo.chargeState == 0) {
|
||||||
|
this.popupType = 'bettery';
|
||||||
|
this.popupMessage = '请及时充电';
|
||||||
|
this.showPopupFlag = true;
|
||||||
|
}
|
||||||
|
if (this.apiType === 'listA') {
|
||||||
|
this.fetchDeviceDetail(data.data.id)
|
||||||
|
} else {
|
||||||
|
// 分享权限详情
|
||||||
|
this.fetchSharedDeviceDetail(data.data.id)
|
||||||
|
}
|
||||||
|
}, 10000);
|
||||||
|
// 上报电量,在列表里面同步
|
||||||
|
uni.$emit('deviceStatusUpdate', {
|
||||||
|
message: parsedMessage,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('未知的 deviceState 类型:', deviceState[0]);
|
||||||
|
}
|
||||||
|
},
|
||||||
bleStatuToggle() {
|
bleStatuToggle() {
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
if (!f) {
|
if (!f) {
|
||||||
@ -532,11 +584,9 @@
|
|||||||
}
|
}
|
||||||
let data = rec.ReceiveData(receive, device, pagePath, recArr);
|
let data = rec.ReceiveData(receive, device, pagePath, recArr);
|
||||||
console.log("蓝牙收到消息", data)
|
console.log("蓝牙收到消息", data)
|
||||||
this.receivData(data);
|
this.onReceive(data.state);
|
||||||
},
|
|
||||||
receivData(data) {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
bleStateBreak() {
|
bleStateBreak() {
|
||||||
if (this.Status.pageHide) {
|
if (this.Status.pageHide) {
|
||||||
return;
|
return;
|
||||||
@ -1566,6 +1616,7 @@
|
|||||||
// this.popupConfirmText="";
|
// this.popupConfirmText="";
|
||||||
},
|
},
|
||||||
OpenWarn(val){//开启/解除强制报警
|
OpenWarn(val){//开启/解除强制报警
|
||||||
|
debugger;
|
||||||
const topic = `B/${this.itemInfo.deviceImei}`;
|
const topic = `B/${this.itemInfo.deviceImei}`;
|
||||||
let message={"instruct":[7,val,0,0,0,0]};
|
let message={"instruct":[7,val,0,0,0,0]};
|
||||||
message=JSON.stringify(message);
|
message=JSON.stringify(message);
|
||||||
@ -1575,6 +1626,8 @@
|
|||||||
});
|
});
|
||||||
if(flag){
|
if(flag){
|
||||||
this.itemInfo.alarmStatus=val;
|
this.itemInfo.alarmStatus=val;
|
||||||
|
}else{
|
||||||
|
MsgError("操作没有成功",'确定',this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showPopupFlag = false;
|
this.showPopupFlag = false;
|
||||||
@ -1644,11 +1697,11 @@
|
|||||||
// 3.解除告警状态
|
// 3.解除告警状态
|
||||||
const registerRes = await deviceSendAlarmMessage(data);
|
const registerRes = await deviceSendAlarmMessage(data);
|
||||||
if (registerRes.code !== 200) {
|
if (registerRes.code !== 200) {
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: registerRes.msg,
|
// title: registerRes.msg,
|
||||||
icon: 'none'
|
// icon: 'none'
|
||||||
})
|
// })
|
||||||
|
this.OpenWarn(0);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.itemInfo.alarmStatus=0;
|
this.itemInfo.alarmStatus=0;
|
||||||
@ -1908,53 +1961,8 @@
|
|||||||
const deviceState = parsedMessage.state; // 直接取 state 数组
|
const deviceState = parsedMessage.state; // 直接取 state 数组
|
||||||
// 切换主灯光模式,亮度值设备同步
|
// 切换主灯光模式,亮度值设备同步
|
||||||
if (!deviceState) return;
|
if (!deviceState) return;
|
||||||
// 1设备切换灯光实时返回
|
|
||||||
switch (deviceState[0]) {
|
this.onReceive(deviceState);
|
||||||
case 1:
|
|
||||||
this.currentMainMode = this.getMainLightModeLabel(
|
|
||||||
deviceState[
|
|
||||||
1]);
|
|
||||||
this.sliderValue = deviceState[2];
|
|
||||||
this.deviceInfo.batteryRemainingTime = deviceState[3];
|
|
||||||
break;
|
|
||||||
// 12为设备实时上报
|
|
||||||
case 12:
|
|
||||||
this.currentMainMode = this.getMainLightModeLabel(
|
|
||||||
deviceState[
|
|
||||||
1]);
|
|
||||||
this.isLaserOn = deviceState[2] === 1; //第3位表示当时激光灯档位
|
|
||||||
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
|
|
||||||
if (this.deviceInfo) {
|
|
||||||
this.deviceInfo.batteryPercentage = deviceState[
|
|
||||||
3]; //第4位电量百分比
|
|
||||||
this.deviceInfo.chargeState = deviceState[
|
|
||||||
4]; //第5位为充电状态(0没有充电,1正在充电,2为已充满)
|
|
||||||
this.deviceInfo.batteryRemainingTime = deviceState[
|
|
||||||
5]; //第6位200代表电池剩余续航时间200分钟
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.deviceInfo.batteryPercentage < 20 &&
|
|
||||||
this.deviceInfo.chargeState == 0) {
|
|
||||||
this.popupType = 'bettery';
|
|
||||||
this.popupMessage = '请及时充电';
|
|
||||||
this.showPopupFlag = true;
|
|
||||||
}
|
|
||||||
if (this.apiType === 'listA') {
|
|
||||||
this.fetchDeviceDetail(data.data.id)
|
|
||||||
} else {
|
|
||||||
// 分享权限详情
|
|
||||||
this.fetchSharedDeviceDetail(data.data.id)
|
|
||||||
}
|
|
||||||
}, 10000);
|
|
||||||
// 上报电量,在列表里面同步
|
|
||||||
uni.$emit('deviceStatusUpdate', {
|
|
||||||
message: parsedMessage,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log('未知的 deviceState 类型:', deviceState[0]);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
|
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -482,20 +482,20 @@
|
|||||||
|
|
||||||
|
|
||||||
ble.addStateBreakCallback(() => {
|
ble.addStateBreakCallback(() => {
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '蓝牙不可用'
|
MsgError('蓝牙不可用','',these);
|
||||||
});
|
|
||||||
|
|
||||||
these.EquipMents.filter((v, i) => {
|
these.EquipMents.filter((v, i) => {
|
||||||
these.$set(these.EquipMents[i], 'link', false);
|
these.$set(these.EquipMents[i], 'link', false);
|
||||||
});
|
});
|
||||||
}, pagePath);
|
}, pagePath);
|
||||||
ble.addStateRecoveryCallback(() => {
|
ble.addStateRecoveryCallback(() => {
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '蓝牙恢复可用'
|
MsgSuccess('蓝牙恢复可用','',these,()=>{
|
||||||
});
|
MsgClear(these);
|
||||||
|
})
|
||||||
},
|
},
|
||||||
pagePath);
|
pagePath);
|
||||||
|
|
||||||
@ -568,7 +568,7 @@
|
|||||||
|
|
||||||
|
|
||||||
plus.runtime.openURL('weixin://', (err) => {
|
plus.runtime.openURL('weixin://', (err) => {
|
||||||
MsgError("打开微信失败,请手动打开微信粘贴");
|
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail(ex){
|
fail(ex){
|
||||||
@ -805,10 +805,8 @@
|
|||||||
|
|
||||||
let json = getUrlParams(res.result);
|
let json = getUrlParams(res.result);
|
||||||
if (!json.key) {
|
if (!json.key) {
|
||||||
uni.showModal({
|
|
||||||
title: '错误',
|
MsgError('无效的二维码','',these);
|
||||||
content: "无效的二维码"
|
|
||||||
})
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.scanKey = json.key;
|
this.scanKey = json.key;
|
||||||
@ -1050,9 +1048,8 @@
|
|||||||
these.sendEquipToMq();
|
these.sendEquipToMq();
|
||||||
}).catch(ex => {
|
}).catch(ex => {
|
||||||
console.log("ex=", ex)
|
console.log("ex=", ex)
|
||||||
uni.showModal({
|
|
||||||
content: "连接失败:" + ex.msg
|
MsgError("连接失败:" + ex.msg,'',these);
|
||||||
});
|
|
||||||
hideLoading(these);
|
hideLoading(these);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,6 +134,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<!-- 蒙板、用于点击任意位置关闭悬浮的菜单 -->
|
<!-- 蒙板、用于点击任意位置关闭悬浮的菜单 -->
|
||||||
<view class="mask" v-show="showTooltip||showshare" @click.stop="closePopMenu"></view>
|
<view class="mask" v-show="showTooltip||showshare" @click.stop="closePopMenu"></view>
|
||||||
|
|
||||||
|
|
||||||
|
<MsgBox ref="msgPop" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -772,7 +775,8 @@
|
|||||||
this.downCallback();
|
this.downCallback();
|
||||||
});
|
});
|
||||||
ble = bleTool.getBleTool();
|
ble = bleTool.getBleTool();
|
||||||
recei = BleReceive.getBleReceive();
|
console.log("this=",this);
|
||||||
|
recei = BleReceive.getBleReceive(this);
|
||||||
//蓝牙连接成功的回调
|
//蓝牙连接成功的回调
|
||||||
ble.addRecoveryCallback((res) => {
|
ble.addRecoveryCallback((res) => {
|
||||||
// console.log("蓝牙连接成功的回调");
|
// console.log("蓝牙连接成功的回调");
|
||||||
@ -799,8 +803,9 @@
|
|||||||
|
|
||||||
//接收到消息的回调
|
//接收到消息的回调
|
||||||
ble.addReceiveCallback((receive, device, path, recArr) => {
|
ble.addReceiveCallback((receive, device, path, recArr) => {
|
||||||
// console.error("首页收到消息了");
|
console.error("首页收到消息了");
|
||||||
recei.ReceiveData(receive, device, path, recArr);
|
let json=recei.ReceiveData(receive, device, path, recArr);
|
||||||
|
console.error("消息内容",json);
|
||||||
this.updateBleStatu();
|
this.updateBleStatu();
|
||||||
}, pagePath);
|
}, pagePath);
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,6 @@ const serviceDic = [ //合作供应商的蓝牙主服务
|
|||||||
class BleHelper {
|
class BleHelper {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.StorageKey = "linkedDevices";
|
this.StorageKey = "linkedDevices";
|
||||||
|
|
||||||
recei = receivTool.getBleReceive();
|
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
init() {
|
init() {
|
||||||
@ -41,16 +38,12 @@ class BleHelper {
|
|||||||
if (!v) return false;
|
if (!v) return false;
|
||||||
v.Linked = false;
|
v.Linked = false;
|
||||||
v.notifyState = false;
|
v.notifyState = false;
|
||||||
return !!v.device;
|
return v.device;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const systemInfo = uni.getSystemInfoSync();
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.data = {
|
this.data = {
|
||||||
isOpenBlue: false, //蓝牙模块是否开启
|
isOpenBlue: false, //蓝牙模块是否开启
|
||||||
available: false, //蓝牙状态是否可用
|
available: false, //蓝牙状态是否可用
|
||||||
@ -71,17 +64,7 @@ class BleHelper {
|
|||||||
stateRecoveryCallback: [], //蓝牙适配器恢复可用事件
|
stateRecoveryCallback: [], //蓝牙适配器恢复可用事件
|
||||||
stateBreakCallback: [] //蓝牙适配器不可用事件
|
stateBreakCallback: [] //蓝牙适配器不可用事件
|
||||||
}
|
}
|
||||||
//蓝牙模块不再订阅,改到首页订阅
|
|
||||||
// this.addReceiveCallback((receive, f, path, recArr) => {
|
|
||||||
// recei.ReceiveData(receive, f, path, recArr);
|
|
||||||
// }, "BleReceiveData");
|
|
||||||
|
|
||||||
// setTimeout(() => {
|
|
||||||
// this.OpenBlue().then(() => {
|
|
||||||
// this.linkAllDevices();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// }, 10);
|
|
||||||
|
|
||||||
this.dic = {
|
this.dic = {
|
||||||
errRemarks: [{
|
errRemarks: [{
|
||||||
|
|||||||
@ -1,8 +1,20 @@
|
|||||||
import Common from '@/utils/Common.js'
|
import Common from '@/utils/Common.js'
|
||||||
import { parseBleData } from '@/api/100J/HBY100-J.js'
|
import {
|
||||||
|
parseBleData
|
||||||
|
} from '@/api/100J/HBY100-J.js'
|
||||||
|
import {
|
||||||
|
MsgSuccess,
|
||||||
|
MsgError,
|
||||||
|
MsgClose,
|
||||||
|
MsgWarning,
|
||||||
|
showPop,
|
||||||
|
MsgClear,
|
||||||
|
MsgInfo
|
||||||
|
} from '@/utils/MsgPops.js';
|
||||||
|
|
||||||
class BleReceive {
|
class BleReceive {
|
||||||
constructor() {
|
constructor(_ref) {
|
||||||
|
this.ref = _ref;
|
||||||
this.StorageKey = "linkedDevices";
|
this.StorageKey = "linkedDevices";
|
||||||
this.HandlerMap = {
|
this.HandlerMap = {
|
||||||
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
|
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
|
||||||
@ -13,10 +25,11 @@ class BleReceive {
|
|||||||
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
||||||
'/pages/100/HBY100': this.Receive_100.bind(this),
|
'/pages/100/HBY100': this.Receive_100.bind(this),
|
||||||
'/pages/102/HBY102': this.Receive_102.bind(this),
|
'/pages/102/HBY102': this.Receive_102.bind(this),
|
||||||
'/pages/6170/deviceControl/index':this.Receive_6170.bind(this),
|
'/pages/6170/deviceControl/index': this.Receive_6170.bind(this),
|
||||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
|
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
|
||||||
'/pages/6075J/BJQ6075J':this.Receive_6075.bind(this)
|
'/pages/6075J/BJQ6075J': this.Receive_6075.bind(this)
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,23 +76,23 @@ class BleReceive {
|
|||||||
return receive;
|
return receive;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f && f.macAddress && f.device && f.device.id) {
|
if (fReady) {
|
||||||
let handler = null;
|
let handler = null;
|
||||||
let keys = Object.keys(this.HandlerMap);
|
let keys = Object.keys(this.HandlerMap);
|
||||||
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, '').toLowerCase() : '';
|
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, '').toLowerCase() : '';
|
||||||
|
|
||||||
for (let index = 0; index < keys.length; index++) {
|
for (let index = 0; index < keys.length; index++) {
|
||||||
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, "").toLowerCase() : '';
|
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, "").toLowerCase() : '';
|
||||||
let key = keys[index].replace(/\//g, '').toLowerCase();
|
let key = keys[index].replace(/\//g, '').toLowerCase();
|
||||||
if (key == devKey) {
|
if (key == devKey) {
|
||||||
handler = this.HandlerMap[keys[index]];
|
handler = this.HandlerMap[keys[index]];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler) {
|
if (handler) {
|
||||||
let data = handler(receive, f, path, recArr);
|
let data = handler(receive, f, path, recArr);
|
||||||
this.setBleFormData(data, f);
|
this.setBleFormData(data, f);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
@ -89,7 +102,7 @@ class BleReceive {
|
|||||||
} else {
|
} else {
|
||||||
// 100J AE30 二进制帧在 f 不完整时已在上方 parseBleData,此处不再误报「无法处理」
|
// 100J AE30 二进制帧在 f 不完整时已在上方 parseBleData,此处不再误报「无法处理」
|
||||||
if (!is100JAe30) {
|
if (!is100JAe30) {
|
||||||
console.log("已收到该消息,但无法处理", receive, "f:", f);
|
console.error("已收到该消息,但无法处理", receive, "f:", f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,40 +193,33 @@ class BleReceive {
|
|||||||
formData.modeCurr = modeCurr;
|
formData.modeCurr = modeCurr;
|
||||||
formData.warnLevel = warn;
|
formData.warnLevel = warn;
|
||||||
formData.iswarn = iswarn;
|
formData.iswarn = iswarn;
|
||||||
|
|
||||||
|
|
||||||
let recCnt = recArr.find(v => {
|
let recCnt = recArr.find(v => {
|
||||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||||
.replace(/\//g, "").toLowerCase();
|
.replace(/\//g, "").toLowerCase();
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
|
let msg = [];
|
||||||
|
if (f) {
|
||||||
|
if (formData.battary <= 20) {
|
||||||
|
msg.push("设备'" + f.device.deviceName + "'电量低");
|
||||||
|
}
|
||||||
|
if (iswarn) {
|
||||||
|
msg.push("设备'" + f.device.deviceName + "'环境存在漏电电源");
|
||||||
|
}
|
||||||
|
|
||||||
if (iswarn) {
|
if (this.ref && msg.length>0) {
|
||||||
uni.showModal({
|
if (msg.length > 0) {
|
||||||
content: "'" + f.device.deviceName + "'环境存在漏电电源",
|
msg = msg.join(',');
|
||||||
title: "警告",
|
MsgError("'" + f.device.deviceName + "'环境存在漏电电源", '', this.ref, () => {
|
||||||
success(res) {
|
MsgClear(this.ref);
|
||||||
if (res.confirm) {
|
});
|
||||||
|
|
||||||
if (f) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: f.detailPageUrl,
|
|
||||||
events: {
|
|
||||||
ack: function(data) {}
|
|
||||||
},
|
|
||||||
success: (res) => {
|
|
||||||
res.eventChannel.emit('detailData', {
|
|
||||||
data: f,
|
|
||||||
deviceType: '',
|
|
||||||
apiType: 'listA'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -229,7 +235,7 @@ class BleReceive {
|
|||||||
if (str.indexOf('mac address:') == 0) {
|
if (str.indexOf('mac address:') == 0) {
|
||||||
let formData = {};
|
let formData = {};
|
||||||
formData.macAddress = str.split(':')[1];
|
formData.macAddress = str.split(':')[1];
|
||||||
|
|
||||||
return formData;
|
return formData;
|
||||||
} else {
|
} else {
|
||||||
let receiveData = {
|
let receiveData = {
|
||||||
@ -348,7 +354,7 @@ class BleReceive {
|
|||||||
receiveData.fourGStrenth = fourGStrenth;
|
receiveData.fourGStrenth = fourGStrenth;
|
||||||
receiveData.SOS = sosTxt;
|
receiveData.SOS = sosTxt;
|
||||||
receiveData.qzwarn = sosTxt === 'sg';
|
receiveData.qzwarn = sosTxt === 'sg';
|
||||||
|
|
||||||
console.log("recArr=", recArr);
|
console.log("recArr=", recArr);
|
||||||
let recCnt = recArr.find(v => {
|
let recCnt = recArr.find(v => {
|
||||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||||
@ -362,13 +368,22 @@ class BleReceive {
|
|||||||
if (staticWarn) { //有静止报警
|
if (staticWarn) { //有静止报警
|
||||||
msgs.push("静止报警中");
|
msgs.push("静止报警中");
|
||||||
}
|
}
|
||||||
|
if (receiveData.battary <= 20) {
|
||||||
|
msg.push("设备'" + f.device.deviceName + "'电量低");
|
||||||
|
}
|
||||||
if (msgs.length > 0) {
|
if (msgs.length > 0) {
|
||||||
msgs = "设备'" + f.device.deviceName + msgs.join(";");
|
msgs = msgs.join(";");
|
||||||
uni.showModal({
|
if (this.ref) {
|
||||||
title: "警告",
|
MsgError(msgs, '', this.ref, () => {
|
||||||
content: msgs,
|
MsgClear(this.ref);
|
||||||
showCancel: false
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// uni.showModal({
|
||||||
|
// title: "警告",
|
||||||
|
// content: msgs,
|
||||||
|
// showCancel: false
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -436,7 +451,7 @@ class BleReceive {
|
|||||||
console.log('将数据转文本失败', ex);
|
console.log('将数据转文本失败', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,12 +529,13 @@ class BleReceive {
|
|||||||
|
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (batteryLevel <= 20) {
|
if (batteryLevel <= 20 && warn == 0x00) {
|
||||||
// 会弹出两个框,暂且注释掉这段代码
|
|
||||||
uni.showModal({
|
if (this.ref) {
|
||||||
content: "设备'" + f.device.deviceName + "'电量低",
|
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||||
title: "提示"
|
MsgClear(this.ref);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,13 +629,17 @@ class BleReceive {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
console.log("formData=",formData)
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (batteryLevel <= 20) {
|
console.log("11111");
|
||||||
// 会弹出两个框,暂且注释掉这段代码
|
if (formData.battary <= 20 && bytes[5] == 0x00) {
|
||||||
uni.showModal({
|
console.log("2222")
|
||||||
content: "设备'" + f.device.deviceName + "'电量低",
|
if (this.ref) {
|
||||||
title: "提示"
|
console.log("3333333");
|
||||||
});
|
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||||
|
MsgClear(this.ref);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,11 +666,13 @@ class BleReceive {
|
|||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (receiveData.sta_PowerPercent <= 20) {
|
if (receiveData.sta_PowerPercent <= 20) {
|
||||||
uni.showModal({
|
|
||||||
title: "提示",
|
if (this.ref) {
|
||||||
content: "设备'" + f.device.deviceName + "'电量低",
|
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||||
showCancel: false
|
MsgClear(this.ref);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -674,12 +696,16 @@ class BleReceive {
|
|||||||
.replace(/\//g, "").toLowerCase();
|
.replace(/\//g, "").toLowerCase();
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (receiveData.sta_battery <= 20) {
|
if (receiveData.sta_battery <= 20 && (receiveData.sta_system != '1' || receiveData.sta_system !=
|
||||||
uni.showModal({
|
'3')) {
|
||||||
title: "提示",
|
|
||||||
content: "设备'" + f.device.deviceName + "'电量低",
|
if (this.ref) {
|
||||||
showCancel: false
|
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||||
});
|
MsgClear(this.ref);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -695,19 +721,22 @@ class BleReceive {
|
|||||||
try {
|
try {
|
||||||
if (!receive.bytes || receive.bytes.length < 3) return receiveData;
|
if (!receive.bytes || receive.bytes.length < 3) return receiveData;
|
||||||
// 与 HBY100-J 页 bleValueNotify 共用 notify,避免 parseBleData 执行两次:重复日志、FB05 双次 resolve、onNotify 双次
|
// 与 HBY100-J 页 bleValueNotify 共用 notify,避免 parseBleData 执行两次:重复日志、FB05 双次 resolve、onNotify 双次
|
||||||
const parsed = parseBleData(receive.bytes, { skipSideEffects: true });
|
const parsed = parseBleData(receive.bytes, {
|
||||||
|
skipSideEffects: true
|
||||||
|
});
|
||||||
if (!parsed) return receiveData;
|
if (!parsed) return receiveData;
|
||||||
if (parsed.longitude !== undefined) receiveData.longitude = parsed.longitude;
|
if (parsed.longitude !== undefined) receiveData.longitude = parsed.longitude;
|
||||||
if (parsed.latitude !== undefined) receiveData.latitude = parsed.latitude;
|
if (parsed.latitude !== undefined) receiveData.latitude = parsed.latitude;
|
||||||
if (parsed.batteryPercentage !== undefined) receiveData.batteryPercentage = parsed.batteryPercentage;
|
if (parsed.batteryPercentage !== undefined) receiveData.batteryPercentage = parsed.batteryPercentage;
|
||||||
if (parsed.batteryRemainingTime !== undefined) receiveData.batteryRemainingTime = parsed.batteryRemainingTime;
|
if (parsed.batteryRemainingTime !== undefined) receiveData.batteryRemainingTime = parsed
|
||||||
|
.batteryRemainingTime;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('[100J] BleReceive 解析失败', e);
|
console.log('[100J] BleReceive 解析失败', e);
|
||||||
}
|
}
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_6170(receive, f, path, recArr) {
|
Receive_6170(receive, f, path, recArr) {
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -721,21 +750,20 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
.replace(/\//g, "").toLowerCase();
|
.replace(/\//g, "").toLowerCase();
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (receiveData.sta_PowerPercent <= 20) {
|
let deviceState = receiveData.state;
|
||||||
uni.showModal({
|
if (deviceState && deviceState instanceof Array) {
|
||||||
title: "提示",
|
if (deviceState[0] == 12 && deviceState[3] <= 20 && deviceState[4] == 0) {
|
||||||
content: "设备'" + f.device.deviceName + "'电量低",
|
if (this.ref) {
|
||||||
showCancel: false
|
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||||
});
|
MsgClear(this.ref);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData = {};
|
receiveData = {};
|
||||||
console.error("文本解析失败", error)
|
console.error("文本解析失败", error)
|
||||||
@ -758,18 +786,21 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
.replace(/\//g, "").toLowerCase();
|
.replace(/\//g, "").toLowerCase();
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt) {
|
||||||
if (receiveData.sta_PowerPercent <= 20) {
|
|
||||||
uni.showModal({
|
let msgs = [];
|
||||||
title: "提示",
|
|
||||||
content: "设备'" + f.device.deviceName + "'电量低",
|
if (receiveData.sta_PowerPercent <= 20 && receiveData.sta_charge == 0) {
|
||||||
showCancel: false
|
msgs.push("设备'" + f.device.deviceName + "'电量低");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (receiveData.sta_Intrusion === 1) {
|
if (receiveData.sta_Intrusion === 1) {
|
||||||
uni.showModal({
|
msgs.push("设备'" + f.device.deviceName + "'闯入报警中");
|
||||||
title: "提示",
|
}
|
||||||
content: "闯入报警中",
|
|
||||||
showCancel: false
|
|
||||||
|
if (this.ref && msg.length>0) {
|
||||||
|
msgs = msgs.join(",");
|
||||||
|
MsgError(msgs, '', this.ref, () => {
|
||||||
|
MsgClear(this.ref);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,7 +818,7 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
|
|
||||||
if (receiveData.sta_tomac.indexOf(':') == -1) {
|
if (receiveData.sta_tomac.indexOf(':') == -1) {
|
||||||
receiveData.sta_tomac = receiveData.sta_tomac.replace(/(.{2})/g, '$1:').slice(0, -
|
receiveData.sta_tomac = receiveData.sta_tomac.replace(/(.{2})/g, '$1:').slice(0, -
|
||||||
1); //mac地址自动补:
|
1); //mac地址自动补:
|
||||||
}
|
}
|
||||||
uni.getStorageInfo({
|
uni.getStorageInfo({
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
@ -814,9 +845,9 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
let dev = arr.find(v => {
|
let dev = arr.find(v => {
|
||||||
if (v.linkId == f.linkId) {
|
if (v.linkId == f.linkId) {
|
||||||
let vl = v.linkEqs.find(cvl => {
|
let vl = v.linkEqs.find(cvl => {
|
||||||
if(cvl.linkMac === receiveData.sta_tomac){
|
if (cvl.linkMac === receiveData.sta_tomac) {
|
||||||
v.read=false;
|
v.read = false;
|
||||||
cvl.linkTime=time;
|
cvl.linkTime = time;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -853,7 +884,7 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
console.error("某个设备闯入报警");
|
console.error("某个设备闯入报警");
|
||||||
if (receiveData.sta_sosadd.indexOf(':') == -1) {
|
if (receiveData.sta_sosadd.indexOf(':') == -1) {
|
||||||
receiveData.sta_sosadd = receiveData.sta_sosadd.replace(/(.{2})/g, '$1:').slice(0, -
|
receiveData.sta_sosadd = receiveData.sta_sosadd.replace(/(.{2})/g, '$1:').slice(0, -
|
||||||
1); //mac地址自动补:
|
1); //mac地址自动补:
|
||||||
}
|
}
|
||||||
warnArrs.push({
|
warnArrs.push({
|
||||||
linkId: f.linkId,
|
linkId: f.linkId,
|
||||||
@ -911,35 +942,33 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Receive_6075(receive,f,path,recArr){
|
Receive_6075(receive, f, path, recArr) {
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
receiveData = JSON.parse(receive.str);
|
receiveData = JSON.parse(receive.str);
|
||||||
|
|
||||||
let recCnt = recArr.find(v => {
|
let recCnt = recArr.find(v => {
|
||||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||||
.replace(/\//g, "").toLowerCase();
|
.replace(/\//g, "").toLowerCase();
|
||||||
});
|
});
|
||||||
if (!recCnt) {
|
if (!recCnt && this.ref) {
|
||||||
// if (receiveData.sta_PowerPercent <= 20) {
|
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
|
||||||
// uni.showModal({
|
|
||||||
// title: "提示",
|
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||||
// content: "设备'" + f.device.deviceName + "'电量低",
|
MsgClear(this.ref);
|
||||||
// showCancel: false
|
});
|
||||||
// });
|
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData = {};
|
receiveData = {};
|
||||||
console.log("文本解析失败", error)
|
console.log("文本解析失败", error)
|
||||||
}
|
}
|
||||||
return receiveData;
|
return receiveData;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -947,10 +976,12 @@ Receive_6170(receive, f, path, recArr) {
|
|||||||
|
|
||||||
let receiveInstance = null;
|
let receiveInstance = null;
|
||||||
export default {
|
export default {
|
||||||
getBleReceive: function(found, receive) {
|
getBleReceive: function(_ref) {
|
||||||
|
console.log("_ref=",_ref);
|
||||||
if (!receiveInstance) {
|
if (!receiveInstance) {
|
||||||
receiveInstance = new BleReceive();
|
receiveInstance = new BleReceive(_ref);
|
||||||
|
}else{
|
||||||
|
console.log("使用现有实例receiveInstance")
|
||||||
}
|
}
|
||||||
return receiveInstance;
|
return receiveInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user