2025年4月2日19:51:49

This commit is contained in:
17792275749
2025-04-02 19:51:52 +08:00
parent cb50138e38
commit 62091ee0c1
3 changed files with 33 additions and 19 deletions
-5
View File
@@ -41,10 +41,5 @@ App({
wx.hideLoading(); wx.hideLoading();
}); });
plugin.bus.subscribe("devicesModel", (res) => {
console.log('app.js devicesModel', res);
this.globalData.ppScale.device.mac = res.deviceMac;
});
}, },
}) })
+6
View File
@@ -110,6 +110,7 @@ Page({
// }, // },
getDeviceSettingList() { getDeviceSettingList() {
// app.globalData.ppScale.plugin.Blue.visibleLog(true);
this.setData({ this.setData({
initText: "设备搜索中..." initText: "设备搜索中..."
}); });
@@ -168,6 +169,11 @@ Page({
}); });
this.selectDevice(); this.selectDevice();
}); });
app.globalData.ppScale.plugin.bus.subscribe("devicesModel", (res) => {
console.log("searchDevice ===》devicesModel", res);
app.globalData.ppScale.device.mac = res.deviceMac;
});
}, },
selectDevice() { selectDevice() {
+27 -14
View File
@@ -13,30 +13,43 @@ Page({
app.globalData.ppScale.wifi.ssid = ssid; app.globalData.ppScale.wifi.ssid = ssid;
app.globalData.ppScale.wifi.password = password; app.globalData.ppScale.wifi.password = password;
let scaleDeviceId = app.globalData.ppScale.device.mac.replace(/:/g, ''); let mac = app.globalData.ppScale.device.mac;
let params = { if(mac) {
equipmentName: app.globalData.ppScale.device.name, let scaleDeviceId = mac.replace(/:/g, '');
scaleDeviceId: scaleDeviceId, let params = {
}; equipmentName: app.globalData.ppScale.device.name,
$.ajax("weighingScale/binding/device", params, "POST").then(res => { scaleDeviceId: scaleDeviceId,
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => { };
console.log("setNetwork.js codeSetBindingState", res); $.ajax("weighingScale/binding/device", params, "POST").then(res => {
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
wx.navigateTo({ console.log("setNetwork.js codeSetBindingState", res);
url: "/pages/setNetworkSuccessful/setNetworkSuccessful"
wx.navigateTo({
url: "/pages/setNetworkSuccessful/setNetworkSuccessful"
})
}) })
}).catch(err => {
wx.showToast({
icon: "none",
title: err.message
})
setTimeout(() => {
wx.switchTab({
url: "/pages/home/home"
})
}, 1500)
}) })
}).catch(err => { } else {
wx.showToast({ wx.showToast({
icon: "none", icon: "none",
title: err.message title: "Mac 地址获取失败,请重新绑定"
}) })
setTimeout(() => { setTimeout(() => {
wx.switchTab({ wx.switchTab({
url: "/pages/home/home" url: "/pages/home/home"
}) })
}, 1500) }, 1500)
}) }
}) })
} }
}) })