[AI Generated]: feat(Comp): 优化WiFi获取状态展示、下发失败自动重试、同步前清除设备用户数据
This commit is contained in:
@@ -250,8 +250,11 @@ Component({
|
||||
syncIndex++;
|
||||
syncNext();
|
||||
} else {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "用户信息下发失败,请重试。", icon: "none" });
|
||||
// wx.hideLoading();
|
||||
// wx.showToast({ title: "用户信息下发失败,请重试。", icon: "none" });
|
||||
|
||||
// 失败自动重试当前用户
|
||||
syncNext();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<view class="configureDevice2">
|
||||
<view class="header">
|
||||
<view>
|
||||
<view>智能蓝牙秤</view>
|
||||
<view bind:longpress="fetchUserList">智能蓝牙秤</view>
|
||||
<view bind:longpress="onDeviceLongPress">型号:{{device.name}}</view>
|
||||
</view>
|
||||
<view>
|
||||
|
||||
@@ -3,7 +3,8 @@ const app = getApp();
|
||||
Component({
|
||||
data: {
|
||||
progress: 0,
|
||||
|
||||
// loading=正在获取,failed=获取失败,success=获取成功
|
||||
wifiStatus: 'loading',
|
||||
wifiList: [],
|
||||
|
||||
selectWifi: null,
|
||||
@@ -23,21 +24,19 @@ Component({
|
||||
// 组件的方法
|
||||
methods: {
|
||||
initWifi() {
|
||||
wx.showLoading({ title: "正在获取Wi-Fi列表...", mask: true });
|
||||
this.setData({ wifiStatus: 'loading' });
|
||||
const activeProtocol = app.globalData.ppScale.activeProtocol;
|
||||
if (!activeProtocol) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '设备未连接,请重试', icon: 'none' });
|
||||
this.setData({ wifiStatus: 'failed' });
|
||||
return;
|
||||
}
|
||||
activeProtocol.dataFindSurroundDevice((res) => {
|
||||
wx.hideLoading();
|
||||
if (!Array.isArray(res)) {
|
||||
// 获取失败,自动重试
|
||||
this.initWifi();
|
||||
// 获取失败,显示失败状态,等待用户手动点击重试
|
||||
this.setData({ wifiStatus: 'failed' });
|
||||
return;
|
||||
}
|
||||
this.setData({ wifiList: res });
|
||||
this.setData({ wifiList: res, wifiStatus: 'success' });
|
||||
});
|
||||
},
|
||||
|
||||
@@ -45,6 +44,7 @@ Component({
|
||||
reInitWifi() {
|
||||
this.setData({
|
||||
progress: 0,
|
||||
wifiStatus: 'loading',
|
||||
wifiList: [],
|
||||
selectWifi: null,
|
||||
selectWifiPWD: ""
|
||||
|
||||
@@ -22,11 +22,16 @@
|
||||
</scroll-view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="nullData" bind:tap="initWifi">
|
||||
<view class="nullData">
|
||||
<view>
|
||||
<image src="/images/configureDevice/null.png" />
|
||||
</view>
|
||||
<view>暂无WIFI数据,点击重新获取</view>
|
||||
<block wx:if="{{wifiStatus === 'loading'}}">
|
||||
<view>正在获取WiFi列表中...</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view bind:tap="initWifi">获取WiFi失败,点击重试</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -170,14 +170,14 @@ Page({
|
||||
setTimeout(() => {
|
||||
const comp = this.selectComponent('#configureDevice3');
|
||||
if (comp) comp.initWifi();
|
||||
}, 100);
|
||||
}, 1000);
|
||||
}
|
||||
// 进入步骤3(OTA升级)时,等待组件渲染完成后由父页面显式触发升级
|
||||
if (newIndex === 3) {
|
||||
setTimeout(() => {
|
||||
const comp = this.selectComponent('#configureDevice4');
|
||||
if (comp) comp.startOtaUpgrade();
|
||||
}, 100);
|
||||
}, 1000);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user