完成102添加联机日志,报警日志

This commit is contained in:
liub
2026-01-28 16:31:34 +08:00
parent 1b48751944
commit d6ca84170f
16 changed files with 2651 additions and 805 deletions

View File

@ -53,6 +53,9 @@
}, },
onHide: function() { onHide: function() {
console.log('App Hide'); console.log('App Hide');
},
onError(ex) {
console.error("出现了未知的异常",ex);
} }
} }
</script> </script>

View File

@ -229,12 +229,12 @@
let linePixls = []; let linePixls = [];
let item = this.validTxts[i]; let item = this.validTxts[i];
console.log("item=",item);
for (var j = 0; j < item.length; j++) { for (var j = 0; j < item.length; j++) {
let result = await drawTxt(item[j]); let result = await drawTxt(item[j]);
linePixls.push(convertCharToMatrix(result.pixelData)); linePixls.push(convertCharToMatrix(result.pixelData));
} }
console.log("hexs=",linePixls.join(",")); // console.log("hexs=",linePixls.join(","));
arr.push(linePixls); arr.push(linePixls);
} }

View File

@ -2,7 +2,7 @@
"name" : "星汉物联", "name" : "星汉物联",
"appid" : "__UNI__A21EF43", "appid" : "__UNI__A21EF43",
"description" : "设备管控", "description" : "设备管控",
"versionName" : "1.0.11", "versionName" : "1.0.12",
"versionCode" : "100", "versionCode" : "100",
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
@ -99,23 +99,7 @@
}, },
"push" : { "push" : {
"unipush" : { "unipush" : {
"version" : "2", "offline" : false
"offline" : true,
"hms" : {},
"oppo" : {},
"vivo" : {},
"mi" : {},
"meizu" : {},
"honor" : {},
"icons" : {
"small" : {
"xxhdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/48x48.png",
"hdpi" : "unpackage/res/icons/36x36.png",
"mdpi" : "unpackage/res/icons/24x24.png",
"ldpi" : "unpackage/res/icons/18x18.png"
}
}
} }
} }
}, },

View File

@ -339,6 +339,7 @@
"path" : "pages/102/HBY102", "path" : "pages/102/HBY102",
"style" : "style" :
{ {
"navigationStyle": "custom",
"navigationBarTitleText" : "HBY102" "navigationBarTitleText" : "HBY102"
} }
}, },
@ -376,6 +377,13 @@
{ {
"navigationBarTitleText" : "BJQ6155" "navigationBarTitleText" : "BJQ6155"
} }
},
{
"path" : "pages/102/HBY102_History",
"style" :
{
"navigationStyle": "custom"
}
} }

View File

