[AI Generated]: feat(Comp): 重写用户同步逻辑支持主子用户、移除callWithTimeout、新增用户上限10人及主用户删除保护
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
const app = getApp();
|
||||
|
||||
// 超时时间:15 秒
|
||||
const SDK_TIMEOUT = 15000;
|
||||
|
||||
Component({
|
||||
data: {
|
||||
progress: 0,
|
||||
@@ -27,25 +24,21 @@ Component({
|
||||
methods: {
|
||||
initWifi() {
|
||||
wx.showLoading({ title: "正在获取Wi-Fi列表...", mask: true });
|
||||
// activeProtocol 由父页面在 deviceConnect 回调中赋值,此处直接使用
|
||||
const activeProtocol = app.globalData.ppScale.activeProtocol;
|
||||
if (!activeProtocol) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: '设备未连接,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
this._sdkCancel = app.callWithTimeout(
|
||||
(done) => activeProtocol.dataFindSurroundDevice(done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ wifiList: Array.isArray(res) ? res : [] });
|
||||
},
|
||||
() => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "获取Wi-Fi列表超时,请重试", icon: "none" });
|
||||
activeProtocol.dataFindSurroundDevice((res) => {
|
||||
wx.hideLoading();
|
||||
if (!Array.isArray(res)) {
|
||||
// 获取失败,自动重试
|
||||
this.initWifi();
|
||||
return;
|
||||
}
|
||||
);
|
||||
this.setData({ wifiList: res });
|
||||
});
|
||||
},
|
||||
|
||||
// 最小化后重连,重置所有状态并重新获取 WiFi 列表
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<view>
|
||||
<image src="/images/configureDevice/null.png" />
|
||||
</view>
|
||||
<view>获取WIFI失败</view>
|
||||
<view>暂无WIFI数据,点击重新获取</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user