[AI Generated]: feat(*): 新增WiFi获取15秒超时静默重连、优化连接loading可控、修复setConfigSuccessful函数结构
This commit is contained in:
@@ -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 列表
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<view>正在获取WiFi列表中...</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view bind:tap="initWifi">获取WiFi失败,点击重试</view>
|
||||
<view bind:tap="reInitWifi">获取WiFi失败,点击重试</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
@@ -5,7 +5,7 @@ Component({
|
||||
|
||||
methods: {
|
||||
bindOk() {
|
||||
wx.switchTab({ url: '/pages/home/home' });
|
||||
this.triggerEvent('deviceEvent', { status: true });
|
||||
},
|
||||
|
||||
// 开始 OTA 升级
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<configureDevice1 bind:deviceEvent="deviceChange"></configureDevice1>
|
||||
</block>
|
||||
<block wx:if="{{progress.index === 1}}">
|
||||
<configureDevice2 bind:deviceEvent="setDeviceUserList" bind:connectedDeviceEvent="connectedDevice"></configureDevice2>
|
||||
<configureDevice2 bind:deviceEvent="setDeviceUserList" bind:connectedDeviceEvent="connectedDevice"></configureDevice2>
|
||||
</block>
|
||||
<block wx:if="{{progress.index === 2}}">
|
||||
<configureDevice3 id="configureDevice3" bind:deviceEvent="setDeviceConfig"></configureDevice3>
|
||||
|
||||
Reference in New Issue
Block a user