diff --git a/app.js b/app.js
index d382745..ef920a8 100644
--- a/app.js
+++ b/app.js
@@ -5,8 +5,8 @@ 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.209:8889/",
// 秤的所有信息
ppScale: {
diff --git a/app.json b/app.json
index c0a4fb5..0207532 100644
--- a/app.json
+++ b/app.json
@@ -2,11 +2,8 @@
"pages": [
"pages/home/home",
"pages/searchDevice/searchDevice",
- "pages/configureDevice/configureDevice",
- "pages/my/my",
- "pages/userInfo/userInfo",
- "pages/deviceInfo/deviceInfo",
- "pages/replaceNetwork/replaceNetwork"
+ "pages/configureDevice/configureDevice",
+ "pages/my/my"
],
"window": {
"navigationBarTitleText": "",
@@ -15,35 +12,38 @@
},
"tabBar": {
"color": "#808080",
- "selectedColor": "#1385FA",
- "borderStyle": "white",
- "list": [{
- "pagePath": "pages/home/home",
- "iconPath": "/images/tabBar/home.png",
- "selectedIconPath": "/images/tabBar/home_.png",
- "text": "首页"
- }, {
- "pagePath": "pages/my/my",
- "iconPath": "/images/tabBar/my.png",
- "selectedIconPath": "/images/tabBar/my_.png",
- "text": "我的"
- }]
+ "selectedColor": "#1385FA",
+ "borderStyle": "white",
+ "list": [
+ {
+ "pagePath": "pages/home/home",
+ "iconPath": "/images/tabBar/home.png",
+ "selectedIconPath": "/images/tabBar/home_.png",
+ "text": "首页"
+ },
+ {
+ "pagePath": "pages/my/my",
+ "iconPath": "/images/tabBar/my.png",
+ "selectedIconPath": "/images/tabBar/my_.png",
+ "text": "我的"
+ }
+ ]
},
"style": "v2",
- "plugins": {
- "ppScale-plugin": {
- "version": "1.2.19",
- "provider": "wx0ffb48417ce6345c"
- }
- },
- "permission": {
- "scope.userLocation": {
- "desc": "您的位置信息将用于发现附近的蓝牙设备,以便连接蓝牙秤。"
- }
- },
- "requiredPrivateInfos": [
- "getLocation"
- ],
+ "plugins": {
+ "ppScale-plugin": {
+ "version": "1.2.19",
+ "provider": "wx0ffb48417ce6345c"
+ }
+ },
+ "permission": {
+ "scope.userLocation": {
+ "desc": "您的位置信息将用于发现附近的蓝牙设备,以便连接蓝牙秤。"
+ }
+ },
+ "requiredPrivateInfos": [
+ "getLocation"
+ ],
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}
\ No newline at end of file
diff --git a/components/configureDevice_2/configureDevice_2.js b/components/configureDevice_2/configureDevice_2.js
index e2468f5..3cc412b 100644
--- a/components/configureDevice_2/configureDevice_2.js
+++ b/components/configureDevice_2/configureDevice_2.js
@@ -6,31 +6,7 @@ Component({
BLUE_STATE: {},
device: null,
connectState: "",
-
- userId: "",
- realname: "",
- sex: {
- index: "",
- data: [{
- id: 1,
- name: '男'
- }, {
- id: 2,
- name: '女'
- }]
- },
- birthday: {
- label: "1980年01月01日",
- value: "1980-01-01"
- },
- height: {
- index: 50,
- data: Array.from({ length: 200 - 120 + 1 }, (_, i) => i + 120)
- },
- weight: {
- index: [60, 0],
- data: [Array.from({ length: 120 + 1 }, (_, i) => i + 10), Array.from({ length: 10 }, (_, i) => i)]
- },
+ userList: [],
},
// 存储回调函数的引用,以便在 detached 时取消监听
@@ -52,31 +28,7 @@ Component({
};
app.watch('ppScale.device.connectState', this._connectStateWatcher);
- let userInfo = wx.getStorageSync("userInfo") || null;
- if(userInfo) {
- let [year, month, day] = userInfo.birthday.split("-");
-
- this.setData({
- userId: userInfo.userId,
- realname: userInfo.realname,
- ["sex.index"]: this.data.sex.data.findIndex(item => {return item.id === userInfo.sex}),
- birthday: {
- label: year + "年" + month + "月" + day + "日",
- value: userInfo.birthday
- },
- ["height.index"]: this.data.height.data.findIndex(item => {return item === userInfo.height}),
- })
-
- if(userInfo.weight) {
- const integerPart = Math.floor(userInfo.weight);
- const decimalPart = Math.round((userInfo.weight - integerPart) * 10);
- const integerIndex = this.data.weight.data[0].indexOf(integerPart);
- const decimalIndex = this.data.weight.data[1].indexOf(decimalPart);
- this.setData({
- ["weight.index"]: [integerIndex !== -1 ? integerIndex : null, decimalIndex !== -1 ? decimalIndex : null],
- })
- }
- }
+ this.fetchUserList();
},
detached() {
// 4. 在组件销毁时取消监听,防止内存泄漏
@@ -96,204 +48,136 @@ Component({
});
},
- // 姓名输入
- realnameInput(e) {
- let realname = e.detail.value.replace(/\s+/g, '');
- this.setData({
- realname: realname
+ addUser() {
+ this.selectComponent("#configureDevice2AddUser").showModal();
+ },
+
+ getAddUserInfo() {
+ this.fetchUserList();
+ },
+
+ // 获取设备绑定的用户列表
+ fetchUserList() {
+ let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
+ $.ajax("weighingScale/v2/select/user", { sn }, "GET", true, "正在获取用户列表...").then(res => {
+ if (res.result && res.result.length) {
+ this.setData({ userList: res.result });
+ } else {
+ this.setData({ userList: [] });
+ }
+ }).catch(() => {
+ wx.showToast({
+ title: "用户列表获取失败",
+ icon: "none"
+ })
})
},
- // 性别选择
- sexChange(e) {
- let sex = e.detail.value;
- console.log(sex);
- this.setData({
- ['sex.index']: e.detail.value
- })
- if(this.data.height.index === null) {
- this.setData({
- ['height.index']: sex == 0 ? 50 : 40
- })
- }
- if(this.data.weight.index === null) {
- this.setData({
- ['weight.index']: sex == 0 ? 20 : 10
- })
- }
- },
-
- // 生日选择
- birthdayChange(e) {
- let v = e.detail.value;
- let [year, month, day] = v.split("-");
- this.setData({
- birthday: {
- label: year + "年" + month + "月" + day + "日",
- value: v
+ // 删除用户
+ delUserClick(e) {
+ let id = e.currentTarget.dataset.id;
+ wx.showModal({
+ title: "提示",
+ content: "确定要删除该用户吗?",
+ success: (res) => {
+ if (res.confirm) {
+ $.ajax("weighingScale/v2/del/user", { id }, "DELETE", true, "正在删除...").then(() => {
+ wx.showToast({
+ title: "删除成功",
+ icon: "success"
+ })
+ this.fetchUserList();
+ }).catch(() => {
+ wx.showToast({
+ title: "删除失败,请重试",
+ icon: "none"
+ })
+ })
+ }
}
})
},
-
- // 身高选择
- heightChange(e) {
- this.setData({
- ['height.index']: e.detail.value
- })
- },
-
- // 体重选择
- weightChange(e) {
- console.log(e.detail.value)
- this.setData({
- ['weight.index']: e.detail.value
- })
- },
setUserInfo() {
- // app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
- // console.log("deviceInfo === codeClearDeviceData", res);
- // })
+ if (this.data.connectState != this.data.BLUE_STATE.CONNECTSUCCESS && this.data.connectState != this.data.BLUE_STATE.WIFISUCCESS) {
+ wx.showToast({
+ title: "设备连接失败,请重试。",
+ icon: "none"
+ })
+ return;
+ }
- if(this.data.connectState == this.data.BLUE_STATE.CONNECTSUCCESS || this.data.connectState == this.data.BLUE_STATE.WIFISUCCESS) {
- if(this.data.userId) {
+ let userList = this.data.userList;
+ if (!userList.length) {
+ wx.showToast({
+ title: "暂无用户信息,请先添加用户",
+ icon: "none"
+ })
+ return;
+ }
+
+ // 先获取设备端已有用户,只下发新用户
+ wx.showLoading({ title: "正在下发用户信息...", mask: true });
+ app.globalData.ppScale.activeProtocol.dataFetchUserID((deviceUserIds) => {
+ console.log("设备端已有用户ID列表", deviceUserIds);
+ let existIds = Array.isArray(deviceUserIds) ? deviceUserIds : [];
+ let needSyncList = userList.filter(user => !existIds.includes(user.userId));
+
+ if (!needSyncList.length) {
+ wx.hideLoading();
+ wx.showToast({
+ title: "用户信息已同步",
+ icon: "success"
+ })
+ setTimeout(() => {
+ this.triggerEvent('deviceEvent', { status: true });
+ }, 1500)
+ return;
+ }
+
+ let index = 0;
+ const syncNext = () => {
+ if (index >= needSyncList.length) {
+ wx.hideLoading();
+ wx.showToast({
+ title: "用户信息下发成功",
+ icon: "success"
+ })
+ setTimeout(() => {
+ this.triggerEvent('deviceEvent', { status: true });
+ }, 1500)
+ return;
+ }
+ let user = needSyncList[index];
app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
- userID: this.data.userId,
- userName: this.data.realname,
+ userID: user.userId,
+ userName: user.realname,
memberID: "",
- age: this.getAge(this.data.birthday.value),
- gender: this.data.sex.data[this.data.sex.index].id,
- height: this.data.height.data[this.data.height.index],
+ age: user.age,
+ gender: user.sex,
+ height: user.height,
isAthleteMode: 0,
- currentWeight: this.data.weight.data[0][this.data.weight.index[0]] + '.' + this.data.weight.data[1][this.data.weight.index[1]],
- deviceHeaderIndex: 0,
+ currentWeight: String(user.weight),
+ deviceHeaderIndex: index,
targetWeight: "",
idealWeight: "",
recentData: [],
}, (res) => {
- if(res == 0) {
- this.triggerEvent('deviceEvent', {
- status: true
- });
+ if (res == 0) {
+ index++;
+ syncNext();
} else {
- console.log("dataSyncUserInfo", res)
+ wx.hideLoading();
+ console.log("dataSyncUserInfo", res);
wx.showToast({
title: "用户信息下发失败,请重试。",
icon: "none"
})
}
})
- } else {
- let realname = this.data.realname;
- let sex = this.data.sex;
- let birthday = this.data.birthday;
- let height = this.data.height;
- let weight = this.data.weight;
- if(!realname) {
- wx.showToast({
- icon: "none",
- title: "姓名不能为空"
- })
- return false;
- }
- if(sex.index === "") {
- wx.showToast({
- icon: "none",
- title: "性别不能为空"
- })
- return false;
- }
- if(!birthday.value) {
- wx.showToast({
- icon: "none",
- title: "生日不能为空"
- })
- return false;
- }
- if(height.index === "") {
- wx.showToast({
- icon: "none",
- title: "身高不能为空"
- })
- return false;
- }
- if(weight.index[0] === null && weight.index[1] === null) {
- console.log(weight)
- wx.showToast({
- icon: "none",
- title: "体重不能为空"
- })
- return false;
- }
- let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
- $.ajax("weighingScale/edit/user", {
- sn: sn,
- realname: realname,
- sex: sex.data[sex.index].id,
- birthday: birthday.value,
- height: height.data[height.index],
- weight: weight.data[0][weight.index[0]] + '.' + weight.data[1][weight.index[1]]
- }, "POST", true, "保存中...").then(res => {
- $.ajax("weighingScale/select/user", {
- sn: sn
- }, "GET", true, "更新用户信息中...").then(res_ => {
- wx.setStorageSync("userInfo", res_.result);
- wx.showToast({
- icon: "none",
- title: res.message
- })
- app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
- userID: res_.result.userId,
- userName: res_.result.realname,
- memberID: "",
- age: this.getAge(res_.result.birthday), //
- gender: res_.result.sex, //
- height: res_.result.height, //
- isAthleteMode: 0,
- currentWeight: res_.result.weight, //
- deviceHeaderIndex: 0,
- targetWeight: "",
- idealWeight: "",
- recentData: [],
- }, (res) => {
- if(res == 0) {
- this.triggerEvent('deviceEvent', {
- status: true
- });
- } else {
- console.log("dataSyncUserInfo", res)
- wx.showToast({
- title: "用户信息下发失败,请重试。",
- icon: "none"
- })
- }
- })
- })
- })
- }
- } else {
- wx.showToast({
- title: "设备连接失败,请重试。",
- icon: "none"
- })
- }
- },
-
- // 根据生日获取年龄
- getAge(birthDateString) {
- const birthDate = new Date(birthDateString);
- const today = new Date();
-
- let age = today.getFullYear() - birthDate.getFullYear();
- const monthDiff = today.getMonth() - birthDate.getMonth();
- const dayDiff = today.getDate() - birthDate.getDate();
-
- // 如果当前月份小于出生月份,或者同月但当前日期小于出生日期,年龄需要减 1
- if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
- age--;
- }
-
- return age;
+ };
+ syncNext();
+ });
},
}
});
\ No newline at end of file
diff --git a/components/configureDevice_2/configureDevice_2.json b/components/configureDevice_2/configureDevice_2.json
index 62389a9..8d3db77 100644
--- a/components/configureDevice_2/configureDevice_2.json
+++ b/components/configureDevice_2/configureDevice_2.json
@@ -1,4 +1,6 @@
{
"component": true,
- "usingComponents": {}
+ "usingComponents": {
+ "configureDevice_2_addUser": "/components/configureDevice_2_addUser/configureDevice_2_addUser"
+ }
}
\ No newline at end of file
diff --git a/components/configureDevice_2/configureDevice_2.wxml b/components/configureDevice_2/configureDevice_2.wxml
index 5cfb5d8..3dc4153 100644
--- a/components/configureDevice_2/configureDevice_2.wxml
+++ b/components/configureDevice_2/configureDevice_2.wxml
@@ -33,111 +33,38 @@
-
- 姓名
-
- {{realname}}
-
-
-
-
-
-
-
-
-
-
- 性别
-
- {{sex.data[sex.index].name}}
-
-
-
-
-
-
- 请选择您的性别
-
-
- {{sex.data[sex.index].name}}
-
-
-
-
-
-
-
- 生日
-
- {{birthday.label}}
-
-
-
-
-
-
- 请选择您的生日
-
-
- {{birthday.label}}
-
-
-
-
-
-
-
- 身高
-
- {{height.data[height.index]}}cm
-
-
-
-
-
-
- 请选择您的身高
-
-
- {{height.data[height.index]}}
-
-
-
- cm
-
-
-
-
- 体重
-
- {{weight.data[0][weight.index[0]]}}.{{weight.data[1][weight.index[1]]}}kg
-
-
-
-
-
-
- {{weight.data[0][weight.index[0]]}}.{{weight.data[1][weight.index[1]]}}
-
-
- 请选择您的体重
-
-
-
- kg
-
-
-
+
+
+
+
+
+
+
+ {{item.realname}}
+
+
+ {{item.age}}
+
+
+
+ 身高:{{item.height}}cm
+
+ 体重:{{item.weight}}kg
+
+
+ -
+
+
+
+
+ 添加用户
下一步
- 请认真填写和完善您家人的健康信息,用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。(填写数据同时,踩亮蓝牙秤并与其保持连接)。
+
+ 请认真填写和完善员工健康信息,用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。(填写数据同时,踩亮蓝牙称并与其保持连接)。
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/components/configureDevice_2/configureDevice_2.wxss b/components/configureDevice_2/configureDevice_2.wxss
index e667c6a..89de309 100644
--- a/components/configureDevice_2/configureDevice_2.wxss
+++ b/components/configureDevice_2/configureDevice_2.wxss
@@ -24,6 +24,8 @@ input {
.configureDevice2 {
width: 100%;
height: 100%;
+ display: flex;
+ flex-flow: column;
}
.header {
@@ -78,72 +80,168 @@ input {
}
.section {
+ flex: 1;
+ overflow: hidden;
width: 100%;
- padding: 0 30rpx;
- box-sizing: border-box;
+ display: flex;
+ flex-flow: column;
}
.from {
width: 100%;
- margin-bottom: 66rpx;
-}
-
-.from>view {
- width: 100%;
- padding: 48rpx 10rpx 0;
- box-sizing: border-box;
- border-bottom: 1rpx solid #EAECF1;
-}
-
-.from>view>view:nth-of-type(1) {
- color: #252535;
- height: 32rpx;
- font-size: 32rpx;
- font-weight: bold;
- line-height: 32rpx;
- margin-bottom: 18rpx;
-}
-
-.from>view>view:nth-of-type(2) {
- width: 100%;
- height: 58rpx;
- display: flex;
- flex-wrap: nowrap;
- padding-right: 26rpx;
- box-sizing: border-box;
-}
-
-.from>view>view:nth-of-type(2)>view:nth-of-type(1) {
+ padding: 24rpx 0;
flex: 1;
- width: 0;
+ overflow: hidden;
}
-.from>view>view:nth-of-type(2)>view:nth-of-type(2) {
- color: #77849E;
- height: 58rpx;
- font-size: 28rpx;
- font-weight: bold;
- line-height: 58rpx;
+.scrollViewContent {
+ width: 100%;
+ padding: 0 30rpx;
+ box-sizing: border-box;
}
+.userList {
+ width: 100%;
+ height: 162rpx;
+ border-radius: 16px;
+ padding: 0 30rpx;
+ display: flex;
+ flex-wrap: nowrap;
+ align-items: center;
+ box-sizing: border-box;
+ margin-bottom: 24rpx;
+ border: 1rpx solid #E6E6EA;
+}
+
+.userAvatar {
+ width: 90rpx;
+ height: 90rpx;
+ border-radius: 50%;
+ margin-right: 24rpx;
+ border: 2rpx solid #FF8FB5;
+}
+
+.userInfo {
+ flex: 1;
+}
+
+.userInfo_1 {
+ width: 100%;
+ height: 32rpx;
+ display: flex;
+ flex-wrap: nowrap;
+ align-items: center;
+ margin-bottom: 20rpx;
+}
+
+.userInfo_1>view:nth-of-type(1) {
+ color: #333333;
+ font-size: 30rpx;
+ height: 32rpx;
+ font-weight: bold;
+ line-height: 32rpx;
+ margin-right: 20rpx;
+}
+
+.userInfo_1>view:nth-of-type(2) {
+ height: 32rpx;
+ display: flex;
+ flex-wrap: nowrap;
+ align-items: center;
+ padding: 0 8rpx;
+ border-radius: 8rpx;
+}
+
+.userInfo_1 .man {
+ background: linear-gradient(90deg, #54D9FC 0%, #6FC1FB 100%);
+}
+
+.userInfo_1 .woman {
+ background: linear-gradient(90deg, #FF91B6 0%, #FD6C9D 100%);
+}
+
+.userInfo_1>view:nth-of-type(2)>view:nth-of-type(1) {
+ width: 20rpx;
+ height: 20rpx;
+ margin-right: 4rpx;
+}
+
+.userInfo_1>view:nth-of-type(2)>view:nth-of-type(2) {
+ color: #FFFFFF;
+ height: 32rpx;
+ font-weight: bold;
+ font-size: 22rpx;
+ line-height: 32rpx;
+}
+
+.userInfo_2 {
+ width: 100%;
+ height: 26rpx;
+ display: flex;
+ align-items: center;
+ flex-wrap: nowrap;
+}
+
+.userInfo_2>view {
+ color: #77849E;
+ height: 26rpx;
+ font-size: 26rpx;
+ line-height: 26rpx;
+}
+
+.userInfo_2>view:nth-of-type(2) {
+ margin: 0 20rpx;
+ width: 4rpx;
+ height: 24rpx;
+ border-radius: 1rpx;
+ background-color: #EAECF1;
+}
+
+.delUser {
+ color: #FFFFFF;
+ width: 40rpx;
+ height: 40rpx;
+ font-size: 36rpx;
+ font-weight: bold;
+ line-height: 34rpx;
+ text-align: center;
+ border-radius: 50%;
+ background-color: #F24439;
+}
.btn {
width: 100%;
- padding: 0 26rpx;
+ padding: 0 55rpx;
box-sizing: border-box;
}
-.btn>view {
+.btn>view:nth-of-type(1) {
+ color: #1385FA;
+ width: 100%;
+ height: 88rpx;
+ font-size: 32rpx;
+ font-weight: bold;
+ text-align: center;
+ line-height: 86rpx;
+ border-radius: 44rpx;
+ margin-bottom: 40rpx;
+ box-sizing: border-box;
+ border: 1px solid #1385FA;
+}
+
+.btn>view:nth-of-type(2) {
color: #FFFFFF;
width: 100%;
height: 88rpx;
font-size: 32rpx;
font-weight: bold;
text-align: center;
- line-height: 88rpx;
+ line-height: 86rpx;
border-radius: 44rpx;
margin-bottom: 40rpx;
+ box-sizing: border-box;
background-color: #1385FA;
+ border: 1px solid #1385FA;
}
.describe {
@@ -151,6 +249,8 @@ input {
width: 100%;
font-size: 24rpx;
line-height: 40rpx;
+ padding: 0 30rpx 20rpx;
+ box-sizing: border-box;
}
.describe text {
diff --git a/components/configureDevice_2_addUser/configureDevice_2_addUser.js b/components/configureDevice_2_addUser/configureDevice_2_addUser.js
new file mode 100644
index 0000000..59f3666
--- /dev/null
+++ b/components/configureDevice_2_addUser/configureDevice_2_addUser.js
@@ -0,0 +1,145 @@
+import $ from "../../utils/request";
+const app = getApp();
+
+Component({
+ properties: {
+
+ },
+ data: {
+ animationData: null,
+ modalStatus: false,
+ workNo: "",
+ userInfo: null,
+ },
+ lifetimes: {
+ // 在组件实例进入页面节点树时执行
+ attached() {
+
+ },
+
+ // 在组件实例被从页面节点树移除时执行
+ detached() {
+
+ },
+ },
+ methods: {
+ // 显示对话框
+ showModal() {
+ // 显示遮罩层
+ let animation = wx.createAnimation({
+ duration: 200,
+ timingFunction: "linear",
+ delay: 0
+ })
+ this.animation = animation;
+ animation.translateY(1100).step();
+ this.setData({
+ animationData: animation.export(),
+ modalStatus: true
+ })
+ setTimeout(() => {
+ animation.translateY(0).step();
+ this.setData({
+ animationData: animation.export()
+ })
+ }, 200);
+ },
+
+ //隐藏对话框
+ hideModal() {
+ // 隐藏遮罩层
+ let animation = wx.createAnimation({
+ duration: 200,
+ timingFunction: "linear",
+ delay: 0
+ })
+ this.animation = animation;
+ animation.translateY(1100).step();
+ this.setData({
+ animationData: animation.export(),
+ })
+ setTimeout(() => {
+ animation.translateY(0).step();
+ this.setData({
+ animationData: animation.export(),
+ modalStatus: false
+ })
+ }, 200);
+ },
+
+ // 关闭弹窗并重置数据
+ closeModal() {
+ this.setData({
+ workNo: "",
+ userInfo: null,
+ });
+ this.hideModal();
+ },
+
+ // 监听工号输入
+ onWorkNoInput(e) {
+ this.setData({ workNo: e.detail.value });
+ },
+
+ // 根据工号查询用户信息
+ searchUser() {
+ let workNo = this.data.workNo.trim();
+ if (!workNo) {
+ wx.showToast({
+ title: "请输入工号",
+ icon: "none"
+ })
+ return;
+ }
+ $.ajax("weighingScale/v2/getUserInfoByWkno", { workNo }, "GET", true, "正在查询...").then(res => {
+ if (res.result) {
+ this.setData({ userInfo: res.result });
+ } else {
+ this.setData({ userInfo: null });
+ wx.showToast({
+ title: "未查询到该工号的用户信息",
+ icon: "none"
+ })
+ }
+ }).catch(() => {
+ wx.showToast({
+ title: "查询失败,请重试",
+ icon: "none"
+ })
+ })
+ },
+
+ // 确定提交
+ submit() {
+ if (!this.data.userInfo) {
+ wx.showToast({
+ title: "请先查询用户信息",
+ icon: "none"
+ })
+ return;
+ }
+ let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
+ let user = this.data.userInfo;
+ $.ajax("weighingScale/v2/edit/user", {
+ sn,
+ realname: user.realname,
+ sex: user.sex,
+ birthday: user.birthday,
+ height: user.height,
+ weight: user.weight
+ }, "POST", true, "正在添加...").then(res => {
+ wx.showToast({
+ title: "添加成功",
+ icon: "success"
+ })
+ this.triggerEvent('returnDate', { userInfo: user });
+ this.closeModal();
+ }).catch(() => {
+ wx.showToast({
+ title: "添加失败,请重试",
+ icon: "none"
+ })
+ })
+ }
+ }
+});
\ No newline at end of file
diff --git a/components/configureDevice_2_addUser/configureDevice_2_addUser.json b/components/configureDevice_2_addUser/configureDevice_2_addUser.json
new file mode 100644
index 0000000..fba482a
--- /dev/null
+++ b/components/configureDevice_2_addUser/configureDevice_2_addUser.json
@@ -0,0 +1,3 @@
+{
+ "component": true
+}
\ No newline at end of file
diff --git a/components/configureDevice_2_addUser/configureDevice_2_addUser.wxml b/components/configureDevice_2_addUser/configureDevice_2_addUser.wxml
new file mode 100644
index 0000000..740f7d0
--- /dev/null
+++ b/components/configureDevice_2_addUser/configureDevice_2_addUser.wxml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+ 工号:
+
+
+
+
+
+
+ 姓名:
+
+ {{userInfo.realname || ''}}
+
+
+
+
+ 性别:
+
+ {{userInfo.sex === 1 ? '男' : userInfo.sex === 2 ? '女' : ''}}
+
+
+
+
+ 生日:
+
+ {{userInfo.birthday || ''}}
+
+
+
+
+ 身高:
+
+ {{userInfo.height || ''}}
+ cm
+
+
+
+ 体重:
+
+ {{userInfo.weight || ''}}
+ kg
+
+
+
+
+
\ No newline at end of file
diff --git a/components/configureDevice_2_addUser/configureDevice_2_addUser.wxss b/components/configureDevice_2_addUser/configureDevice_2_addUser.wxss
new file mode 100644
index 0000000..744313e
--- /dev/null
+++ b/components/configureDevice_2_addUser/configureDevice_2_addUser.wxss
@@ -0,0 +1,172 @@
+.modalBg {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: #000;
+ opacity: 0.2;
+ overflow: hidden;
+ z-index: 10;
+}
+
+.modal {
+ height: 1100rpx;
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ z-index: 11;
+ display: flex;
+ flex-flow: column;
+ overflow: hidden;
+ background-color: #ffffff;
+ border-radius: 30rpx 30rpx 0 0;
+}
+
+.header {
+ height: 150rpx;
+ width: 100%;
+ padding-top: 30rpx;
+ box-sizing: border-box;
+}
+
+.header>view:nth-of-type(1) {
+ width: 72rpx;
+ height: 6rpx;
+ border-radius: 3rpx;
+ margin: 0 auto 40rpx;
+ background-color: #77849E;
+}
+
+.header>view:nth-of-type(2) {
+ color: #252535;
+ height: 32rpx;
+ font-size: 32rpx;
+ font-weight: bold;
+ line-height: 32rpx;
+ text-align: center;
+}
+
+.seaction {
+ flex: 1;
+ padding: 0 30rpx;
+ overflow: hidden;
+}
+
+.only,
+.input {
+ width: 100%;
+ height: 104rpx;
+ display: flex;
+ flex-wrap: nowrap;
+ margin-bottom: 32rpx;
+}
+
+.only>view:nth-of-type(1),
+.input>view:nth-of-type(1) {
+ color: #333333;
+ height: 104rpx;
+ font-size: 32rpx;
+ line-height: 104rpx;
+}
+
+.only>view:nth-of-type(2) {
+ flex: 1;
+ width: 0;
+ height: 104rpx;
+ padding: 0 30rpx;
+ border-radius: 16rpx;
+ display: flex;
+ flex-wrap: nowrap;
+ align-items: center;
+ background-color: #F5F7FB;
+ border: 1rpx solid #E6E6EA;
+}
+
+.only>view:nth-of-type(2)>view:nth-of-type(1) {
+ flex: 1;
+ width: 0;
+ color: #252535;
+ font-size: 32rpx;
+ font-weight: 500;
+ height: 100rpx;
+ line-height: 100rpx;
+}
+
+.only>view:nth-of-type(2)>view:nth-of-type(2) {
+ color: #77849E;
+ height: 28rpx;
+ font-size: 28rpx;
+ line-height: 28rpx;
+}
+
+.input>view:nth-of-type(2) {
+ flex: 1;
+ width: 0;
+ height: 104rpx;
+ padding: 0 30rpx;
+ border-radius: 16rpx;
+ border: 1rpx solid #E6E6EA;
+}
+
+.input>view:nth-of-type(2) input {
+ width: 100%;
+ height: 100%;
+ color: #252535;
+ font-size: 32rpx;
+ font-weight: 500;
+}
+
+.searchBtn {
+ color: #FFFFFF;
+ width: 120rpx;
+ height: 104rpx;
+ font-size: 28rpx;
+ font-weight: bold;
+ text-align: center;
+ line-height: 104rpx;
+ margin-left: 16rpx;
+ border-radius: 16rpx;
+ background-color: #1385FA;
+}
+
+.footer {
+ width: 100%;
+ padding: 0 30rpx;
+ height: 120rpx;
+ display: flex;
+ flex-wrap: nowrap;
+ align-items: center;
+ justify-content: space-between;
+ box-sizing: border-box;
+ background-color: #FFFFFF;
+ border-top: 1rpx solid #EAECF1;
+}
+
+.footer>view:nth-of-type(1) {
+ color: #1385FA;
+ width: 330rpx;
+ height: 88rpx;
+ font-size: 32rpx;
+ font-weight: bold;
+ border-radius: 44rpx;
+ text-align: center;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ border: 1rpx solid #1385FA;
+}
+
+.footer>view:nth-of-type(2) {
+ color: #FFFFFF;
+ width: 330rpx;
+ height: 88rpx;
+ font-size: 32rpx;
+ font-weight: bold;
+ border-radius: 44rpx;
+ text-align: center;
+ line-height: 86rpx;
+ box-sizing: border-box;
+ background-color: #1385FA;
+ border: 1rpx solid #1385FA;
+}
\ No newline at end of file
diff --git a/pages/configureDevice/configureDevice.js b/pages/configureDevice/configureDevice.js
index 82502e1..3e44934 100644
--- a/pages/configureDevice/configureDevice.js
+++ b/pages/configureDevice/configureDevice.js
@@ -28,6 +28,8 @@ Page({
ppScale.plugin.bus.subscribe("deviceInfo", (res) => {
console.log("===》deviceInfo", res);
ppScale.device.mac = res.serialNumber;
+ this._macReady = true;
+ this._tryProgress();
});
ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
@@ -59,99 +61,20 @@ Page({
return;
}
- // 步骤 0:首次连接设备,走完整的绑定检查链路
+ // 步骤 0:首次连接设备
ppScale.activeProtocol.codeUpdateMTU((res) => {
console.log("===》codeUpdateMTU", res);
- ppScale.activeProtocol.codeFetchBindingState((res) => {
- console.log("===》codeFetchBindingState", res);
+ ppScale.activeProtocol.codeSyncTime((codeSyncTime) => {
+ console.log("===》codeSyncTime", codeSyncTime)
- ppScale.activeProtocol.codeSyncTime((codeSyncTime) => {
- console.log("===》codeSyncTime", codeSyncTime)
-
- wx.hideLoading();
- if (res === 1) {
- wx.showModal({
- title: '提示',
- content: '当前设备已被绑定,你确定要覆盖绑定吗?',
- success: (res) => {
- if (res.confirm) {
- wx.showLoading({
- title: "正在初始化设备...",
- mask: true
- });
- ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
- console.log("deviceInfo === codeClearDeviceData", res);
- wx.hideLoading();
-
- if (res === 0) {
- let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
- let params = {
- equipmentCode: scaleDeviceId,
- };
- $.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => {
- ppScale.plugin.Blue.stop();
- wx.showToast({
- icon: "none",
- title: "设备初始化成功,请重新绑定。",
- })
- setTimeout(() => {
- wx.navigateBack({
- delta: 1
- })
- }, 1500);
- });
- } else {
- ppScale.plugin.Blue.stop();
- wx.showToast({
- icon: "none",
- title: "设备初始化失败。",
- })
- }
- })
- } else if (res.cancel) {
- ppScale.plugin.Blue.stop();
- }
- }
- })
- } else {
- ppScale.device.name = this.data.device.name;
- ppScale.device.connection = this.data.device;
- const nameArr = this.data.device.name.split("-");
- ppScale.version = nameArr.length === 5 ? "domain2" : "domain1";
- if (this.data.progressNext) {
- // 立即重置,防止最小化后重连时重复推进进度
- this.setData({ progressNext: false });
- let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
- let params = {
- sn: scaleDeviceId,
- };
- $.ajax("weighingScale/getUserInfoBySn", params, "GET", true, "正在同步用户信息...").then(res => {
- if (res.result) {
- wx.setStorageSync("userInfo", res.result);
- this.setProgress();
- } else {
- wx.removeStorageSync("userInfo");
- wx.showToast({
- title: "暂无用户信息,请手动补充",
- icon: "none"
- })
- setTimeout(() => {
- this.setProgress();
- }, 1500)
- }
- }).catch(() => {
- wx.showToast({
- title: "用户信息同步失败,请手动补充",
- icon: "none"
- })
- setTimeout(() => {
- this.setProgress();
- }, 1500)
- })
- }
- }
- })
+ wx.hideLoading();
+ ppScale.device.name = this.data.device.name;
+ ppScale.device.connection = this.data.device;
+ const nameArr = this.data.device.name.split("-");
+ ppScale.version = nameArr.length === 5 ? "domain2" : "domain1";
+ this._connectReady = true;
+ this._tryProgress();
})
});
});
@@ -214,7 +137,7 @@ Page({
}
},
- setDeviceUserInfo(e) {
+ setDeviceUserList(e) {
let status = e.detail.status;
if (status) {
this.setProgress();
@@ -241,6 +164,18 @@ Page({
})
},
+ // 连接完成 + mac 获取完成,双条件满足后才进入下一步
+ _connectReady: false,
+ _macReady: false,
+ _tryProgress() {
+ if (this._connectReady && this._macReady && this.data.progressNext) {
+ this._connectReady = false;
+ this._macReady = false;
+ this.setData({ progressNext: false });
+ this.setProgress();
+ }
+ },
+
checkBluetoothPermissionAndInit() {
wx.getSetting({
success: (res) => {
@@ -313,6 +248,8 @@ Page({
}
app.resetReconnectCount();
app.setGlobalData('ppScale.device.connectState', null);
+ this._connectReady = false;
+ this._macReady = false;
ppScale.plugin.Blue.stop();
},
@@ -320,6 +257,8 @@ Page({
console.log("configureDevice onUnload");
app.resetReconnectCount();
app.setGlobalData('ppScale.device.connectState', null);
+ this._connectReady = false;
+ this._macReady = false;
ppScale.plugin.Blue.stop();
}
})
\ No newline at end of file
diff --git a/pages/configureDevice/configureDevice.wxml b/pages/configureDevice/configureDevice.wxml
index 8add779..bfdb988 100644
--- a/pages/configureDevice/configureDevice.wxml
+++ b/pages/configureDevice/configureDevice.wxml
@@ -15,7 +15,7 @@
-
+
diff --git a/pages/deviceInfo/deviceInfo.js b/pages/deviceInfo/deviceInfo.js
deleted file mode 100644
index 4292486..0000000
--- a/pages/deviceInfo/deviceInfo.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const app = getApp();
-import $ from "../../utils/request";
-
-Page({
- data: {
- deviceInfo: null,
- },
-
- onShow() {
- this.getDevice();
- },
-
- // 获取已经绑定的设备列表
- getDevice() {
- let params = {};
- $.ajax("weighingScale/list/device", params, "GET", false).then((res) => {
- this.setData({
- deviceInfo: res.result[0]
- })
- })
- },
-
- openReplaceNetwork() {
- wx.navigateTo({
- url: "/pages/replaceNetwork/replaceNetwork"
- })
- },
-
- delDevice() {
- let params = {
- equipmentCode: this.data.deviceInfo.equipmentCode,
- };
- $.ajax("weighingScale/del/device", params, "POST", true, "正在解绑设备...").then(res_ => {
- wx.showToast({
- icon: "none",
- title: res_.message,
- })
- setTimeout(() => {
- wx.navigateBack({
- delta: 1
- })
- }, 1500);
- });
- }
-})
\ No newline at end of file
diff --git a/pages/deviceInfo/deviceInfo.json b/pages/deviceInfo/deviceInfo.json
deleted file mode 100644
index a1e80a4..0000000
--- a/pages/deviceInfo/deviceInfo.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "usingComponents": {},
- "navigationBarTitleText": "设备详情",
- "disableScroll": true
-}
\ No newline at end of file
diff --git a/pages/deviceInfo/deviceInfo.wxml b/pages/deviceInfo/deviceInfo.wxml
deleted file mode 100644
index 99ae6ae..0000000
--- a/pages/deviceInfo/deviceInfo.wxml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
- {{deviceInfo.equipmentName}}
- 型号:{{deviceInfo.type}}
-
-
-
-
-
- 设备名称
- {{deviceInfo.equipmentName}}
-
-
- 设备SN
- {{deviceInfo.equipmentCode}}
-
-
- Wi-Fi名称
- {{deviceInfo.wifiName}}
-
-
- 成员
- {{deviceInfo.subUserNum}}人
-
-
-
-删除设备
diff --git a/pages/deviceInfo/deviceInfo.wxss b/pages/deviceInfo/deviceInfo.wxss
deleted file mode 100644
index 3ba6bd8..0000000
--- a/pages/deviceInfo/deviceInfo.wxss
+++ /dev/null
@@ -1,102 +0,0 @@
-page {
- padding: 30rpx 30rpx 0;
-}
-
-.device {
- width: 100%;
- display: flex;
- flex-wrap: nowrap;
- align-items: center;
- padding: 30rpx;
- box-sizing: border-box;
- border-radius: 24rpx;
- margin-bottom: 24rpx;
- background-color: #FFFFFF;
-}
-
-.device>view:first-of-type {
- width: 180rpx;
- height: 180rpx;
- margin-right: 20rpx;
-}
-
-.device>view:last-of-type {
- flex: 1;
- width: 0;
-}
-
-.device>view:last-of-type>view:first-of-type {
- color: #252535;
- width: 100%;
- height: 40rpx;
- font-weight: bold;
- font-size: 40rpx;
- line-height: 40rpx;
- margin-bottom: 22rpx;
-}
-
-.device>view:last-of-type>view:last-of-type {
- color: #808080;
- width: 100%;
- height: 26rpx;
- font-size: 26rpx;
- line-height: 26rpx;
-}
-
-.info {
- width: 100%;
- border-radius: 24rpx;
- margin-bottom: 88rpx;
- background-color: #FFFFFF;
-}
-
-.info>view {
- width: 100%;
- height: 120rpx;
- padding: 0 30rpx;
- box-sizing: border-box;
- display: flex;
- flex-wrap: nowrap;
- justify-content: space-between;
- border-bottom: 1rpx solid #EAECF1;
-}
-
-.info>view:last-of-type {
- border-bottom: 0;
-}
-
-.info>view>view {
- height: 120rpx;
- font-size: 30rpx;
- line-height: 120rpx;
-}
-
-.info>view>view:first-of-type {
- color: #252535;
- font-weight: bold;
-}
-
-.info>view>view:last-of-type {
- color: #808080;
-}
-
-.arrowAfter {
- padding-right: 60rpx !important;
-}
-
-.arrowAfter::after {
- right: 30rpx;
-}
-
-.btn {
- color: #FFFFFF;
- width: 580rpx;
- height: 88rpx;
- margin: 0 auto;
- font-size: 32rpx;
- font-weight: bold;
- line-height: 88rpx;
- text-align: center;
- border-radius: 44rpx;
- background-color: #1385FA;
-}
\ No newline at end of file
diff --git a/pages/home/home.js b/pages/home/home.js
index e28a4ce..c05a782 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -3,22 +3,14 @@ import $ from "../../utils/request";
Page({
data: {
token: null,
- userInfo: null,
-
- deviceList: []
},
onShow() {
- let userInfo = wx.getStorageSync("userInfo") || null;
let token = wx.getStorageSync("token") || null;
this.setData({
token: token,
- userInfo: userInfo,
- deviceList: []
+ // deviceList: []
})
- if(token) {
- this.getDevice();
- }
},
// 点击登录或注册
@@ -43,12 +35,10 @@ Page({
let params = {
code: code
};
- $.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "加载中...").then((res) => {
- wx.setStorageSync("userInfo", res.result.user);
+ $.ajax("weighingScale/v2/checkOpenIdLogin", params, "POST", true, "加载中...").then((res) => {
wx.setStorageSync("token", res.result.token);
this.setData({
- token: res.result.token,
- userInfo: res.result.user
+ token: res.result.token
})
if(bol) {
@@ -57,27 +47,10 @@ Page({
})
},
- // 获取已经绑定的设备列表
- getDevice() {
- let params = {};
- $.ajax("weighingScale/list/device", params, "GET", true, "获取设备列表").then((res) => {
- this.setData({
- deviceList: res.result
- })
- })
- },
-
// 添加设备
openSearchDevice() {
wx.navigateTo({
url: "/pages/searchDevice/searchDevice"
})
- },
-
- // 打开设备详情
- 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 ed3e3d5..084eae7 100644
--- a/pages/home/home.wxml
+++ b/pages/home/home.wxml
@@ -8,8 +8,8 @@
-
- {{userInfo ? userInfo.realname : '已登录'}}
+
+ 已登录
登录/注册
@@ -19,24 +19,14 @@
注重更好的健康生活品质
-
-
-
-
-
- 设备名称:{{deviceList[0].equipmentName}}
-
-
-
-
- 请添加设备
- 添加设备后,解锁更多体验
-
- 添加设备
-
-
- 添加设备
-
-
-
+
+ 请添加设备
+ 添加设备后,解锁更多体验
+
+ 添加设备
+
+
+ 添加设备
+
+
\ No newline at end of file
diff --git a/pages/home/home.wxss b/pages/home/home.wxss
index 14e9028..e8e3e49 100644
--- a/pages/home/home.wxss
+++ b/pages/home/home.wxss
@@ -79,26 +79,6 @@
background-color: #FFFFFF;
}
-.device {
- width: 100%;
-}
-
-.device>view:nth-of-type(1) {
- width: 500rpx;
- height: 500rpx;
- margin: 0 auto 16rpx;
-}
-
-.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;
diff --git a/pages/my/my.js b/pages/my/my.js
index c2c899f..aff6204 100644
--- a/pages/my/my.js
+++ b/pages/my/my.js
@@ -2,93 +2,25 @@ import $ from "../../utils/request";
Page({
data: {
- userInfo: null,
- token: null,
-
- deviceInfo: null
+ token: null
},
onShow() {
let token = wx.getStorageSync("token") || null;
- let userInfo = wx.getStorageSync("userInfo") || null;
this.setData({
- userInfo: userInfo,
token: token
})
- if(token) {
- this.getDevice(false);
- }
},
openLoginOrReg() {
- if(this.data.token) {
- this.openLoginOrReg_();
- } else {
+ if (!this.data.token) {
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"
- })
- }
- }
+ title: "登录失败,请重试!",
+ icon: "none"
+ })
})
}
},
@@ -101,12 +33,10 @@ Page({
let params = {
code: res.code
};
- $.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
- wx.setStorageSync("userInfo", res.result.user);
+ $.ajax("weighingScale/v2/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
wx.setStorageSync("token", res.result.token);
this.setData({
token: res.result.token,
- userInfo: res.result.user
})
resolve();
}).catch((err) => {
@@ -120,19 +50,6 @@ Page({
})
},
- // 获取已经绑定的设备列表
- 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_();
- }
- })
- },
-
// 退出登录
exitLogin() {
wx.showModal({
diff --git a/pages/my/my.wxml b/pages/my/my.wxml
index a9c1e7f..c8e2fc9 100644
--- a/pages/my/my.wxml
+++ b/pages/my/my.wxml
@@ -1,43 +1,18 @@
-
+
-
- {{userInfo ? userInfo.realname : '已登录'}}
-
+ 已登录
未登录
-
-
- 身高(cm)
- {{userInfo && userInfo.height ? userInfo.height : '--'}}
-
-
-
- 体重(kg)
- {{userInfo && userInfo.weight ? userInfo.weight : '--'}}
-
-
-
- BMI
- {{userInfo && userInfo.bmi ? userInfo.bmi : '--'}}
-
-
我的服务
-
-
-
-
- 设备绑定
- {{deviceInfo ? '已绑定('+ deviceInfo.equipmentName +')' : '未绑定'}}
-
diff --git a/pages/my/my.wxss b/pages/my/my.wxss
index ec64727..64c76a5 100644
--- a/pages/my/my.wxss
+++ b/pages/my/my.wxss
@@ -1,6 +1,6 @@
.userInfo {
width: 100%;
- height: 488rpx;
+ /* height: 488rpx; */
margin-bottom: 24rpx;
box-sizing: border-box;
padding: 185rpx 40rpx 0;
@@ -12,7 +12,8 @@
height: 136rpx;
display: flex;
flex-wrap: nowrap;
- margin-bottom: 46rpx;
+ padding-bottom: 23px;
+ /* margin-bottom: 46rpx; */
}
.user>view:first-of-type {
@@ -75,7 +76,8 @@
width: 100%;
padding: 0 30rpx;
box-sizing: border-box;
- margin-bottom: 480rpx;
+ margin-bottom: 600rpx;
+ /* margin-bottom: 480rpx; */
}
.content .arrowAfter::after {
diff --git a/pages/userInfo/userInfo.js b/pages/userInfo/userInfo.js
deleted file mode 100644
index e0599f2..0000000
--- a/pages/userInfo/userInfo.js
+++ /dev/null
@@ -1,465 +0,0 @@
-const app = getApp();
-import $ from "../../utils/request";
-
-Page({
- data: {
- BLUE_STATE: {},
- device: null,
- connectState: "",
-
- userId: "",
- realname: "",
- sex: {
- index: "",
- data: [{
- id: 1,
- name: '男'
- }, {
- id: 2,
- name: '女'
- }]
- },
- birthday: {
- label: "1980年01月01日",
- value: "1980-01-01"
- },
- height: {
- index: 50,
- data: Array.from({ length: 200 - 120 + 1 }, (_, i) => i + 120)
- },
- weight: {
- index: [60, 0],
- data: [Array.from({ length: 120 + 1 }, (_, i) => i + 10), Array.from({ length: 10 }, (_, i) => i)]
- },
- },
-
- // 存储回调函数的引用,以便在 detached 时取消监听
- _connectStateWatcher: null,
-
- onLoad(options) {
- // 一次性数据初始化
- this.checkBluetoothPermissionAndInit();
-
- console.log(`[userInfo] 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(`[userInfo] connectState 变化: ${oldValue} -> ${newValue}`);
- this.setData({
- connectState: newValue || ''
- });
- };
- app.watch('ppScale.device.connectState', this._connectStateWatcher);
-
- let userInfo = wx.getStorageSync("userInfo") || null;
- if(userInfo) {
- let [year, month, day] = userInfo.birthday.split("-");
-
- this.setData({
- userId: userInfo.userId,
- realname: userInfo.realname,
- ["sex.index"]: this.data.sex.data.findIndex(item => {return item.id === userInfo.sex}),
- birthday: {
- label: year + "年" + month + "月" + day + "日",
- value: userInfo.birthday
- },
- ["height.index"]: this.data.height.data.findIndex(item => {return item === userInfo.height}),
- })
-
- if(userInfo.weight) {
- const integerPart = Math.floor(userInfo.weight);
- const decimalPart = Math.round((userInfo.weight - integerPart) * 10);
- const integerIndex = this.data.weight.data[0].indexOf(integerPart);
- const decimalIndex = this.data.weight.data[1].indexOf(decimalPart);
- this.setData({
- ["weight.index"]: [integerIndex !== -1 ? integerIndex : null, decimalIndex !== -1 ? decimalIndex : null],
- })
- }
- }
- },
-
- onShow() {
- console.log("userInfo onShow");
- // 延迟 300ms 确保 stop() 完全释放后再重新注册(参照官方 demo)
- setTimeout(() => {
- // 重新注册 app 级别的全局 bus 订阅
- app.registerBusListeners();
-
- // 页面级 bus 订阅
- app.globalData.ppScale.plugin.bus.subscribe("devicesModel", (res) => {
- console.log("userInfo ===》devicesModel", res);
- app.globalData.ppScale.device.mac = res.deviceMac;
- });
-
- app.globalData.ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
- console.log('userInfo ===》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("userInfo ===》codeUpdateMTU", res);
-
- app.globalData.ppScale.device.name = this.data.device.name;
- app.globalData.ppScale.device.connection = this.data.device;
-
- wx.hideLoading();
- });
- });
-
- // 通过完整链路重新初始化蓝牙(权限检查 → 打开蓝牙 → 获取设备 → start)
- this.checkBluetoothPermissionAndInit();
- }, 300);
- },
-
- // 姓名输入
- realnameInput(e) {
- let realname = e.detail.value.replace(/\s+/g, '');
- this.setData({
- realname: realname
- })
- },
-
- // 性别选择
- sexChange(e) {
- let sex = e.detail.value;
- console.log(sex);
- this.setData({
- ['sex.index']: e.detail.value
- })
- if(this.data.height.index === null) {
- this.setData({
- ['height.index']: sex == 0 ? 50 : 40
- })
- }
- if(this.data.weight.index === null) {
- this.setData({
- ['weight.index']: sex == 0 ? 20 : 10
- })
- }
- },
-
- // 生日选择
- birthdayChange(e) {
- let v = e.detail.value;
- let [year, month, day] = v.split("-");
- this.setData({
- birthday: {
- label: year + "年" + month + "月" + day + "日",
- value: v
- }
- })
- },
-
- // 身高选择
- heightChange(e) {
- this.setData({
- ['height.index']: e.detail.value
- })
- },
-
- // 体重选择
- weightChange(e) {
- console.log(e.detail.value)
- this.setData({
- ['weight.index']: e.detail.value
- })
- },
-
- setUserInfo() {
- if(this.data.connectState == this.data.BLUE_STATE.CONNECTSUCCESS || this.data.connectState == this.data.BLUE_STATE.WIFISUCCESS) {
- let realname = this.data.realname;
- let sex = this.data.sex;
- let birthday = this.data.birthday;
- let height = this.data.height;
- let weight = this.data.weight;
- if(!realname) {
- wx.showToast({
- icon: "none",
- title: "姓名不能为空"
- })
- return false;
- }
- if(sex.index === "") {
- wx.showToast({
- icon: "none",
- title: "性别不能为空"
- })
- return false;
- }
- if(!birthday.value) {
- wx.showToast({
- icon: "none",
- title: "生日不能为空"
- })
- return false;
- }
- if(height.index === "") {
- wx.showToast({
- icon: "none",
- title: "身高不能为空"
- })
- return false;
- }
- if(weight.index[0] === null && weight.index[1] === null) {
- console.log(weight)
- wx.showToast({
- icon: "none",
- title: "体重不能为空"
- })
- return false;
- }
- let sn = app.globalData.ppScale.device.mac.replace(/:/g, '');
- $.ajax("weighingScale/edit/user", {
- sn: sn,
- realname: realname,
- sex: sex.data[sex.index].id,
- birthday: birthday.value,
- height: height.data[height.index],
- weight: weight.data[0][weight.index[0]] + '.' + weight.data[1][weight.index[1]]
- }, "POST", true, "保存中...").then(res => {
- $.ajax("weighingScale/select/user", {
- sn: sn
- }, "GET", true, "更新用户信息中...").then(res_ => {
- wx.setStorageSync("userInfo", res_.result);
- wx.showToast({
- icon: "none",
- title: res.message
- })
- app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
- userID: res_.result.userId,
- userName: res_.result.realname,
- memberID: "",
- age: this.getAge(res_.result.birthday), //
- gender: res_.result.sex, //
- height: res_.result.height, //
- isAthleteMode: 0,
- currentWeight: res_.result.weight, //
- deviceHeaderIndex: 0,
- targetWeight: "",
- idealWeight: "",
- recentData: [],
- }, (res) => {
- if(res == 0) {
- wx.showToast({
- title: "用户信息更新成功。",
- icon: "none"
- })
- setTimeout(() => {
- wx.navigateBack({
- delta: 1
- })
- }, 1500)
- } else {
- console.log("dataSyncUserInfo", res)
- wx.showToast({
- title: "用户信息下发失败,请重试。",
- icon: "none"
- })
- }
- })
- })
- })
- } else {
- wx.showToast({
- title: "设备连接失败,请重试。",
- icon: "none"
- })
- }
- },
-
- // 根据生日获取年龄
- getAge(birthDateString) {
- const birthDate = new Date(birthDateString);
- const today = new Date();
-
- let age = today.getFullYear() - birthDate.getFullYear();
- const monthDiff = today.getMonth() - birthDate.getMonth();
- const dayDiff = today.getDate() - birthDate.getDate();
-
- // 如果当前月份小于出生月份,或者同月但当前日期小于出生日期,年龄需要减 1
- if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
- age--;
- }
-
- return age;
- },
-
- checkBluetoothPermissionAndInit() {
- wx.showLoading({
- title: '正在检查蓝牙权限...',
- mask: true
- })
- wx.getSetting({
- success: (res) => {
- if (res.authSetting['scope.bluetooth']) {
- this.openBluetoothAdapter();
- } else {
- wx.hideLoading();
- wx.authorize({
- scope: 'scope.bluetooth',
- success: () => {
- this.openBluetoothAdapter();
- },
- fail: (err) => {
- wx.hideLoading();
- 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) => {
- wx.hideLoading();
- wx.showToast({
- title: '获取权限设置失败',
- icon: 'none'
- });
- wx.navigateBack({
- delta: 1
- });
- }
- });
- },
-
- openBluetoothAdapter() {
- wx.showLoading({
- title: "正在初始化蓝牙...",
- mask: true
- });
- wx.openBluetoothAdapter({
- success: () => {
- this.getDeviceSettingList();
- },
- fail: (err) => {
- wx.hideLoading();
- 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) => {
- wx.showLoading({
- title: "正在寻找设备...",
- mask: true
- });
- 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();
- wx.showLoading({
- title: "正在连接设备...",
- mask: true
- });
- this.setData({
- device: res_[fIndex]
- })
- app.globalData.ppScale.plugin.Blue.createBLEConnection(res_[fIndex]);
- }
- });
- })
- },
-
- // 手动重连设备
- connectedDevice() {
- app.resetReconnectCount();
- let device = this.data.device;
- if(device) {
- wx.showLoading({
- title: "正在重新连接设备...",
- mask: true
- });
- app.globalData.ppScale.plugin.Blue.disconnect((disres) => {
- if (disres.errCode == 0) {
- app.globalData.ppScale.plugin.Blue.createBLEConnection(device);
- } else {
- app.globalData.ppScale.plugin.Blue.createBLEConnection(device);
- }
- });
- }
- },
-
- onHide() {
- console.log("userInfo onHide");
- app.resetReconnectCount();
- app.setGlobalData('ppScale.device.connectState', null);
- app.globalData.ppScale.plugin.Blue.stop();
- },
-
- onUnload() {
- console.log("userInfo onUnload");
- app.resetReconnectCount();
- app.setGlobalData('ppScale.device.connectState', null);
- app.globalData.ppScale.plugin.Blue.stop();
- if (this._connectStateWatcher) {
- app.unwatch('ppScale.device.connectState', this._connectStateWatcher);
- }
- }
-})
\ No newline at end of file
diff --git a/pages/userInfo/userInfo.json b/pages/userInfo/userInfo.json
deleted file mode 100644
index 8c9a940..0000000
--- a/pages/userInfo/userInfo.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "usingComponents": {},
- "navigationBarTitleText": "个人信息",
- "disableScroll": true
-}
\ No newline at end of file
diff --git a/pages/userInfo/userInfo.wxml b/pages/userInfo/userInfo.wxml
deleted file mode 100644
index cc062d7..0000000
--- a/pages/userInfo/userInfo.wxml
+++ /dev/null
@@ -1,118 +0,0 @@
-
-
-
-
-
- 姓名
-
-
-
-
-
-
-
- 性别
-
-
-
-
- 请选择您的性别
-
-
- {{sex.data[sex.index].name}}
-
-
-
-
-
-
- 生日
-
-
-
-
- 请选择您的生日
-
-
- {{birthday.label}}
-
-
-
-
-
-
- 身高
-
-
-
-
- 请选择您的身高
-
-
- {{height.data[height.index]}}
-
-
-
- cm
-
-
-
- 体重
-
-
-
-
- {{weight.data[0][weight.index[0]]}}.{{weight.data[1][weight.index[1]]}}
-
-
- 请选择您的体重
-
-
-
- kg
-
-
-
-
- 完成
-
- 请认真填写和完善您家人的健康信息,用于计算身体数据及运动卡路里消耗等,以便准确的分析数据。(填写数据同时,踩亮蓝牙秤并与其保持连接)。
-
-
\ No newline at end of file
diff --git a/pages/userInfo/userInfo.wxss b/pages/userInfo/userInfo.wxss
deleted file mode 100644
index 6959e29..0000000
--- a/pages/userInfo/userInfo.wxss
+++ /dev/null
@@ -1,166 +0,0 @@
-input {
- width: 100%;
- height: 58rpx;
- font-size: 28rpx;
- line-height: 58rpx;
-}
-
-.placeholderClass {
- color: #B6B6B6;
- height: 58rpx;
- font-size: 28rpx;
- line-height: 58rpx;
-}
-
-.valueClass {
- color: #77849E;
- height: 58rpx;
- font-size: 28rpx;
- font-weight: bold;
- line-height: 58rpx;
-}
-
-.userInfo {
- 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 {
- width: 100%;
- flex: 1;
- overflow: hidden;
- padding: 0 30rpx;
- box-sizing: border-box;
- background-color: #FFFFFF;
-}
-
-.from {
- width: 100%;
- margin-bottom: 66rpx;
-}
-
-.from>view {
- width: 100%;
- padding: 48rpx 10rpx 0;
- box-sizing: border-box;
- border-bottom: 1rpx solid #EAECF1;
-}
-
-.from>view>view:nth-of-type(1) {
- color: #252535;
- height: 32rpx;
- font-size: 32rpx;
- font-weight: bold;
- line-height: 32rpx;
- margin-bottom: 18rpx;
-}
-
-.from>view>view:nth-of-type(2) {
- width: 100%;
- height: 58rpx;
- display: flex;
- flex-wrap: nowrap;
- padding-right: 26rpx;
- box-sizing: border-box;
-}
-
-.from>view>view:nth-of-type(2)>view:nth-of-type(1) {
- flex: 1;
- width: 0;
-}
-
-.from>view>view:nth-of-type(2)>view:nth-of-type(2) {
- color: #77849E;
- height: 58rpx;
- font-size: 28rpx;
- font-weight: bold;
- line-height: 58rpx;
-}
-
-
-.btn {
- width: 100%;
- padding: 0 26rpx;
- box-sizing: border-box;
-}
-
-.btn>view {
- color: #FFFFFF;
- width: 100%;
- height: 88rpx;
- font-size: 32rpx;
- font-weight: bold;
- text-align: center;
- line-height: 88rpx;
- border-radius: 44rpx;
- margin-bottom: 40rpx;
- background-color: #1385FA;
-}
-
-.describe {
- color: #77849E;
- width: 100%;
- font-size: 24rpx;
- line-height: 40rpx;
-}
-
-.describe text {
- color: #F24439;
-}
\ No newline at end of file
diff --git a/project.private.config.json b/project.private.config.json
index e629413..ae231f0 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -1,24 +1,24 @@
{
- "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
- "projectname": "bodyWeight",
- "setting": {
- "compileHotReLoad": true,
- "urlCheck": false,
- "bigPackageSizeSupport": true,
- "coverView": true,
- "lazyloadPlaceholderEnable": false,
- "skylineRenderEnable": false,
- "preloadBackgroundData": false,
- "autoAudits": false,
- "useApiHook": true,
- "useApiHostProcess": true,
- "showShadowRootInWxmlPanel": true,
- "useStaticServer": false,
- "useLanDebug": false,
- "showES6CompileOption": false,
- "checkInvalidKey": true,
- "ignoreDevUnusedFiles": true
- },
- "libVersion": "3.11.3",
- "condition": {}
+ "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+ "projectname": "bodyWeight",
+ "setting": {
+ "compileHotReLoad": true,
+ "urlCheck": false,
+ "bigPackageSizeSupport": true,
+ "coverView": true,
+ "lazyloadPlaceholderEnable": false,
+ "skylineRenderEnable": false,
+ "preloadBackgroundData": false,
+ "autoAudits": false,
+ "useApiHook": true,
+ "useApiHostProcess": true,
+ "showShadowRootInWxmlPanel": true,
+ "useStaticServer": false,
+ "useLanDebug": false,
+ "showES6CompileOption": false,
+ "checkInvalidKey": true,
+ "ignoreDevUnusedFiles": true
+ },
+ "libVersion": "3.14.2",
+ "condition": {}
}
\ No newline at end of file