|
@@ -20,7 +20,14 @@ Page({
|
|
|
|
|
|
day: '7',
|
|
|
target: '',
|
|
|
- sharList:[]
|
|
|
+ sharList: [],
|
|
|
+
|
|
|
+ stardate: '',
|
|
|
+ daysDifference: "",
|
|
|
+ totalSteps: 0,
|
|
|
+ totalDistance: 0,
|
|
|
+ totalBurnCalories: 0,
|
|
|
+ totalsportDate:0
|
|
|
},
|
|
|
|
|
|
|
|
@@ -47,6 +54,7 @@ Page({
|
|
|
});
|
|
|
this.gettarget()
|
|
|
this.order()
|
|
|
+ this.allorder()
|
|
|
},
|
|
|
|
|
|
|
|
@@ -128,32 +136,93 @@ Page({
|
|
|
console.log('当前步数', this.data.target);
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
- async order() {
|
|
|
- const currentUser = Parse.User.current();
|
|
|
- let ActivityDataquery = new Parse.Query('ActivityData');
|
|
|
- ActivityDataquery.equalTo('user', currentUser.id);
|
|
|
- ActivityDataquery.equalTo('company', company);
|
|
|
- ActivityDataquery.equalTo('type', 'today');
|
|
|
- ActivityDataquery.notEqualTo('isDeleted', true);
|
|
|
-
|
|
|
-
|
|
|
- const today = new Date();
|
|
|
- const todayStart = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
|
- const todayEnd = new Date(todayStart);
|
|
|
- todayEnd.setHours(23, 59, 59, 999);
|
|
|
-
|
|
|
-
|
|
|
- ActivityDataquery.greaterThanOrEqualTo('createdAt', todayStart);
|
|
|
- ActivityDataquery.lessThanOrEqualTo('createdAt', todayEnd);
|
|
|
- ActivityDataquery.include('user');
|
|
|
-
|
|
|
- let r = await ActivityDataquery.find();
|
|
|
- let sharList = r.map(item => item.toJSON());
|
|
|
-
|
|
|
- this.setData({
|
|
|
- sharList
|
|
|
- });
|
|
|
- console.log(this.data.sharList);
|
|
|
- },
|
|
|
+
|
|
|
+ async order() {
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ let ActivityDataquery = new Parse.Query('ActivityData');
|
|
|
+ ActivityDataquery.equalTo('user', currentUser.id);
|
|
|
+ ActivityDataquery.equalTo('company', company);
|
|
|
+ ActivityDataquery.equalTo('type', 'today');
|
|
|
+ ActivityDataquery.notEqualTo('isDeleted', true);
|
|
|
+
|
|
|
+
|
|
|
+ const today = new Date();
|
|
|
+ const todayStart = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
|
+ const todayEnd = new Date(todayStart);
|
|
|
+ todayEnd.setHours(23, 59, 59, 999);
|
|
|
+
|
|
|
+
|
|
|
+ ActivityDataquery.greaterThanOrEqualTo('createdAt', todayStart);
|
|
|
+ ActivityDataquery.lessThanOrEqualTo('createdAt', todayEnd);
|
|
|
+ ActivityDataquery.include('user');
|
|
|
+
|
|
|
+ let r = await ActivityDataquery.find();
|
|
|
+ let sharList = r.map(item => item.toJSON());
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ sharList
|
|
|
+ });
|
|
|
+ console.log(this.data.sharList);
|
|
|
+ },
|
|
|
+
|
|
|
+ async allorder() {
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ let ActivityDataquery = new Parse.Query('ActivityData');
|
|
|
+ ActivityDataquery.equalTo('user', currentUser.id);
|
|
|
+ ActivityDataquery.equalTo('company', company);
|
|
|
+ ActivityDataquery.equalTo('type', 'today');
|
|
|
+ ActivityDataquery.notEqualTo('isDeleted', true);
|
|
|
+
|
|
|
+ let r = await ActivityDataquery.find();
|
|
|
+ let allList = r.map(item => item.toJSON());
|
|
|
+
|
|
|
+
|
|
|
+ allList.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt));
|
|
|
+
|
|
|
+
|
|
|
+ const earliestDate = new Date(allList[0].createdAt);
|
|
|
+
|
|
|
+
|
|
|
+ const formattedDate = `${earliestDate.getFullYear()}年${String(earliestDate.getMonth() + 1).padStart(2, '0')}月${String(earliestDate.getDate()).padStart(2, '0')}日`;
|
|
|
+
|
|
|
+
|
|
|
+ const today = new Date();
|
|
|
+
|
|
|
+
|
|
|
+ earliestDate.setHours(0, 0, 0, 0);
|
|
|
+ today.setHours(0, 0, 0, 0);
|
|
|
+
|
|
|
+
|
|
|
+ const timeDifference = today - earliestDate;
|
|
|
+ const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
|
|
|
+
|
|
|
+
|
|
|
+ let totalSteps = 0;
|
|
|
+ let totalDistance = 0;
|
|
|
+ let totalBurnCalories = 0;
|
|
|
+ let totalsportDate = 0;
|
|
|
+
|
|
|
+ allList.forEach(item => {
|
|
|
+ totalSteps += Number(item.steps) || 0;
|
|
|
+ totalDistance += Number(item.distance) || 0;
|
|
|
+ totalBurnCalories += Number(item.burnCalories) || 0;
|
|
|
+ totalsportDate += Number(item.sportDate) || 0;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ const days = Math.floor(totalsportDate / (60 * 24));
|
|
|
+ const hours = Math.floor((totalsportDate % (60 * 24)) / 60);
|
|
|
+ const minutes = totalsportDate % 60;
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ stardate: formattedDate,
|
|
|
+ daysDifference: daysDifference,
|
|
|
+ totalSteps,
|
|
|
+ totalDistance,
|
|
|
+ totalBurnCalories,
|
|
|
+ totalsportDate: `${days}天 ${hours}小时 ${minutes}分钟`
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(allList, this.data.totalsportDate);
|
|
|
+ }
|
|
|
})
|