1
0
forked from dyf/APP

修复有时候蓝牙配对成功依然提示未连接的异常

This commit is contained in:
liub
2026-05-20 10:58:55 +08:00
parent 7ed3813e7c
commit 7f56e46ace
19 changed files with 1031 additions and 914 deletions

View File

@ -379,6 +379,12 @@
these.formData.deviceId = v.deviceId; these.formData.deviceId = v.deviceId;
return true; return true;
} }
if(v.device){
if(v.device.id==device.id){
these.formData.deviceId = v.deviceId;
return true;
}
}
return false; return false;
}); });
if (!f) { if (!f) {
@ -603,14 +609,24 @@
}, },
getDevice: function() { getDevice: function() {
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB // #ifdef WEB
f = { f = {
deviceId: '123' deviceId: '123'
} }
// #endif // #endif
return f; return f;
}, },
showBleUnConnect() { showBleUnConnect() {

View File

@ -1160,14 +1160,23 @@
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag=v.macAddress == these.device.deviceMac ;
}); if(!flag && v.device){
if (f) { flag= v.device.id==these.device.id;
this.formData.deviceId = f.deviceId;
} }
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },

View File

@ -509,14 +509,7 @@
} }
}); });
} }
let f = ble.data.LinkedList.find((v) => { let f =this.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -1300,12 +1293,23 @@ onFreqChanging(e){
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },

View File

@ -97,7 +97,7 @@
var ble = null; var ble = null;
var recei = null; var recei = null;
var mq = null; var mq = null;
var pagePath=null; var pagePath = null;
export default { export default {
data() { data() {
@ -193,7 +193,7 @@
onUnload() { onUnload() {
console.log("页面卸载,释放资源"); console.log("页面卸载,释放资源");
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`; let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
if(ble){ if (ble) {
ble.removeAllCallback(pagePath); ble.removeAllCallback(pagePath);
ble.removeReceiveCallback(pagePath); ble.removeReceiveCallback(pagePath);
} }
@ -248,14 +248,7 @@
if (these.device.deviceImei) { if (these.device.deviceImei) {
these.initMQ(); these.initMQ();
} }
let f = ble.data.LinkedList.find((v) => { let f =these.getDevice();
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
these.showBleUnConnect(); these.showBleUnConnect();
these.getDetail(); these.getDetail();
@ -472,7 +465,27 @@
}) })
} }
}, },
getDevice: function() {
let f = ble.data.LinkedList.find((v) => {
let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
});
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f;
}
} }
} }
</script> </script>

View File

@ -459,14 +459,7 @@ created() {
} }
these.device = device; these.device = device;
these.getWarns(); these.getWarns();
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -1304,13 +1297,27 @@ created() {
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
bleStatuToggle() { bleStatuToggle() {

View File

@ -465,14 +465,7 @@
} }
these.device = device; these.device = device;
these.getWarns(); these.getWarns();
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -1328,12 +1321,23 @@
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag=v.macAddress == these.device.deviceMac ;
if(!flag && v.device){
flag= v.device.id==these.device.id;
}
if(flag){
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },

View File

@ -562,14 +562,7 @@
if (these.device.deviceImei) { if (these.device.deviceImei) {
these.initMQ(); these.initMQ();
} }
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
these.showBleUnConnect(); these.showBleUnConnect();
these.getDetail(); these.getDetail();
@ -1277,9 +1270,9 @@
if (!batchTool) { if (!batchTool) {
batchTool = new SendBatchData(these, f, ble); batchTool = new SendBatchData(these, f, ble);
} }
console.log("batch",batchTool); console.log("batch", batchTool);
// batchTool.SendUsr(4); // batchTool.SendUsr(4);
let txts=[these.formData.company, these.formData.name, these.formData.job,this.formData.id] let txts = [these.formData.company, these.formData.name, these.formData.job, this.formData.id]
batchTool.sendUsrByGBK(txts); batchTool.sendUsrByGBK(txts);
return; return;
@ -1390,7 +1383,7 @@
console.log("these.formData.sta_Ms=" + these.formData.sta_Ms); console.log("these.formData.sta_Ms=" + these.formData.sta_Ms);
if (ble && f) { if (ble && f) {
ble.sendString(f.deviceId, json).then(res=>{ ble.sendString(f.deviceId, json).then(res => {
these.formData.sta_Ms = newVal; these.formData.sta_Ms = newVal;
}).catch(ex => { }).catch(ex => {
these.mqSend(json); these.mqSend(json);
@ -1468,18 +1461,22 @@
}, },
getDevice: function() { getDevice: function() {
let f ={deviceId:'123'}; let f = ble.data.LinkedList.find((v) => {
// #ifdef APP let flag = v.macAddress == these.device.deviceMac;
f= ble.data.LinkedList.find((v) => { if (!flag && v.device) {
if (v.macAddress == these.device.deviceMac) { flag = v.device.id == these.device.id;
if (!this.formData.deviceId) {
this.formData.deviceId = v.deviceId
};
return true;
} }
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #endif
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
@ -1527,7 +1524,7 @@
batchTool = new SendBatchData(these, f, ble); batchTool = new SendBatchData(these, f, ble);
} }
batchTool.SendMsgByGBK(this.formData.textLines,mq); batchTool.SendMsgByGBK(this.formData.textLines, mq);
return; return;

View File

@ -324,7 +324,7 @@
apiType: 'listA' apiType: 'listA'
}], }],
title: 'BJQ4877', title: 'BJQ4877',
height:90 height: 90
}, },
ShowEditChannel: false, ShowEditChannel: false,
@ -531,14 +531,7 @@
}); });
}) })
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -1014,21 +1007,21 @@
this.Status.sendDisc = true; this.Status.sendDisc = true;
let sendNextPacket = () => { let sendNextPacket = () => {
if(index>total){ if (index > total) {
this.Status.sendDisc = false; this.Status.sendDisc = false;
return; return;
} }
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => { ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
index++; index++;
setTimeout(sendNextPacket,300); setTimeout(sendNextPacket, 300);
}).catch(err => { }).catch(err => {
if (err.code == '10007') { if (err.code == '10007') {
setTimeout(sendNextPacket, 800); setTimeout(sendNextPacket, 800);
return; return;
} }
if(index==0){ if (index == 0) {
MsgError(err.msg,'',these); MsgError(err.msg, '', these);
} }
this.Status.sendDisc = false; this.Status.sendDisc = false;
}); });
@ -1271,12 +1264,23 @@
}, },
getDevice: function() { getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("formData=", these.device);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
@ -1614,7 +1618,8 @@
border-color: #aed600 !important; border-color: #aed600 !important;
} }
.lampMode .mode.active .bigTxt,.lampMode .mode.active .smallTxt { .lampMode .mode.active .bigTxt,
.lampMode .mode.active .smallTxt {
color: #aed600 !important; color: #aed600 !important;
} }

View File

@ -1282,17 +1282,23 @@
}, },
getDevice: function() { getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == these.device.deviceMac) { let flag = v.macAddress == these.device.deviceMac;
if (!this.formData.deviceId) { if (!flag && v.device) {
this.formData.deviceId = v.deviceId flag = v.device.id == these.device.id;
};
return true;
} }
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
showBleUnConnect() { showBleUnConnect() {
@ -1524,7 +1530,8 @@
}, },
gotoMap() { gotoMap() {
let promise = Promise.resolve([this.formData.sta_longitude, this.formData let promise = Promise.resolve([this.formData.sta_longitude, this.formData
.sta_latitude]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude); .sta_latitude
]); //lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
promise.then(lnglat => { promise.then(lnglat => {
this.detailData.longitude = lnglat[0]; this.detailData.longitude = lnglat[0];

View File

@ -377,14 +377,7 @@
// console.log("收到父页面的参数:" + JSON.stringify(data)); // console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data; var device = data.data;
these.device = device; these.device = device;
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -555,7 +548,7 @@
buttonText: '确定', buttonText: '确定',
buttonCancelText: '取消', buttonCancelText: '取消',
showCancel: true showCancel: true
},these); }, these);
} else { } else {
exec(); exec();
} }
@ -671,7 +664,7 @@
buttonText: '确定', buttonText: '确定',
buttonCancelText: '取消', buttonCancelText: '取消',
showCancel: true showCancel: true
},these); }, these);
}, },
deviceRecovry(res) { deviceRecovry(res) {
@ -803,12 +796,23 @@
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
@ -856,7 +860,7 @@
} }
}) })
} }
},these); }, these);
}, },
@ -922,7 +926,7 @@
buttonText: '确定', buttonText: '确定',
okCallback: this.closePop okCallback: this.closePop
}; };
showPop(options,these); showPop(options, these);
} }
} }
} }
@ -1846,6 +1850,4 @@
.volMath { .volMath {
color: rgba(174, 214, 0, 1); color: rgba(174, 214, 0, 1);
} }
</style> </style>

View File

@ -37,7 +37,8 @@
<view class="row"> <view class="row">
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image> <image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
<view class="txt"> <view class="txt">
<view class="bigTxt" v-show="getMode('main')!='关闭'||getMode('fu')!='关闭'">{{formData.xuhang}}</view> <view class="bigTxt" v-show="getMode('main')!='关闭'||getMode('fu')!='关闭'">{{formData.xuhang}}
</view>
<view class="smallTxt">续航时间</view> <view class="smallTxt">续航时间</view>
</view> </view>
</view> </view>
@ -209,7 +210,7 @@
apiType: 'listA' apiType: 'listA'
}], }],
title: 'BJQ6155', title: 'BJQ6155',
height:90 height: 90
}, },
lightMode: { lightMode: {
@ -375,14 +376,7 @@
} }
}); });
} }
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
these.getDetail(); these.getDetail();
@ -665,12 +659,23 @@
}) })
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
bleValueNotify: function(receive, device, path, recArr) { bleValueNotify: function(receive, device, path, recArr) {
@ -1658,8 +1663,8 @@
unitName: these.formData.textLines[2], unitName: these.formData.textLines[2],
code: "" code: ""
}; };
usrApi.sendUsr(json).catch(ex=>{ usrApi.sendUsr(json).catch(ex => {
console.error("ex=",ex); console.error("ex=", ex);
}); });
hideLoading(these); hideLoading(these);
@ -1748,7 +1753,9 @@
res = res.data; res = res.data;
let personnelInfo = res.personnelInfo; let personnelInfo = res.personnelInfo;
if (personnelInfo) { if (personnelInfo) {
these.formData.textLines=[personnelInfo.position, personnelInfo.name,personnelInfo.unitName]; these.formData.textLines = [personnelInfo.position, personnelInfo.name, personnelInfo
.unitName
];
} }
} }
}); });

View File

@ -212,7 +212,7 @@
apiType: 'listA' apiType: 'listA'
}], }],
title: 'BJQ6155', title: 'BJQ6155',
height:90 height: 90
}, },
Pop: { Pop: {
@ -344,14 +344,7 @@
} }
}); });
} }
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
these.getDetail(); these.getDetail();
@ -391,8 +384,8 @@
onShow() { onShow() {
this.Status.pageHide = false; this.Status.pageHide = false;
let f=this.getDevice(); let f = this.getDevice();
if(f){ if (f) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功") console.log("连接成功")
@ -567,9 +560,9 @@
// return; // return;
// } // }
if (res.deviceId == these.formData.deviceId) { if (res.deviceId == these.formData.deviceId) {
if(res.device){ if (res.device) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
}else{ } else {
this.formData.bleStatu = false; this.formData.bleStatu = false;
} }
setTimeout(() => { setTimeout(() => {
@ -632,12 +625,23 @@
}) })
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
bleValueNotify: function(receive, device, path, recArr) { bleValueNotify: function(receive, device, path, recArr) {
@ -901,7 +905,7 @@
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album','camera'], sourceType: ['album', 'camera'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop", url: "/pages/common/ImgCrop/ImgCrop",
@ -1594,7 +1598,7 @@
option.buttonBgColor = '#BBE600'; option.buttonBgColor = '#BBE600';
} }
these.Status.Pop.showPop = true; these.Status.Pop.showPop = true;
showPop(option,this); showPop(option, this);
}, },
sendUsr() { sendUsr() {

View File

@ -557,14 +557,22 @@
if (ble) { if (ble) {
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == this.itemInfo.deviceMac) { let flag = v.macAddress == these.device.deviceMac;
if (!this.formData.deviceId) { if (!flag && v.device) {
this.formData.deviceId = v.deviceId flag = v.device.id == these.device.id;
};
return true;
} }
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
} }
return null; return null;
@ -2117,14 +2125,7 @@
this.initBle(); this.initBle();
console.log("ble=", ble); console.log("ble=", ble);
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == this.itemInfo.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (f) { if (f) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';

View File

@ -218,7 +218,9 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js'; import request, {
baseURL
} from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js'; import usrApi from '@/api/670/HBY670.js';
import { import {
@ -360,14 +362,7 @@ import request, { baseURL } from '@/utils/request.js';
// console.log("收到父页面的参数:" + JSON.stringify(data)); // console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data; var device = data.data;
these.device = device; these.device = device;
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -467,7 +462,7 @@ import request, { baseURL } from '@/utils/request.js';
modelValue: '', modelValue: '',
visibleClose: true, visibleClose: true,
okCallback: play okCallback: play
},these); }, these);
}, },
audioManage() { //语音管理 audioManage() { //语音管理
uni.navigateTo({ uni.navigateTo({
@ -597,7 +592,7 @@ import request, { baseURL } from '@/utils/request.js';
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}); });
}, },
@ -617,9 +612,9 @@ import request, { baseURL } from '@/utils/request.js';
// return; // return;
//} //}
if (res.deviceId == these.formData.deviceId) { if (res.deviceId == these.formData.deviceId) {
if(res.device){ if (res.device) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
}else{ } else {
this.formData.bleStatu = false; this.formData.bleStatu = false;
} }
setTimeout(() => { setTimeout(() => {
@ -693,12 +688,23 @@ import request, { baseURL } from '@/utils/request.js';
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
getDetail() { getDetail() {
@ -755,7 +761,7 @@ import request, { baseURL } from '@/utils/request.js';
} }
}) })
} }
},these); }, these);

View File

@ -113,8 +113,7 @@
</view> </view>
</view> </view>
<view class="mode marginLeft fleft" <view class="mode marginLeft fleft" v-on:click.stop="ShowUpload()">
v-on:click.stop="ShowUpload()">
<view class="leftImg"> <view class="leftImg">
<image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image> <image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image>
</view> </view>
@ -183,7 +182,9 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js'; import request, {
baseURL
} from '@/utils/request.js';
import usrApi from '@/api/670/HBY670.js'; import usrApi from '@/api/670/HBY670.js';
import { import {
@ -196,7 +197,7 @@ import request, { baseURL } from '@/utils/request.js';
} from '@/utils/MsgPops.js' } from '@/utils/MsgPops.js'
const pagePath = "/pages/650/HBY650"; const pagePath = "/pages/650/HBY650";
import SendBatchData from '@/utils/SendBatchData.js'; import SendBatchData from '@/utils/SendBatchData.js';
var batchTool=null; var batchTool = null;
var ble = null; var ble = null;
var these = null; var these = null;
var recei = null; var recei = null;
@ -221,11 +222,11 @@ import request, { baseURL } from '@/utils/request.js';
showHeader: true, showHeader: true,
menuItems: [{ menuItems: [{
text: '照片', text: '照片',
value:'img' value: 'img'
}, },
{ {
text: '动画', text: '动画',
value:'flash' value: 'flash'
} }
], ],
activeIndex: -1, activeIndex: -1,
@ -296,7 +297,7 @@ import request, { baseURL } from '@/utils/request.js';
}, },
} }
}, },
created() { created() {
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44; this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
}, },
onUnload() { onUnload() {
@ -334,14 +335,7 @@ created() {
} }
}); });
} }
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
@ -363,7 +357,7 @@ created() {
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.bleStatu='connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex => { }).catch(ex => {
@ -384,8 +378,8 @@ created() {
onShow() { onShow() {
this.Status.pageHide = false; this.Status.pageHide = false;
let f=this.getDevice(); let f = this.getDevice();
if(f){ if (f) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功") console.log("连接成功")
@ -397,42 +391,42 @@ created() {
} }
}, },
computed: { computed: {
getbleStatu(){ getbleStatu() {
if(this.formData.bleStatu===true){ if (this.formData.bleStatu === true) {
return '已连接'; return '已连接';
} }
if(this.formData.bleStatu==='connecting'){ if (this.formData.bleStatu === 'connecting') {
return '连接中'; return '连接中';
} }
if(this.formData.bleStatu==='dicconnect'){ if (this.formData.bleStatu === 'dicconnect') {
return '正在断开'; return '正在断开';
} }
if(this.formData.bleStatu==='err'){ if (this.formData.bleStatu === 'err') {
return '连接异常'; return '连接异常';
} }
return '未连接'; return '未连接';
} }
}, },
methods: { methods: {
bleStatuToggle(){ bleStatuToggle() {
let f=this.getDevice(); let f = this.getDevice();
if(!f){ if (!f) {
this.showBleUnConnect(); this.showBleUnConnect();
return; return;
} }
if(this.formData.bleStatu===true){ if (this.formData.bleStatu === true) {
this.formData.bleStatu='dicconnect'; this.formData.bleStatu = 'dicconnect';
ble.disconnectDevice(f.deviceId).finally(r=>{ ble.disconnectDevice(f.deviceId).finally(r => {
this.formData.bleStatu=false; this.formData.bleStatu = false;
}); });
return; return;
} }
if(this.formData.bleStatu===false || this.formData.bleStatu==='err'){ if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
this.formData.bleStatu='connecting'; this.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex=>{ }).catch(ex => {
these.formData.bleStatu = 'err'; these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these); MsgError("连接错误:" + ex.msg, "确定", these);
}); });
@ -486,9 +480,9 @@ created() {
// return; // return;
// } // }
if (res.deviceId == these.formData.deviceId) { if (res.deviceId == these.formData.deviceId) {
if(res.device){ if (res.device) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
}else{ } else {
this.formData.bleStatu = false; this.formData.bleStatu = false;
} }
setTimeout(() => { setTimeout(() => {
@ -523,7 +517,7 @@ created() {
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
this.formData.bleStatu='connecting'; this.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {
@ -624,7 +618,7 @@ created() {
iconUrl: "/static/images/6155/DeviceDetail/warnning.png", iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
} }
these.setBleFormData(); these.setBleFormData();
@ -640,12 +634,23 @@ created() {
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
getDetail() { getDetail() {
@ -691,7 +696,7 @@ created() {
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
@ -769,7 +774,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}).finally(() => { }).finally(() => {
@ -817,7 +822,7 @@ created() {
} }
}) })
} }
},these); }, these);
}, },
LampToggle: function() { LampToggle: function() {
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') { if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
@ -829,7 +834,7 @@ created() {
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
this.formData.cMode = !this.formData.cMode; this.formData.cMode = !this.formData.cMode;
@ -838,13 +843,13 @@ created() {
checkImgUpload: function(type, index) { checkImgUpload: function(type, index) {
let f = these.getDevice(); let f = these.getDevice();
if(!f){ if (!f) {
this.showBleUnConnect(); this.showBleUnConnect();
return; return;
} }
if(!batchTool){ if (!batchTool) {
batchTool=new SendBatchData(these,f,ble); batchTool = new SendBatchData(these, f, ble);
} }
@ -853,7 +858,7 @@ created() {
if (type == 'img') { if (type == 'img') {
// sendImagePackets(index); // sendImagePackets(index);
batchTool.SendImg(); batchTool.SendImg();
} else{ } else {
// sendVideoPackets(index); // sendVideoPackets(index);
batchTool.SendVideo(506); batchTool.SendVideo(506);
} }
@ -886,7 +891,7 @@ created() {
showPop: true, showPop: true,
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
},these); }, these);
if (!ReSendNo) { if (!ReSendNo) {
setTimeout(() => { setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f these.HoldYouHand("transmit complete", 0, f
@ -928,7 +933,7 @@ created() {
dataView.setUint8(2, currentPacket); // 包序号 dataView.setUint8(2, currentPacket); // 包序号
dataView.setUint16(3, packetData.length*2,false); // 包t长度 dataView.setUint16(3, packetData.length * 2, false); // 包t长度
// 填充数据每个RGB565值占2字节 // 填充数据每个RGB565值占2字节
for (let i = 0; i < packetData.length; i++) { for (let i = 0; i < packetData.length; i++) {
@ -971,7 +976,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
hideLoading(these); hideLoading(these);
reject(err); reject(err);
}); });
@ -992,7 +997,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
hideLoading(these); hideLoading(these);
reject(err); reject(err);
}); });
@ -1068,7 +1073,7 @@ created() {
showPop: true, showPop: true,
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png" iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
},these); }, these);
@ -1145,7 +1150,7 @@ created() {
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonText: "确定", buttonText: "确定",
iconUrl: "/static/images/common/uploadErr.png" iconUrl: "/static/images/common/uploadErr.png"
},these); }, these);
reject(err); reject(err);
return; return;
} }
@ -1245,7 +1250,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
} }
}).catch((ex) => { }).catch((ex) => {
@ -1256,7 +1261,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}) })
} }
let f = these.getDevice(); let f = these.getDevice();
@ -1330,14 +1335,14 @@ created() {
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
//上传开机画面 //上传开机画面
this.Status.BottomMenu.title = "上传开机画面"; this.Status.BottomMenu.title = "上传开机画面";
this.Status.BottomMenu.type = "checkImg"; this.Status.BottomMenu.type = "checkImg";
this.Status.BottomMenu.show = true; this.Status.BottomMenu.show = true;
this.Status.BottomMenu.activeIndex=0; this.Status.BottomMenu.activeIndex = 0;
}, },
showMenu(flag) { showMenu(flag) {
@ -1348,7 +1353,7 @@ created() {
}, },
btnClick(item, index) { btnClick(item, index) {
this.Status.BottomMenu.show = false; this.Status.BottomMenu.show = false;
this.checkImgUpload(item.value,index); this.checkImgUpload(item.value, index);
}, },
@ -1376,7 +1381,7 @@ created() {
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
@ -1436,7 +1441,7 @@ created() {
promptTitle: '', promptTitle: '',
modelValue: '', modelValue: '',
visibleClose: true visibleClose: true
},these); }, these);
these.setBleFormData(); these.setBleFormData();
@ -1499,7 +1504,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}).finally(() => { }).finally(() => {
hideLoading(these); hideLoading(these);
}); });
@ -1533,7 +1538,7 @@ created() {
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}); });
}, 0); }, 0);

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" <uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
background-color="#121212" color="#FFFFFF" :title="Status.navbar.title"> color="#FFFFFF" :title="Status.navbar.title">
<template v-slot:left> <template v-slot:left>
<view> <view>
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons> <uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
@ -9,7 +9,8 @@
</template> </template>
<block slot="right"> <block slot="right">
<view class="navbarRight center"> <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>
</block> </block>
@ -18,7 +19,7 @@
<view class="eq":style="{marginTop:Status.navbar.height+'px'}"> <view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
<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>
</view> </view>
@ -287,7 +288,9 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import request, { baseURL } from '@/utils/request.js'; import request, {
baseURL
} from '@/utils/request.js';
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'; import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
import { import {
MsgSuccess, MsgSuccess,
@ -299,7 +302,7 @@
} from '@/utils/MsgPops.js' } from '@/utils/MsgPops.js'
const pagePath = "/pages/670/HBY670"; const pagePath = "/pages/670/HBY670";
import SendBatchData from '@/utils/SendBatchData.js'; import SendBatchData from '@/utils/SendBatchData.js';
var batchTool=null; var batchTool = null;
var ble = null; var ble = null;
var these = null; var these = null;
var recei = null; var recei = null;
@ -355,11 +358,11 @@
showHeader: true, showHeader: true,
menuItems: [{ menuItems: [{
text: '照片', text: '照片',
value:'img' value: 'img'
}, },
{ {
text: '动画', text: '动画',
value:'flash' value: 'flash'
} }
], ],
activeIndex: -1, activeIndex: -1,
@ -479,7 +482,7 @@
ble = BleTool.getBleTool(); ble = BleTool.getBleTool();
this.$watch("formData.battary", (newVal, oldVal) => { this.$watch("formData.battary", (newVal, oldVal) => {
if (newVal <= 20 && this.formData.sta_system == 2) { if (newVal <= 20 && this.formData.sta_system == 2) {
MsgError("设备电量低",'',these); MsgError("设备电量低", '', these);
} }
}); });
@ -511,14 +514,7 @@
if (these.device.deviceImei) { if (these.device.deviceImei) {
these.initMQ(); these.initMQ();
} }
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
these.showBleUnConnect(); these.showBleUnConnect();
these.getDetail(); these.getDetail();
@ -540,7 +536,7 @@
} }
these.getDetail(); these.getDetail();
these.formData.bleStatu='connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex => { }).catch(ex => {
@ -553,8 +549,8 @@
onShow() { onShow() {
this.Status.pageHide = false; this.Status.pageHide = false;
let f=this.getDevice(); let f = this.getDevice();
if(f){ if (f) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功") console.log("连接成功")
@ -572,42 +568,42 @@
ble.removeReceiveCallback(pagePath); ble.removeReceiveCallback(pagePath);
}, },
computed: { computed: {
getbleStatu(){ getbleStatu() {
if(this.formData.bleStatu===true){ if (this.formData.bleStatu === true) {
return '已连接'; return '已连接';
} }
if(this.formData.bleStatu==='connecting'){ if (this.formData.bleStatu === 'connecting') {
return '连接中'; return '连接中';
} }
if(this.formData.bleStatu==='dicconnect'){ if (this.formData.bleStatu === 'dicconnect') {
return '正在断开'; return '正在断开';
} }
if(this.formData.bleStatu==='err'){ if (this.formData.bleStatu === 'err') {
return '连接异常'; return '连接异常';
} }
return '未连接'; return '未连接';
} }
}, },
methods: { methods: {
bleStatuToggle(){ bleStatuToggle() {
let f=this.getDevice(); let f = this.getDevice();
if(!f){ if (!f) {
this.showBleUnConnect(); this.showBleUnConnect();
return; return;
} }
if(this.formData.bleStatu===true){ if (this.formData.bleStatu === true) {
this.formData.bleStatu='dicconnect'; this.formData.bleStatu = 'dicconnect';
ble.disconnectDevice(f.deviceId).finally(r=>{ ble.disconnectDevice(f.deviceId).finally(r => {
this.formData.bleStatu=false; this.formData.bleStatu = false;
}); });
return; return;
} }
if(this.formData.bleStatu===false || this.formData.bleStatu==='err'){ if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
this.formData.bleStatu='connecting'; this.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex=>{ }).catch(ex => {
these.formData.bleStatu = 'err'; these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these); MsgError("连接错误:" + ex.msg, "确定", these);
}); });
@ -636,9 +632,9 @@
// return; // return;
// } // }
if (res.deviceId == these.formData.deviceId) { if (res.deviceId == these.formData.deviceId) {
if(res.device){ if (res.device) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
}else{ } else {
this.formData.bleStatu = false; this.formData.bleStatu = false;
} }
setTimeout(() => { setTimeout(() => {
@ -673,7 +669,7 @@
showLoading(this, { showLoading(this, {
text: "蓝牙恢复可用,正在连接设备" text: "蓝牙恢复可用,正在连接设备"
}); });
this.formData.bleStatu='connecting'; this.formData.bleStatu = 'connecting';
ble.LinkBlue(these.formData.deviceId).then(() => { ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
updateLoading(these, { updateLoading(these, {
@ -737,7 +733,7 @@
} }
}) })
} }
},these); }, these);
}, },
gotoMap() { gotoMap() {
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat); let promise = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat);
@ -931,13 +927,14 @@
// console.log("收到文本回复", payload); // console.log("收到文本回复", payload);
// // this.SendTxtMQ(json); // // this.SendTxtMQ(json);
// } // }
if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知 if (keys.indexOf('sta_BreakNews') > -
if(json.sta_BreakNews=='I get it'){ 1) { //紧急通知
if (json.sta_BreakNews == 'I get it') {
showPop({ showPop({
showPop: true, showPop: true,
message: "用户已确认收到紧急通知", message: "用户已确认收到紧急通知",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png" iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
},these); }, these);
} }
} }
@ -1126,7 +1123,7 @@
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonText: "确定", buttonText: "确定",
clickEvt: "staticWarn" clickEvt: "staticWarn"
},these); }, these);
} }
@ -1134,12 +1131,23 @@
}, },
getDevice: function() { getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
setBleFormData() { setBleFormData() {
@ -1167,7 +1175,7 @@
buttonTextColor: "#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
if (this.formData.lightCurr == type) { if (this.formData.lightCurr == type) {
@ -1209,7 +1217,7 @@
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonTextColor: "#FFFFFFde" buttonTextColor: "#FFFFFFde"
},these); }, these);
}).finally(() => { }).finally(() => {
hideLoading(these); hideLoading(these);
@ -1255,7 +1263,7 @@
these.formData.qzwarn = false; these.formData.qzwarn = false;
these.Status.staticWarn.inteval=null these.Status.staticWarn.inteval = null
clearInterval(these.Status.staticWarn.inteval); clearInterval(these.Status.staticWarn.inteval);
let requestCloseSOS = () => { let requestCloseSOS = () => {
@ -1275,7 +1283,7 @@
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonTextColor: "#FFFFFFde" buttonTextColor: "#FFFFFFde"
},these); }, these);
}).finally(() => { }).finally(() => {
hideLoading(these); hideLoading(these);
@ -1346,7 +1354,7 @@
this.Status.Pop.okCallback = null; this.Status.Pop.okCallback = null;
}, },
clickEvt: 'time' clickEvt: 'time'
},these); }, these);
}, },
sosSetting: function(type) { sosSetting: function(type) {
debugger; debugger;
@ -1360,7 +1368,7 @@
buttonTextColor: "#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
@ -1431,7 +1439,7 @@
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonTextColor: "#FFFFFFde" buttonTextColor: "#FFFFFFde"
},these); }, these);
}).finally(() => { }).finally(() => {
hideLoading(these); hideLoading(these);
@ -1553,14 +1561,14 @@
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonTextColor:"#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: OpenSOS, okCallback: OpenSOS,
buttonText: "开启" buttonText: "开启"
},these); }, these);
return; return;
} else if (type == 'close') { } else if (type == 'close') {
console.log("this.formData.SOS=",this.formData.SOS); console.log("this.formData.SOS=", this.formData.SOS);
console.log("inteval=",this.Status.staticWarn.inteval); console.log("inteval=", this.Status.staticWarn.inteval);
if (this.formData.SOS = 'sg' && this.Status.staticWarn.inteval) { //解除声光报警 if (this.formData.SOS = 'sg' && this.Status.staticWarn.inteval) { //解除声光报警
this.CloseWarn(true); this.CloseWarn(true);
} else { } else {
@ -1586,7 +1594,7 @@
buttonTextColor: "#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
if (this.formData.modeCurr == type) { if (this.formData.modeCurr == type) {
@ -1627,7 +1635,7 @@
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonTextColor: "#FFFFFFde" buttonTextColor: "#FFFFFFde"
},these); }, these);
}).finally(() => { }).finally(() => {
hideLoading(these); hideLoading(these);
@ -1680,13 +1688,13 @@
checkImgUpload: function(type, index) { checkImgUpload: function(type, index) {
console.log("123213213213"); console.log("123213213213");
let f = these.getDevice(); let f = these.getDevice();
if(!f){ if (!f) {
this.showBleUnConnect(); this.showBleUnConnect();
return; return;
} }
if(!batchTool){ if (!batchTool) {
batchTool=new SendBatchData(these,f,ble); batchTool = new SendBatchData(these, f, ble);
} }
if (type) { if (type) {
@ -1712,7 +1720,7 @@
showPop: true, showPop: true,
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
},these); }, these);
resolve(); resolve();
return; return;
} else { } else {
@ -1722,7 +1730,7 @@
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
reject(res); reject(res);
} }
}).catch((ex) => { }).catch((ex) => {
@ -1758,7 +1766,7 @@
showPop: true, showPop: true,
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png", iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
},these); }, these);
if (!ReSendNo) { if (!ReSendNo) {
setTimeout(() => { setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f these.HoldYouHand("transmit complete", 0, f
@ -1801,7 +1809,7 @@
'0')); // 包序号 '0')); // 包序号
dataView.setUint16(3, packetData.length*2,false); // 包t长度 dataView.setUint16(3, packetData.length * 2, false); // 包t长度
// 填充数据每个RGB565值占2字节 // 填充数据每个RGB565值占2字节
for (let i = 0; i < packetData.length; i++) { for (let i = 0; i < packetData.length; i++) {
@ -1943,7 +1951,7 @@
showPop: true, showPop: true,
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png" iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
},these); }, these);
@ -2022,7 +2030,7 @@
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonText: "确定", buttonText: "确定",
iconUrl: "/static/images/common/uploadErr.png" iconUrl: "/static/images/common/uploadErr.png"
},these); }, these);
reject(err); reject(err);
return; return;
} }
@ -2124,7 +2132,7 @@
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
} }
}).catch((ex) => { }).catch((ex) => {
@ -2135,7 +2143,7 @@
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}) })
} }
@ -2209,7 +2217,7 @@
buttonTextColor: "#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
//上传开机画面 //上传开机画面
@ -2218,7 +2226,7 @@
this.Status.BottomMenu.type = "checkImg"; this.Status.BottomMenu.type = "checkImg";
this.Status.BottomMenu.show = true; this.Status.BottomMenu.show = true;
this.Status.BottomMenu.showBtn = true; this.Status.BottomMenu.showBtn = true;
this.Status.BottomMenu.activeIndex=0; this.Status.BottomMenu.activeIndex = 0;
}, },
showMenu(flag) { showMenu(flag) {
@ -2229,7 +2237,7 @@
}, },
btnClick(item, index) { btnClick(item, index) {
this.Status.BottomMenu.show = false; this.Status.BottomMenu.show = false;
this.checkImgUpload(item.value,index); this.checkImgUpload(item.value, index);
}, },
setMode(mode) { setMode(mode) {
@ -2250,7 +2258,7 @@
this.Status.BottomMenu.activeIndex = index; this.Status.BottomMenu.activeIndex = index;
}, },
HidePop: function () { HidePop: function() {
if (this.Status.Pop.clickEvt == 'staticWarn') { if (this.Status.Pop.clickEvt == 'staticWarn') {
// this.Status.staticWarnTime=0; // this.Status.staticWarnTime=0;
// clearInterval(this.Status.staticWarn.inteval); // clearInterval(this.Status.staticWarn.inteval);
@ -2263,14 +2271,14 @@
this.Status.Pop.showPop = false; this.Status.Pop.showPop = false;
}, },
closePop: function () { closePop: function() {
this.Status.Pop.showPop = false; this.Status.Pop.showPop = false;
if (this.Status.Pop.cancelCallback) { if (this.Status.Pop.cancelCallback) {
this.Status.Pop.cancelCallback(); this.Status.Pop.cancelCallback();
} }
}, },
showPop: function (option) { showPop: function(option) {
hideLoading(this); hideLoading(this);
let def = { let def = {
showPop: true, //是否显示弹窗 showPop: true, //是否显示弹窗
@ -2330,7 +2338,7 @@
buttonTextColor: "#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
@ -2362,7 +2370,7 @@
promptTitle: '', promptTitle: '',
modelValue: '', modelValue: '',
visibleClose: true visibleClose: true
},these); }, these);
these.setBleFormData(); these.setBleFormData();
}).catch((ex) => { }).catch((ex) => {
showPop({ showPop({
@ -2370,7 +2378,7 @@
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
}).finally(() => { }).finally(() => {
hideLoading(these); hideLoading(these);
}); });
@ -2434,7 +2442,7 @@
promptTitle: '', promptTitle: '',
modelValue: '', modelValue: '',
visibleClose: true visibleClose: true
},these); }, these);
these.setBleFormData(); these.setBleFormData();
hideLoading(these); hideLoading(these);
@ -2549,7 +2557,7 @@
buttonTextColor: "#FFFFFFde", buttonTextColor: "#FFFFFFde",
okCallback: null, okCallback: null,
buttonText: "确定" buttonText: "确定"
},these) }, these)
return; return;
} }
if (!this.formData.msgTxt) { if (!this.formData.msgTxt) {
@ -2593,7 +2601,7 @@
promptTitle: '', promptTitle: '',
modelValue: '', modelValue: '',
visibleClose: true visibleClose: true
},these); }, these);
// clearInterval(this.Status.msgOkIntval); // clearInterval(this.Status.msgOkIntval);
@ -2614,7 +2622,7 @@
iconUrl: "/static/images/common/uploadErr.png", iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
},these); }, these);
} }
}).finally(() => { }).finally(() => {
hideLoading(this); hideLoading(this);
@ -3340,13 +3348,14 @@
background: #FFFFFF !important; background: #FFFFFF !important;
} }
.navbarRight .img{ .navbarRight .img {
width: 35rpx; width: 35rpx;
height: 35rpx; height: 35rpx;
margin-right: 30rpx; margin-right: 30rpx;
} }
.uni-navbar--fixed{
top:0rpx; .uni-navbar--fixed {
top: 0rpx;
} }
/deep/ .uni-navbar--fixed { /deep/ .uni-navbar--fixed {

View File

@ -119,15 +119,18 @@
<view class="item"> <view class="item">
<text class="lbl">单位</text> <text class="lbl">单位</text>
<input class="value" maxlength="5" v-model="formData.inputLines[0]" placeholder="请输入单位" placeholder-class="usrplace" /> <input class="value" maxlength="5" v-model="formData.inputLines[0]" placeholder="请输入单位"
placeholder-class="usrplace" />
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">部门</text> <text class="lbl">部门</text>
<input class="value" maxlength="5" v-model="formData.inputLines[1]" placeholder="请输入姓名" placeholder-class="usrplace" /> <input class="value" maxlength="5" v-model="formData.inputLines[1]" placeholder="请输入姓名"
placeholder-class="usrplace" />
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">姓名</text> <text class="lbl">姓名</text>
<input class="value" maxlength="5" v-model="formData.inputLines[2]" placeholder="请输入职位" placeholder-class="usrplace" /> <input class="value" maxlength="5" v-model="formData.inputLines[2]" placeholder="请输入职位"
placeholder-class="usrplace" />
</view> </view>
</view> </view>
@ -188,7 +191,7 @@
apiType: 'listA' apiType: 'listA'
}], }],
title: 'BJQ6155', title: 'BJQ6155',
height:90 height: 90
}, },
pageHide: false, pageHide: false,
@ -260,7 +263,7 @@
textLines: [], textLines: [],
mode: '', mode: '',
bleStatu: '', bleStatu: '',
inputLines:[] inputLines: []
}, },
inteval: 500, inteval: 500,
device: { device: {
@ -320,14 +323,7 @@
} }
}); });
} }
let f = ble.data.LinkedList.find((v) => { let f = these.getDevice();
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
these.formData.deviceId = v.deviceId;
return true;
}
return false;
});
if (!f) { if (!f) {
these.getDetail(); these.getDetail();
@ -369,8 +365,8 @@
onShow: function() { onShow: function() {
this.Status.pageHide = false; this.Status.pageHide = false;
let f=this.getDevice(); let f = this.getDevice();
if(f){ if (f) {
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功") console.log("连接成功")
@ -568,12 +564,23 @@
}) })
}, },
getDevice: function() { getDevice: function() {
// console.log("LinkedList=", ble.data.LinkedList);
// console.log("formData=", these.formData);
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac; let flag = v.macAddress == these.device.deviceMac;
if (!flag && v.device) {
flag = v.device.id == these.device.id;
}
if (flag) {
these.formData.deviceId = v.deviceId;
}
return flag;
}); });
// #ifdef WEB
f = {
deviceId: '123'
}
// #endif
return f; return f;
}, },
bleValueNotify: function(receive, device, path, recArr) { bleValueNotify: function(receive, device, path, recArr) {
@ -595,8 +602,8 @@
these.formData[key] = json[key]; these.formData[key] = json[key];
} }
}); });
these.formData.mode=parseInt(receive.hexs[2],16); these.formData.mode = parseInt(receive.hexs[2], 16);
console.error("mode="+these.formData.mode); console.error("mode=" + these.formData.mode);
if ('statu' in json) { if ('statu' in json) {
const chargingVal = json.statu; const chargingVal = json.statu;
const isCharging = chargingVal === 1 || chargingVal === '1' || chargingVal === true || const isCharging = chargingVal === 1 || chargingVal === '1' || chargingVal === true ||
@ -756,7 +763,7 @@
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album','camera'], sourceType: ['album', 'camera'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop", url: "/pages/common/ImgCrop/ImgCrop",
@ -1042,7 +1049,7 @@
}); });
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).then(() => { ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).then(() => {
this.formData.mode = mode+1; this.formData.mode = mode + 1;
this.setBleFormData(); this.setBleFormData();
}).catch((ex) => { }).catch((ex) => {
these.showPop({ these.showPop({
@ -1059,7 +1066,7 @@
}, },
handleItemClick(item, index) { handleItemClick(item, index) {
debugger; debugger;
this.Status.BottomMenu.activeIndex = index; this.Status.BottomMenu.activeIndex = index;
@ -1143,7 +1150,7 @@ debugger;
option.buttonBgColor = '#BBE600'; option.buttonBgColor = '#BBE600';
} }
these.Status.Pop.showPop = true; these.Status.Pop.showPop = true;
showPop(option,this); showPop(option, this);
}, },
sendUsr() { sendUsr() {
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') { if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
@ -1184,14 +1191,16 @@ debugger;
} }
this.formData.textLines=[this.formData.inputLines[0],this.formData.inputLines[1],this.formData.inputLines[2]]; this.formData.textLines = [this.formData.inputLines[0], this.formData.inputLines[1], this.formData
.inputLines[2]
];
showLoading(these, { showLoading(these, {
text: "发送中..." text: "发送中..."
}); });
this.setBleFormData(); this.setBleFormData();
let task = async () => { let task = async () => {
var sendTxtPackge = (rgbdata, type, str,index) => { var sendTxtPackge = (rgbdata, type, str, index) => {
var promise = new Promise((resolve, reject) => { var promise = new Promise((resolve, reject) => {
try { try {
@ -1234,7 +1243,10 @@ debugger;
.toString(16).padStart(2, '0')); .toString(16).padStart(2, '0'));
console.log(`发送数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray console.log(`发送数据块 ${chunkIndex + 1}/${numChunks}:`, hexArray
.join(' ')); .join(' '));
updateLoading(these,{text:'正在发送'+((index-1)*14+chunkIndex + 1)+'/42'}) updateLoading(these, {
text: '正在发送' + ((index - 1) * 14 + chunkIndex +
1) + '/42'
})
ble.sendData(f.deviceId, chunk, f.writeServiceId, f ble.sendData(f.deviceId, chunk, f.writeServiceId, f
.wirteCharactId, 100).then(() => { .wirteCharactId, 100).then(() => {
chunkIndex++; chunkIndex++;
@ -1291,7 +1303,7 @@ debugger;
try { try {
// console.log("1111"); // console.log("1111");
await sendTxtPackge(rgb, h3dic[i], str,i+1); await sendTxtPackge(rgb, h3dic[i], str, i + 1);
// console.log("222222"); // console.log("222222");
} catch (ex) { } catch (ex) {
flag = false; flag = false;
@ -1344,7 +1356,9 @@ debugger;
res = res.data; res = res.data;
let personnelInfo = res.personnelInfo; let personnelInfo = res.personnelInfo;
if (personnelInfo) { if (personnelInfo) {
these.formData.inputLines=[personnelInfo.position,personnelInfo.name,personnelInfo.unitName]; these.formData.inputLines = [personnelInfo.position, personnelInfo.name, personnelInfo
.unitName
];
} }
} }
}); });
@ -1358,7 +1372,7 @@ debugger;
}); });
}, },
sliderChanging(evt){ sliderChanging(evt) {
this.formData.liangDu = evt.detail.value; this.formData.liangDu = evt.detail.value;
}, },

View File

@ -58,7 +58,7 @@
</view> </view>
<view class="list searchList"> <view class="list searchList">
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents" <view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
v-show="item.name.indexOf(search)>-1"> v-show="item.name.toLowerCase().indexOf(search.toLowerCase())>-1">
<view class="before" v-if="item.isTarget"></view> <view class="before" v-if="item.isTarget"></view>
<view class="leftImg "> <view class="leftImg ">
<image src="/static/images/BLEAdd/bluetooth.png" class="titleIco" mode="heightFix"> <image src="/static/images/BLEAdd/bluetooth.png" class="titleIco" mode="heightFix">
@ -131,7 +131,7 @@
var ble = null; var ble = null;
var these = null; var these = null;
var eventChannel = null; var eventChannel = null;
var sortTime=null;
export default { export default {
data() { data() {
return { return {
@ -362,15 +362,18 @@
device.isTarget = true; device.isTarget = true;
} }
if (device.name) { if (device.name) {
device.name = device.name.replace(/^JQZM-/i, '').replace(/^HBY102J-/i, ''); device.name = device.name.replace(/^HBY102J-/i, '');
} }
these.EquipMents.push(device); these.EquipMents.push(device);
} }
} }
clearTimeout(sortTime);
sortTime=setTimeout(()=>{
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI);
},500);
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
}, pagePath); }, pagePath);
@ -632,9 +635,9 @@
} }
hideLoading(these); hideLoading(these);
these.device.bleId=deviceId; these.device.bleId=deviceId;
eventChannel.emit('BindOver', these.device);
ble.updateCache(); ble.updateCache();
eventChannel.emit('BindOver', these.device);
uni.navigateBack(); uni.navigateBack();
} }
@ -642,7 +645,8 @@
if (f && f.macAddress) { if (f && f.macAddress) {
if (!these.device || !these.device.deviceMac) { //走服务端验证 if (!these.device || !these.device.deviceMac) { //走服务端验证
console.error("走服务端验证") console.error("理论上永远不会走这里,走服务端验证");
console.error("我TM太相信理论了");
request({ request({
url: '/app/device/getDeviceInfoByDeviceMac', url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET', method: 'GET',
@ -650,8 +654,6 @@
deviceMac: f.macAddress deviceMac: f.macAddress
} }
}).then(res => { }).then(res => {
if (res && res.code == 200) { if (res && res.code == 200) {
let data = res.data; let data = res.data;
@ -701,17 +703,7 @@
clearInterval(this.Status.intval) clearInterval(this.Status.intval)
this.Status.intval = null; this.Status.intval = null;
this.Status.time = null; this.Status.time = null;
f = ble.data.LinkedList.find(v => { deviceInvalid();
if (v.deviceId == deviceId) {
v.device = these.device;
return true;
}
return false;
});
if (!(f && f.macAddress)) {
deviceInvalid()
return;
}
return; return;
} }

View File

@ -164,7 +164,20 @@ class BleHelper {
//更新缓存 //更新缓存
updateCache() { updateCache() {
uni.setStorageSync(this.StorageKey, this.data.LinkedList); let task =async () => {
await uni.setStorage({
key: this.StorageKey,
data: this.data.LinkedList,
success() {
},
fail(ex) {
console.error("更新蓝牙缓存失败");
}
});
}
task();
} }
//连接所有已连接过的设备 //连接所有已连接过的设备
@ -1595,7 +1608,7 @@ class BleHelper {
LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId, maxRetries) { LinkBlue(deviceId, targetServiceId, writeCharId, notifyCharId, maxRetries) {
//连接成功的回调 //连接成功的回调
let LinkedCallback=() => { let LinkedCallback = () => {
if (this.cfg.recoveryCallback.length > 0) { if (this.cfg.recoveryCallback.length > 0) {
this.cfg.recoveryCallback.forEach(( this.cfg.recoveryCallback.forEach((
c) => { c) => {
@ -1711,9 +1724,11 @@ 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; this.data.LinkedList[fIndex].linkId =
this.data.LinkedList[fIndex].name =cr.name; linkId;
this.data.LinkedList[fIndex].advertisData =cr.advertisData; this.data.LinkedList[fIndex].name = cr.name;
this.data.LinkedList[fIndex].advertisData =
cr.advertisData;
} else { } else {
this.data.LinkedList.push(cr); this.data.LinkedList.push(cr);
} }
@ -1735,7 +1750,7 @@ class BleHelper {
}); });
}, },
fail: (ex) => { fail: (ex) => {
if(ex.code===10010){ if (ex.code === 10010) {
console.log("设备已连接,无需重复连接"); console.log("设备已连接,无需重复连接");
delete this.data.connectingDevices[deviceId]; delete this.data.connectingDevices[deviceId];
resolve(true); resolve(true);