From f3d502b00ee6d7590391ea916a5be990833090af Mon Sep 17 00:00:00 2001 From: liub Date: Mon, 2 Feb 2026 10:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E6=9C=BA?= =?UTF-8?q?=E5=9E=8B=E8=93=9D=E7=89=99=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 2 +- manifest.json | 2 +- pages/common/addBLE/addEquip.vue | 64 ++++++++++++++++++++------------ 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/config/index.js b/config/index.js index 5459c4c..d239f4a 100644 --- a/config/index.js +++ b/config/index.js @@ -2,7 +2,7 @@ const config = { // 开发环境 development: { - BASE_URL: 'http://139.224.253.23:8000',//http://139.224.253.23:8000 + BASE_URL: 'http://192.168.110.172:8000',//http://139.224.253.23:8000 API_PREFIX: '', // MQTT 配置 MQTT_HOST: 'www.cnxhyc.com', diff --git a/manifest.json b/manifest.json index ffa9fe6..489e44b 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name" : "星汉物联", "appid" : "__UNI__A21EF43", "description" : "设备管控", - "versionName" : "1.0.13", + "versionName" : "1.0.14", "versionCode" : "100", "transformPx" : false, /* 5+App特有相关 */ diff --git a/pages/common/addBLE/addEquip.vue b/pages/common/addBLE/addEquip.vue index 102bec6..24adcab 100644 --- a/pages/common/addBLE/addEquip.vue +++ b/pages/common/addBLE/addEquip.vue @@ -184,22 +184,22 @@ }, onLoad(option) { eventChannel = this.getOpenerEventChannel(); - + eventChannel.on('detailData', function(rec) { console.log("接收到父页面的参数:", rec); these.device = rec.data; if (rec.data.bluetoothName) { these.search = rec.data.bluetoothName; - }else if(rec.data.deviceName){ + } else if (rec.data.deviceName) { these.search = rec.data.deviceName; } - + startValidDevice(); - + }); let search = option.search; these = this; - + const systemInfo = uni.getSystemInfoSync(); ble = bleTool.getBleTool(); // Ensure ble is initialized @@ -464,7 +464,7 @@ StartSubsrib(); - + }, @@ -533,21 +533,15 @@ return; } } - - - - ble.StopSearch().finally(() => { - - let disconnectPromises = []; - if (ble.data && ble.data.LinkedList) { - ble.data.LinkedList.forEach(device => { - console.log(`Requesting disconnect for ${device.deviceId}`); - disconnectPromises.push(ble.disconnectDevice(device.deviceId)); - }); + showLoading(these,{text:'正在刷新'}) + let time = null; + let startSearch = () => { + + if(time){ + clearTimeout(time); } - - Promise.allSettled(disconnectPromises).finally(() => { - + + time = setTimeout(() => { these.EquipMents = []; these.PairEquip = []; @@ -563,8 +557,31 @@ content: '开始搜索失败:' + err.msg }); } + }).finally(()=>{ + hideLoading(these); }); - }); + }, 500); + + } + + ble.StopSearch().finally(() => { + + let disconnectPromises = []; + if (ble.data && ble.data.LinkedList) { + ble.data.LinkedList.forEach(device => { + if (device.Linked) { + disconnectPromises.push(ble.disconnectDevice(device.deviceId)); + } + }); + } + + if (disconnectPromises.length > 0) { + Promise.allSettled(disconnectPromises).finally(() => { + startSearch(); + }); + } else { + startSearch(); + } }); @@ -678,12 +695,11 @@ console.log("客户端验证失败"); deviceInvalid(); return; - } - else if (f.macAddress == these.device.deviceMac){ + } else if (f.macAddress == these.device.deviceMac) { console.log("客户端验证成功"); deviceOK(); } - + return true; } else {