[AI Generated]: feat(Comp): 优化WiFi获取状态展示、下发失败自动重试、同步前清除设备用户数据
This commit is contained in:
@@ -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: ""
|
||||
|
||||
Reference in New Issue
Block a user