diff --git a/src/main/resources/app2/src/services/studentDrinkStatsService.js b/src/main/resources/app2/src/services/studentDrinkStatsService.js new file mode 100644 index 0000000..027be23 --- /dev/null +++ b/src/main/resources/app2/src/services/studentDrinkStatsService.js @@ -0,0 +1,49 @@ +// src/services/studentDrinkStatsService.js +import apiClient from '@/services/api' + +export const studentDrinkStatsService = { + /** + * 获取今日饮水统计 + */ + async getTodayStats(studentId) { + try { + const response = await apiClient.post('/api/student/drink-stats/today', { + studentId: studentId + }) + return response.data + } catch (error) { + console.error('获取今日饮水统计失败:', error) + throw error + } + }, + + /** + * 获取本周饮水统计 + */ + async getThisWeekStats(studentId) { + try { + const response = await apiClient.post('/api/student/drink-stats/this-week', { + studentId: studentId + }) + return response.data + } catch (error) { + console.error('获取本周饮水统计失败:', error) + throw error + } + }, + + /** + * 获取本月饮水统计 + */ + async getThisMonthStats(studentId) { + try { + const response = await apiClient.post('/api/student/drink-stats/this-month', { + studentId: studentId + }) + return response.data + } catch (error) { + console.error('获取本月饮水统计失败:', error) + throw error + } + } +} diff --git a/src/main/resources/app2/src/views/ProfilePage.vue b/src/main/resources/app2/src/views/ProfilePage.vue index 0669cfb..29fb07e 100644 --- a/src/main/resources/app2/src/views/ProfilePage.vue +++ b/src/main/resources/app2/src/views/ProfilePage.vue @@ -39,18 +39,36 @@
-
{{ userStats.days }}
-
累计用水天数
+
{{ userStats.totalConsumption }}ml
+
累计饮水量
-
{{ userStats.todayWater }}
-
今日饮水量
+
{{ userStats.drinkCount }}
+
饮水次数
+
+
+ +
+
+
{{ userStats.avgDaily }}ml
+
日均饮水量
+
+
+
{{ userStats.days }}天
+
饮水天数
+
+ 今日 +
-
800ml
-
600ml
-
400ml
-
200ml
+
{{ maxChartValue }}ml
+
{{ Math.round(maxChartValue * 0.75) }}ml
+
{{ Math.round(maxChartValue * 0.5) }}ml
+
{{ Math.round(maxChartValue * 0.25) }}ml
0ml
@@ -97,7 +115,7 @@ >
{{ item.value }}ml
@@ -110,6 +128,26 @@
+ +
+
每日详情
+
+
+
{{ formatDate(detail.date) }}
+
{{ detail.consumption }}ml
+
{{ detail.count }}次
+
+ +
+ 暂无饮水记录 +
+
+
+