diff --git a/components/configureDevice_3/configureDevice_3.js b/components/configureDevice_3/configureDevice_3.js index 9b27031..28b96cd 100644 --- a/components/configureDevice_3/configureDevice_3.js +++ b/components/configureDevice_3/configureDevice_3.js @@ -25,19 +25,30 @@ Component({ methods: { initWifi() { this.setData({ wifiStatus: 'loading' }); + wx.showLoading({ title: "正在获取Wi-Fi列表...", mask: true }); const activeProtocol = app.globalData.ppScale.activeProtocol; if (!activeProtocol) { + wx.hideLoading(); this.setData({ wifiStatus: 'failed' }); return; } - activeProtocol.dataFindSurroundDevice((res) => { - if (!Array.isArray(res)) { - // 获取失败,显示失败状态,等待用户手动点击重试 - this.setData({ wifiStatus: 'failed' }); - return; - } - this.setData({ wifiList: res, wifiStatus: 'success' }); - }); + // 15秒超时:断开设备静默重连 + const timer = setTimeout(() => { + wx.hideLoading(); + this.setData({ wifiStatus: 'failed' }); + }, 15000); + // 延时两秒后再调用接口 + setTimeout(() => { + activeProtocol.dataFindSurroundDevice((res) => { + clearTimeout(timer); + wx.hideLoading(); + if (!Array.isArray(res)) { + this.setData({ wifiStatus: 'failed' }); + return; + } + this.setData({ wifiList: res, wifiStatus: 'success' }); + }); + }, 2000); }, // 最小化后重连,重置所有状态并重新获取 WiFi 列表 diff --git a/components/configureDevice_3/configureDevice_3.wxml b/components/configureDevice_3/configureDevice_3.wxml index 1438066..592cf00 100644 --- a/components/configureDevice_3/configureDevice_3.wxml +++ b/components/configureDevice_3/configureDevice_3.wxml @@ -30,7 +30,7 @@ 正在获取WiFi列表中... - 获取WiFi失败,点击重试 + 获取WiFi失败,点击重试 diff --git a/components/configureDevice_4/configureDevice_4.js b/components/configureDevice_4/configureDevice_4.js index d8f3953..117f824 100644 --- a/components/configureDevice_4/configureDevice_4.js +++ b/components/configureDevice_4/configureDevice_4.js @@ -5,7 +5,7 @@ Component({ methods: { bindOk() { - wx.switchTab({ url: '/pages/home/home' }); + this.triggerEvent('deviceEvent', { status: true }); }, // 开始 OTA 升级 diff --git a/pages/configureDevice/configureDevice.js b/pages/configureDevice/configureDevice.js index d4495c8..f1584f1 100644 --- a/pages/configureDevice/configureDevice.js +++ b/pages/configureDevice/configureDevice.js @@ -108,13 +108,8 @@ Page({ connectedDevice(e) { app.resetReconnectCount(); - wx.showLoading({ - title: "正在尝试连接...", - mask: true - }); - this.setData({ - progressNext: false - }) + wx.showLoading({ title: "正在尝试连接...", mask: true }); + this.setData({ progressNext: false }); let device = e.detail.device; // 先断开旧连接再重新连接 ppScale.plugin.Blue.disconnect((disres) => { @@ -170,14 +165,14 @@ Page({ setTimeout(() => { const comp = this.selectComponent('#configureDevice3'); if (comp) comp.initWifi(); - }, 1000); + }, 300); } // 进入步骤3(OTA升级)时,等待组件渲染完成后由父页面显式触发升级 if (newIndex === 3) { setTimeout(() => { const comp = this.selectComponent('#configureDevice4'); if (comp) comp.startOtaUpgrade(); - }, 1000); + }, 300); } }, diff --git a/pages/configureDevice/configureDevice.wxml b/pages/configureDevice/configureDevice.wxml index cfcbef6..06c05bb 100644 --- a/pages/configureDevice/configureDevice.wxml +++ b/pages/configureDevice/configureDevice.wxml @@ -15,7 +15,7 @@ - +