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