邹能昇 2 сар өмнө
parent
commit
adf15c1b0e

+ 1 - 1
nova-werun/pages/home/medal/index.wxml

@@ -6,7 +6,7 @@
         <view class="info">
             <view class="name">{{userList[0].nickname}}</view>
             <view class="but-box">
-                <image src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241112/m61jkv024259213.png?imageView2/1/w/200/h/200"></image>
+                <image src="https://file-cloud.fmode.cn/qpFbRRSZrO/20250113/314h43042541125.png?imageView2/1/w/200/h/200"></image>
                 <view class="text">分享 ></view>
             </view>
         </view>

+ 48 - 1
nova-werun/pages/home/statistics/index.js

@@ -42,6 +42,8 @@ Page({
         percentage: '',
         percent: '',
 
+        //排名百分比
+        percebtage:0
     },
 
     /**
@@ -72,6 +74,7 @@ Page({
         await this.getweekday()
         this.echartsComponnet = this.selectComponent('#mychart')
         await this.initChart()
+        this.gettoday()
     },
     //图表
     // 将 initChart 定义在 Page 上下文中
@@ -155,7 +158,6 @@ Page({
         const dates =  daylist.map(item=>{
             return `${item}号`
         })
-        console.log('dates',dates);
         return index === dayindex ? '今天' : value + '\n' + '\n' + dates[index];
     },
     /**
@@ -400,5 +402,50 @@ Page({
         console.log('resultList', resultList);
 
     },
+    //获取今日排名百分比
+    async gettoday() {
+        const currentUser = Parse.User.current();
+        let ActivityDataquery = new Parse.Query('ActivityData');
+        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); // 今天的结束时间
+        console.log(todayStart, todayEnd);
+        // 在查询条件中添加对 createdAt 的限制
+        ActivityDataquery.greaterThanOrEqualTo('createdAt', todayStart);
+        ActivityDataquery.lessThanOrEqualTo('createdAt', todayEnd);
+
+        // 根据 steps 字段进行降序排序
+        ActivityDataquery.descending('steps');
+        ActivityDataquery.include('user');
+
+        try {
+            let P = await ActivityDataquery.find();
+            let todayList = P.map(item => item.toJSON());
+            console.log('todayList',todayList);
+            let rank = 0
+            // 更新页面数据
+            todayList.forEach((item,index)=>{
+                if(item.user.objectId==currentUser.id){
+                    rank = index+1;
+                    return
+                }
+            })
+
+            var ranper =100 - (rank/todayList.length)*100
+            ranper = parseFloat(ranper.toFixed(2));
+            this.setData({
+                percebtage:ranper
+            })
+            console.log('percebtage',this.data.percebtage);
+        } catch (error) {
+            console.error('Error fetching today\'s data:', error);
+        }
+    },
 
 })

+ 1 - 1
nova-werun/pages/home/statistics/index.wxml

@@ -91,7 +91,7 @@
         <view class="card2-bottom">
             <view class="card2-bottom1">今日步数已超过</view>
             <view class="card2-bottom2">
-                <view class="card2-bottom2t">60.00</view>
+                <view class="card2-bottom2t">{{percebtage}}</view>
                 <view class="card2-bottom2t2">%</view>
             </view>
             <view class="card2-bottom3">的用户,赶紧行动起来</view>