From a76176346f80b66c9f569445f8483f292b585d04 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Wed, 23 Apr 2025 09:56:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=B0=83=E5=A5=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 2 +- app.json | 4 +- pages/familyMembers/familyMembers.wxml | 4 +- pages/setNetwork/setNetwork.js | 54 +++++++++++-------- .../setNetworkSuccessful.js | 51 +++++++++--------- 5 files changed, 64 insertions(+), 51 deletions(-) diff --git a/app.js b/app.js index 281e7db..4094c2a 100644 --- a/app.js +++ b/app.js @@ -12,7 +12,7 @@ App({ ppScale: { plugin: null, activeProtocol: null, - // domain: "https://device.shuziweidao.com/gateway", + // domain: "http://device.shuziweidao.com/gateway", domain: "http://192.168.10.173:8889", wifi: { ssid: "", diff --git a/app.json b/app.json index 9252bf3..d00b593 100644 --- a/app.json +++ b/app.json @@ -38,8 +38,8 @@ "style": "v2", "plugins": { "ppScale-plugin": { - "version": "0.0.11", - "provider": "wx0826af4e4908f524" + "version": "1.2.15", + "provider": "wx0ffb48417ce6345c" } }, "sitemapLocation": "sitemap.json", diff --git a/pages/familyMembers/familyMembers.wxml b/pages/familyMembers/familyMembers.wxml index 944b486..afc746d 100644 --- a/pages/familyMembers/familyMembers.wxml +++ b/pages/familyMembers/familyMembers.wxml @@ -23,9 +23,9 @@ - + - 添加新成员 + 添加新成员 \ No newline at end of file diff --git a/pages/setNetwork/setNetwork.js b/pages/setNetwork/setNetwork.js index 6ff675f..71d57e6 100644 --- a/pages/setNetwork/setNetwork.js +++ b/pages/setNetwork/setNetwork.js @@ -10,41 +10,53 @@ Page({ ssid: options.ssid, password: options.password }, (res) => { - app.globalData.ppScale.wifi.ssid = ssid; - app.globalData.ppScale.wifi.password = password; + if(res === 23) { + app.globalData.ppScale.wifi.ssid = ssid; + app.globalData.ppScale.wifi.password = password; - 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 => { - app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => { - console.log("setNetwork.js codeSetBindingState", res); - - wx.navigateTo({ - url: "/pages/setNetworkSuccessful/setNetworkSuccessful" + 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 => { + app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => { + console.log("setNetwork.js codeSetBindingState", res); + + 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({ icon: "none", - title: err.message + title: "Mac 地址与 deviceId 获取失败,请重新绑定" }) setTimeout(() => { wx.switchTab({ url: "/pages/home/home" }) }, 1500) - }) + } } else { wx.showToast({ icon: "none", - title: "Mac 地址与 deviceId 获取失败,请重新绑定" + title: "配网失败,错误码:" + res }) setTimeout(() => { wx.switchTab({ diff --git a/pages/setNetworkSuccessful/setNetworkSuccessful.js b/pages/setNetworkSuccessful/setNetworkSuccessful.js index f3acebe..789f741 100644 --- a/pages/setNetworkSuccessful/setNetworkSuccessful.js +++ b/pages/setNetworkSuccessful/setNetworkSuccessful.js @@ -1,4 +1,5 @@ const app = getApp(); +import $ from "../../utils/request"; Page({ data: { @@ -58,35 +59,35 @@ Page({ let userInfo = this.data.userInfo; let i = this.data.subUser.i; let subUser = this.data.subUser.data; - app.globalData.ppScale.activeProtocol.dataSyncUserInfo({ - userID: userInfo.id, - userName: subUser[i].realname, - memberID: subUser[i].id, - age: this.getAge(subUser[i].birthday), // - gender: subUser[i].sex, // - height: subUser[i].height, // - isAthleteMode: 0, - currentWeight: subUser[i].weight, // - deviceHeaderIndex: 0, - targetWeight: "", - idealWeight: "", - recentData: [], - }, (res) => { - console.log("dataSyncSubUserInfo", res); - if(i < subUser.length) { + if(i < subUser.length) { + app.globalData.ppScale.activeProtocol.dataSyncUserInfo({ + userID: userInfo.id, + userName: subUser[i].realname, + memberID: subUser[i].id, + age: this.getAge(subUser[i].birthday), // + gender: subUser[i].sex, // + height: subUser[i].height, // + isAthleteMode: 0, + currentWeight: subUser[i].weight, // + deviceHeaderIndex: 0, + targetWeight: "", + idealWeight: "", + recentData: [], + }, (res) => { + console.log("dataSyncSubUserInfo", res); this.setData({ ['subUser.i']: i + 1 }) this.setSubUser(); - } else { - this.resetDevice(); - app.globalData.ppScale.plugin.Blue.stop(); - wx.hideLoading(); - wx.switchTab({ - url: "/pages/home/home" - }) - } - }) + }) + } else { + this.resetDevice(); + app.globalData.ppScale.plugin.Blue.stop(); + wx.hideLoading(); + wx.switchTab({ + url: "/pages/home/home" + }) + } }, resetDevice() {