|
@@ -90,6 +90,8 @@ Page({
|
|
|
ec: {
|
|
|
onInit: initChart
|
|
|
},
|
|
|
+ resultList: [],
|
|
|
+ stepsData: [],
|
|
|
|
|
|
percentage: '',
|
|
|
percent: '',
|
|
@@ -99,7 +101,7 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: async function (options) {
|
|
|
+ onLoad: async function (options) {
|
|
|
// 计算
|
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
|
const statusBarHeight = systemInfo.statusBarHeight || 0;
|
|
@@ -121,6 +123,7 @@ Page({
|
|
|
await this.gettarget()
|
|
|
await this.order()
|
|
|
this.allorder()
|
|
|
+ this.getweekday()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -311,6 +314,43 @@ Page({
|
|
|
percentage: `conic-gradient(from 0deg, #015EEA ${percent}%, white 0%)`,
|
|
|
})
|
|
|
console.log('百分比', this.data.percentage);
|
|
|
- }
|
|
|
+ },
|
|
|
+ //获取本周记录
|
|
|
+ async getweekday() {
|
|
|
+ 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(b.createdAt) - new Date(a.createdAt));
|
|
|
+
|
|
|
+ // 获取今天是星期几(0 = 周日, 1 = 周一, ..., 6 = 周六)
|
|
|
+ const today = new Date();
|
|
|
+ const dayOfWeek = today.getDay(); // 获取当前星期几
|
|
|
+
|
|
|
+ // 根据星期几决定取多少条数据
|
|
|
+ let numItemsToTake;
|
|
|
+ if (dayOfWeek === 0) {
|
|
|
+ numItemsToTake = 7; // 周日取7条数据
|
|
|
+ } else {
|
|
|
+ numItemsToTake = dayOfWeek; // 周一至周六取对应条数
|
|
|
+ }
|
|
|
+
|
|
|
+ // 取出对应数量的数据
|
|
|
+ const resultList = allList.slice(0, numItemsToTake);
|
|
|
+ const stepsData = resultList.map(item => item.steps);
|
|
|
+ this.setData({
|
|
|
+ resultList,
|
|
|
+ stepsData
|
|
|
+ })
|
|
|
+ console.log('resultList', resultList);
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
})
|