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

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
@@ -103,74 +103,10 @@ Component({
if(res === 23) {
app.globalData.ppScale.wifi.ssid = this.data.selectWifi.ssid;
app.globalData.ppScale.wifi.password = this.data.selectWifiPWD;
let mac = app.globalData.ppScale.device.mac;
let deviceId = app.globalData.ppScale.device.connection.deviceId;
if(mac && deviceId) {
let scaleDeviceId = mac.replace(/:/g, '');
let params = {
equipmentName: app.globalData.ppScale.device.name,
scaleDeviceId: scaleDeviceId,
deviceId: deviceId
};
$.ajax("weighingScale/binding/device", params, "POST").then(res => {
if (res.success) {
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
console.log("setNetwork.js codeSetBindingState", res);
if(res == 0) {
this.triggerEvent('deviceEvent', {
status: true
});
} else {
app.globalData.ppScale.plugin.Blue.stop();
wx.showToast({
title: "绑定失败,请重试。",
icon: "none"
})
setTimeout(() => {
wx.navigateBack({
delta: 2
})
}, 1500)
}
})
} else {
app.globalData.ppScale.plugin.Blue.stop();
wx.showToast({
icon: "none",
title: res.message
})
setTimeout(() => {
wx.navigateBack({
delta: 2
})
}, 1500)
}
}).catch(err => {
app.globalData.ppScale.plugin.Blue.stop();
wx.showToast({
icon: "none",
title: err.message
})
setTimeout(() => {
wx.navigateBack({
delta: 2
})
}, 1500)
})
} else {
app.globalData.ppScale.plugin.Blue.stop();
wx.showToast({
icon: "none",
title: "Mac 地址与 deviceId 获取失败,请重新绑定"
})
setTimeout(() => {
wx.navigateBack({
delta: 2
})
}, 1500)
}
this.triggerEvent('deviceEvent', {
status: true
});
} else {
app.globalData.ppScale.plugin.Blue.stop();
wx.showToast({