1
0
forked from dyf/APP

完成008A功能开发

This commit is contained in:
liub
2026-05-19 17:38:56 +08:00
parent 6d9df4c945
commit 8f53a45280
63 changed files with 4162 additions and 766 deletions

View File

@ -58,7 +58,11 @@
<view>电量{{item.battery || '0'}}%</view>
</view>
<!-- <view @click.stop="Disc()">识别</view> -->
<view @click.stop="Disc(item,index)" class="disc center" :class="{active:item.isDisc}">
<image src="/static/images/common/disc.png"
class="discImg" mode="aspectFit"></image>
<text>识别</text>
</view>
</view>
</view>
</view>
@ -158,26 +162,28 @@
deviceInfo,
deviceUnbind, //删除设备
deviceReName
} from '@/api/common/index.js'
} from '@/api/common/index.js'
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue';
import bleTool from '@/utils/BleHelper.js';
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
import BleReceive from '@/utils/BleReceive';
import {
MsgError
MsgError, MsgSuccess
} from '@/utils/MsgPops';
import MqttClient from '@/utils/mqtt.js';
var pagePath = 'pages/common/index';
var ble = null;
var mq=null;
var timeout = null;
var ble = null;
var recei = null;
var these=null;
export default {
components: {
MescrollUni
},
computed: {
showSendFlex() {
// return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2);
showSendFlex() {
if (this.showMap || this.ShowSendmessage || this.showWarn) {
return true;
}
@ -243,6 +249,11 @@
text: '所有分享',
icon: '/static/images/common/share.png',
action: 'share'
},
{
text: '预警布防',
icon: '/static/images/common/defence.png',
action: 'defence'
}
],
downOption: {
@ -299,21 +310,14 @@
},
// 下拉刷新
downCallback() {
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData();
},
// 上拉加载
upCallback() {
this.getData();
},
bleStateBreak() {
@ -325,22 +329,18 @@
console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices();
}
},
bleBreak(res) {
console.error("蓝牙断开连接", res);
if (res.deviceId) {
this.updateBleStatu(res.deviceId);
}
},
bleRecovery(res) {
// console.log("蓝牙连接成功", res);
if (res.deviceId) {
this.updateBleStatu(res.deviceId);
}
},
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
@ -390,6 +390,7 @@
},
// 所有分享,所有类型
handleshareClick(item) {
debugger;
this.showshare = false; // 关闭弹窗
var that = this;
switch (item.action) {
@ -414,8 +415,12 @@
case 'share':
uni.navigateTo({
url: "/pages/common/allShare/index",
})
});
break;
case 'defence':
uni.navigateTo({
url: "/pages/common/linkDefence/defence"
});
break;
}
},
@ -720,6 +725,8 @@
this.$set(this.deviceList[index], 'showOption', 'none');
},
Disc(item, index) { //发送识别指令
this.$set(this.deviceList[index], 'isDisc', true);
let json = {
ins_disc: 1
};
@ -729,51 +736,100 @@
return v.macAddress == item.deviceMac;
});
if (f) {
console.log("f=",f);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
index++;
setTimeout(sendNextPacket, 300);
MsgSuccess("发送识别指令成功",'',these);
this.$set(this.deviceList[index], 'isDisc', false);
}).catch(err => {
console.error('err=',err);
if (item.communicationMode == 1) {
MsgError(err.msg, '', this);
this.$set(this.deviceList[index], 'isDisc', false);
return;
}
mqSend();
mqSend(true);
});
}else{
if (item.communicationMode == 1) {
MsgError("请连接蓝牙后再试", '去连接', this,()=>{
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver(data) {
console.log("蓝牙配对成功了");
}
},
success: function(res) {
res.eventChannel.emit('detailData', {
data: item
});
}
});
});
this.$set(this.deviceList[index], 'isDisc', false);
return;
}
mqSend(true);
}
}
let mqSend = () => {
let mqSend = (isBle) => {
if(!item.deviceImei){
if(ble){
MsgError("发送识别指令,蓝牙发送失败、IMEI缺失4G发送也失败",'',these);
}else{
MsgError("发送识别指令失败,设备IMEI缺失",'',these);
}
this.$set(this.deviceList[index], 'isDisc', false);
return;
}
let Send = () => {
let flag = mq.publish("B/" + item.deviceImei, JSON.stringify(json));
if (!flag) {
MsgError("识别设备失败,请检查手机网络连接", '', this);
MsgError("发送识别指令失败,请检查手机网络连接", '', this);
this.$set(this.deviceList[index], 'isDisc', false);
return;
}
this.$set(this.deviceList[index], 'isDisc', false);
}
if (!mq) {
mq = new MqttClient();
mq.connect(() => {
console.log("MQTT连接成功")
Send();
},()=>{
MsgError("发送识别指令时,无法连接消息服务器");
mq.disconnect();
mq=null;
}).catch(ex=>{
console.error("ex=",ex);
this.$set(this.deviceList[index], 'isDisc', false);
});
return ;
}else{
console.log("mq=",mq);
Send();
}
Send();
}
if (item.communicationMode == 1 || item.communicationMode == 2) {
bleSend.catch(ex => {
mqSend();
});
setTimeout(()=>{
if (item.communicationMode == 1 || item.communicationMode == 2) {
bleSend();
return;
}
if (item.communicationMode == 0) {
mqSend();
return;
}
},250);
},
// 列表跳转
handleFile(item, index) {
@ -781,6 +837,7 @@
this.$set(this.deviceList[index], 'showOption', 'none');
return;
}
this.$set(this.deviceList[index], 'active', true);
setTimeout(() => {
@ -846,6 +903,7 @@
},
onLoad() {
// console.error("首页加载");
these=this;
this.getTab()
this.downCallback();
@ -914,6 +972,9 @@
console.log("onUnload...");
uni.$off('deviceStatusUpdate');
ble && ble.removeAllCallback(pagePath);
if(mq){
mq.disconnect();
}
}
}
@ -1387,15 +1448,26 @@
}
.splitLine {
background: linear-gradient(90.00deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
opacity: 0.2;
width: 25rpx;
height: 4rpx;
margin: 0rpx 10rpx;
transform: rotate(90.00deg);
width: 4rpx;
height: 25rpx;
margin: 0rpx 20rpx;
}
.p10 {
padding-left: 20rpx;
}
.disc{
padding: 5rpx 10rpx;
margin-right: -30rpx;
}
.disc.active{
background-color: #2a2a2a !important;;
}
.discImg{
width:24rpx;
height: 24rpx;
margin-right: 10rpx;
}
</style>