[AI Generated]: feat(Comp): 重写用户同步逻辑支持主子用户、移除callWithTimeout、新增用户上限10人及主用户删除保护
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
const app = getApp();
|
||||
import $ from "../../utils/request";
|
||||
|
||||
// 超时时间:15 秒
|
||||
const SDK_TIMEOUT = 15000;
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
ssid: {
|
||||
@@ -26,7 +23,6 @@ Component({
|
||||
this.setNerwork();
|
||||
},
|
||||
detached() {
|
||||
if (this._sdkCancel) { this._sdkCancel(); this._sdkCancel = null; }
|
||||
}
|
||||
},
|
||||
|
||||
@@ -37,46 +33,26 @@ Component({
|
||||
let password = this.properties.password;
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
this._sdkCancel = 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);
|
||||
}
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
this._sdkCancel = 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);
|
||||
}
|
||||
);
|
||||
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);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user