feat(设备管理): 重构设备数据管理逻辑,统一使用deviceData对象

- 将分散的设备信息存储改为统一的deviceData对象
- 更新相关API请求参数传递方式
- 增加设备类型支持,动态构建API路径
- 修复设备信息初始化问题,确保数据一致性
This commit is contained in:
2025-06-25 12:43:31 +08:00
parent ea5ed7c9ce
commit fec4276cc8
7 changed files with 45 additions and 27 deletions

View File

@@ -26,6 +26,7 @@ Page({
}), e.globalData.qrcode = i.result, t.request("/v2/miniprogram/identify/index", i, !0).then(function (t) {
console.log("data", t), wx.hideLoading();
// 保存设备编号
getApp().globalData.deviceData = t.data || getApp().globalData.deviceData || {};
getApp().globalData.devicecode = t.data.devicecode || getApp().globalData.devicecode;
a.startup();
}).catch(function (e) {
@@ -36,9 +37,15 @@ Page({
},
// 启动
startup: function () {
if (getApp().globalData.devicecode) {
if (getApp().globalData.deviceData.devicecode) {
// 合并参数 t.globalData.deviceData 与 washcode
let params = Object.assign(getApp().globalData.deviceData, {
washcode: this.data.code
});
// 已扫码,启动机器
t.request('/v2/miniprogram/machine/carwashcodestartup', { devicecode: getApp().globalData.devicecode, washcode: this.data.code }, !0).then((startRes) => {
t.request('/v2/miniprogram/' + getApp().globalData.deviceData.type + '/carwashcodestartup', params, !0).then((startRes) => {
if (startRes.code == 200) {
wx.showToast({ title: startRes.message || '启动成功', icon: 'success' });
// 跳转到洗车券列表页面
@@ -92,7 +99,7 @@ Page({
wx.showModal({
title: "提示",
content: "你当前将要使用的机器编号是:".concat(getApp().globalData.devicecode, ",确认开机吗?"),
content: "你当前将要使用的机器编号是:".concat(getApp().globalData.deviceData.devicecode, ",确认开机吗?"),
success: (res) => {
if (res.confirm) {
// 用户点击了确认按钮,执行开机操作