[AI Generated]: feat(*): 新增配网状态检测与SDK超时保护,优化配置流程稳定性
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
// 超时时间:15 秒
|
||||
const SDK_TIMEOUT = 15000;
|
||||
|
||||
Component({
|
||||
data: {
|
||||
@@ -32,10 +34,18 @@ Component({
|
||||
wx.showToast({ title: '设备未连接,请重试', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
activeProtocol.dataFindSurroundDevice((res) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ wifiList: Array.isArray(res) ? res : [] });
|
||||
});
|
||||
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" });
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
// 最小化后重连,重置所有状态并重新获取 WiFi 列表
|
||||
@@ -69,34 +79,46 @@ Component({
|
||||
},
|
||||
|
||||
setWifiPWD() {
|
||||
this.setData({
|
||||
progress: 2
|
||||
})
|
||||
this.setData({ progress: 2 });
|
||||
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
|
||||
this.netWorkCallBack(res);
|
||||
})
|
||||
app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD
|
||||
}, done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
this.netWorkCallBack(res);
|
||||
},
|
||||
() => {
|
||||
this.setData({ progress: 1 });
|
||||
wx.showToast({ title: "配网超时,请重试", icon: "none" });
|
||||
}
|
||||
);
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6",
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
|
||||
this.netWorkCallBack(res);
|
||||
})
|
||||
app.callWithTimeout(
|
||||
(done) => app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6",
|
||||
}, done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
this.netWorkCallBack(res);
|
||||
},
|
||||
() => {
|
||||
this.setData({ progress: 1 });
|
||||
wx.showToast({ title: "配网超时,请重试", icon: "none" });
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user