From bffc0e7d582479bebb62a584c14c39f42c5735d1 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Tue, 1 Apr 2025 10:43:31 +0800 Subject: [PATCH] =?UTF-8?q?2025=E5=B9=B44=E6=9C=881=E6=97=A510:43:29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 ++ pages/searchDevice/searchDevice.js | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index f8754ba..36dbae1 100644 --- a/app.js +++ b/app.js @@ -36,6 +36,8 @@ App({ plugin.bus.subscribe("connectState", (res) => { console.log("app.js ===> connectState", res); + + wx.hideLoading(); }); plugin.bus.subscribe("devicesModel", (res) => { diff --git a/pages/searchDevice/searchDevice.js b/pages/searchDevice/searchDevice.js index 822736b..84250e7 100644 --- a/pages/searchDevice/searchDevice.js +++ b/pages/searchDevice/searchDevice.js @@ -5,7 +5,8 @@ Page({ getDeviceSetting: false, initText: "", - devicesList: [] + devicesList: [], + searchDevicesList: true, }, onLoad(options) { @@ -161,6 +162,7 @@ Page({ app.globalData.ppScale.plugin.Blue.start(deviceNames, false); app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => { console.log("searchDevice ===> devicesList", res); + this.setData({ devicesList: res }); @@ -169,12 +171,11 @@ Page({ }, selectDevice() { - setTimeout(() => { - if(this.data.devicesList && this.data.devicesList.length) { - this.setData({ - getDeviceSetting: false, - initText: "设备搜索完成" - }); + if(this.data.devicesList && this.data.devicesList.length && this.data.searchDevicesList) { + this.setData({ + searchDevicesList: false + }); + setTimeout(() => { app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery(); app.globalData.ppScale.device.list = this.data.devicesList; if(this.data.devicesList.length === 1) { @@ -200,9 +201,7 @@ Page({ } }) } - } else { - this.selectDevice(); - } - }, 3000); + }, 3000); + } } }) \ No newline at end of file