|
@@ -20,7 +20,7 @@ Component({
|
|
|
bottomNavHeight: 0, // 底部导航栏高度
|
|
|
contentHeight: 0, // 可用内容高度
|
|
|
contentpadding: 0, //顶部padding高度
|
|
|
- navheight:0,
|
|
|
+ navheight: 0,
|
|
|
//选择
|
|
|
rows: [{
|
|
|
image: 'https://file-cloud.fmode.cn/qpFbRRSZrO/20241225/r5j1uc041211788.png',
|
|
@@ -73,6 +73,13 @@ Component({
|
|
|
sharList: [],
|
|
|
|
|
|
address: "",
|
|
|
+ //排行榜
|
|
|
+ todayList: [],
|
|
|
+ changetitle: 'today',
|
|
|
+ //点赞
|
|
|
+ isclick:false,
|
|
|
+ //正序
|
|
|
+ rank:'up'
|
|
|
},
|
|
|
lifetimes: {
|
|
|
|
|
@@ -91,10 +98,10 @@ Component({
|
|
|
|
|
|
const contentpadding = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
|
|
|
const contentHeight = (screenHeight - bottomNavHeight - 50 - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
|
|
|
- const navheight = (statusBarHeight+customHeight) * 750 / systemInfo.windowWidth;
|
|
|
+ const navheight = (statusBarHeight + customHeight) * 750 / systemInfo.windowWidth;
|
|
|
this.setData({
|
|
|
statusBarHeight,
|
|
|
- screenHeight:(screenHeight-50-bottomNavHeight) * 750 / systemInfo.windowWidth,
|
|
|
+ screenHeight: (screenHeight - 50 - bottomNavHeight) * 750 / systemInfo.windowWidth,
|
|
|
customHeight,
|
|
|
bottomNavHeight,
|
|
|
contentHeight,
|
|
@@ -105,8 +112,8 @@ Component({
|
|
|
this.getWeRunData()
|
|
|
this.gettarget()
|
|
|
// this.order()
|
|
|
- this.Getlocation()
|
|
|
-
|
|
|
+ this.Getlocation()
|
|
|
+ this.gettoday()
|
|
|
},
|
|
|
},
|
|
|
|
|
@@ -212,7 +219,7 @@ Component({
|
|
|
success: (ops) => { // 使用箭头函数
|
|
|
console.log(ops);
|
|
|
// const address = ops.data.result.formatted_address;//详细地址
|
|
|
- const address = ops.data.result.addressComponent.city;//市
|
|
|
+ const address = ops.data.result.addressComponent.city; //市
|
|
|
this.setData({
|
|
|
address: address,
|
|
|
});
|
|
@@ -345,6 +352,119 @@ Component({
|
|
|
console.error("保存数据时出现错误:", error);
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ //切换
|
|
|
+ change() {
|
|
|
+ // 使用数组来简化切换逻辑
|
|
|
+ const titles = ['today', 'weekdday', 'month'];
|
|
|
+ const currentIndex = titles.indexOf(this.data.changetitle); //获取index
|
|
|
+ const nextIndex = (currentIndex + 1) % titles.length; // 循环切换
|
|
|
+ this.setData({
|
|
|
+ changetitle: titles[nextIndex]
|
|
|
+ });
|
|
|
+ if (this.data.changetitle == 'today') {
|
|
|
+ this.setData({
|
|
|
+ rank:'up'
|
|
|
+ })
|
|
|
+ this.gettoday()
|
|
|
+ }
|
|
|
+ if (this.data.changetitle == 'weekdday') {
|
|
|
+ this.setData({
|
|
|
+ rank:'up'
|
|
|
+ })
|
|
|
+ console.log('weekdday');
|
|
|
+ }
|
|
|
+ if (this.data.changetitle == 'month') {
|
|
|
+ this.setData({
|
|
|
+ rank:'up'
|
|
|
+ })
|
|
|
+ console.log('month');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取本日排行
|
|
|
+ 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());
|
|
|
+
|
|
|
+ // // 初始化 myList
|
|
|
+ // let myList = [];
|
|
|
+
|
|
|
+ // // 找到当前用户的数据并计算排名
|
|
|
+ // todayList.forEach((item, index) => {
|
|
|
+ // if (item.user.objectId === currentUser.id) {
|
|
|
+ // myList.push({
|
|
|
+ // ...item, // 包含用户数据
|
|
|
+ // rank: index + 1 // 计算排名(index 从 0 开始,所以加 1)
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
+ // 更新页面数据
|
|
|
+ this.setData({
|
|
|
+ todayList,
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(this.data.todayList);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error fetching today\'s data:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //正序逆序
|
|
|
+ changeup(){
|
|
|
+ if(this.data.rank=='up'){
|
|
|
+ this.setData({
|
|
|
+ rank:'down'
|
|
|
+ })
|
|
|
+ if (this.data.changetitle == 'today') {
|
|
|
+ this.setData({
|
|
|
+ todayList:this.data.todayList.reverse(),
|
|
|
+ })
|
|
|
+ console.log('逆序');
|
|
|
+ }
|
|
|
+ if (this.data.changetitle == 'weekdday') {
|
|
|
+ console.log('weekdday逆序');
|
|
|
+ }
|
|
|
+ if (this.data.changetitle == 'month') {
|
|
|
+ console.log('month逆序');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ rank:'up'
|
|
|
+ })
|
|
|
+ if (this.data.changetitle == 'today') {
|
|
|
+ this.setData({
|
|
|
+ todayList:this.data.todayList.reverse(),
|
|
|
+ })
|
|
|
+ console.log('顺序');
|
|
|
+ }
|
|
|
+ if (this.data.changetitle == 'weekdday') {
|
|
|
+ console.log('weekdday顺序');
|
|
|
+ }
|
|
|
+ if (this.data.changetitle == 'month') {
|
|
|
+ console.log('month顺序');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|