优化设备配置流程,重构用户增删改查及信息下发逻辑

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-03-11 11:04:29 +08:00
co-authored by Claude Opus 4.6
parent 05b388020b
commit f89f0f9531
10 changed files with 204 additions and 155 deletions
@@ -81,6 +81,16 @@ Component({
this.setData({ workNo: e.detail.value });
},
// 监听身高输入
onHeightInput(e) {
this.setData({ 'userInfo.height': e.detail.value });
},
// 监听体重输入
onWeightInput(e) {
this.setData({ 'userInfo.weight': e.detail.value });
},
// 根据工号查询用户信息
searchUser() {
let workNo = this.data.workNo.trim();
@@ -105,9 +115,11 @@ Component({
icon: "none"
})
}
}).catch(() => {
}).catch((err) => {
console.log(err);
this.setData({ userInfo: null });
wx.showToast({
title: "查询失败,请重试",
title: (err && err.message) || "查询失败",
icon: "none"
})
})
@@ -122,21 +134,24 @@ Component({
})
return;
}
let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
let user = this.data.userInfo;
$.ajax("weighingScale/v2/edit/user", {
sn,
realname: user.realname,
sex: user.sex,
birthday: user.birthday,
height: user.height,
weight: user.weight
}, "POST", true, "正在添加...").then(res => {
let userInfo = this.data.userInfo;
// 校验身高
if (!userInfo.height) {
wx.showToast({ title: "请输入身高", icon: "none" });
return;
}
// 校验体重
if (!userInfo.weight) {
wx.showToast({ title: "请输入体重", icon: "none" });
return;
}
userInfo.sn = app.globalData.ppScale.device.mac.replace(/:/g, '')
$.ajax("weighingScale/v2/edit/user", userInfo, "POST", true, "正在添加...").then(res => {
wx.showToast({
title: "添加成功",
icon: "success"
})
this.triggerEvent('returnDate', { userInfo: user });
this.triggerEvent('returnDate', { userInfo });
this.closeModal();
}).catch(() => {
wx.showToast({