@ -1,5 +1,26 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<uni-nav-bar class="nvbar" leftIcon="left" @clickLeft="navigatorBack">
<view slot="left">
<uni-icons type="back" size="23" color="#FFFFFF"></uni-icons>
</view>
<view slot="default" class="center uninavebartext">
{{Status.navbar.title}}
</view>
<view slot="right">
<view class="navbarRight center">
<view class="imgContent" @click.stop="handleRightClick(item,index)"
v-for="item,index in Status.navbar.icons">
<image class="img" :src="item.src" mode="aspectFit"></image>
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
</view>
</view>
</view>
</uni-nav-bar>
<view class="eq"> <view class="eq">
<view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
@ -16,7 +37,8 @@
<view class="row"> <view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image> <image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<view class="txt"> <view class="txt">
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}</view> <view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
</view>
<view class="smallTxt">设备状态</view> <view class="smallTxt">设备状态</view>
</view> </view>
</view> </view>
@ -46,7 +68,7 @@
</view> --> </view> -->
</view> </view>
<view class="warnnig" v-for="item,index in warnDevices"> <view class="warnnig" v-for="item,index in warnDevices">
<view>闯入报警</view> <view>闯入报警</view>
<view> <view>
{{item.name}} {{item.name}}
@ -223,30 +245,30 @@
show: false, show: false,
showHeader: true, showHeader: true,
menuItems: [{ menuItems: [{
text: '2M', text: '2M',
value:'status_2M', value: 'status_2M',
icon: '' icon: ''
}, },
{ {
text: '4M', text: '4M',
value:'status_4M', value: 'status_4M',
icon: '' icon: ''
}, },
{ {
text: '7M', text: '7M',
value:'status_7M', value: 'status_7M',
icon: '' icon: ''
}, },
{ {
text: '10M', text: '10M',
value:'status_10M', value: 'status_10M',
icon: '' icon: ''
}, },
{ {
text: '关闭', text: '关闭',
value:'status_off', value: 'status_off',
icon: '' icon: ''
} }
], ],
activeIndex: -1, activeIndex: -1,
bgColor: '#2a2a2a', bgColor: '#2a2a2a',
@ -269,6 +291,21 @@
showClose: false showClose: false
}, },
usrToggle: false, usrToggle: false,
navbar: {
icons: [{
src: '/static/images/common/history.png',
callback: this.gotoHistory,
math: 0
},
{
src: '/static/images/common/shape.png',
callback: this.gotoShare
}
],
title: 'HBY102'
},
apiType: ''
}, },
formData: { formData: {
img: '/static/images/common/HBY102.png', img: '/static/images/common/HBY102.png',
@ -281,13 +318,13 @@
statu: '', statu: '',
sta_address: '', sta_address: '',
bleStatu: false, bleStatu: false,
sta_charge:'', sta_charge: '',
sta_LedType: '', sta_LedType: '',
sta_RadarType: '', sta_RadarType: '',
sta_Online: '', sta_Online: '',
warnTime: '', warnTime: '',
sta_sosadd: "", sta_sosadd: "",
sta_sosName:'', sta_sosName: '',
sta_IntrusTime: '' sta_IntrusTime: ''
}, },
@ -300,7 +337,8 @@
show: true, show: true,
img: '/static/images/100/light.png', img: '/static/images/100/light.png',
activeImg: '/static/images/100/lightActive.png', activeImg: '/static/images/100/lightActive.png',
group: 'sta_LedType' group: 'sta_LedType',
permission: '1'
}, },
{ {
key: 'led_low_flash', key: 'led_low_flash',
@ -308,7 +346,8 @@
show: true, show: true,
img: '/static/images/102/lowFlash.png', img: '/static/images/102/lowFlash.png',
activeImg: '/static/images/102/lowFlashActive.png', activeImg: '/static/images/102/lowFlashActive.png',
group: 'sta_LedType' group: 'sta_LedType',
permission: '1'
}, },
{ {
key: 'led_steady', key: 'led_steady',
@ -316,7 +355,8 @@
show: true, show: true,
img: '/static/images/102/liting.png', img: '/static/images/102/liting.png',
activeImg: '/static/images/102/litingActive.png', activeImg: '/static/images/102/litingActive.png',
group: 'sta_LedType' group: 'sta_LedType',
permission: '1'
}, },
{ {
key: 'status_on', key: 'status_on',
@ -324,7 +364,8 @@
show: true, show: true,
img: '/static/images/102/redar.png', img: '/static/images/102/redar.png',
activeImg: '/static/images/102/redarActive.png', activeImg: '/static/images/102/redarActive.png',
group: 'sta_RadarType' group: 'sta_RadarType',
permission: '48'
}, },
{ {
key: 'E49_on', key: 'E49_on',
@ -332,7 +373,8 @@
show: true, show: true,
img: '/static/images/102/line.png', img: '/static/images/102/line.png',
activeImg: '/static/images/102/lineActive.png', activeImg: '/static/images/102/lineActive.png',
group: 'sta_Online' group: 'sta_Online',
permission: '49'
}, },
{ {
key: 'led_off', key: 'led_off',
@ -377,7 +419,8 @@
showConfirm: false showConfirm: false
}, },
groupDevices: [], groupDevices: [],
warnDevices:[] warnDevices: [],
permissions: []
} }
}, },
@ -404,9 +447,20 @@
eventChannel.on('detailData', function(data) { eventChannel.on('detailData', function(data) {
// console.log("收到父页面的参数:" + JSON.stringify(data)); console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data; var device = data.data;
these.Status.apiType = data.apiType;
if (data.apiType !== 'listA') {
Common.getdeviceShareId(data.data.id).then(res => {
if (res.code == 200) {
if (res.data.permission) {
these.permissions = res.data.permission.split(',');
}
}
});
}
these.device = device; these.device = device;
these.getWarns();
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) { if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v); // console.log("找到设备了", v);
@ -452,34 +506,181 @@
}, },
onShow() { onShow() {
this.Status.pageHide = false; this.Status.pageHide = false;
this.getLinkedCnt();
}, },
computed: { computed: {
Distance:function(){ Distance: function() {
let f=this.Status.BottomMenu.menuItems.find((item,index)=>{ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
return item.value===this.formData.sta_RadarType; return item.value === this.formData.sta_RadarType;
}); });
if(f){ if (f) {
return f.text; return f.text;
} }
return '关闭'; return '关闭';
}, },
activeIndex:function(){ activeIndex: function() {
let active=4; let active = 4;
let f=this.Status.BottomMenu.menuItems.find((item,index)=>{ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
if(item.value===this.formData.sta_RadarType){ if (item.value === this.formData.sta_RadarType) {
active=index; active = index;
} }
}); });
return active; return active;
} }
}, },
methods: { methods: {
getLinkedCnt() {//获取在线设备的数量
let f = this.getDevice();
// #ifdef APP-PLUS
if (!f) {
return;
}
// #endif
// #ifdef H5
f = {
deviceId: '12345'
}
// #endif
if (ble) {
let buffer = {
ins_Quantity: "query"
};
ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
setTimeout(()=>{
this.getWarns();
},1500);
}).catch(()=>{
this.getWarns();
})
}
},
getWarns() {
return new Promise((resolve, reject) => {
if (!these.device.id) {
return;
}
let warnKey = "102_" + these.device.id + "_warning";
let linkKey = "102_" + these.device.id + "_linked";
let p1 = new Promise((succ, err) => {
uni.getStorage({
key: warnKey,
success(res) {
let data = res.data;
let fs = data.filter(v => {
return !v.read
});
succ(fs);
},
fail(ex) {
err(null);
}
});
});
let p2 = new Promise((succ, err) => {
uni.getStorage({
key: linkKey,
success(res) {
console.error("获取到联机数据",res);
let data = res.data;
let fs = data.filter(v => {
return !v.read
});
console.error("未读联机数据",fs);
succ(fs);
},
fail(ex) {
err(null);
}
});
});
Promise.allSettled([p1, p2]).then(results => {
let fs = [];
if (results[0].status == 'fulfilled') {
fs=fs.concat(results[0].value);
}
if (results[1].status == 'fulfilled') {
fs=fs.concat(results[1].value);
}
console.error("获取到未读消息",fs);
these.$set(these.Status.navbar.icons[0], "math", fs.length);
});
});
},
gotoHistory(item, s) {
uni.navigateTo({
url: '/pages/102/HBY102_History',
success: (res) => {
res.eventChannel.emit('detailData', {
data: these.device
});
}
});
},
gotoShare(item, s) {
uni.navigateTo({
url: '/pages/common/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
let json = {
persissonType: '102'
};
Object.assign(json, this.device);
res.eventChannel.emit('share', {
data: json
});
}
})
},
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
} else {
uni.showModal({
content: '敬请期待'
})
}
},
navigatorBack() {
uni.navigateBack();
},
actionSett(item, index) { actionSett(item, index) {
if (!this.permissions.includes(item.permission) && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (item.group == 'sta_LedType') { if (item.group == 'sta_LedType') {
this.sosSetting(item, index); this.sosSetting(item, index);
return; return;
@ -488,7 +689,7 @@
if (item.group == 'sta_RadarType') { if (item.group == 'sta_RadarType') {
// this.toggleRedar(item, index); // this.toggleRedar(item, index);
this.showRedarSetting(item,index); this.showRedarSetting(item, index);
return; return;
} }
@ -555,24 +756,24 @@
}, },
showRedarSetting(){ showRedarSetting() {
this.Status.BottomMenu.show=true; this.Status.BottomMenu.show = true;
this.Status.BottomMenu.showBtn=false; this.Status.BottomMenu.showBtn = false;
this.Status.BottomMenu.title="感应距离设置"; this.Status.BottomMenu.title = "感应距离设置";
this.Status.BottomMenu.textAlign="center"; this.Status.BottomMenu.textAlign = "center";
this.Status.BottomMenu.showMask=true; this.Status.BottomMenu.showMask = true;
this.Status.BottomMenu.activeIndex=this.activeIndex; this.Status.BottomMenu.activeIndex = this.activeIndex;
}, },
btnClick(item,index){ btnClick(item, index) {
this.Status.BottomMenu.show=false; this.Status.BottomMenu.show = false;
console.log("选中的项:"+index+",值:"+JSON.stringify(item)); console.log("选中的项:" + index + ",值:" + JSON.stringify(item));
this.toggleRedar(item,index); this.toggleRedar(item, index);
}, },
closeActionSheet(){ closeActionSheet() {
this.Status.BottomMenu.show=false; this.Status.BottomMenu.show = false;
}, },
toggleRedar(item, index) { //雷达启停 toggleRedar(item, index) { //雷达启停
let f = this.getDevice(); let f = this.getDevice();
@ -601,7 +802,7 @@
.then(res => { .then(res => {
debugger; debugger;
this.formData.sta_RadarType = val; this.formData.sta_RadarType = val;
this.Status.BottomMenu.activeIndex=index; this.Status.BottomMenu.activeIndex = index;
these.setBleFormData(); these.setBleFormData();
resolve(); resolve();
}) })
@ -642,6 +843,19 @@
sosSetting(item, isOk) { sosSetting(item, isOk) {
if (!this.permissions.includes('46') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') { if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') {
return; return;
} }
@ -817,27 +1031,29 @@
let json = recei.ReceiveData(receive, device, pagePath, recArr); let json = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("json=", json) console.log("json=", json)
setTimeout(()=>{
this.getWarns();
},500);
let active = -1;
let f = this.Status.BottomMenu.menuItems.find((item, index) => {
let active=-1; if (item.value === json.sta_RadarType) {
let f=this.Status.BottomMenu.menuItems.find((item,index)=>{ active = index;
if(item.value===json.sta_RadarType){
active=index;
} }
}); });
this.Status.BottomMenu.activeIndex=active; this.Status.BottomMenu.activeIndex = active;
let msg = []; let msg = [];
if (json.sta_PowerPercent <= 20 && (json.sta_charge===0 || json.sta_charge==='0')) { if (json.sta_PowerPercent <= 20 && (json.sta_charge === 0 || json.sta_charge === '0')) {
msg.push("设备电量低"); msg.push("设备电量低");
} }
if(json.sta_sosadd_off){//某个设备解除报警 if (json.sta_sosadd_off) { //某个设备解除报警
this.warnDevices.filter((d,index)=>{ this.warnDevices.filter((d, index) => {
if(d.mac===json.sta_sosadd_off){ if (d.mac === json.sta_sosadd_off) {
this.warnDevices.splice(index,1); this.warnDevices.splice(index, 1);
} }
}); });
} }
@ -853,23 +1069,28 @@
}); });
if (json.sta_sosadd) {//某个设备闯入报警 if (json.sta_sosadd) { //某个设备闯入报警
console.log("查询设备中",json.sta_sosadd); console.log("查询设备中", json.sta_sosadd);
this.searchDevice(json.sta_sosadd).catch(ex => {}).then(dev => { this.searchDevice(json.sta_sosadd).catch(ex => {}).then(dev => {
console.log("dev=", dev); console.log("dev=", dev);
let d=this.warnDevices.find(v=>{return v.mac===json.sta_sosadd}); let d = this.warnDevices.find(v => {
let deviceName=""; return v.mac === json.sta_sosadd
});
let deviceName = "";
if (dev) { if (dev) {
// this.formData.sta_sosName=dev.deviceName; // this.formData.sta_sosName=dev.deviceName;
msg.push('"' + dev.deviceName + '"闯入报警中'); msg.push('"' + dev.deviceName + '"闯入报警中');
deviceName=dev.deviceName; deviceName = dev.deviceName;
} else { } else {
msg.push('闯入报警中'); msg.push('闯入报警中');
// this.formData.sta_sosName=""; // this.formData.sta_sosName="";
} }
if(!d){ if (!d) {
this.warnDevices.push({mac:json.sta_sosadd,name:deviceName}); this.warnDevices.push({
mac: json.sta_sosadd,
name: deviceName
});
} }
this.showMsg(msg.join(',')); this.showMsg(msg.join(','));
}); });
@ -898,7 +1119,7 @@
}, },
getWarDevice(macStr) { getWarDevice(macStr) {
console.log("macStr=",macStr); console.log("macStr=", macStr);
if (macStr) { if (macStr) {
if (!macStr.includes(':')) { if (!macStr.includes(':')) {
@ -1158,6 +1379,11 @@
</script> </script>
<style> <style>
.uninavebartext {
width: 100%;
font-size: 32rpx;
}
.content { .content {
padding: 30rpx; padding: 30rpx;
box-sizing: border-box; box-sizing: border-box;
@ -1919,4 +2145,65 @@
letter-spacing: 0.07px; letter-spacing: 0.07px;
} }
.navbarRight {
width: 60px;
height: 100%;
}
.navbarRight .imgContent {
width: 36rpx;
height: 36rpx;
position: relative;
}
.navbarRight .imgContent:first-child {
margin-right: 36rpx;
width: 38rpx !important;
height: 38rpx !important;
margin-top: -2rpx;
}
.navbarRight .imgContent .baber {
position: absolute;
z-index: 100;
width: 30rpx;
height: 30rpx;
line-height: 30rpx;
right: -15rpx;
top: -15rpx;
border-radius: 50%;
background: #f12828;
color: #ffffff;
font-family: 'PingFang SC';
font-style: Regular;
font-size: 20rpx;
font-weight: 400;
text-align: center;
overflow: hidden;
white-space: nowrap;
}
.navbarRight .imgContent .img {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
}
.navbarRight .imgContent .img:last-child {
padding: 1rpx;
}
.nvbar {
top: 0px;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
</style> </style>

1327
pages/102/HBY102_History.vue Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons> <uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
</view></template> </view></template>
<block slot="right"> <block slot="right">
<view class="navbarRight"> <view class="navbarRight center">
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons" class="img" :src="item.src" mode="aspectFit"></image> <image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons" class="img" :src="item.src" mode="aspectFit"></image>
</view> </view>

View File

@ -422,8 +422,11 @@
if (these.Status.isPageHidden) { if (these.Status.isPageHidden) {
return; return;
} }
if(receivData.bytes[0]===0xFC && receivData.hexs.length>=7){
console.log("22222222");
}
if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1 if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1
|| (receivData.hexs[0]===0xFC && receivData.hexs.length>=7)) || (receivData.bytes[0]===0xFC && receivData.bytes.length>=7))
{ {
console.log("1111111"); console.log("1111111");
if (f.macAddress && these.device) { if (f.macAddress && these.device) {
@ -716,8 +719,8 @@
}); });
return; return;
} }
console.log("验证设备") // console.log("验证设备")
these.DeviceVerdict(item.deviceId); // these.DeviceVerdict(item.deviceId);
} }
let execLink = () => { let execLink = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -25,7 +25,7 @@
<view class="Sendmessage" @click="handleSend">发送信息</view> <view class="Sendmessage" @click="handleSend">发送信息</view>
</view> </view>
<!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100" style="height:80vh;"> --> <!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100" style="height:80vh;"> -->
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" <mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
:down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }"> :down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
<view v-if="deviceList.length>0"> <view v-if="deviceList.length>0">
<uni-swipe-action ref="swipeAction"> <uni-swipe-action ref="swipeAction">
@ -147,11 +147,12 @@
} from '@/api/common/index.js' } from '@/api/common/index.js'
import bleTool from '@/utils/BleHelper.js'; import bleTool from '@/utils/BleHelper.js';
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue' import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
import BleReceive from '@/utils/BleReceive';
var pagePath = 'pages/common/index'; var pagePath = 'pages/common/index';
var ble = null; var ble = null;
var timeout = null; var timeout = null;
var recei=null;
export default { export default {
components: { components: {
MescrollUni MescrollUni
@ -498,6 +499,9 @@
case 'scan': case 'scan':
// 扫一扫 // 扫一扫
uni.scanCode({ uni.scanCode({
autoDecodeCharset:true,
autoZoom:true,
barCodeInput:true,
success: (res) => { success: (res) => {
console.log('条码内容:', res); console.log('条码内容:', res);
// 清除之前的数据 // 清除之前的数据
@ -512,14 +516,19 @@
if ('imei' in json) { if ('imei' in json) {
url = url =
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(json.imei)}`; `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(json.imei)}`;
} else if ('blue' in json) { } else if ('blue' in json || 'ble' in json) {
if (!json.blue.includes(':')) { if(json.ble){
json.blue = json.blue.replace( json.blue=json.ble;
/(.{2})/g, '$1:')
.slice(0, -1)
} }
url = if(json.blue){
`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(json.blue)}`; if (!json.blue.includes(':')) {
json.blue = json.blue.replace(
/(.{2})/g, '$1:')
.slice(0, -1)
}
}
url =`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(json.blue)}`;
} }
} catch (ex) { } catch (ex) {
@ -771,7 +780,7 @@
this.downCallback(); this.downCallback();
}); });
ble = bleTool.getBleTool(); ble = bleTool.getBleTool();
recei = BleReceive.getBleReceive();
//蓝牙连接成功的回调 //蓝牙连接成功的回调
ble.addRecoveryCallback((res) => { ble.addRecoveryCallback((res) => {
console.log("蓝牙连接成功的回调"); console.log("蓝牙连接成功的回调");
@ -797,7 +806,9 @@
}, pagePath); }, pagePath);
//接收到消息的回调 //接收到消息的回调
ble.addReceiveCallback((rec, f, path, arr) => { ble.addReceiveCallback((receive, device, path, recArr) => {
console.error("首页收到消息了");
recei.ReceiveData(receive, device, path, recArr);
this.updateBleStatu(); this.updateBleStatu();
}, pagePath); }, pagePath);
@ -809,7 +820,7 @@
uni.$off('refreshDeviceList'); uni.$off('refreshDeviceList');
}, },
onUnload() { onUnload() {
console.log("onUnload...");
uni.$off('deviceStatusUpdate'); uni.$off('deviceStatusUpdate');
ble && ble.removeAllCallback(pagePath); ble && ble.removeAllCallback(pagePath);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

View File

@ -74,7 +74,7 @@
props: { props: {
dark: { dark: {
type: Boolean, type: Boolean,
default: false default: true
}, },
title: { title: {
type: String, type: String,
@ -98,7 +98,7 @@
}, },
fixed: { fixed: {
type: [Boolean, String], type: [Boolean, String],
default: false default: true
}, },
color: { color: {
type: String, type: String,
@ -110,7 +110,7 @@
}, },
statusBar: { statusBar: {
type: [Boolean, String], type: [Boolean, String],
default: false default: true
}, },
shadow: { shadow: {
type: [Boolean, String], type: [Boolean, String],
@ -118,7 +118,7 @@
}, },
border: { border: {
type: [Boolean, String], type: [Boolean, String],
default: true default: false
}, },
height: { height: {
type: [Number, String], type: [Number, String],
@ -126,11 +126,11 @@
}, },
leftWidth: { leftWidth: {
type: [Number, String], type: [Number, String],
default: 60 default: 90
}, },
rightWidth: { rightWidth: {
type: [Number, String], type: [Number, String],
default: 60 default: 90
}, },
showMenuButtonWidth: { showMenuButtonWidth: {
type: Boolean, type: Boolean,
@ -153,7 +153,7 @@
if (this.backgroundColor) { if (this.backgroundColor) {
return this.backgroundColor return this.backgroundColor
} else { } else {
return this.dark ? '#333' : '#FFF' return this.dark ? '#121212' : '#FFF'
} }
} }
return this.backgroundColor || '#FFF' return this.backgroundColor || '#FFF'

View File

@ -780,7 +780,6 @@ class BleHelper {
if (this.cfg.receivDataCallback.length > 0) { if (this.cfg.receivDataCallback.length > 0) {
let path = this.getCurrentPagePath();
// console.log("有人订阅消息") // console.log("有人订阅消息")
this.cfg.receivDataCallback.forEach(( this.cfg.receivDataCallback.forEach((
rec) => { rec) => {
@ -789,7 +788,7 @@ class BleHelper {
try { try {
// console.log("正在处理订阅消息",rec); // console.log("正在处理订阅消息",rec);
rec.callback(recData, f, rec.callback(recData, f,
path, this.cfg rec.key, this.cfg
.receivDataCallback .receivDataCallback
); );
// console.log("处理订阅消息完毕"); // console.log("处理订阅消息完毕");
@ -1601,12 +1600,23 @@ class BleHelper {
timeout: 30000, timeout: 30000,
success: (info) => { success: (info) => {
//释放连接锁 //释放连接锁
delete this.data.connectingDevices[deviceId]; delete this.data.connectingDevices[deviceId];
console.log("新连接成功", this.data.LinkedList); console.log("新连接成功", this.data.LinkedList);
// 处理 MTU 设置
if (plus.os.name === 'Android') {
this.setMtu(deviceId).catch(ex => {
console.error("mtu设置失败=", ex);
});
}
this.getLinkBlue().then((arr) => { this.getLinkBlue().then((arr) => {
let linkId=new Date().getTime();//本次连接的id
let cr = arr.devices.find(c => { let cr = arr.devices.find(c => {
if (c.deviceId == deviceId) { if (c.deviceId == deviceId) {
c.Linked = true; c.Linked = true;
c.linkId=linkId
return true; return true;
} }
return false; return false;
@ -1614,6 +1624,7 @@ class BleHelper {
if (fIndex > -1) { if (fIndex > -1) {
this.data.LinkedList[fIndex].Linked = true; this.data.LinkedList[fIndex].Linked = true;
this.data.LinkedList[fIndex].linkId=linkId;
} else { } else {
this.data.LinkedList.push(cr); this.data.LinkedList.push(cr);
} }
@ -1647,12 +1658,7 @@ class BleHelper {
}); });
} }
// 处理 MTU 设置
if (plus.os.name === 'Android') {
this.setMtu(deviceId).catch(ex => {
console.error("mtu设置失败=", ex);
});
}
resolve(true); resolve(true);
}).catch((ex) => { }).catch((ex) => {

View File

@ -1,8 +1,11 @@
import Common from '@/utils/Common.js'
class BleReceive { class BleReceive {
constructor() { constructor() {
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),
'/pages/6155/BJQ6155': this.Receive_6155_XH.bind(this),
'/pages/7305/BJQ7305': this.Receive_6155.bind(this), '/pages/7305/BJQ7305': this.Receive_6155.bind(this),
'/pages/650/HBY650': this.Receive_650.bind(this), '/pages/650/HBY650': this.Receive_650.bind(this),
'/pages/670/HBY670': this.Receive_670.bind(this), '/pages/670/HBY670': this.Receive_670.bind(this),
@ -423,6 +426,94 @@ class BleReceive {
return data; return data;
} }
Receive_6155_XH(receive, f, path, recArr) {
let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
try {
let light = null;
let mode = null;
if (bytes[2] === 0x01 && bytes[3] === 0x00) {
light = 0;
mode = 'main';
} else if (bytes[2] === 0x02 && bytes[3] === 0x00) {
light = 1;
mode = 'main';
} else if (bytes[2] === 0x00 && bytes[3] === 0x01) {
light = 2;
mode = 'main';
} else if (bytes[2] === 0x03 && bytes[3] === 0x00) {
light = 0;
mode = 'fu';
} else if (bytes[2] === 0x04 && bytes[3] === 0x00) {
light = 1;
mode = 'fu';
}
if (bytes[2] === 0x05 && bytes[3] === 0x00) {
light = 3;
}
// 解析剩余电量
let batteryLevelByte = bytes[4];
// 电量百分比范围检查
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
//充电状态
let warn = bytes[5];
if (warn == 0x00) {
warn = '未充电';
} else if (warn == 0x01) {
warn = '充电中';
}
// 解析剩余照明时间(第三和第四字节,小端序)
let lightingTime = "";
let HH = Math.max(0, Math.min(100, bytes[6]));
let mm = Math.max(0, Math.min(100, bytes[7]));
lightingTime = HH + "小时" + mm + "分钟";
let formData = {};
formData.mode = mode;
formData.light = light;
formData.battary = batteryLevel;
formData.statu = warn;
formData.xuhang = lightingTime;
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g,
'').toLowerCase();
});
if (!recCnt) {
if (batteryLevel <= 20) {
// 会弹出两个框,暂且注释掉这段代码
uni.showModal({
content: "设备'" + f.device.deviceName + "'电量低",
title: "提示"
});
}
}
this.setBleFormData(formData, f);
return formData;
} catch (error) {
console.log('7305数据解析错误:', error);
return null;
}
}
return null;
}
Receive_6155(receive, f, path, recArr) { Receive_6155(receive, f, path, recArr) {
let bytes = receive.bytes; let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) { if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
@ -588,8 +679,9 @@ class BleReceive {
let receiveData = {}; let receiveData = {};
try { try {
console.log("订阅消息者:", path);
// console.log("str=",receive.str); console.log("设备收到消息:", f);
console.log("消息内容:", receive);
receiveData = JSON.parse(receive.str); receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
@ -613,6 +705,134 @@ class BleReceive {
} }
} }
if (f.device && path === "pages/common/index") { //仅在首页订阅此操作
console.error("1111111111");
let linkKey = "102_" + f.device.id + "_linked";
let warnKey = "102_" + f.device.id + "_warning";
let time = new Date(); //Common.DateFormat(new Date(),'yyyy-MM-dd HH:mmss');
if (receiveData.sta_tomac) { //某个设备上线了
if (receiveData.sta_tomac.indexOf(':') == -1) {
receiveData.sta_tomac = receiveData.sta_tomac.replace(/(.{2})/g, '$1:').slice(0, -
1); //mac地址自动补:
}
uni.getStorageInfo({
success: function(res) {
let arr = [];
let linked = {
linkId: f.linkId,
read: false,
linkEqs: [{
linkTime: time,
linkMac: f.macAddress
}, {
linkTime: time,
linkMac: receiveData.sta_tomac
}]
};
if (res.keys.includes(linkKey)) {
arr = uni.getStorageSync(linkKey);
}
if (arr.length == 0) {
arr.unshift(linked);
} else {
let dev = arr.find(v => {
if (v.linkId == f.linkId) {
let vl = v.linkEqs.find(cvl => {
if(cvl.linkMac === receiveData.sta_tomac){
v.read=false;
cvl.linkTime=time;
return true;
}
return false;
});
if (!vl) {
v.linkEqs.push({
linkTime: time,
linkMac: receiveData.sta_tomac
});
}
return vl;
}
return false;
});
if (!dev) {
arr.unshift(linked);
}
}
console.error("某个设备上线了", arr)
uni.setStorage({
key: linkKey,
data: arr
});
}
});
}
let warnArrs = [];
let guid = Common.guid();
if (receiveData.sta_sosadd) { //某个设备闯入报警
console.error("某个设备闯入报警");
if (receiveData.sta_sosadd.indexOf(':') == -1) {
receiveData.sta_sosadd = receiveData.sta_sosadd.replace(/(.{2})/g, '$1:').slice(0, -
1); //mac地址自动补:
}
warnArrs.push({
linkId: f.linkId,
read: false,
key: guid,
warnType: "闯入报警",
warnMac: receiveData.sta_sosadd,
warnTime: time,
warnName: ""
});
}
if (receiveData.sta_LedType === 'led_alarm' || receiveData.ins_LedType === 'led_alarm') { //强制报警
console.error("强制报警了", f);
warnArrs.push({
linkId: f.linkId,
read: false,
key: guid,
warnType: "强制报警",
warnMac: f.macAddress,
warnTime: time,
warnName: ""
});
}
if (warnArrs.length > 0) {
uni.getStorageInfo({
success: function(res) {
let arr = [];
if (res.keys.includes(warnKey)) {
arr = uni.getStorageSync(warnKey);
arr = warnArrs.concat(arr);
} else {
arr = warnArrs
}
uni.setStorage({
key: warnKey,
data: arr
});
}
});
}
}
} catch (error) { } catch (error) {
receiveData = {}; receiveData = {};
console.log("文本解析失败", error) console.log("文本解析失败", error)

View File

@ -218,7 +218,7 @@ export default {
value: "1", value: "1",
label: "灯光模式", label: "灯光模式",
checked: false, checked: false,
type: ['6170', '670'] type: ['6170', '670','102']
}, },
{ {
value: "2", value: "2",
@ -282,7 +282,7 @@ export default {
value: "46", value: "46",
label: "手动报警", label: "手动报警",
checked: false, checked: false,
type: ['210'] type: ['210','102']
}, },
{ {
value: "47", value: "47",
@ -290,6 +290,18 @@ export default {
checked: false, checked: false,
type: ['210'] type: ['210']
}, },
{
value: "48",
label: "物体感应",
checked: false,
type: ['102']
},
{
value: "49",
label: "联机模式",
checked: false,
type: ['102']
},
] ]
let arr = []; let arr = [];