[AI Generated]: feat(*): 新增配网状态检测与SDK超时保护,优化配置流程稳定性
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
// 超时时间:15 秒
|
||||
const SDK_TIMEOUT = 15000;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
ssid: {
|
||||
@@ -34,28 +37,46 @@ Component({
|
||||
let password = this.properties.password;
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: ssid,
|
||||
password: password
|
||||
}, (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: ssid,
|
||||
password: password
|
||||
}, done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
this.netWorkCallBack(res);
|
||||
},
|
||||
() => {
|
||||
wx.showToast({ title: "配网超时,请重试", icon: "none" });
|
||||
setTimeout(() => {
|
||||
this.triggerEvent('wifiEvent', { status: false });
|
||||
}, 1500);
|
||||
}
|
||||
);
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: ssid,
|
||||
password: password,
|
||||
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: ssid,
|
||||
password: password,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6"
|
||||
}, done),
|
||||
SDK_TIMEOUT,
|
||||
(res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
this.netWorkCallBack(res);
|
||||
},
|
||||
() => {
|
||||
wx.showToast({ title: "配网超时,请重试", icon: "none" });
|
||||
setTimeout(() => {
|
||||
this.triggerEvent('wifiEvent', { status: false });
|
||||
}, 1500);
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user