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