102真机测试完成

This commit is contained in:
liub
2025-12-01 16:24:22 +08:00
parent 052a7116c5
commit 6a2688caf4
6 changed files with 253 additions and 80 deletions

View File

@ -52,8 +52,9 @@
<view @click="refreshBleList()">刷新</view>
</view>
<view class="lblTitle">
<uni-easyinput :styles="{color:'#ffffff'}" :clearable="true" class="uni-mt-5" :trim="'both'"
prefixIcon="search" v-model="search" placeholder="名称筛选"></uni-easyinput>
<input class="uni-input" v-model="search" placeholder="名称筛选" />
<!-- <uni-easyinput :styles="{color:'#ffffffde',borderColor:'#cbcbcba8'}" :clearable="true" class="uni-mt-5" :trim="'both'"
prefixIcon="search" v-model="search" placeholder="名称筛选"></uni-easyinput> -->
</view>
<view class="list searchList">
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
@ -152,7 +153,7 @@
}
},
search:'',//筛选
search: '', //筛选
PairEquip: [], //已配对设备
EquipMents: [], //搜索出来的设备
device: null,
@ -181,9 +182,9 @@
these = this;
eventChannel = this.getOpenerEventChannel();
const systemInfo = uni.getSystemInfoSync();
ble = bleTool.getBleTool(); // Ensure ble is initialized
if (systemInfo.uniPlatform == 'web') {
@ -208,6 +209,67 @@
"linkStatu": false,
"isTarget": true
},
{
"RSSI": -69,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
"name": "4877-BF743D",
"linkStatu": false
},
{
"RSSI": -55,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
"name": "HBY670-BF74EA",
"linkStatu": false
},
{
"RSSI": -61,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
"name": "EF4651",
"linkStatu": false,
"isTarget": true
},
{
"RSSI": -69,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
"name": "4877-BF743D",
"linkStatu": false
},{
"RSSI": -55,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
"name": "HBY670-BF74EA",
"linkStatu": false
},
{
"RSSI": -61,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
"name": "EF4651",
"linkStatu": false,
"isTarget": true
},
{
"RSSI": -69,
"advertisData": "",
@ -222,6 +284,7 @@
these.PairEquip = [this.EquipMents[0]];
this.$forceUpdate();
return;
}
let StartSubsrib = () => {
@ -262,7 +325,7 @@
}, pagePath);
//搜索到新设备的回调 (Always active)
ble.addDeviceFound((arr) => {
@ -283,7 +346,9 @@
let f = these.EquipMents.find((v, index) => {
if (v.deviceId == device.deviceId) {
console.log(`更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`);
console.log(
`更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
);
these.$set(these.EquipMents[index], 'RSSI', device.RSSI);
return true;
}
@ -294,9 +359,11 @@
console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
if (these.device && these.device.bluetoothName && device.name) {
if (these.device.bluetoothName === device.name || (device.name && device.name.indexOf(these
.device.bluetoothName) > -1) || (device.name && this.device.bluetoothName.indexOf(
device.name) > -1)) {
if (these.device.bluetoothName === device.name || (device.name && device.name
.indexOf(these
.device.bluetoothName) > -1) || (device.name && this.device
.bluetoothName.indexOf(
device.name) > -1)) {
device.isTarget = true;
}
}
@ -308,8 +375,8 @@
}
}, pagePath);
}
let startValidDevice=()=>{
let startValidDevice = () => {
if (these.device) {
console.log("进入配对模式,启用连接恢复和验证逻辑。");
//蓝牙连接已恢复的回调
@ -330,17 +397,17 @@
showLoading(these, {
text: '蓝牙连接已恢复,正在验证设备'
});
setTimeout(() => {
these.DeviceVerdict(res.deviceId);
}, 0);
} else {
hideLoading(these);
}
}, pagePath);
//收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => {
console.log("000000");
@ -353,17 +420,17 @@
clearInterval(this.Status.intval);
this.Status.intval = null;
this.Status.time = null;
showLoading(these, {
text: '正在验证设备'
});
setTimeout(() => {
these.DeviceVerdict(f.deviceId);
}, 0);
}
}, pagePath);
}
}
@ -373,10 +440,10 @@
eventChannel.on('detailData', function(rec) {
console.log("接收到父页面的参数:", rec);
these.device = rec.data;
if(rec.data.bluetoothName){
these.search=rec.data.bluetoothName.replace('JQZM-','');
if (rec.data.bluetoothName) {
these.search = rec.data.bluetoothName.replace('JQZM-', '');
}
startValidDevice();
these.refreshBleList();
});
@ -392,9 +459,9 @@
return new Promise((resolve) => {
if (uni.getSystemInfoSync().platform !== 'android') {
return resolve(true);
return resolve(true);
}
plus.android.requestPermissions(
['android.permission.ACCESS_FINE_LOCATION'],
(result) => {
@ -428,14 +495,17 @@
});
},
async refreshBleList() {
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform == 'web') {
return;
}
const hasPermission = await this.checkAndRequestLocationPermission();
if (!hasPermission) {
console.log("缺少定位权限,已中止蓝牙扫描。");
return;
}
if (!ble) {
ble = bleTool.getBleTool();
if (!ble) {
@ -443,9 +513,9 @@
return;
}
}
ble.StopSearch().finally(() => {
let disconnectPromises = [];
if (ble.data && ble.data.LinkedList) {
ble.data.LinkedList.forEach(device => {
@ -453,17 +523,17 @@
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
});
}
Promise.allSettled(disconnectPromises).finally(() => {
these.EquipMents = [];
these.PairEquip = [];
ble.StartSearch().then(result => {
console.log("Fresh scan started successfully.");
}).catch(err => {
console.error("Failed to start fresh scan:", err);
if (err.code === 10001) {
if (err.code === 10001) {
these.showOpenSetting();
} else {
uni.showModal({
@ -820,6 +890,7 @@
position: absolute;
top: 240rpx;
left: 0rpx;
/* border: 1px solid #BBE600; */
}
@ -840,18 +911,20 @@
align-content: center;
align-items: center;
justify-content: space-between;
margin-bottom:30rpx;
margin-bottom: 30rpx;
}
.list {
min-height: 120rpx;
}
.searchList {
width: 100%;
height: calc(100% - 260rpx);
height: calc(100% - 300rpx);
overflow-y: scroll;
box-sizing: border-box;
/* border: 1px solid red; */
}
.list .item {
@ -1021,12 +1094,21 @@
filter: none !important;
-webkit-filter: none !important;
}
.uni-mt-5 {
background-color: #000000;
}
.uni-easyinput__content {
background-color: #121212 !important;
.uni-input{
background-color: #121212;
width:100%;
height: 60rpx;
color: #ffffffde;
border:1rpx solid #cbcbcbde;
border-radius: 8rpx;
font-size: 26rpx;
text-indent: 8rpx;
font-family: "PingFang SC";
line-height: 60rpx;
caret-color:#BBE600;
font-weight: 200;
}
</style>