Bladeren bron

home-share page

邹能昇 3 maanden geleden
bovenliggende
commit
1fbcc9f16f
2 gewijzigde bestanden met toevoegingen van 45 en 6 verwijderingen
  1. 40 1
      nova-werun/pages/home/share/index.js
  2. 5 5
      nova-werun/pages/home/share/index.wxml

+ 40 - 1
nova-werun/pages/home/share/index.js

@@ -1,4 +1,6 @@
 // nova-werun/pages/home/share/index.js
+const Parse = getApp().Parse;
+const company = getApp().globalData.company;
 Page({
 
     /**
@@ -13,6 +15,8 @@ Page({
         contentHeight: 0, // 可用内容高度
         contentHeight2: 0,
         contentpadding: 0, //顶部padding高度
+
+        sharList: [],
     },
 
     /**
@@ -37,6 +41,7 @@ Page({
             contentpadding,
             contentHeight
         });
+        this.order()
     },
 
     /**
@@ -87,5 +92,39 @@ Page({
     onShareAppMessage: function () {
 
     },
-    
+    //获取当天运动数据
+    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); // 今天的结束时间
+
+        // 在查询条件中添加对 createdAt 的限制
+        ActivityDataquery.greaterThanOrEqualTo('createdAt', todayStart);
+        ActivityDataquery.lessThanOrEqualTo('createdAt', todayEnd);
+        ActivityDataquery.include('user');
+
+        let r = await ActivityDataquery.find();
+        let sharList = r.map(item => {
+            let itemData = item.toJSON();
+            // 获取当前时间并格式化
+            const now = new Date();
+            const formattedTime = `${now.getFullYear()}/${String(now.getMonth() + 1).padStart(2, '0')}/${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`;
+            itemData.currentTime = formattedTime; // 将当前时间添加到 item 中
+            return itemData;
+        });
+
+        this.setData({
+            sharList
+        });
+        console.log(this.data.sharList);
+    },
 })

+ 5 - 5
nova-werun/pages/home/share/index.wxml

@@ -4,10 +4,10 @@
     <view class="box">
         <image class="picture" src="https://file-cloud.fmode.cn//tmp/sBX4tFxdGjkk1fea2c9db35cbd67b50b01dd3bae1592.png?imageView2/1/w/200/h/200"></image>
         <view class="namebox">
-            <image src="https://file-cloud.fmode.cn//tmp/sBX4tFxdGjkk1fea2c9db35cbd67b50b01dd3bae1592.png?imageView2/1/w/200/h/200"></image>
+            <image src="{{sharList[0].user.avatar}}"></image>
             <view class="textbox">
-                <view class="name">超级无敌暴龙战士</view>
-                <view class="time">2024/09/17 20:46</view>
+                <view class="name">{{sharList[0].user.nickname}}</view>
+                <view class="time">{{sharList[0].currentTime}}</view>
             </view>
         </view>
         <view class="bigtext">梦想家</view>
@@ -19,12 +19,12 @@
             </view>
             <view class="num-tex">
                 <view class="nu-nam">今日步数</view>
-                <view class="num">77777</view>
+                <view class="num">{{sharList[0].steps}}</view>
             </view>
             <view class="num-tex">
                 <view class="nu-nam">公里数</view>
                 <view class="num">
-                    <view class="num-num">5</view>
+                    <view class="num-num">{{sharList[0].distance}}</view>
                     <view class="num-km">km</view>
                 </view>
             </view>