完成6075J蓝牙对接

This commit is contained in:
liub
2026-03-30 13:17:47 +08:00
parent 4e518e7340
commit 37f5047a46
32 changed files with 472 additions and 281 deletions

View File

@ -7,7 +7,7 @@
},
{
"customPlaygroundType" : "local",
"playground" : "standard",
"playground" : "custom",
"type" : "uni-app:app-android"
},
{

View File

@ -3,7 +3,7 @@
import upgrade from '@/utils/update.js';
// 延迟断开蓝牙:选择文件/录音等会触发 onHide8 秒内返回则不断开
const BLE_DISCONNECT_DELAY = 8000;
const BLE_DISCONNECT_DELAY = 30000;
let _bleDisconnectTimer = null;
export default {
@ -74,6 +74,9 @@
initOS();
}
let system=uni.getSystemInfoSync();
console.log("system=",system);
// #endif
},
onShow: function() {

View File

@ -124,9 +124,10 @@
*/
async drawAndGetPixels() {
// 第一次调用时先预热画布解决APP重新打开后第一次获取数据不完整的问题
await this.warmupCanvas();
// await this.warmupCanvas();
let convertCharToMatrix=function(imageData) {
debugger;
// console.log("imgData=",imageData)
let matrix = [];
@ -166,6 +167,7 @@
}
let drawTxt=async (textLine)=> {
debugger;
let result = {};
let ctx = this.ctx;
@ -226,7 +228,7 @@
let arr = [];
// 循环处理每行文本
for (let i = 0; i < this.validTxts.length; i++) {
debugger;
let linePixls = [];
let item = this.validTxts[i];

View File

@ -7,14 +7,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
</view>

View File

@ -28,14 +28,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_battery}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_system?dic.sta_system[formData.sta_system]:"" }}</view>
<view class="smallTxt">设备状态</view>
@ -475,9 +475,9 @@
sta_system: {
"0": '关机',
"1": '充电',
"2": '开机未充电',
"3": '开机且充电',
"1": '充电',//仅充电
"2": '未充电',//开机未充电
"3": '充电',//开机且充电
"": ""
}

View File

@ -11,7 +11,7 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt" :style="{ color: deviceInfo.batteryPercentage < 20 ? '#FF0000' : '' }">
{{ deviceInfo.batteryPercentage }}%
@ -20,7 +20,7 @@
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">
{{ Math.floor((Number(deviceInfo.batteryRemainingTime) || 0) / 60) }}小时

View File

@ -28,14 +28,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
</view>
@ -526,7 +526,7 @@
these.formData.bleStatu = true;
});
}
this.getWarns();
// this.getLinkedCnt();
},
computed: {
@ -673,7 +673,7 @@
}
let warnKey = "102_" + these.device.id + "_warning";
let linkKey = "102_" + these.device.id + "_linked";
// let linkKey = "102_" + these.device.id + "_linked";
let p1 = new Promise((succ, err) => {
uni.getStorage({
key: warnKey,
@ -690,33 +690,33 @@
});
});
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);
}
});
});
// 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 => {
Promise.allSettled([p1]).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);
}
// if (results[1].status == 'fulfilled') {
// fs = fs.concat(results[1].value);
// }
console.error("获取到未读消息", fs);
these.$set(these.Status.navbar.icons[0], "math", fs.length);
});
@ -945,7 +945,7 @@
sosSetting(item, isOk) {
debugger;
if (!this.permissions.includes('46') && this.Status.apiType !== 'listA') {
this.showPop({
@ -1034,7 +1034,8 @@
});
} else {
task(item.key);
let newval=this.formData.sta_LedType===item.key?'led_off':item.key;
task(newval);
}
}
@ -1155,7 +1156,7 @@
this.Status.BottomMenu.activeIndex = active;
let msg = [];
if (json.sta_PowerPercent <= 20 && (json.sta_charge === 0 || json.sta_charge === '0')) {
if (json.sta_PowerPercent <= 20 && json.sta_PowerPercent!=this.formData.sta_PowerPercent && (json.sta_charge === 0 || json.sta_charge === '0')) {
msg.push("设备电量低");
}

View File

@ -18,14 +18,14 @@
</view>
<view>
<view class="battery-v1">
<image src="/static/images/common/dl.png" class="dlIMG"></image>
<image src="/static/images/common/battry.png" class="dlIMG"></image>
<view>
<view class="battery-v2">{{deviceInfo.batteryPercentage}}%</view>
<view class="battery-v3">电量</view>
</view>
</view>
<view class="battery-v1">
<image src="/static/images/common/nz.png" class="dlIMG" mode="aspectFit"></image>
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">{{deviceInfo.batteryRemainingTime}}分钟</view>
<view class="battery-v3">续航时间</view>

View File

@ -26,14 +26,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<!-- <view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -7,14 +7,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<!-- <view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -18,14 +18,14 @@
</view>
<view>
<view class="battery-v1">
<image src="/static/images/common/dl.png" class="dlIMG"></image>
<image src="/static/images/common/battry.png" class="dlIMG"></image>
<view>
<view class="battery-v2">{{deviceInfo.batteryPercentage}}%</view>
<view class="battery-v3">电量</view>
</view>
</view>
<view class="battery-v1">
<image src="/static/images/common/nz.png" class="dlIMG" mode="aspectFit"></image>
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">{{deviceInfo.batteryRemainingTime}}分钟</view>
<view class="battery-v3">续航时间</view>

View File

@ -23,24 +23,24 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{battery}}</view>
<view class="bigTxt">{{formData.sta_PowerTime}}</view>
<view class="smallTxt">续航时间</view>
</view>
</view>
</view>
</view>
<view class="warnnig" :class="formData.sta_ShakeBit!==0 && formData.showShakeBit ?'':'displayNone'">
<view>{{formData.sta_ShakeBit==1?'设备疑似受到外力碰撞':'设备声光报警中'}}</view>
<view class="warnnig" :class="formData.sta_ShakeBit!==0 ?'':'displayNone'">
<view>{{formData.sta_ShakeBit==3?'设备疑似受到外力碰撞':'设备声光报警中'}}</view>
<view @click.stop="SOSToggle()">
<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
</view>
@ -76,7 +76,10 @@
<text class="lbl">设备状态</text>
<text class="value valueFont">{{sta_system}}</text>
</view>
<view class="item">
<text class="lbl">环境温度</text>
<text class="value " :class="heatStyle">{{formData.sta_Heat}}</text>
</view>
<view class="item">
<text class="lbl">定位信息</text>
<view class="multiValue" @click.stop="gotoMap()">
@ -108,7 +111,7 @@
<view class="item">
<view>
<text class="lbl">海拔高度</text>
<view class="value valueFont leftIndent">{{formData.sta_height}}m</view>
<view class="value valueFont leftIndent">{{formData.sta_Height}}m</view>
</view>
<view>
<text class="lbl">相对高度</text>
@ -150,23 +153,23 @@
<text class="smallTxt">{{FuLight}}</text>
</view>
</view>
<view class="mode " :class="{active:formData.sta_laser===1}" v-on:click.stop="laserToggle">
<view class="mode " :class="{active:formData.sta_laser==1}" v-on:click.stop="laserToggle">
<view class="leftImg">
<image class="img" src="/static/images/common/jig.png" v-show="formData.sta_laser!==1"
<image class="img" src="/static/images/common/jig.png" v-show="formData.sta_laser!=1"
mode="aspectFit"></image>
<image class="img" src="/static/images/common/jigA.png" v-show="formData.sta_laser===1"
<image class="img" src="/static/images/common/jigA.png" v-show="formData.sta_laser==1"
mode="aspectFit"></image>
</view>
<view class="rightTxt">
<text class="bigTxt">激光模式</text>
</view>
</view>
<view class="mode " :class="{active:formData.sta_ShakeBit!==0}" v-on:click.stop="SOSToggle">
<view class="mode " :class="{active:formData.sta_ShakeBit!=0}" v-on:click.stop="SOSToggle">
<view class="leftImg">
<image class="img" src="/static/images/common/sg.png" v-show="formData.sta_ShakeBit===0"
<image class="img" src="/static/images/common/sg.png" v-show="formData.sta_ShakeBit==0"
mode="aspectFit"></image>
<image class="img" src="/static/images/common/sgActive.png" v-show="formData.sta_ShakeBit!==0"
<image class="img" src="/static/images/common/sgActive.png" v-show="formData.sta_ShakeBit!=0"
mode="aspectFit"></image>
</view>
<view class="rightTxt">
@ -236,7 +239,7 @@
<view>
<view class="item">
<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt"
<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.sendMsg"
placeholder="请输入文字" placeholder-class="usrplace" />
</view>
@ -296,7 +299,7 @@
var eventChannel = null;
var these = null;
var ble = null;
var rec = null;
var recei = null;
var mq = null;
var pagePath = "pages/6075J/BJQ6075J";
var brightnessTimer = null;
@ -334,7 +337,7 @@
sta_imei: "", //sta_imei
sta_longitude: "", //经度
sta_latitude: "", //纬度
address:'',
address: '',
textLines: [],
company: "湖北星汉文化", //单位
@ -348,19 +351,20 @@
bleStatu: false,
sta_LightGrade: "", //主灯档位
sta_LightGrade: "", //副灯档位
sta_ShakeBit: "1", //报警状态
sta_Side_Light: "", //副灯档位
sta_ShakeBit: 0, //报警状态
sta_4gSinal: "", //4G信号强度
sta_laser: "", //激光状态
sta_brightness: 100, //亮度
sta_SOSGrade: "1", //强制报警状态
showSosGrade:false,
showShakeBit:false,
sta_height:'',//海拔
sta_releaHeight:'',
sta_BreakNews:'',
deviceId:''
sta_Height: '', //海拔
sta_Heat: '', //温度
sta_releaHeight: '',
sta_BreakNews: '',
deviceId: ''
},
device: {
id: "",
@ -412,7 +416,7 @@
staPowerPercent: null,
staDetectResult: null
},
inteval:50
inteval: 80
}
},
computed: {
@ -449,20 +453,24 @@
}
return state;
},
battery(){
let hours = Math.floor(this.formData.sta_PowerTime / 60);
let remainingMinutes = this.formData.sta_PowerTime % 60;
let xuhang = '0分';
// 处理不同情况的显示
if (hours === 0) {
xuhang = `${remainingMinutes}`;
} else if (remainingMinutes === 0) {
xuhang = `${hours}小时`;
} else {
xuhang = `${hours}小时${remainingMinutes}`;
heatStyle() {
if (this.formData.sta_Heat < 0) {
return 'hanleng';
}
return xuhang;
if (this.formData.sta_Heat >= 0 && this.formData.sta_Heat <= 30) {
return 'green';
}
if (this.formData.sta_Heat > 30 && this.formData.sta_Heat <= 40) {
return 're'
}
if (this.formData.sta_Heat > 40 && this.formData.sta_Heat <= 60) {
return 'yanRe'
}
if (this.formData.sta_Heat > 60) {
return 'kuRe'
}
return '';
}
},
created() {
@ -487,8 +495,8 @@
onShow() {
this.Status.pageHide = false;
let f=this.getDevice();
if(f){
let f = this.getDevice();
if (f) {
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
@ -509,7 +517,7 @@
rec = BleReceive.getBleReceive();
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
@ -587,52 +595,40 @@
this.formData.usrid = personnelInfo.code
}
this.formData.sta_PowerPercent = json.staPowerPercent
this.formData.sta_PowerTime = json.staPowerTime;
this.formData.sta_SOSGrade = json.staSOSGrade;
}
});
},
initWatch(){
this.$watch("formData.sta_SOSGrade", (newVal, oldVal) => {
console.log("报警状态发生变化");
if (newVal == 1) {
this.formData.showSosGrade = true;
initWatch() {
this.$watch("formData.sta_Heat", (newVal, oldVal) => {
if (newVal) {
if (newVal < -30) {
MsgError("危险:环境温度过低,当前温度" + newVal + ",请立即撤离", "确定");
}
if (newVal >= 40 && newVal < 60) {
MsgWarning("注意:环境温度过高,当前温度" + newVal, "确定");
} else if (newVal >= 60 && newVal < 80) {
MsgWarning("警告:环境温度过高,当前温度" + newVal + ",注意停留时间", "确定");
} else if (newVal >= 80) {
MsgError("危险:环境温度过高,当前温度" + newVal + ",请立即撤离", "确定");
}
}
});
this.$watch("formData.sta_ShakeBit", (newVal, oldVal) => {
console.log("碰撞状态发生变化");
if (newVal != 0) {
this.formData.showShakeBit = true;
}
});
this.$watch("formData.sta_BreakNews",(newVal,oldVal)=>{
if(newVal){
MsgSuccess("用户已确认收到紧急通知","确定",these);
setTimeout(()=>{
these.formData.sta_BreakNews="";
},10);
this.$watch("formData.sta_BreakNews", (newVal, oldVal) => {
if (newVal) {
MsgSuccess("用户已确认收到紧急通知", "确定", these);
setTimeout(() => {
these.formData.sta_BreakNews = "";
}, 10);
}
});
this.$watch("formData.sta_PowerPercent", (newVal, oldVal) => {
console.log("电量发生变化");
if (newVal <=20 && this.formData.sta_system===2 || this.formData.sta_system===0) {
if (newVal <= 20 && (this.formData.sta_system === 2 || this.formData.sta_system === 0)) {
//电量在20%及以及下,且是未充电状态提醒
showPop({
message: "设备电量低于20%,请充电",
@ -644,8 +640,8 @@
showHeader: false,
visibleClose: true,
textColor: '#E03434',
iconUrl:'/static/images/common/path.png'
},this);
iconUrl: '/static/images/common/path.png'
}, this);
}
});
@ -1025,16 +1021,17 @@
if (currentPacket > totalPackets) {
hideLoading(these);
these.closeAction();
these.showPop({
showPop({
showPop: true,
message: "上传成功",
iconUrl: "/static/images/common/success.png",
});
setTimeout(()=>{
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f
setTimeout(() => {
ble.sendString(f.deviceId, "transmit complete", f
.writeServiceId, f
.wirteCharactId);
},1000);
}, 1000);
these.rgb565Data = null;
resolve();
@ -1083,11 +1080,7 @@
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
}
if (currentPacket > 51) { //第52包补FF
for (var i = 105; i < bufferSize; i++) {
dataView.setUint8(i, 0xFF);
}
}
@ -1111,7 +1104,7 @@
return;
}
these.closeAction();
these.showPop({
showPop({
message: err.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
@ -1134,7 +1127,7 @@
}).catch((err) => {
console.log("握手没有成功");
these.showPop({
showPop({
message: err.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
@ -1205,7 +1198,7 @@
ins_brightness: e.detail.value
}
this.sendData(json, null, 'string').then(res=>{
this.sendData(json, null, 'string').then(res => {
this.setBleFormData();
}).catch(ex => {
@ -1220,18 +1213,18 @@
},
getLightMode(type) {
let item = null;
let index = null;
let value = null;
if (type === 'main') {
index = 0;
value = this.formData.sta_LightGrade;
item = this.dic.actionSheets[0];
} else {
index = 1;
value = this.formData.sta_Side_Light;
item = this.dic.actionSheets[1];
}
let f = item.menuItems.find(v => {
if (v.value == this.dic.actionSheets[index].value) {
if (v.value == value) {
return true;
}
});
@ -1286,37 +1279,37 @@
item.menuItems = [{
text: '强光',
icon: '/static/images/lightImg/qiang.png',
value: '1',
value: 1,
key: 'ins_LightGrade'
},
{
text: '工作光',
icon: '/static/images/lightImg/work.png',
value: '2',
value: 2,
key: 'ins_LightGrade'
},
{
text: '节能光',
icon: '/static/images/lightImg/jieN.png',
value: '3',
value: 3,
key: 'ins_LightGrade'
},
{
text: '爆闪',
icon: '/static/images/lightImg/shan.png',
value: '4',
value: 4,
key: 'ins_LightGrade'
},
{
text: 'SOS',
icon: '/static/images/lightImg/sos.png',
value: '5',
value: 5,
key: 'ins_LightGrade'
},
{
text: '关闭',
icon: '/static/images/lightImg/closeLight.png',
value: '6',
value: 6,
key: 'ins_LightGrade'
}
];
@ -1329,31 +1322,31 @@
item1.menuItems = [{
text: '泛光',
icon: '/static/images/lightImg/fan.png',
value: '2',
value: 2,
key: 'ins_Side_Light'
},
{
text: '泛光爆闪',
icon: '/static/images/lightImg/fan.png',
value: '3',
value: 3,
key: 'ins_Side_Light'
},
{
text: '警示灯',
icon: '/static/images/lightImg/warn.png',
value: '1',
value: 1,
key: 'ins_Side_Light'
},
{
text: '警示灯/泛光',
icon: '/static/images/lightImg/warn.png',
value: '4',
value: 4,
key: 'ins_Side_Light'
},
{
text: '关闭',
icon: '/static/images/lightImg/closeLight.png',
value: '5',
value: 5,
key: 'ins_Side_Light'
}
];
@ -1418,13 +1411,16 @@
this.dic.actionSheets = [item, item1, item3];
},
SOSToggle() {
debugger;
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
MsgError('无操作权限', '确定', these);
return;
}
let val = 1;
if (this.formData.sta_ShakeBit === 1) {
if (this.formData.sta_ShakeBit == 3) {
val = 0;
} else if (this.formData.sta_ShakeBit == 1) {
val = 0;
}
@ -1438,7 +1434,7 @@
console.error("出现错误", ex)
});
}
let msg=val==1?'确定开启声光报警':'确定关闭声光报警';
let msg = val == 1 ? '确定开启声光报警' : '确定关闭声光报警';
showPop({
message: msg,
@ -1508,6 +1504,7 @@
let key = li.key.replace(/ins_/g, 'sta_');
this.formData[key] = li.value;
this.setBleFormData();
this.formData.sta_brightness = 100;
}).catch((ex) => {
console.error("出现错误", ex)
});
@ -1674,11 +1671,14 @@
}, 0);
},
sendMsg() {
debugger;
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
MsgError('无操作权限', '确定', these);
return;
}
this.formData.sendMsg.padStart(16, ' ');
this.formData.textLines = [this.formData.sendMsg.slice(0, 8), this.formData.sendMsg.slice(8, 16)];
@ -1907,11 +1907,13 @@
},
getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => {
if(v.macAddress == these.device.deviceMac){
if(!this.formData.deviceId){this.formData.deviceId=v.deviceId};
if (v.macAddress == these.device.deviceMac) {
if (!this.formData.deviceId) {
this.formData.deviceId = v.deviceId
};
return true;
}
});
@ -1987,10 +1989,17 @@
keys.forEach(key => {
this.formData[key] = data[key];
});
this.$set(this.dic.actionSheets[0], 'value', this.formData.sta_LightGrade);
this.$set(this.dic.actionSheets[1], 'value', this.formData.sta_Side_Light);
this.setBleFormData();
},
setBleFormData() {
if (!ble) {
return;
}
let f = ble.data.LinkedList.find((v) => {
if (v.deviceId == these.formData.deviceId) {
v.formData = these.formData;
@ -2078,6 +2087,32 @@
}, 1000);
});
},
bleStatuToggle() {
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
if (this.formData.bleStatu === true) {
this.formData.bleStatu = 'dicconnect';
ble.disconnectDevice(f.deviceId).finally(r => {
this.formData.bleStatu = false;
});
return;
}
if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
this.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
});
return;
}
},
gotoMap() {
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
@ -2914,4 +2949,20 @@
text-indent: 10rpx;
display: inline-block;
}
.hanleng {
color: #66CCFF;
}
.re {
color: #FFB74D
}
.yanRe {
color: #F57C00;
}
.kuRe {
color: #B71C1C;
}
</style>

View File

@ -7,14 +7,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
</view>

View File

@ -28,14 +28,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -29,14 +29,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -16,7 +16,7 @@
</view>
<view>
<view class="battery-v1">
<image src="/static/images/common/dl.png" class="dlIMG"></image>
<image src="/static/images/common/battry.png" class="dlIMG"></image>
<view>
<view class="battery-v2"
:style="{ color: deviceInfo.batteryPercentage < 20 ? '#FF0000' : '' }">
@ -29,7 +29,7 @@
</view>
</view>
<view class="battery-v1">
<image src="/static/images/common/nz.png" class="dlIMG" mode="aspectFit"></image>
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">{{ deviceInfo.batteryRemainingTime || '0' }}分钟</view>
<view class="battery-v3">续航时间</view>
@ -54,7 +54,7 @@
</view>
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
<text class="info-label">蓝牙状态</text>
<text class="info-value status-running" >
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'" >
{{getbleStatu}}
</text>
</view>
@ -115,6 +115,17 @@
</view>
</view>
</view>
<view class="mode-v1" :class="{'active':itemInfo.alarmStatus===1 || itemInfo.alarmStatus==='1'}" >
<view class="mode-v2" @click="warnToggle">
<image v-show="itemInfo.alarmStatus!=1" src="/static/images/common/sg.png" class="setIMG" mode="aspectFit"></image>
<image v-show="itemInfo.alarmStatus==1" src="/static/images/common/sgActive.png" class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">{{itemInfo.alarmStatus==1?'解除报警':'强制报警'}}</view>
</view>
</view>
</view>
<view class="mode-v1" v-if="hasPermission('3')">
<view class="mode-v2" @click="uploadStartup">
<image src="/static/images/common/path7.png" class="setIMG" mode="aspectFit"></image>
@ -273,9 +284,16 @@
<!-- 解除报警 -->
<CustomPopup v-if="popupType === 'cancel'" :show="showPopupFlag"
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="false"
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
@confirm="onPopupConfirmPolice" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
<!-- 强制报警 -->
<CustomPopup v-if="popupType === 'openWarn'" :show="showPopupFlag"
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
@confirm="OpenWarn(1)" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
</view>
@ -405,7 +423,7 @@
Status: {
pageHide: null
},
inteval: 120
inteval: 1000
}
},
computed: {
@ -461,8 +479,7 @@
},
getDevice: function() {
if (ble) {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.itemInfo);
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == this.itemInfo.deviceMac) {
if (!this.formData.deviceId) {
@ -926,6 +943,7 @@
},
// 激光确认框提交
handleBtn() {
@ -1561,16 +1579,69 @@
// 强制报警()
handlePolice() {
this.popupType = 'cancel';
this.popupMessage = '确认解除所选设备的报警状态';
this.popupMessage = '确认解除报警状态';
this.showPopupFlag = true;
// this.popupConfirmText="";
},
OpenWarn(val){//开启/解除强制报警
const topic = `B/${this.itemInfo.deviceImei}`;
let message={"instruct":[7,val,0,0,0,0]};
message=JSON.stringify(message);
let flag=this.mqttClient.publish(topic, message, {
qos: 1
});
if(flag){
this.itemInfo.alarmStatus=val;
}
this.showPopupFlag = false;
},
warnToggle(){
if(this.itemInfo.alarmStatus==1){
this.popupType = 'cancel';
this.popupMessage = '确认解除报警状态';
}else{
this.popupType = 'openWarn';
this.popupMessage = '确认开启报警状态';
}
this.showPopupFlag = true;
// this.popupConfirmText="开启";
// let val=1;
// let msg="确认开启强制报警?";
// if(this.itemInfo.alarmStatus==1){
// val=0;
// msg="确认解除强制报警?";
// }
// let mqSend=()=>{
// const topic = `B/${this.itemInfo.deviceImei}`;
// let message={"instruct":[7,val,0,0,0,0]};
// message=JSON.stringify(message);
// let flag=this.mqttClient.publish(topic, message, {
// qos: 1
// });
// if(flag){
// this.itemInfo.alarmStatus=val;
// }
// }
},
// 解除报警逻辑
async onPopupConfirmPolice() {
if (this.deviceInfo.onlineStatus !== 1) {
uni.showToast({
title: '设备已离线',
icon: 'none'
});
// uni.showToast({
// title: '设备已离线',
// icon: 'none'
// });
this.OpenWarn(0);//走mq直发
return;
}
this.isPolling = true; // 标记开始轮询
@ -1595,8 +1666,10 @@
title: registerRes.msg,
icon: 'none'
})
return
}
this.itemInfo.alarmStatus=0;
// 4. 获取设备状态FunctionAccessBatchStatusRule 批量
let deviceImei = this.itemInfo.deviceImei
let typeName = this.itemInfo.typeName
@ -2210,6 +2283,11 @@
width: 47%;
display: flex;
text-align: center;
box-sizing: border-box;
border: 1rpx solid #00000000;
}
.mode-v1.active{
border:1rpx solid #bbe600 !important;
}
.mode-v2 {

View File

@ -6,14 +6,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -27,14 +27,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -22,14 +22,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -26,14 +26,14 @@
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.xuhang}}</view>
<view class="smallTxt">续航时间</view>

View File

@ -530,7 +530,7 @@
ble.StartSearch().then(result => {
// console.log("开始搜索成功", result);
these.Status.BottomMenu.show=false;
}).catch(err => {
console.error("开始搜索失败:", err);
if (err.code === 10001) {
@ -582,6 +582,9 @@
ble.showBlueSetting(false);
},
DeviceVerdict(deviceId) { //判断是否是目标设备
if (these.Status.isPageHidden) {
return;
}
console.log("deviceid=", deviceId);
console.log("these.device=", these.device)
if (these.device) { //从设备详情过来的,回设备详情去
@ -618,6 +621,9 @@
}
//找到目标设备的处理方法
let deviceOK = () => {
if (these.Status.isPageHidden) {
return;
}
hideLoading(these);
eventChannel.emit('BindOver', these.device);
@ -779,6 +785,9 @@
execLink().then((res) => {
console.log("res=", res);
if(this.Status.isPageHidden){
return;
}
linkCallback(res);
}).catch(ex => {
console.error("ex=", ex)

View File

@ -24,7 +24,7 @@
<view class="scanPanel center">
<image @click.stop="scan" class="img" src="/static/images/common/scan.png" mode="aspectFit"></image>
</view>
<view class="txt">
<view class="txt" @click.stop="scan">
对准二维码进行扫描
</view>
@ -284,9 +284,10 @@
.btnOK {
color: rgba(255, 255, 255, 0.6);
font-family: 'PingFang SC';
font-size: 30rpx;
font-size: 40rpx;
font-weight: 400;
letter-spacing: 5rpx;
margin-top: 20rpx;
}
.btnOK.active {

View File

@ -363,7 +363,7 @@
}
//统一通信协议方法
let CommonSend = () => {
let json=JSON.stringify({ins_ShakeBit:1});
let json=JSON.stringify({ins_ShakeBit:isAlarming?1:0});
for (let i = 0; i < deviceImeiList.length; i++) {
let imei = deviceImeiList[i];
mq.sendData("B/"+imei,json,false);

View File

@ -18,13 +18,10 @@
<image src="/static/images/common/more.png" mode="aspectFit" class="more"></image>
</view>
</view>
<view class="sendFlex"
v-show="showSendFlex"
>
<view class="sendFlex" v-show="showSendFlex">
<view class="callpolice" @click="callpolice" v-show="showWarn">报警</view>
<view class="Sendmessage" @click="location" v-show="showMap">位置</view>
<view class="Sendmessage" @click="handleSend"
v-show="ShowSendmessage">发送信息</view>
<view class="Sendmessage" @click="handleSend" v-show="ShowSendmessage">发送信息</view>
</view>
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
@ -159,22 +156,22 @@
components: {
MescrollUni
},
computed:{
showSendFlex(){
computed: {
showSendFlex() {
// return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2);
if(this.showMap || this.ShowSendmessage || this.showWarn){
if (this.showMap || this.ShowSendmessage || this.showWarn) {
return true;
}
return false;
},
ShowSendmessage(){
return this.dic.showMsgTypes.indexOf(this.activeTabInfo.typeName)>-1
ShowSendmessage() {
return this.dic.showMsgTypes.indexOf(this.activeTabInfo.typeName) > -1
},
showMap(){
return this.dic.showMapTypes.indexOf(this.activeTabInfo.typeName)>-1
showMap() {
return this.dic.showMapTypes.indexOf(this.activeTabInfo.typeName) > -1
},
showWarn(){
return this.dic.showCallPolice.indexOf(this.activeTabInfo.typeName)>-1
showWarn() {
return this.dic.showCallPolice.indexOf(this.activeTabInfo.typeName) > -1
}
},
data() {
@ -254,10 +251,15 @@
deviceName: "", //重命名
activeTabInfo: '',
dic: {
showMsgTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'BJQ6075J'],//需要发送消息的类型
showMapTypes:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y'],//需要显示地图的类型
showCallPolice:['BJQ6170','HBY210','HBY670','BJQ6075','HBY018A','HBY100-J','BJQ6075J','HBY008A','HBY100-Y']//需要发送报警的类型
}
showMsgTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'BJQ6075J'], //需要发送消息的类型
showMapTypes: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'HBY018A', 'HBY100-J', 'BJQ6075J', 'HBY008A',
'HBY100-Y'
], //需要显示地图的类型
showCallPolice: ['BJQ6170', 'HBY210', 'HBY670', 'BJQ6075', 'HBY018A', 'HBY100-J', 'BJQ6075J',
'HBY008A', 'HBY100-Y'
] //需要发送报警的类型
},
isPageShow: true
}
},
methods: {
@ -299,8 +301,11 @@
this.updateBleStatu();
},
bleStateRecovery() {
if (this.isPageShow) {
console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices();
}
},
bleBreak(res) {
@ -738,8 +743,11 @@
.filter(Boolean);
},
},
onHide() {
this.isPageShow = false;
},
onShow() {
this.isPageShow = true;
if (ble) {
//因为vue视图只能后退不能隐藏后再显示
//所以回到首页后将其他所有页面的订阅都删除

View File

@ -77,6 +77,8 @@
import {
Logout
} from '@/api/common/login.js'
import bleTool from '@/utils/BleHelper.js';
var ble=null;
export default {
data() {
return {
@ -87,6 +89,7 @@
},
onLoad() {
var these=this;
ble=bleTool.getBleTool();
uni.getSystemInfo({
success(res) {
if(res.uniPlatform=='app'){
@ -139,7 +142,12 @@
uni.showToast({
title: '退出成功',
icon: 'success'
})
});
if(ble){
ble.StopSearch().catch(ex => {});
ble.disconnectDevice().catch(ex => {});
}
uni.reLaunch({
url: '/pages/common/login/index'
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

View File

@ -651,7 +651,7 @@ class BleHelper {
BleReceive() {
uni.onBLECharacteristicValueChange((receive) => {
//订阅消息
// console.log("收到订阅消息", receive);
console.log("收到订阅消息", receive);
let f = this.data.LinkedList.find((v) => {
return v.deviceId == receive.deviceId;
})

View File

@ -14,7 +14,8 @@ class BleReceive {
'/pages/100/HBY100': this.Receive_100.bind(this),
'/pages/102/HBY102': this.Receive_102.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)
};
}
@ -893,7 +894,36 @@ Receive_6170(receive, f, path, recArr) {
}
Receive_6075(receive,f,path,recArr){
let receiveData = {};
try {
receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
// if (receiveData.sta_PowerPercent <= 20) {
// uni.showModal({
// title: "提示",
// content: "设备'" + f.device.deviceName + "'电量低",
// showCancel: false
// });
// }
}
} catch (error) {
receiveData = {};
console.log("文本解析失败", error)
}
return receiveData;
}
}

View File

@ -282,7 +282,7 @@ export default {
value: "46",
label: "手动报警",
checked: false,
type: ['210','102']
type: ['210','102','6170']
},
{
value: "47",