diff --git a/app.js b/app.js index ded7944..3af1c14 100644 --- a/app.js +++ b/app.js @@ -5,15 +5,15 @@ App({ globalData: { // wx.request 请求的服务地址 - wxRequestUrl: "https://device.shuziweidao.com/gateway/", - // wxRequestUrl: "http://192.168.1.12:8889/", + // wxRequestUrl: "https://device.shuziweidao.com/gateway/", + wxRequestUrl: "http://192.168.1.12:8889/", // 秤的所有信息 ppScale: { plugin: null, activeProtocol: null, - domain: "http://device.shuziweidao.com:80/gateway", - // domain: "http://192.168.1.12:8889", + // domain: "http://device.shuziweidao.com:80/gateway", + domain: "http://192.168.1.12:8889", wifi: { ssid: "", password: "" diff --git a/app.json b/app.json index 214dfb6..5971f4b 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,9 @@ "pages/searchDevice/searchDevice", "pages/configureDevice/configureDevice", "pages/my/my", - "pages/deviceInfo/deviceInfo" + "pages/userInfo/userInfo", + "pages/deviceInfo/deviceInfo", + "pages/replaceNetwork/replaceNetwork" ], "window": { "navigationBarTitleText": "", diff --git a/components/configureDevice_2/configureDevice_2.wxml b/components/configureDevice_2/configureDevice_2.wxml index 9953741..db1dc9e 100644 --- a/components/configureDevice_2/configureDevice_2.wxml +++ b/components/configureDevice_2/configureDevice_2.wxml @@ -122,6 +122,6 @@ 下一步 - 请填写和完善您家人的健康信息(填写数据同时,踩亮蓝牙秤并与其保持连接),将用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。 + 请认真填写和完善您家人的健康信息,用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。(填写数据同时,踩亮蓝牙秤并与其保持连接)。 \ No newline at end of file diff --git a/components/configureDevice_2/configureDevice_2.wxss b/components/configureDevice_2/configureDevice_2.wxss index 15297b7..e667c6a 100644 --- a/components/configureDevice_2/configureDevice_2.wxss +++ b/components/configureDevice_2/configureDevice_2.wxss @@ -151,4 +151,8 @@ input { width: 100%; font-size: 24rpx; line-height: 40rpx; +} + +.describe text { + color: #F24439; } \ No newline at end of file diff --git a/components/replaceNetwork_1/replaceNetwork_1.js b/components/replaceNetwork_1/replaceNetwork_1.js new file mode 100644 index 0000000..c95e9d1 --- /dev/null +++ b/components/replaceNetwork_1/replaceNetwork_1.js @@ -0,0 +1,37 @@ +const app = getApp(); + +Component({ + data: { + wifiList: [] + }, + + // 生命周期方法 + lifetimes: { + attached() { + + }, + detached() { + + } + }, + + // 组件的方法 + methods: { + getWiFiList() { + app.globalData.ppScale.activeProtocol.dataFindSurroundDevice((res) => { + console.log("connectedDevice ===》dataFindSurroundDevice", res); + + this.setData({ + wifiList: res + }) + }) + }, + + selectDevice(e) { + this.triggerEvent('wifiEvent', { + status: true, + data: e.currentTarget.dataset.item + }); + } + } +}); \ No newline at end of file diff --git a/components/replaceNetwork_1/replaceNetwork_1.json b/components/replaceNetwork_1/replaceNetwork_1.json new file mode 100644 index 0000000..7e37c03 --- /dev/null +++ b/components/replaceNetwork_1/replaceNetwork_1.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/replaceNetwork_1/replaceNetwork_1.wxml b/components/replaceNetwork_1/replaceNetwork_1.wxml new file mode 100644 index 0000000..9b3d120 --- /dev/null +++ b/components/replaceNetwork_1/replaceNetwork_1.wxml @@ -0,0 +1,20 @@ + + + 可用Wi-Fi + 网络列表(设备暂不支持5GWi-Fi网络) + + + + + + + + + + {{item.ssid}} + + + + + + \ No newline at end of file diff --git a/components/replaceNetwork_1/replaceNetwork_1.wxss b/components/replaceNetwork_1/replaceNetwork_1.wxss new file mode 100644 index 0000000..caf0cf3 --- /dev/null +++ b/components/replaceNetwork_1/replaceNetwork_1.wxss @@ -0,0 +1,71 @@ +.replaceNetwork1 { + width: 100%; + height: 100%; + padding-top: 60rpx; + box-sizing: border-box; +} + +.title { + width: 100%; + padding: 0 60rpx; + box-sizing: border-box; + margin-bottom: 40rpx; +} + +.title>view:nth-of-type(1) { + color: #252535; + width: 100%; + height: 48rpx; + font-size: 48rpx; + font-weight: bold; + line-height: 48rpx; + margin-bottom: 48rpx; +} + +.title>view:nth-of-type(2) { + color: #B6B6B6; + width: 100%; + height: 30rpx; + font-size: 30rpx; + line-height: 30rpx; +} + +.content { + width: 100%; + height: calc(100% - 166rpx); +} + +.scrollView { + width: 100%; + height: 100%; +} + +.scrollViewContent { + width: 100%; + padding: 0 60rpx; + box-sizing: border-box; +} + +.scrollViewContent>view { + width: 100%; + height: 80rpx; + display: flex; + flex-wrap: nowrap; + margin-bottom: 32rpx; +} + +.scrollViewContent>view>view:nth-of-type(1) { + width: 80rpx; + height: 80rpx; + margin-right: 24rpx; +} + +.scrollViewContent>view>view:nth-of-type(2) { + color: #252535; + flex: 1; + width: 0; + height: 80rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 80rpx; +} \ No newline at end of file diff --git a/components/replaceNetwork_2/replaceNetwork_2.js b/components/replaceNetwork_2/replaceNetwork_2.js new file mode 100644 index 0000000..e883677 --- /dev/null +++ b/components/replaceNetwork_2/replaceNetwork_2.js @@ -0,0 +1,56 @@ +const app = getApp(); + +Component({ + properties: { + ssid: { + type: String, + value: "" + } + }, + + data: { + type: true, + + ssid: "", + password: "" + }, + + // 生命周期方法 + lifetimes: { + attached() { + + }, + detached() { + + } + }, + + // 组件的方法 + methods: { + setWiFiName() { + this.setData({ + ssid: this.properties.ssid, + type: true, + }) + }, + + passwordInput(e) { + this.setData({ + password: e.detail.value + }) + }, + + inputTypeChange() { + this.setData({ + type: !this.data.type + }) + }, + + setWifiPWD() { + this.triggerEvent('wifiEvent', { + status: true, + data: this.data.password + }); + } + } +}); \ No newline at end of file diff --git a/components/replaceNetwork_2/replaceNetwork_2.json b/components/replaceNetwork_2/replaceNetwork_2.json new file mode 100644 index 0000000..7e37c03 --- /dev/null +++ b/components/replaceNetwork_2/replaceNetwork_2.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/replaceNetwork_2/replaceNetwork_2.wxml b/components/replaceNetwork_2/replaceNetwork_2.wxml new file mode 100644 index 0000000..bb0f310 --- /dev/null +++ b/components/replaceNetwork_2/replaceNetwork_2.wxml @@ -0,0 +1,36 @@ + + 输入Wi-Fi密码 + + + + + + {{ssid}} + + + 密码 + + + + + + + + + + + + + + 连接 + \ No newline at end of file diff --git a/components/replaceNetwork_2/replaceNetwork_2.wxss b/components/replaceNetwork_2/replaceNetwork_2.wxss new file mode 100644 index 0000000..eb36896 --- /dev/null +++ b/components/replaceNetwork_2/replaceNetwork_2.wxss @@ -0,0 +1,95 @@ +.replaceNetwork2 { + width: 100%; + height: 100%; + padding: 60rpx 30rpx 0; + box-sizing: border-box; +} + +.title { + color: #252535; + width: 100%; + height: 48rpx; + font-size: 48rpx; + font-weight: bold; + line-height: 48rpx; + margin-bottom: 48rpx; +} + +.form { + width: 100%; + margin-bottom: 64rpx; +} + +.form>view { + width: 100%; + height: 96rpx; + display: flex; + flex-wrap: nowrap; + align-items: center; + padding: 0 24rpx; + box-sizing: border-box; + border-radius: 16rpx; + background-color: #F6F6F6; +} + +.form>view:first-of-type { + margin-bottom: 32rpx; +} + +.form>view>view:nth-of-type(1) { + color: #252535; + width: 100rpx; + height: 96rpx; + line-height: 96rpx; + font-size: 32rpx; + font-weight: bold; +} + +.form>view:first-of-type>view:nth-of-type(1) { + padding: 24rpx 45rpx 24rpx 7rpx; + box-sizing: border-box; + display: flex; + align-items: center; +} + +.form>view>view:nth-of-type(2) { + color: #252535; + flex: 1; + width: 0; + height: 96rpx; + font-size: 32rpx; + line-height: 96rpx; +} + +.form>view>view:nth-of-type(2) input { + color: #252535; + width: 100%; + height: 96rpx; + font-size: 32rpx; + line-height: 96rpx; +} + +.placeholderClass { + color: #B6B6B6; + height: 96rpx; + font-size: 32rpx; + line-height: 96rpx; +} + +.form>view>view:nth-of-type(3) { + width: 56rpx; + height: 56rpx; +} + +.btn { + color: #FFFFFF; + width: 580rpx; + height: 88rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 88rpx; + margin: 0 auto; + text-align: center; + border-radius: 44rpx; + background-color: #1385FA; +} \ No newline at end of file diff --git a/components/replaceNetwork_3/replaceNetwork_3.js b/components/replaceNetwork_3/replaceNetwork_3.js new file mode 100644 index 0000000..59c28cb --- /dev/null +++ b/components/replaceNetwork_3/replaceNetwork_3.js @@ -0,0 +1,131 @@ +const app = getApp(); + +Component({ + properties: { + ssid: { + type: String, + value: "" + }, + password: { + type: String, + value: "" + } + }, + + data: { + + }, + + // 生命周期方法 + lifetimes: { + attached() { + this.setNerwork(); + }, + detached() { + + } + }, + + // 组件的方法 + methods: { + setNerwork() { + let ssid = this.properties.ssid; + let password = this.properties.password; + app.globalData.ppScale.activeProtocol.dataConfigNetWork({ + domain: app.globalData.ppScale.domain, + ssid: ssid, + password: password + }, (res) => { + console.log("setNetwork.js dataConfigNetWork", res); + + if(res === 23) { + app.globalData.ppScale.wifi.ssid = ssid; + app.globalData.ppScale.wifi.password = password; + + this.triggerEvent('wifiEvent', { + status: true + }); + + // 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.disconnect(); + // wx.showToast({ + // title: "绑定失败,请重试。", + // icon: "none" + // }) + // setTimeout(() => { + // wx.navigateBack({ + // delta: 2 + // }) + // }, 1500) + // } + // }) + // } else { + // app.globalData.ppScale.plugin.Blue.disconnect(); + // wx.showToast({ + // icon: "none", + // title: res.message + // }) + // setTimeout(() => { + // wx.navigateBack({ + // delta: 2 + // }) + // }, 1500) + // } + // }).catch(err => { + // app.globalData.ppScale.plugin.Blue.disconnect(); + // wx.showToast({ + // icon: "none", + // title: err.message + // }) + // setTimeout(() => { + // wx.navigateBack({ + // delta: 2 + // }) + // }, 1500) + // }) + // } else { + // app.globalData.ppScale.plugin.Blue.disconnect(); + // wx.showToast({ + // icon: "none", + // title: "Mac 地址与 deviceId 获取失败,请重新绑定" + // }) + // setTimeout(() => { + // wx.navigateBack({ + // delta: 2 + // }) + // }, 1500) + // } + } else { + app.globalData.ppScale.plugin.Blue.disconnect(); + wx.showToast({ + icon: "none", + title: "配网失败,错误码:" + res + }) + setTimeout(() => { + this.triggerEvent('wifiEvent', { + status: false + }); + }, 1500) + } + }) + } + } +}); \ No newline at end of file diff --git a/components/replaceNetwork_3/replaceNetwork_3.json b/components/replaceNetwork_3/replaceNetwork_3.json new file mode 100644 index 0000000..7e37c03 --- /dev/null +++ b/components/replaceNetwork_3/replaceNetwork_3.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/replaceNetwork_3/replaceNetwork_3.wxml b/components/replaceNetwork_3/replaceNetwork_3.wxml new file mode 100644 index 0000000..705078b --- /dev/null +++ b/components/replaceNetwork_3/replaceNetwork_3.wxml @@ -0,0 +1,7 @@ + + + + + 设备正在配对网络中,请稍等... + 请持续站在秤上,耐心等待 + \ No newline at end of file diff --git a/components/replaceNetwork_3/replaceNetwork_3.wxss b/components/replaceNetwork_3/replaceNetwork_3.wxss new file mode 100644 index 0000000..2dc1157 --- /dev/null +++ b/components/replaceNetwork_3/replaceNetwork_3.wxss @@ -0,0 +1,32 @@ +.replaceNetwork3 { + width: 100%; + height: 100%; + padding: 90rpx 62rpx 0; + box-sizing: border-box; +} + +.replaceNetwork3>view:nth-of-type(1) { + width: 565rpx; + height: 500rpx; + margin: 0 auto; +} + +.replaceNetwork3>view:nth-of-type(2) { + color: #1385FA; + width: 100%; + height: 36rpx; + font-size: 36rpx; + font-weight: bold; + line-height: 36rpx; + text-align: center; + margin-bottom: 28rpx; +} + +.replaceNetwork3>view:nth-of-type(3) { + color: #808080; + width: 100%; + height: 30rpx; + font-size: 30rpx; + text-align: center; + line-height: 30rpx; +} \ No newline at end of file diff --git a/components/replaceNetwork_4/replaceNetwork_4.js b/components/replaceNetwork_4/replaceNetwork_4.js new file mode 100644 index 0000000..d636823 --- /dev/null +++ b/components/replaceNetwork_4/replaceNetwork_4.js @@ -0,0 +1,26 @@ +const app = getApp(); + +Component({ + data: { + + }, + + // 生命周期方法 + lifetimes: { + attached() { + + }, + detached() { + + } + }, + + // 组件的方法 + methods: { + replaceNetworkOk() { + wx.navigateBack({ + delta: 1 + }) + } + } +}); \ No newline at end of file diff --git a/components/replaceNetwork_4/replaceNetwork_4.json b/components/replaceNetwork_4/replaceNetwork_4.json new file mode 100644 index 0000000..7e37c03 --- /dev/null +++ b/components/replaceNetwork_4/replaceNetwork_4.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/replaceNetwork_4/replaceNetwork_4.wxml b/components/replaceNetwork_4/replaceNetwork_4.wxml new file mode 100644 index 0000000..b9051d5 --- /dev/null +++ b/components/replaceNetwork_4/replaceNetwork_4.wxml @@ -0,0 +1,12 @@ + + + + + + Wi-Fi 切换成功 + + + 随时随地同步测量数据 + + 完成 + \ No newline at end of file diff --git a/components/replaceNetwork_4/replaceNetwork_4.wxss b/components/replaceNetwork_4/replaceNetwork_4.wxss new file mode 100644 index 0000000..72e7366 --- /dev/null +++ b/components/replaceNetwork_4/replaceNetwork_4.wxss @@ -0,0 +1,49 @@ +.replaceNetwork4 { + width: 100%; + height: 100%; + padding: 105rpx 55rpx 0; + box-sizing: border-box; +} + +.icon { + width: 100%; + margin-bottom: 475rpx; +} + +.icon>view:first-of-type { + width: 360rpx; + height: 295rpx; + margin: 0 auto 50rpx; +} + +.icon>view:last-of-type { + color: #252535; + width: 100%; + height: 40rpx; + font-size: 40rpx; + font-weight: bold; + line-height: 40rpx; + text-align: center; +} + +.describe { + color: #B6B6B6; + width: 100%; + height: 26rpx; + font-size: 28rpx; + line-height: 28rpx; + text-align: center; + margin-bottom: 46rpx; +} + +.btn { + color: #FFFFFF; + width: 100%; + height: 88rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 88rpx; + text-align: center; + border-radius: 44rpx; + background-color: #1385FA; +} diff --git a/images/replaceNetwork/bluetooth.png b/images/replaceNetwork/bluetooth.png new file mode 100644 index 0000000..adde03a Binary files /dev/null and b/images/replaceNetwork/bluetooth.png differ diff --git a/images/replaceNetwork/close.png b/images/replaceNetwork/close.png new file mode 100644 index 0000000..6e32387 Binary files /dev/null and b/images/replaceNetwork/close.png differ diff --git a/images/replaceNetwork/configureDevice_3_icon.png b/images/replaceNetwork/configureDevice_3_icon.png new file mode 100644 index 0000000..9974df8 Binary files /dev/null and b/images/replaceNetwork/configureDevice_3_icon.png differ diff --git a/images/replaceNetwork/configureDevice_4_icon.png b/images/replaceNetwork/configureDevice_4_icon.png new file mode 100644 index 0000000..6c7a21e Binary files /dev/null and b/images/replaceNetwork/configureDevice_4_icon.png differ diff --git a/images/replaceNetwork/open.png b/images/replaceNetwork/open.png new file mode 100644 index 0000000..2b2c650 Binary files /dev/null and b/images/replaceNetwork/open.png differ diff --git a/images/replaceNetwork/wifi.png b/images/replaceNetwork/wifi.png new file mode 100644 index 0000000..a0882a8 Binary files /dev/null and b/images/replaceNetwork/wifi.png differ diff --git a/images/replaceNetwork/wifiPwd.png b/images/replaceNetwork/wifiPwd.png new file mode 100644 index 0000000..2999896 Binary files /dev/null and b/images/replaceNetwork/wifiPwd.png differ diff --git a/pages/configureDevice/configureDevice.js b/pages/configureDevice/configureDevice.js index e0cb5d8..829016f 100644 --- a/pages/configureDevice/configureDevice.js +++ b/pages/configureDevice/configureDevice.js @@ -171,6 +171,7 @@ Page({ }, setConfigSuccessful() { + ppScale.plugin.Blue.disconnect(); wx.switchTab({ url: "/pages/home/home" }) diff --git a/pages/deviceInfo/deviceInfo.js b/pages/deviceInfo/deviceInfo.js index e4e191a..6075a33 100644 --- a/pages/deviceInfo/deviceInfo.js +++ b/pages/deviceInfo/deviceInfo.js @@ -6,7 +6,7 @@ Page({ deviceInfo: null, }, - onLoad(options) { + onShow() { this.getDevice(); }, @@ -20,6 +20,12 @@ Page({ }) }, + openReplaceNetwork() { + wx.navigateTo({ + url: "/pages/replaceNetwork/replaceNetwork" + }) + }, + delDevice() { let scaleDeviceId = this.data.deviceInfo.macAddress.replace(/:/g, ''); let params = { diff --git a/pages/deviceInfo/deviceInfo.wxml b/pages/deviceInfo/deviceInfo.wxml index 116e043..99ae6ae 100644 --- a/pages/deviceInfo/deviceInfo.wxml +++ b/pages/deviceInfo/deviceInfo.wxml @@ -19,7 +19,7 @@ 设备SN {{deviceInfo.equipmentCode}} - + Wi-Fi名称 {{deviceInfo.wifiName}} diff --git a/pages/deviceInfo/deviceInfo.wxss b/pages/deviceInfo/deviceInfo.wxss index 88487ae..3ba6bd8 100644 --- a/pages/deviceInfo/deviceInfo.wxss +++ b/pages/deviceInfo/deviceInfo.wxss @@ -80,6 +80,14 @@ page { color: #808080; } +.arrowAfter { + padding-right: 60rpx !important; +} + +.arrowAfter::after { + right: 30rpx; +} + .btn { color: #FFFFFF; width: 580rpx; diff --git a/pages/my/my.js b/pages/my/my.js index 3d44098..c2c899f 100644 --- a/pages/my/my.js +++ b/pages/my/my.js @@ -15,13 +15,86 @@ Page({ userInfo: userInfo, token: token }) - if(token && userInfo) { - this.getDevice(); + if(token) { + this.getDevice(false); } }, openLoginOrReg() { - if(this.data.userInfo === null && this.data.token === null) { + if(this.data.token) { + this.openLoginOrReg_(); + } else { + this.starLogin().then(() => { + this.getDevice(true); + }).catch(() => { + wx.showToast({ + title: "登录失败,请重试!", + icon: "none" + }) + }) + } + }, + openLoginOrReg_() { + let deviceInfo = this.data.deviceInfo; + if(deviceInfo) { + wx.navigateTo({ + url: "/pages/userInfo/userInfo" + }) + } else { + wx.showModal({ + title: "提示", + content: "当前用户暂未绑定设备,需要绑定吗?", + confirmText: "去绑定", + success: (res) => { + if (res.confirm) { + wx.navigateTo({ + url: "/pages/searchDevice/searchDevice" + }) + } + } + }) + } + }, + + // 打开设备详情 + openDeviceInfo() { + if(this.data.token) { + this.openDeviceInfo_(); + } else { + this.starLogin().then(() => { + this.openDeviceInfo_(); + }).catch(() => { + wx.showToast({ + title: "登录失败,请重试!", + icon: "none" + }) + }) + } + }, + openDeviceInfo_ () { + let deviceInfo = this.data.deviceInfo; + if(deviceInfo) { + wx.navigateTo({ + url: "/pages/deviceInfo/deviceInfo" + }) + } else { + wx.showModal({ + title: "提示", + content: "当前暂未绑定设备,需要绑定吗?", + confirmText: "去绑定", + success: (res) => { + if (res.confirm) { + wx.navigateTo({ + url: "/pages/searchDevice/searchDevice" + }) + } + } + }) + } + }, + + starLogin() { + return new Promise((resolve, reject) => { wx.login({ success: (res) => { if (res.code) { @@ -35,55 +108,28 @@ Page({ token: res.result.token, userInfo: res.result.user }) + resolve(); + }).catch((err) => { + reject(); }) } else { - wx.showToast({ - icon: "none", - title: "登录失败,请稍后再试!", - }) + reject(); } } }) - } + }) }, - // 打开设备详情 - openDeviceInfo() { - if(this.data.userInfo && this.data.token) { - let deviceInfo = this.data.deviceInfo; - if(deviceInfo) { - wx.navigateTo({ - url: "/pages/deviceInfo/deviceInfo" - }) - } else { - wx.showModal({ - title: "提示", - content: "当前暂未绑定设备,需要绑定吗?", - confirmText: "去绑定", - success: (res) => { - if (res.confirm) { - wx.navigateTo({ - url: "/pages/searchDevice/searchDevice" - }) - } - } - }) - } - } else { - wx.showToast({ - icon: "none", - title: "请先登录" - }) - } - }, - // 获取已经绑定的设备列表 - getDevice() { + getDevice(bol) { let params = {}; $.ajax("weighingScale/list/device", params, "GET", false).then((res) => { this.setData({ deviceInfo: res.result && res.result.length ? res.result[0] : null - }) + }) + if(bol) { + this.openLoginOrReg_(); + } }) }, diff --git a/pages/my/my.wxml b/pages/my/my.wxml index d721db6..a9c1e7f 100644 --- a/pages/my/my.wxml +++ b/pages/my/my.wxml @@ -1,5 +1,5 @@ - + @@ -48,7 +48,7 @@ - + 退出登录 diff --git a/pages/replaceNetwork/replaceNetwork.js b/pages/replaceNetwork/replaceNetwork.js new file mode 100644 index 0000000..5b7afb2 --- /dev/null +++ b/pages/replaceNetwork/replaceNetwork.js @@ -0,0 +1,250 @@ +const app = getApp(); +import $ from "../../utils/request"; + +Page({ + data: { + progress: 0, + + BLUE_STATE: {}, + connectState: "", + + device: null, + wifiInfo: { + ssid: "", + password: "" + } + }, + + // 存储回调函数的引用,以便在 detached 时取消监听 + _connectStateWatcher: null, + + onLoad(options) { + this.checkBluetoothPermissionAndInit(); + + + app.globalData.ppScale.plugin.bus.subscribe("devicesModel", (res) => { + console.log("searchDevice ===》devicesModel", res); + app.globalData.ppScale.device.mac = res.deviceMac; + + app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => { + console.log('connectedDevice ===》deviceConnect', res); + + app.globalData.ppScale.plugin.ScaleAction.startDataProgress(true); + app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol(); + + app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => { + console.log("connectedDevice ===》codeUpdateMTU", res); + + + app.globalData.ppScale.device.name = this.data.device.name; + app.globalData.ppScale.device.connection = this.data.device; + this.selectComponent('#replaceNetwork1Component').getWiFiList(); + }); + }); + }); + + console.log(`[Component] connectState 获取: ${app.globalData.ppScale.device.connectState}`); + this.setData({ + BLUE_STATE: app.globalData.ppScale.plugin.BLUE_STATE, + connectState: app.globalData.ppScale.device.connectState + }) + this._connectStateWatcher = (newValue, oldValue) => { + console.log(`[Component] connectState 变化: ${oldValue} -> ${newValue}`); + this.setData({ + connectState: newValue || '' + }); + }; + app.watch('ppScale.device.connectState', this._connectStateWatcher); + }, + + checkBluetoothPermissionAndInit() { + this.setData({ + initText: "正在检查蓝牙权限..." + }); + wx.getSetting({ + success: (res) => { + if (res.authSetting['scope.bluetooth']) { + this.openBluetoothAdapter(); + } else { + wx.authorize({ + scope: 'scope.bluetooth', + success: () => { + this.openBluetoothAdapter(); + }, + fail: (err) => { + this.setData({ + initText: "蓝牙权限被拒绝。" + }); + wx.showModal({ + title: '提示', + content: '您拒绝了蓝牙权限,将无法连接蓝牙秤。是否前往设置开启?', + confirmText: '去开启', + cancelText: '不开启', + success: (modalRes) => { + if (modalRes.confirm) { + wx.openSetting({ + success: (settingRes) => { + console.log('openSetting success', settingRes); + }, + fail: (settingErr) => { + wx.navigateBack({ + delta: 1 + }); + } + }); + } else { + wx.navigateBack({ + delta: 1 + }); + } + } + }); + } + }); + } + }, + fail: (err) => { + this.setData({ + initText: "获取权限设置失败。" + }); + wx.showToast({ + title: '获取权限设置失败', + icon: 'none' + }); + wx.navigateBack({ + delta: 1 + }); + } + }); + }, + + openBluetoothAdapter() { + this.setData({ + initText: "正在初始化蓝牙..." + }); + wx.openBluetoothAdapter({ + success: () => { + this.setData({ + initText: "蓝牙初始化成功" + }); + this.getDeviceSettingList(); + }, + fail: (err) => { + this.setData({ + initText: "蓝牙初始化失败。" + }); + if (err.errCode === 10001) { + wx.showModal({ + title: "提示", + content: "请确保手机蓝牙已开启。", + showCancel: false, + success: () => { + wx.navigateBack({ + delta: 1 + }); + } + }); + } else if (err.errMsg && err.errMsg.includes('permission denied')) { + wx.showModal({ + title: '提示', + content: '蓝牙权限仍被拒绝,无法使用蓝牙功能。', + showCancel: false, + success: () => { + wx.navigateBack({ + delta: 1 + }); + } + }); + } else { + wx.showToast({ + title: `蓝牙适配器打开失败: ${err.errMsg || err.errCode}`, + icon: 'none', + success: () => { + wx.navigateBack({ + delta: 1 + }); + } + }); + } + }, + }); + }, + + // 获取自己已经配对上的设备 + getDeviceSettingList() { + let params = {}; + $.ajax("weighingScale/list/device", params, "GET", true, "获取设备列表").then((res) => { + this.setData({ + initText: "设备搜索中..." + }) + app.globalData.ppScale.device.list = []; + let seviceList = app.globalData.ppScale.device.setting.find((item) => { + return item.deviceName === res.result[0].type + }); + app.globalData.ppScale.plugin.Blue.setDeviceSetting([seviceList]); + app.globalData.ppScale.plugin.Blue.start(res.result[0].type, false); + app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res_) => { + console.log("searchDevice ===> devicesList", res_); + + let fIndex = res_.findIndex(item => item.deviceId === res.result[0].deviceId); + if (fIndex >= 0) { + app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery(); + this.setData({ + device: res_[fIndex] + }) + app.globalData.ppScale.plugin.Blue.createBLEConnection(res_[fIndex]); + } + }); + }) + }, + + // 点击设备重连 + connectedDevice() { + let device = this.data.device; + if(device) { + ppScale.plugin.Blue.createBLEConnection(device); + } + }, + + // 选择了某个wifi + wifiSSIDChange(e) { + let status = e.detail.status; + if(status) { + this.setData({ + ['wifiInfo.ssid']: e.detail.data.ssid, + progress: this.data.progress + 1 + }) + } + }, + + // 设置wifi密码 + wifiPWDChange(e) { + let status = e.detail.status; + if(status) { + this.setData({ + ['wifiInfo.password']: e.detail.data, + progress: this.data.progress + 1 + }) + } + }, + + wifiSetChange(e) { + let status = e.detail.status; + if(status) { + this.setData({ + progress: this.data.progress + 1 + }) + } else { + this.setData({ + progress: 0 + }) + } + }, + + // 卸载事件监听 + onUnload() { + if (this._connectStateWatcher) { + app.unwatch('ppScale.device.connectState', this._connectStateWatcher); + } + } +}) \ No newline at end of file diff --git a/pages/replaceNetwork/replaceNetwork.json b/pages/replaceNetwork/replaceNetwork.json new file mode 100644 index 0000000..a1738f6 --- /dev/null +++ b/pages/replaceNetwork/replaceNetwork.json @@ -0,0 +1,9 @@ +{ + "usingComponents": { + "replaceNetwork1": "/components/replaceNetwork_1/replaceNetwork_1", + "replaceNetwork2": "/components/replaceNetwork_2/replaceNetwork_2", + "replaceNetwork3": "/components/replaceNetwork_3/replaceNetwork_3", + "replaceNetwork4": "/components/replaceNetwork_4/replaceNetwork_4" + }, + "navigationBarTitleText": "更换Wi-Fi" +} \ No newline at end of file diff --git a/pages/replaceNetwork/replaceNetwork.wxml b/pages/replaceNetwork/replaceNetwork.wxml new file mode 100644 index 0000000..f162e82 --- /dev/null +++ b/pages/replaceNetwork/replaceNetwork.wxml @@ -0,0 +1,33 @@ + + + + 智能蓝牙秤 + 型号:{{device.name}} + + + + + 连接成功 + + + + 连接失败,点击重试 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/replaceNetwork/replaceNetwork.wxss b/pages/replaceNetwork/replaceNetwork.wxss new file mode 100644 index 0000000..35511a6 --- /dev/null +++ b/pages/replaceNetwork/replaceNetwork.wxss @@ -0,0 +1,69 @@ +.replaceNetwork { + width: 100%; + height: 100%; + display: flex; + flex-flow: column; + padding: 24rpx 30rpx; + box-sizing: border-box; +} + +.header { + width: 100%; + display: flex; + flex-wrap: nowrap; + align-items: center; + padding: 30rpx 40rpx; + box-sizing: border-box; + border-radius: 16rpx; + margin-bottom: 24rpx; + background-color: #ffffff; +} + +.header>view:nth-of-type(1) { + flex: 1; +} + +.header>view:nth-of-type(1)>view:nth-of-type(1) { + color: #252535; + height: 32rpx; + font-weight: bold; + font-size: 32rpx; + line-height: 32rpx; + margin-bottom: 16rpx; +} + +.header>view:nth-of-type(1)>view:nth-of-type(2) { + color: #808080; + height: 26rpx; + font-size: 26rpx; + line-height: 26rpx; +} + +.header>view:nth-of-type(2) { + height: 28rpx; + display: flex; + flex-wrap: nowrap; + align-items: center; +} + +.header>view:nth-of-type(2)>view:nth-of-type(1) { + width: 12rpx; + height: 12rpx; + border-radius: 50%; + margin-right: 14rpx; +} + +.header>view:nth-of-type(2)>view:nth-of-type(2) { + height: 28rpx; + font-weight: bold; + font-size: 28rpx; + line-height: 28rpx; +} + + +.section { + flex: 1; + overflow: hidden; + border-radius: 16rpx; + background-color: #ffffff; +} diff --git a/pages/userInfo/userInfo.js b/pages/userInfo/userInfo.js new file mode 100644 index 0000000..d138447 --- /dev/null +++ b/pages/userInfo/userInfo.js @@ -0,0 +1,27 @@ +Page({ + data: { + + }, + + onLoad(options) { + + }, + + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + } +}) \ No newline at end of file diff --git a/pages/userInfo/userInfo.json b/pages/userInfo/userInfo.json new file mode 100644 index 0000000..8c9a940 --- /dev/null +++ b/pages/userInfo/userInfo.json @@ -0,0 +1,5 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "个人信息", + "disableScroll": true +} \ No newline at end of file diff --git a/pages/userInfo/userInfo.wxml b/pages/userInfo/userInfo.wxml new file mode 100644 index 0000000..7199abb --- /dev/null +++ b/pages/userInfo/userInfo.wxml @@ -0,0 +1,71 @@ + + + + + 姓名 + + + + + + 性别 + + + {{sex.index === null ? '请选择性别' : sex.data[sex.index].name}} + + + + + 生日 + + + {{birthday.value ? birthday.label : '请选择生日'}} + + + + + + 手机号 + + + {{phone}} + + + + + + + + + 身高 + + + {{height.index === null ? '请选择身高' : height.data[height.index] + ' cm'}} + + + + + 体重 + + + {{weight.index === null ? '请选择体重' : weight.data[weight.index] + ' kg'}} + + + + + +确定 \ No newline at end of file diff --git a/pages/userInfo/userInfo.wxss b/pages/userInfo/userInfo.wxss new file mode 100644 index 0000000..2d80170 --- /dev/null +++ b/pages/userInfo/userInfo.wxss @@ -0,0 +1,145 @@ +page { + padding: 30rpx 30rpx 0; +} + +.device { + width: 100%; + display: flex; + flex-wrap: nowrap; + align-items: center; + padding: 35rpx 40rpx; + border-radius: 24rpx; + box-sizing: border-box; + margin-bottom: 24rpx; + background-color: #FFFFFF; + justify-content: space-between; +} + +.device>view:nth-of-type(1)>view:nth-of-type(1) { + color: #252535; + height: 32rpx; + font-weight: bold; + font-size: 32rpx; + line-height: 32rpx; + margin-bottom: 22rpx; +} + +.device>view:nth-of-type(1)>view:nth-of-type(2) { + color: #808080; + height: 26rpx; + font-size: 26rpx; + line-height: 26rpx; +} + +.device>view:nth-of-type(2) { + height: 28rpx; + display: flex; + flex-wrap: nowrap; + align-items: center; +} + +.device>view:nth-of-type(2)>view:nth-of-type(1) { + width: 14rpx; + height: 14rpx; + border-radius: 50%; +} + +.device>view:nth-of-type(2)>view:nth-of-type(2) { + height: 28rpx; + font-weight: bold; + font-size: 28rpx; + line-height: 28rpx; + padding-left: 8rpx; +} + +.form { + width: 100%; + padding: 0 30rpx; + border-radius: 16rpx; + box-sizing: border-box; + background-color: #FFFFFF; + margin-bottom: 80rpx; +} + +.form>view { + width: 100%; + height: 120rpx; + padding: 0 10rpx; + display: flex; + flex-wrap: nowrap; + box-sizing: border-box; + border-bottom: 1rpx solid #EAECF1; +} + +.form>view>view:first-of-type { + color: #252535; + height: 120rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 120rpx; +} + +.form>view>view:last-of-type { + flex: 1; + width: 0; + color: #B6B6B6; + font-size: 28rpx; + height: 120rpx; + line-height: 120rpx; + text-align: right; +} + +.form>view>view:last-of-type.arrowAfter { + padding-right: 30rpx; +} + +.form>view>view:last-of-type input { + color: #252535; + width: 100%; + height: 120rpx; + line-height: 120rpx; + text-align: right; +} + +.placeholderClass { + color: #B6B6B6; + font-size: 28rpx; +} + +.form>view { + border-bottom: 0; +} + +.btn { + color: #FFFFFF; + width: 580rpx; + height: 88rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 88rpx; + text-align: center; + border-radius: 44rpx; + margin: 0 auto 50rpx; + background-color: #1385FA; +} + +.tips { + color: #77849E; + width: 100%; + font-size: 26rpx; + line-height: 40rpx; + padding: 0 30rpx; + box-sizing: border-box; +} + +.delBtn { + color: #1385FA; + width: 580rpx; + height: 88rpx; + font-size: 32rpx; + font-weight: bold; + line-height: 88rpx; + text-align: center; + border-radius: 44rpx; + margin: 0 auto; +} \ No newline at end of file