From b157ef5d579b67aa1c74ed1c6f43ea66513a1d1b Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Wed, 11 Mar 2026 15:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configureDevice_2/configureDevice_2.js | 18 +++++++++--------- .../configureDevice_2_addUser.js | 5 ++++- .../configureDevice_3/configureDevice_3.js | 16 ++++++++++------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/components/configureDevice_2/configureDevice_2.js b/components/configureDevice_2/configureDevice_2.js index fda31a7..9c5e5a7 100644 --- a/components/configureDevice_2/configureDevice_2.js +++ b/components/configureDevice_2/configureDevice_2.js @@ -181,16 +181,16 @@ Component({ let rawList = Array.isArray(deviceUserIds) ? deviceUserIds : []; // 兼容对象数组和纯ID数组,统一转为字符串比对 let deviceIds = rawList.map(item => ({ - userID: String(item.userID || item), - memberID: String(item.memberID || "") + userID: item.userID, + memberID: item.memberID })); - let localIds = userList.map(user => String(user.id)); + let localIds = userList.map(user => user.id); // 秤有、列表没有 → 需要从秤删除 let needDeleteList = deviceIds.filter(d => !localIds.includes(d.userID)); // 秤没有、列表有 → 需要下发到秤 - let needSyncList = userList.filter(user => !deviceIds.some(d => d.userID === String(user.id))); + let needSyncList = userList.filter(user => !deviceIds.some(d => d.userID == user.id)); console.log("需删除", needDeleteList, "需下发", needSyncList); @@ -221,12 +221,12 @@ Component({ userID: user.id, userName: user.realname, memberID: "", - age: user.age, - gender: user.sex, - height: user.height, + age: user.age || '', + gender: user.sex === 2 ? 0 : user.sex, + height: String(user.height || ''), isAthleteMode: 0, deviceHeaderIndex: syncIndex, - currentWeight: String(user.weight), + currentWeight: String(user.weight || ''), targetWeight: "", idealWeight: "", recentData: [], @@ -258,7 +258,7 @@ Component({ let item = needDeleteList[delIndex]; app.globalData.ppScale.activeProtocol.dataDeleteUser({ userID: item.userID, - memberID: item.memberID + memberID: "" }, (status) => { if (status == 0) { delIndex++; diff --git a/components/configureDevice_2_addUser/configureDevice_2_addUser.js b/components/configureDevice_2_addUser/configureDevice_2_addUser.js index 3c02c85..51b8bbd 100644 --- a/components/configureDevice_2_addUser/configureDevice_2_addUser.js +++ b/components/configureDevice_2_addUser/configureDevice_2_addUser.js @@ -78,7 +78,10 @@ Component({ // 监听工号输入 onWorkNoInput(e) { - this.setData({ workNo: e.detail.value }); + this.setData({ + workNo: e.detail.value, + userInfo: null + }); }, // 监听身高输入 diff --git a/components/configureDevice_3/configureDevice_3.js b/components/configureDevice_3/configureDevice_3.js index 11d069e..34b7fc6 100644 --- a/components/configureDevice_3/configureDevice_3.js +++ b/components/configureDevice_3/configureDevice_3.js @@ -29,12 +29,16 @@ Component({ title: "正在获取Wi-Fi列表...", mask: true }); - app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => { - wx.hideLoading(); - this.setData({ - wifiList: res - }) - }) + // 重新获取协议实例,避免用户同步操作后旧引用失效 + setTimeout(() => { + app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol(); + app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => { + wx.hideLoading(); + this.setData({ + wifiList: res + }) + }) + }, 1500); }, // 最小化后重连,重置所有状态并重新获取 WiFi 列表