[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
+6 -34
View File
@@ -5,8 +5,8 @@ App({
globalData: {
// wx.request 请求的服务地址
wxRequestUrl: "https://device.shuziweidao.com/gateway/",
// wxRequestUrl: "http://192.168.1.207:8889/",
// wxRequestUrl: "https://device.shuziweidao.com/gateway/",
wxRequestUrl: "http://192.168.1.207:8889/",
// 秤的所有信息
ppScale: {
@@ -14,10 +14,10 @@ App({
plugin: null,
activeProtocol: null,
domain1: "http://device.shuziweidao.com:80/gateway", // 老版本 没有鉴权
domain2: "http://device.shuziweidao.com:80/weight", // 新版本 有鉴权
// domain1: "http://192.168.1.207:8889", // 老版本 没有鉴权
// domain2: "http://192.168.1.207:8889/weight", // 新版本 有鉴权
// domain1: "http://device.shuziweidao.com:80/gateway", // 老版本 没有鉴权
// domain2: "http://device.shuziweidao.com:80/weight", // 新版本 有鉴权
domain1: "http://192.168.1.207:8889", // 老版本 没有鉴权
domain2: "http://192.168.1.207:8889/weight", // 新版本 有鉴权
wifi: {
ssid: "",
password: ""
@@ -332,32 +332,4 @@ App({
}
}
},
/**
* 给回调式 SDK 调用包裹超时保护,防止设备无响应时 UI 永久卡死
* @param {Function} caller 接收 done 回调的执行函数,形如 (done) => sdk.method(params, done)
* @param {number} timeout 超时毫秒数
* @param {Function} onResult 正常回调,参数与 SDK 原始回调一致
* @param {Function} onTimeout 超时后执行,负责 hideLoading + 提示
*/
callWithTimeout(caller, timeout, onResult, onTimeout) {
let settled = false;
const timer = setTimeout(() => {
if (settled) return;
settled = true;
onTimeout();
}, timeout);
caller((res) => {
if (settled) return;
settled = true;
clearTimeout(timer);
onResult(res);
});
// 返回取消函数,供组件/页面在销毁时调用,静默取消超时
return () => {
if (settled) return;
settled = true;
clearTimeout(timer);
};
},
})