diff --git a/app.json b/app.json
index d00b593..c26a716 100644
--- a/app.json
+++ b/app.json
@@ -42,6 +42,11 @@
"provider": "wx0ffb48417ce6345c"
}
},
+ "permission": {
+ "scope.bluetooth": {
+ "desc": "用于连接体重秤设备"
+ }
+ },
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}
\ No newline at end of file
diff --git a/pages/searchDevice/searchDevice.js b/pages/searchDevice/searchDevice.js
index 731b68c..692d665 100644
--- a/pages/searchDevice/searchDevice.js
+++ b/pages/searchDevice/searchDevice.js
@@ -143,7 +143,7 @@ Page({
app.globalData.ppScale.device.list = this.data.devicesList;
if(this.data.devicesList.length === 1) {
app.globalData.ppScale.device.connection = this.data.devicesList[0];
- wx.navigateTo({
+ wx.redirectTo({
url: "/pages/connectedDevice/connectedDevice"
})
} else {
@@ -153,7 +153,7 @@ Page({
alertText: "请选择你要使用的设备",
success: (res) => {
app.globalData.ppScale.device.connection = this.data.devicesList[res.tapIndex];
- wx.navigateTo({
+ wx.redirectTo({
url: "/pages/connectedDevice/connectedDevice"
})
},
diff --git a/pages/userInfo/userInfo.js b/pages/userInfo/userInfo.js
index a77f3e0..e2aba56 100644
--- a/pages/userInfo/userInfo.js
+++ b/pages/userInfo/userInfo.js
@@ -8,6 +8,8 @@ Page({
initBluetooth: "0",
customerType: "1",
deviceInfo: null,
+ seviceList: [],
+ userInfo: null,
id: "",
realname: "",
@@ -34,6 +36,12 @@ Page({
index: 20,
data: Array.from({ length: 100 - 50 + 1 }, (_, i) => i + 50)
},
+
+ connectedDevice: {
+ code: "",
+ color: "",
+ message: ""
+ }
},
onLoad(options) {
@@ -57,6 +65,7 @@ Page({
if (userInfo && options.initBluetooth === "1") {
let [year, month, day] = userInfo.birthday.split("-");
this.setData({
+ userInfo: userInfo,
realname: userInfo.realname,
["sex.index"]: this.data.sex.data.findIndex(item => {return item.id === userInfo.sex}),
birthday: {
@@ -70,10 +79,17 @@ Page({
}
}
if(options.initBluetooth === "1") {
- this.getDevice();
+ this.initBluetooth();
app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
console.log('userInfo ===》deviceConnect', res);
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#2AC79F",
+ message: "等待设备回应"
+ }
+ })
app.globalData.ppScale.plugin.ScaleAction.startDataProgress();
app.globalData.ppScale.activeProtocol = app.globalData.ppScale.plugin.ScaleAction.getActiveProtocol();
@@ -82,7 +98,12 @@ Page({
console.log("userInfo ===》codeUpdateMTU", res);
this.setData({
- deviceConnect: true
+ deviceConnect: true,
+ connectedDevice: {
+ code: "",
+ color: "#2AC79F",
+ message: "已连接"
+ }
})
});
});
@@ -91,14 +112,28 @@ Page({
// 获取已经绑定的设备列表
getDevice() {
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#808080",
+ message: "获取设备列表"
+ }
+ })
let params = {};
$.ajax("weighingScale/list/device", params, "GET", false).then((res) => {
if(res.result && res.result.length) {
this.setData({
deviceInfo: res.result[0]
})
- this.initBluetooth();
+ this.getDeviceSettingList();
} else {
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#808080",
+ message: "未绑定设备"
+ }
+ })
wx.showModal({
title: "提示",
content: "当前暂未绑定设备,需要绑定吗?",
@@ -121,12 +156,26 @@ Page({
// 初始化蓝牙
initBluetooth() {
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#808080",
+ message: "初始化蓝牙"
+ }
+ })
wx.openBluetoothAdapter({
success: () => {
- this.getDeviceSettingList();
+ this.getDevice();
},
fail: (err) => {
if (err.errCode === 10001) {
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#F24439",
+ message: "初始化蓝牙失败"
+ }
+ })
wx.showModal({
title: "提示",
content: "请打开手机蓝牙",
@@ -137,20 +186,57 @@ Page({
},
getDeviceSettingList() {
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#808080",
+ message: "获取配置信息"
+ }
+ })
let seviceList = [];
app.globalData.ppScale.device.setting.map(item => {
if(this.data.deviceInfo.type === item.deviceName) {
seviceList.push(item);
}
})
+ this.setData({
+ seviceList: seviceList,
+ connectedDevice: {
+ code: "",
+ color: "#2AC79F",
+ message: "配置获取成功"
+ }
+ })
if(seviceList && seviceList.length) {
app.globalData.ppScale.plugin.Blue.setDeviceSetting(seviceList);
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#808080",
+ message: "开始搜索设备"
+ }
+ })
app.globalData.ppScale.plugin.Blue.start(seviceList[0].deviceName, false);
app.globalData.ppScale.plugin.bus.subscribe("devicesList", (res) => {
console.log("deviceInfo ===> devicesList", res);
+
let fIndex = res.findIndex(item => item.deviceId === this.data.deviceInfo.deviceId);
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#808080",
+ message: "设备搜索中"
+ }
+ })
if (fIndex >= 0) {
app.globalData.ppScale.plugin.Blue.stopBluetoothDevicesDiscovery();
+ this.setData({
+ connectedDevice: {
+ code: "",
+ color: "#2AC79F",
+ message: "连接中"
+ }
+ })
app.globalData.ppScale.plugin.Blue.createBLEConnection(res[fIndex]);
return;
}
@@ -239,7 +325,7 @@ Page({
icon: "none",
title: "请靠近设备并点亮后再试"
})
- this.getDeviceSettingList();
+ app.globalData.ppScale.plugin.Blue.start(this.data.seviceList[0].deviceName, false);
return false;
}
if(!realname) {
@@ -323,7 +409,7 @@ Page({
gender: res_.result.sex, //
height: res_.result.height, //
isAthleteMode: 0,
- currentWeight: res_.result.weight, //
+ currentWeight: res_.result.weight, //
deviceHeaderIndex: 0,
targetWeight: "",
idealWeight: "",
@@ -418,8 +504,7 @@ Page({
icon: "none",
title: "删除失败,请靠近设备并点亮后再试"
})
- app.globalData.ppScale.plugin.Blue.stop();
- this.getDeviceSettingList();
+ app.globalData.ppScale.plugin.Blue.start(this.data.seviceList[0].deviceName, false);
}
},
diff --git a/pages/userInfo/userInfo.wxml b/pages/userInfo/userInfo.wxml
index bf1eb72..9f311b6 100644
--- a/pages/userInfo/userInfo.wxml
+++ b/pages/userInfo/userInfo.wxml
@@ -1,4 +1,15 @@
-请填写和完善您家人的健康信息,将用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。我们会严格保护您的家庭信息安全。
+
+
+
+ {{deviceInfo && deviceInfo.equipmentName ? deviceInfo.equipmentName : '获取中...'}}
+ 型号:{{deviceInfo && deviceInfo.type ? deviceInfo.type : '获取中...'}}
+
+
+
+ {{connectedDevice.message}}
+
+
+
@@ -61,6 +72,10 @@
确定
+
+ 请填写和完善您家人的健康信息,将用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。我们会严格保护您的家庭信息安全。
+
+
删除该档案
-
\ No newline at end of file
+
diff --git a/pages/userInfo/userInfo.wxss b/pages/userInfo/userInfo.wxss
index c8823f2..2d80170 100644
--- a/pages/userInfo/userInfo.wxss
+++ b/pages/userInfo/userInfo.wxss
@@ -2,14 +2,54 @@ page {
padding: 30rpx 30rpx 0;
}
-.tips {
- color: #77849E;
+.device {
width: 100%;
- font-size: 26rpx;
- line-height: 40rpx;
- margin-bottom: 40rpx;
- padding: 0 30rpx;
+ 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 {
@@ -83,6 +123,15 @@ page {
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;