1
0
forked from dyf/APP

加入6107设备页面、蓝牙配对模式修复首次进入找不到设备的问题

This commit is contained in:
liub
2026-01-12 16:18:27 +08:00
parent 78adc0bfed
commit 98162ca214
11 changed files with 1804 additions and 73 deletions

View File

@ -2,7 +2,7 @@
const config = { const config = {
// 开发环境 // 开发环境
development: { development: {
BASE_URL: 'http://139.224.253.23:8000', BASE_URL: 'http://192.168.110.57:8000',//http://139.224.253.23:8000
API_PREFIX: '', API_PREFIX: '',
// MQTT 配置 // MQTT 配置
MQTT_HOST: 'www.cnxhyc.com', MQTT_HOST: 'www.cnxhyc.com',

View File

@ -362,6 +362,13 @@
{ {
"navigationBarTitleText" : "HBY018A" "navigationBarTitleText" : "HBY018A"
} }
},
{
"path" : "pages/6107/BJQ6107",
"style" :
{
"navigationBarTitleText" : "BJQ6107"
}
} }

1622
pages/6107/BJQ6107.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -343,6 +343,7 @@
these.showBleUnConnect(); these.showBleUnConnect();
console.error("111111");
these.getDetail(); these.getDetail();
return; return;
} }
@ -363,6 +364,7 @@
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
these.setBleFormData(); these.setBleFormData();
console.error("222222");
these.getDetail(); these.getDetail();
@ -574,7 +576,7 @@
getDetail() { getDetail() {
var that = this; var that = this;
usrApi.getDetail(this.device.id).then(res => { usrApi.getDetail(this.device.id).then(res => {
console.log("res=", res); console.log("获取人员信息=", res);
if (res && res.code == 200) { if (res && res.code == 200) {
res = res.data; res = res.data;
let personnelInfo = res.personnelInfo; let personnelInfo = res.personnelInfo;
@ -583,8 +585,24 @@
that.formData.name = personnelInfo.name; that.formData.name = personnelInfo.name;
that.formData.job = personnelInfo.position; that.formData.job = personnelInfo.position;
that.formData.id = personnelInfo.code that.formData.id = personnelInfo.code
return;
} }
} }
let phone = uni.getStorageSync('phone');
if (phone === '17671332251') {
console.log("default=",that.device);
that.formData.company = '湖北消防总队';
that.formData.name = '胡红军';
that.formData.job = '中队长';
let arr=that.device.bluetoothName.split('-');
if(arr.length>1){
that.formData.id =arr[arr.length-1];
}else{
that.formData.id =that.device.bluetoothName;
}
}
}); });
}, },
@ -602,7 +620,7 @@
}, },
MainModeSetting: function(type, byteType) { MainModeSetting: function(type, byteType) {
if (this.formData.modeCurr == type) { if (this.formData.modeCurr == type) {
type='close'; type = 'close';
} }
showLoading(this, { showLoading(this, {
text: "请稍候..." text: "请稍候..."
@ -1094,9 +1112,9 @@
hideLoading(these); hideLoading(these);
return; return;
} }
console.log("baseURL=",baseURL); console.log("baseURL=", baseURL);
console.log("token",token); console.log("token", token);
console.log("clientID",clientid); console.log("clientID", clientid);
uni.uploadFile({ uni.uploadFile({
// url: 'http://114.55.111.217/video/upload', // url: 'http://114.55.111.217/video/upload',
url: baseURL + "/app/video/upload", url: baseURL + "/app/video/upload",

View File

@ -46,7 +46,7 @@
var these = null; var these = null;
var eventChannel = null; var eventChannel = null;
var ble = null; var ble = null;
var inteval=null;
export default { export default {
data() { data() {
return { return {
@ -118,7 +118,7 @@
onUnload() { onUnload() {
console.log("返回取消订阅"); console.log("返回取消订阅");
clearInterval(inteval);
ble.removeAllCallback(pagePath); ble.removeAllCallback(pagePath);
}, },
onLoad(option) { onLoad(option) {
@ -226,7 +226,7 @@
} }
}) })
let inteval = setInterval(this.initDevice, 10000); inteval = setInterval(this.initDevice, 10000);
} }
@ -291,6 +291,7 @@
} }
} }
}); });
clearInterval(inteval);
} else { } else {
deviceInvalid(); deviceInvalid();
} }

View File

