diff --git a/images/connectedDevice/device.png b/images/connectedDevice/device.png deleted file mode 100644 index 843faf3..0000000 Binary files a/images/connectedDevice/device.png and /dev/null differ diff --git a/images/deviceInfo/device.png b/images/deviceInfo/device.png deleted file mode 100644 index 6e62bc0..0000000 Binary files a/images/deviceInfo/device.png and /dev/null differ diff --git a/images/devices/CF568_G.png b/images/devices/CF568_G.png new file mode 100644 index 0000000..d4e3516 Binary files /dev/null and b/images/devices/CF568_G.png differ diff --git a/images/devices/CF577.png b/images/devices/CF577.png new file mode 100644 index 0000000..128435b Binary files /dev/null and b/images/devices/CF577.png differ diff --git a/images/devices/CF636_G.png b/images/devices/CF636_G.png new file mode 100644 index 0000000..f77d79f Binary files /dev/null and b/images/devices/CF636_G.png differ diff --git a/pages/connectedDevice/connectedDevice.js b/pages/connectedDevice/connectedDevice.js index 6f23598..026549f 100644 --- a/pages/connectedDevice/connectedDevice.js +++ b/pages/connectedDevice/connectedDevice.js @@ -68,8 +68,12 @@ Page({ }, onShow() { + let token = wx.getStorageSync("token") || null; + let userInfo = wx.getStorageSync("userInfo") || null; let deviceSelect = app.globalData.ppScale.device.connection; this.setData({ + token: token, + userInfo: userInfo, name: deviceSelect.name, deviceSelect: deviceSelect }) @@ -83,6 +87,27 @@ Page({ // 配对 openConnectionSuccessful() { + let token = this.data.token; + let userInfo = this.data.userInfo; + if (token && userInfo) { + this.starConnection(); + } else { + wx.login({ + success: (res) => { + if (res.code) { + this.checkOpenIdLogin(res.code); + } else { + wx.showToast({ + icon: "none", + title: "登录失败,请稍后再试!", + }) + } + } + }) + } + }, + + starConnection() { let deviceSelect = this.data.deviceSelect; if (deviceSelect) { let name = this.data.name; @@ -106,4 +131,16 @@ Page({ }) } }, + + // 微信一键登录 + checkOpenIdLogin(code) { + let params = { + code: code + }; + $.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => { + wx.setStorageSync("userInfo", res.result.user); + wx.setStorageSync("token", res.result.token); + this.starConnection(); + }) + }, }) \ No newline at end of file diff --git a/pages/connectedDevice/connectedDevice.wxml b/pages/connectedDevice/connectedDevice.wxml index 580c8b3..caea25f 100644 --- a/pages/connectedDevice/connectedDevice.wxml +++ b/pages/connectedDevice/connectedDevice.wxml @@ -1,7 +1,9 @@ 型号:{{deviceSelect.name}} - + + + diff --git a/pages/deviceInfo/deviceInfo.js b/pages/deviceInfo/deviceInfo.js index c86a8a4..8dab5d6 100644 --- a/pages/deviceInfo/deviceInfo.js +++ b/pages/deviceInfo/deviceInfo.js @@ -3,7 +3,7 @@ import $ from "../../utils/request"; Page({ data: { - deviceConnect: false, + // deviceConnect: false, deviceInfo: null, }, @@ -11,58 +11,58 @@ Page({ onLoad(options) { this.getDevice(); - app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => { - console.log('deviceInfo ===》deviceConnect', res); + // app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => { + // console.log('deviceInfo ===》deviceConnect', res); - app.globalData.ppScale.plugin.ScaleAction.startDataProgress(); - app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol(); + // app.globalData.ppScale.plugin.ScaleAction.startDataProgress(); + // app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol(); - app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => { - console.log("deviceInfo ===》codeUpdateMTU", res); + // app.globalData.ppScale.activeProtocol.codeUpdateMTU((res) => { + // console.log("deviceInfo ===》codeUpdateMTU", res); - this.setData({ - deviceConnect: true - }) - }); - }); + // this.setData({ + // deviceConnect: true + // }) + // }); + // }); }, // 初始化蓝牙 - initBluetooth() { - wx.openBluetoothAdapter({ - success: () => { - this.getDeviceSettingList(); - }, - fail: (err) => { - if (err.errCode === 10001) { - wx.showModal({ - title: "提示", - content: "请打开手机蓝牙", - }); - } - }, - }); - }, + // initBluetooth() { + // wx.openBluetoothAdapter({ + // success: () => { + // this.getDeviceSettingList(); + // }, + // fail: (err) => { + // if (err.errCode === 10001) { + // wx.showModal({ + // title: "提示", + // content: "请打开手机蓝牙", + // }); + // } + // }, + // }); + // }, - getDeviceSettingList() { - let seviceList = []; - app.globalData.ppScale.device.setting.map(item => { - if(this.data.deviceInfo.type === item.deviceName) { - seviceList.push(item); - } - }) - if(seviceList && seviceList.length) { - app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList); - app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false); - app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => { - let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId); - if (fIndex > -1) { - app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery(); - app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]); - } - }); - } - }, + // getDeviceSettingList() { + // let seviceList = []; + // app.globalData.ppScale.device.setting.map(item => { + // if(this.data.deviceInfo.type === item.deviceName) { + // seviceList.push(item); + // } + // }) + // if(seviceList && seviceList.length) { + // app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList); + // app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false); + // app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => { + // let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId); + // if (fIndex > -1) { + // app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery(); + // app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]); + // } + // }); + // } + // }, // 获取已经绑定的设备列表 getDevice() { @@ -71,14 +71,14 @@ Page({ this.setData({ deviceInfo: res.result[0] }) - this.initBluetooth(); + // this.initBluetooth(); }) }, delDevice() { - if(this.data.deviceConnect) { - app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => { - console.log("deviceInfo === codeClearDeviceData", res); + // if(this.data.deviceConnect) { + // app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => { + // console.log("deviceInfo === codeClearDeviceData", res); let scaleDeviceId = this.data.deviceInfo.macAddress.replace(/:/g, ''); let params = { @@ -95,18 +95,18 @@ Page({ }) }, 1500); }); - }) - } else { - wx.showToast({ - icon: "none", - title: "删除失败,请靠近设备并点亮后再试" - }) - app.globalData.ppScale.plugin.Blue.stop(); - this.getDeviceSettingList(); - } + // }) + // } else { + // wx.showToast({ + // icon: "none", + // title: "删除失败,请靠近设备并点亮后再试" + // }) + // app.globalData.ppScale.plugin.Blue.stop(); + // this.getDeviceSettingList(); + // } }, - onUnload() { - app.globalData.ppScale.plugin.Blue.stop(); - } + // onUnload() { + // app.globalData.ppScale.plugin.Blue.stop(); + // } }) \ No newline at end of file diff --git a/pages/deviceInfo/deviceInfo.wxml b/pages/deviceInfo/deviceInfo.wxml index 0f666ca..0e35bb0 100644 --- a/pages/deviceInfo/deviceInfo.wxml +++ b/pages/deviceInfo/deviceInfo.wxml @@ -1,6 +1,8 @@ - + + + {{deviceInfo.equipmentName}} @@ -18,8 +20,8 @@ {{deviceInfo.equipmentCode}} - 配置Wi-Fi - {{deviceInfo.wifiName}} + Wi-Fi名称 + {{deviceInfo.wifiName}} 成员 diff --git a/pages/home/home.js b/pages/home/home.js index 522b94f..a043385 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -76,17 +76,23 @@ Page({ // 添加设备 openSearchDevice() { - let token = this.data.token; - let userInfo = this.data.userInfo; - if (token && userInfo) { + // let token = this.data.token; + // let userInfo = this.data.userInfo; + // if (token && userInfo) { wx.navigateTo({ url: "/pages/searchDevice/searchDevice" }) - } else { - wx.showToast({ - icon: "none", - title: "请先登录" - }) - } + // } else { + // wx.showToast({ + // icon: "none", + // title: "请先登录" + // }) + // } + }, + + openDeviceInfo() { + wx.navigateTo({ + url: "/pages/deviceInfo/deviceInfo" + }) } }) \ No newline at end of file diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 0acabd7..5f4c38d 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -6,12 +6,7 @@ - - - - - - + {{userInfo.realname}} @@ -24,14 +19,24 @@ 注重更好的健康生活品质 - - 请添加设备 - 添加设备后,解锁更多体验 - - 添加设备 - - - 登录/注册 - - + + + + + + 设备名称:{{deviceList[0].equipmentName}} + + + + + 请添加设备 + 添加设备后,解锁更多体验 + + 添加设备 + + + \ No newline at end of file diff --git a/pages/home/home.wxss b/pages/home/home.wxss index 209f8f8..e19e4db 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -80,11 +80,31 @@ } .device { + width: 100%; +} + +.device>view:nth-of-type(1) { + width: 500rpx; + height: 500rpx; + margin: 0 auto; +} + +.device>view:nth-of-type(2) { + color: #ffffff; + width: 100%; + height: 32rpx; + font-weight: bold; + font-size: 32rpx; + line-height: 32rpx; + text-align: center; +} + +.addDevice { width: 580rpx; margin: 0 auto; } -.device>view:nth-of-type(1) { +.addDevice>view:nth-of-type(1) { color: #FFFFFF; width: 100%; height: 36rpx; @@ -95,7 +115,7 @@ margin-bottom: 30rpx; } -.device>view:nth-of-type(2) { +.addDevice>view:nth-of-type(2) { color: #FFFFFF; width: 100%; height: 30rpx; @@ -105,7 +125,7 @@ margin-bottom: 80rpx; } -.device>view:nth-of-type(3) { +.addDevice>view:nth-of-type(3) { color: #FFFFFF; width: 100%; height: 106rpx; diff --git a/pages/searchDevice/searchDevice.wxml b/pages/searchDevice/searchDevice.wxml index 7f5db43..0a6d437 100644 --- a/pages/searchDevice/searchDevice.wxml +++ b/pages/searchDevice/searchDevice.wxml @@ -9,8 +9,4 @@ {{initText}} 请轻轻踩秤,保证屏幕亮起 - - - - {{item.name}} - \ No newline at end of file + \ No newline at end of file diff --git a/pages/setWifiPassword/setWifiPassword.js b/pages/setWifiPassword/setWifiPassword.js index 895e02d..ce940f2 100644 --- a/pages/setWifiPassword/setWifiPassword.js +++ b/pages/setWifiPassword/setWifiPassword.js @@ -2,8 +2,10 @@ const app = getApp(); Page({ data: { + type: true, + wifiInfo: null, - password: "mimahaojige8" + password: "" }, onLoad(options) { @@ -18,6 +20,12 @@ Page({ }) }, + inputTypeChange() { + this.setData({ + type: !this.data.type + }) + }, + // 打开配网 openSetNetwork() { wx.navigateTo({ diff --git a/pages/setWifiPassword/setWifiPassword.wxml b/pages/setWifiPassword/setWifiPassword.wxml index 4ca529d..536fe6d 100644 --- a/pages/setWifiPassword/setWifiPassword.wxml +++ b/pages/setWifiPassword/setWifiPassword.wxml @@ -9,13 +9,13 @@ 密码 - +