From a76f61a90ad85910605c36f6da45ce41a98cfb16 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Thu, 29 May 2025 15:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A7=A4=E7=9A=84?= =?UTF-8?q?=E7=A8=B3=E5=AE=9A=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configureDevice_3/configureDevice_3.js | 10 +++++----- .../configureDevice_4/configureDevice_4.js | 18 ------------------ .../replaceNetwork_3/replaceNetwork_3.js | 2 +- pages/configureDevice/configureDevice.js | 12 ++++++++---- pages/replaceNetwork/replaceNetwork.js | 2 +- pages/userInfo/userInfo.js | 2 +- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/components/configureDevice_3/configureDevice_3.js b/components/configureDevice_3/configureDevice_3.js index ca4b3cb..1d7f663 100644 --- a/components/configureDevice_3/configureDevice_3.js +++ b/components/configureDevice_3/configureDevice_3.js @@ -91,7 +91,7 @@ Component({ status: true }); } else { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ title: "绑定失败,请重试。", icon: "none" @@ -104,7 +104,7 @@ Component({ } }) } else { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: res.message @@ -116,7 +116,7 @@ Component({ }, 1500) } }).catch(err => { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: err.message @@ -128,7 +128,7 @@ Component({ }, 1500) }) } else { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: "Mac 地址与 deviceId 获取失败,请重新绑定" @@ -140,7 +140,7 @@ Component({ }, 1500) } } else { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: "配网失败,错误码:" + res diff --git a/components/configureDevice_4/configureDevice_4.js b/components/configureDevice_4/configureDevice_4.js index d30308c..19be1bf 100644 --- a/components/configureDevice_4/configureDevice_4.js +++ b/components/configureDevice_4/configureDevice_4.js @@ -1,22 +1,4 @@ -const app = getApp(); -import $ from "../../utils/request"; - Component({ - data: { - - }, - - lifetimes: { - attached() { - - }, - detached() { - // 在组件实例被从页面节点树移除时执行 - console.log('MyComponent detached!'); - } - }, - - // 组件的方法 methods: { bindOk() { this.triggerEvent('deviceEvent', { diff --git a/components/replaceNetwork_3/replaceNetwork_3.js b/components/replaceNetwork_3/replaceNetwork_3.js index facde4a..b8c271f 100644 --- a/components/replaceNetwork_3/replaceNetwork_3.js +++ b/components/replaceNetwork_3/replaceNetwork_3.js @@ -55,7 +55,7 @@ Component({ }) } } else { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: "配网失败,错误码:" + res diff --git a/pages/configureDevice/configureDevice.js b/pages/configureDevice/configureDevice.js index 829016f..ed944b8 100644 --- a/pages/configureDevice/configureDevice.js +++ b/pages/configureDevice/configureDevice.js @@ -50,7 +50,7 @@ Page({ equipmentCode: scaleDeviceId, }; $.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => { - ppScale.plugin.Blue.disconnect(); + ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: "设备初始化成功,请重新绑定。", @@ -64,7 +64,7 @@ Page({ }, 1500); }); } else { - ppScale.plugin.Blue.disconnect(); + ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: "设备初始化失败。", @@ -73,7 +73,7 @@ Page({ }) } else if (res.cancel) { // device.mac = null; - ppScale.plugin.Blue.disconnect(); + ppScale.plugin.Blue.stop(); } } }) @@ -171,7 +171,7 @@ Page({ }, setConfigSuccessful() { - ppScale.plugin.Blue.disconnect(); + ppScale.plugin.Blue.stop(); wx.switchTab({ url: "/pages/home/home" }) @@ -181,5 +181,9 @@ Page({ this.setData({ ["progress.index"]: this.data.progress.index + 1 }) + }, + + onUnload() { + ppScale.plugin.Blue.stop(); } }) \ No newline at end of file diff --git a/pages/replaceNetwork/replaceNetwork.js b/pages/replaceNetwork/replaceNetwork.js index fb89259..5d28cce 100644 --- a/pages/replaceNetwork/replaceNetwork.js +++ b/pages/replaceNetwork/replaceNetwork.js @@ -244,7 +244,7 @@ Page({ // 卸载事件监听 onUnload() { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); if (this._connectStateWatcher) { app.unwatch('ppScale.device.connectState', this._connectStateWatcher); } diff --git a/pages/userInfo/userInfo.js b/pages/userInfo/userInfo.js index de01ce9..fac6863 100644 --- a/pages/userInfo/userInfo.js +++ b/pages/userInfo/userInfo.js @@ -427,7 +427,7 @@ Page({ }, onUnload() { - app.globalData.ppScale.plugin.Blue.disconnect(); + app.globalData.ppScale.plugin.Blue.stop(); if (this._connectStateWatcher) { app.unwatch('ppScale.device.connectState', this._connectStateWatcher); }