[AI Generated]: fix(*): 修复蓝牙连接全链路问题,包含 bus 重复订阅、activeProtocol 空指针、stop 竞速、重连计数器跨页面共享、OTA 超时保护、硬超时改事件驱动、保活定时器泄漏及回调错误处理
This commit is contained in:
@@ -95,7 +95,10 @@ Component({
|
||||
|
||||
addUser() {
|
||||
if (this.data.userList.length >= 10) {
|
||||
wx.showToast({ title: "超过最大用户数", icon: "none" });
|
||||
wx.showToast({
|
||||
title: "超过最大用户数",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.selectComponent("#configureDevice2AddUser").showModal();
|
||||
@@ -178,19 +181,27 @@ Component({
|
||||
wx.showLoading({ title: "正在同步用户信息...", mask: true });
|
||||
app.globalData.ppScale.activeProtocol.dataFetchUserID((deviceUserIds) => {
|
||||
console.log("设备端已有用户ID列表", deviceUserIds);
|
||||
let rawList = Array.isArray(deviceUserIds) ? deviceUserIds : [];
|
||||
|
||||
// 回调返回非数组视为获取失败
|
||||
if (!Array.isArray(deviceUserIds)) {
|
||||
wx.hideLoading();
|
||||
wx.showToast({ title: "获取设备用户列表失败,请重试", icon: "none" });
|
||||
return;
|
||||
}
|
||||
|
||||
let rawList = deviceUserIds;
|
||||
// 兼容对象数组和纯ID数组,统一转为字符串比对
|
||||
let deviceIds = rawList.map(item => ({
|
||||
id: item,
|
||||
memberID: ""
|
||||
}));
|
||||
let localIds = userList.map(user => user.id);
|
||||
let localIds = userList.map(user => user.userId);
|
||||
|
||||
// 秤有、列表没有 → 需要从秤删除
|
||||
let needDeleteList = deviceIds.filter(d => !localIds.includes(d.id));
|
||||
let needDeleteList = deviceIds.filter(d => !localIds.includes(d.userId));
|
||||
|
||||
// 秤没有、列表有 → 需要下发到秤
|
||||
let needSyncList = userList.filter(user => !deviceIds.some(d => d.userID == user.id));
|
||||
let needSyncList = userList.filter(user => !deviceIds.some(d => d.userID == user.userId));
|
||||
|
||||
console.log("需删除", needDeleteList, "需下发", needSyncList);
|
||||
|
||||
@@ -218,7 +229,7 @@ Component({
|
||||
wx.showLoading({ title: "正在下发第" + (syncIndex + 1) + "/" + needSyncList.length + "个用户...", mask: true });
|
||||
let user = needSyncList[syncIndex];
|
||||
app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
|
||||
userID: user.id,
|
||||
userID: user.userId,
|
||||
userName: user.realname,
|
||||
memberID: "",
|
||||
age: user.age || '',
|
||||
@@ -257,7 +268,7 @@ Component({
|
||||
wx.showLoading({ title: "正在删除第" + (delIndex + 1) + "/" + needDeleteList.length + "个多余用户...", mask: true });
|
||||
let item = needDeleteList[delIndex];
|
||||
app.globalData.ppScale.activeProtocol.dataDeleteUser({
|
||||
userID: item.id,
|
||||
userID: item.userId,
|
||||
memberID: ""
|
||||
}, (status) => {
|
||||
if (status == 0) {
|
||||
|
||||
Reference in New Issue
Block a user