@ -120,6 +120,7 @@
var ble = null; var ble = null;
var these = null; var these = null;
var eventChannel = null; var eventChannel = null;
var searchTime=null;
export default { export default {
data() { data() {
return { return {
@ -334,7 +335,7 @@
//搜索到新设备的回调 (Always active) //搜索到新设备的回调 (Always active)
ble.addDeviceFound((arr) => { ble.addDeviceFound((arr) => {
console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr)); // console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
if (these.Status.isPageHidden) { if (these.Status.isPageHidden) {
return; return;
} }
@ -343,7 +344,7 @@
} }
arr = arr.devices; arr = arr.devices;
console.log(`本次扫描批次发现 ${arr.length} 个设备`); // console.log(`本次扫描批次发现 ${arr.length} 个设备`);
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
let device = arr[i]; let device = arr[i];
@ -351,9 +352,9 @@
let f = these.EquipMents.find((v, index) => { let f = these.EquipMents.find((v, index) => {
if (v.deviceId == device.deviceId) { if (v.deviceId == device.deviceId) {
console.log( // console.log(
`更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}` // `更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
); // );
these.$set(these.EquipMents[index], 'RSSI', device.RSSI); these.$set(these.EquipMents[index], 'RSSI', device.RSSI);
return true; return true;
} }
@ -361,7 +362,7 @@
}); });
if (!f) { if (!f) {
console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device)); // console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
if (these.device && these.device.bluetoothName && device.name) { if (these.device && these.device.bluetoothName && device.name) {
if (these.device.bluetoothName === device.name || (device.name && device.name if (these.device.bluetoothName === device.name || (device.name && device.name
@ -417,10 +418,13 @@
//收到设备的消息回调 //收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => { ble.addReceiveCallback((receivData, f, path, arr) => {
console.log("000000"); console.log("000000",receivData);
if (these.Status.isPageHidden) { if (these.Status.isPageHidden) {
return; return;
} }
if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1
|| (receivData.hexs[0]===0xFC && receivData.hexs.length>=7))
{
console.log("1111111"); console.log("1111111");
if (f.macAddress && these.device) { if (f.macAddress && these.device) {
console.log("222222"); console.log("222222");
@ -436,8 +440,7 @@
these.DeviceVerdict(f.deviceId); these.DeviceVerdict(f.deviceId);
}, 0); }, 0);
} }
}
}, pagePath); }, pagePath);
} }
} }
@ -452,7 +455,7 @@
} }
startValidDevice(); startValidDevice();
these.refreshBleList();
}); });
}, },
@ -502,6 +505,8 @@
}); });
}, },
async refreshBleList() { async refreshBleList() {
const systemInfo = uni.getSystemInfoSync(); const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform == 'web') { if (systemInfo.uniPlatform == 'web') {
return; return;
@ -520,6 +525,8 @@
return; return;
} }
} }
clearTimeout(searchTime);
searchTime=setTimeout(()=>{
ble.StopSearch().finally(() => { ble.StopSearch().finally(() => {
@ -551,6 +558,9 @@
}); });
}); });
}); });
},800);
}, },
isItemLink: function(item, index) { isItemLink: function(item, index) {
let src = '/static/images/BLEAdd/noLink.png'; let src = '/static/images/BLEAdd/noLink.png';
@ -599,8 +609,6 @@
if (index > -1) { if (index > -1) {
this.PairEquip.splice(index, 1); this.PairEquip.splice(index, 1);
} }
} }
console.log("f=", f); console.log("f=", f);

View File

@ -4,7 +4,7 @@
<view class="vehicle-list" v-if="vehicles.length>0"> <view class="vehicle-list" v-if="vehicles.length>0">
<view v-for="(item, index) in vehicles" :key="index"> <view v-for="(item, index) in vehicles" :key="index">
<view class="vehicle-item" @click="alltypeInfo(item)"> <view class="vehicle-item" @click="alltypeInfo(item)">
<image src="/static/images/common/bip.6.png" mode="" class="IMG"></image> <image :src="item.img" mode="aspectFit" class="IMG"></image>
</view> </view>
<view class="plate-number">{{ item.typeName }}</view> <view class="plate-number">{{ item.typeName }}</view>
</view> </view>
@ -25,13 +25,88 @@
data() { data() {
return { return {
vehicles: [], vehicles: [],
typeImgs: [{
"Name": "HBY018A",
"sigName": "018A",
"url": "/static/images/common/018A.png"
},
{
"Name": "HBY102",
"sigName": "102",
"url": "/static/images/common/HBY102.png"
},
{
"Name": "BJQ6075",
"sigName": "6075",
"url": "/static/images/common/BJQ6075.png"
},
{
"Name": "HBY100",
"sigName": "100",
"url": "/static/images/common/HBY100J.png"
},
{
"Name": "BJQ4877",
"sigName": "4877",
"url": "/static/images/common/BJQ4877.png"
},
{
"Name": "BJQ7307",
"sigName": "7307",
"url": "/static/images/common/7307.png"
},
{
"Name": "BJQ7305",
"sigName": "7305",
"url": "/static/images/common/7305.png"
},
{
"Name": "HBY650",
"sigName": "650",
"url": "/static/images/common/HBY650.png"
},
{
"Name": "BJQ6155",
"sigName": "6155",
"url": "/static/images/common/HBY6155.png"
},
{
"Name": "HBY670",
"sigName": "670",
"url": "/static/images/common/HBY670.png"
},
{
"Name": "HBY210",
"sigName": "210",
"url": "/static/images/common/210.png"
},
{
"Name": "BJQ6170",
"sigName": "6170",
"url": "/static/images/common/bip.6.png"
}
]
} }
}, },
methods: { methods: {
getTab() { getTab() {
deviceTypeList({}).then((res) => { deviceTypeList({}).then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.vehicles = res.data for (var i = 0; i < res.data.length; i++) {
var item = res.data[i];
item.img="/static/images/common/bip.6.png";
let f=this.typeImgs.find(v=>{
if(item.typeName.toLowerCase()===v.Name.toLowerCase()){
return true;
}
return false;
});
if(f){
item.img=f.url;
}
}
this.vehicles = res.data;
} }
}) })
}, },

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB