[AI Generated]: feat(Comp): 重写用户同步逻辑支持主子用户、移除callWithTimeout、新增用户上限10人及主用户删除保护

This commit is contained in:
17792275749
2026-04-13 13:21:59 +08:00
parent 4e2e8fb899
commit 4fc829a81f
9 changed files with 118 additions and 264 deletions
@@ -4,6 +4,10 @@ Component({
data: {},
methods: {
bindOk() {
wx.switchTab({ url: '/pages/home/home' });
},
// 开始 OTA 升级
startOtaUpgrade() {
const activeProtocol = app.globalData.ppScale.activeProtocol;
@@ -13,42 +17,10 @@ Component({
return;
}
wx.showLoading({ title: '正在升级固件,请稍候...', mask: true });
// 重置完成标志位,防止回调重复触发
this._otaCompleted = false;
// status: false = 成功,true = 失败
activeProtocol.codeOtaUpdate((status) => {
// 延迟 3 秒,让 Loading 多转一会再收口
setTimeout(() => {
if (status == 0) {
// status false → 升级成功
this._finish(true);
} else {
// status true → 升级失败
this._finish(false, '固件升级失败');
}
}, 3000);
console.log(status);
});
},
// 统一收口:成功/失败提示后跳转首页
_finish(success, failMsg) {
if (this._otaCompleted) return;
this._otaCompleted = true;
wx.hideLoading();
if (success) {
wx.showToast({ title: '固件升级成功', icon: 'success', duration: 2000 });
} else {
wx.showToast({ title: failMsg || '固件升级失败', icon: 'none', duration: 2000 });
}
setTimeout(() => {
app.cleanupConnection();
wx.switchTab({ url: '/pages/home/home' });
}, 2000);
}
}
});