This commit is contained in:
fengerli
2025-11-08 10:33:20 +08:00
44 changed files with 6742 additions and 2545 deletions

View File

@ -6,21 +6,21 @@
</image>
</view>
<view class="deviceName">
蓝牙名:{{device.name}}
蓝牙名:{{serverDevice?serverDevice['bluetoothName']: device.name}}
</view>
<view class="deviceName">
状态:{{deviceStatu}}
</view>
<view class="deviceName">
设备名:{{device.deviceName}}
设备名:{{serverDevice?serverDevice['deviceName']:device.deviceName}}
</view>
<view class="deviceId">
设备Mac:{{device.macAddress}}
设备Mac:{{serverDevice?serverDevice['deviceMac']:device.macAddress}}
</view>
<view class="deviceId">
设备IMEI:{{device.imei}}
设备IMEI:{{serverDevice?serverDevice['deviceImei']:device.imei}}
</view>
<view class="bound" v-bind:class="boundStatu">
<view class="bound" :class="boundStatu">
{{Statu.boundRemark}}
</view>
</view>
@ -84,17 +84,18 @@
}
},
deviceStatu: function() {
if (!this.device.name) {
debugger;
if (!this.device.name && !this.device.macAddress) {
return "";
}
if (!this.device.linkStatu) {
if (!this.device.linkStatu && !this.device.macAddress) {
return "蓝牙未连接";
}
if (!this.device.macAddress) {
return '等待设备上报Mac地址';
}
if (!this.device.deviceName) {
if (!this.device.deviceName && !(this.serverDevice && this.serverDevice.deviceName)) {
if (this.Statu.isSearch) {
return "无效设备";
} else {
@ -105,7 +106,10 @@
}
}
} else {
return "找到有效设备"
return "找到有效设备"
}
return "";
@ -192,30 +196,39 @@
}
}, pagePath);
eventChannel = this.getOpenerEventChannel();
eventChannel.on('LinkItem', function(data) {
console.log("data=", data);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == data.deviceId;
});
if (f) {
let keys = Object.keys(f);
keys.forEach((v, index) => {
these.device[v] = f[v];
})
// console.log("LinkedList=", ble.data.LinkedList)
// console.log("f=", f);
// console.log("获取到设备", these.device);
if (f.macAddress) {
these.device.macAddress = f.macAddress;
these.initDevice();
if(option.mac){
this.device.macAddress=option.mac;
these.initDevice();
}
else{
eventChannel.on('LinkItem', function(data) {
console.log("data=", data);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == data.deviceId;
});
if (f) {
let keys = Object.keys(f);
keys.forEach((v, index) => {
these.device[v] = f[v];
})
// console.log("LinkedList=", ble.data.LinkedList)
// console.log("f=", f);
// console.log("获取到设备", these.device);
if (f.macAddress) {
these.device.macAddress = f.macAddress;
these.initDevice();
}
} else {
console.log("未获取到设备");
}
} else {
console.log("未获取到设备");
}
})
let inteval = setInterval(this.initDevice, 10000);
})
let inteval = setInterval(this.initDevice, 10000);
}
},
methods: {
reLinkdevice() {
@ -281,6 +294,7 @@
deviceInvalid();
}
} else {
this.serverDevice =null;
deviceInvalid();
}
@ -297,21 +311,21 @@
},
Link() {
// 调用绑定设备接口
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.device.deviceId;
});
if (!f) {
// let f = ble.data.LinkedList.find((v) => {
// return v.deviceId == these.device.deviceId;
// });
// if (!f) {
// these.Statu.bound = false;
// these.Statu.boundRemark = "蓝牙连接不成功";
// return;
// }
if (!this.device.macAddress) {
these.Statu.bound = false;
these.Statu.boundRemark = "蓝牙连接不成功";
these.Statu.boundRemark = "获取设备Mac地址异常";
return;
}
if (!f.macAddress) {
these.Statu.bound = false;
these.Statu.boundRemark = "设备上报Mac地址异常";
return;
}
if (!this.device.deviceName) {
if (!this.serverDevice) {
these.Statu.bound = false;
these.Statu.boundRemark = "设备未入库";
return;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -333,8 +333,8 @@
this.total = 0; // 重置总数
const deviceType = tab.id === '' ? undefined : tab.id;
this.$nextTick(() => {
this.getSystemInfoSyncH();
});
this.getSystemInfoSyncH();
});
this.getData(deviceType);
if (this.mescroll) {
this.mescroll.resetUpScroll();
@ -400,9 +400,54 @@
case 'scan':
uni.scanCode({
success: (res) => {
const cleanedResult = res.result.trim();
uni.navigateTo({
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
let cleanedResult = res.result.trim();
console.log("scanResult=", cleanedResult);
let promise = new Promise((resolve, reject) => {
let url = '';
try {
let json = JSON.parse(cleanedResult);
console.log("json=", json);
if ('blue' in json) {
let mac = json.blue;
if (mac) {
if (!mac.includes(':')) {
mac = mac.replace(/(.{2})/g,'$1:').slice(0,-1)
}
url =`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(mac)}`;
console.log("蓝牙设备",mac);
}
} else if ('imei' in json) {
let imei = json.imei;
if (iemi) {
url =
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(imei)}`;
console.log("4G设备:",imei)
}
}
} catch (error) {
console.error("识别二维码失败,",error);
} finally {
if(!url){
url =
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
console.log("未知设备:",cleanedResult)
}
resolve(url);
}
});
promise.then(res => {
uni.navigateTo({
url: res
});
});
},
fail: (err) => {
@ -456,9 +501,9 @@
if (this.$refs.swipeAction) {
this.$refs.swipeAction.closeAll();
}
console.log("111111",this.deviceId);
console.log("ble==null,",ble)
ble && ble.DropDevice(null,this.deviceId.id);
console.log("111111", this.deviceId);
console.log("ble==null,", ble)
ble && ble.DropDevice(null, this.deviceId.id);
} else {
uni.showToast({
title: res.msg,
@ -541,10 +586,10 @@
// 列表跳转
handleFile(item) {
let url = item.detailPageUrl;
// url="/pages/6331/BJQ6331";
uni.navigateTo({
url: url,
success: (res) => {