From f85a6ded2a72a5bf828e91e272d7817a51edc3e0 Mon Sep 17 00:00:00 2001
From: Cxx0822 <1556464090@qq.com>
Date: Mon, 31 Aug 2026 22:22:24 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/App.vue | 5 ++-
src/components/Profile/StatsPopup.vue | 46 ++++++++++++++++++++++++
src/pages/stats/index.vue | 52 +++++++++++++++++++++++----
src/pages/user/index.vue | 11 +++++-
src/store/profile.ts | 2 ++
src/utils/profile.ts | 9 +++++
6 files changed, 117 insertions(+), 8 deletions(-)
create mode 100644 src/components/Profile/StatsPopup.vue
diff --git a/src/App.vue b/src/App.vue
index b5885c1..f84973b 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -6,7 +6,7 @@ import {
getPlan,
savePlan,
getDefaultRecordValue,
- saveDefaultRecordValue
+ saveDefaultRecordValue, getStats, saveStats
} from "@/utils/profile";
onLaunch(() => {
@@ -27,6 +27,9 @@ onLaunch(() => {
if (getPlan().length === 0) {
savePlan(['weight', 'sleep', 'sport', 'bloodPressure'])
}
+ if (getStats().length === 0) {
+ saveStats(['weight', 'sleep', 'sport', 'bloodPressure', 'bloodSugar', 'temperature'])
+ }
console.log("App Launch");
});
onShow(() => {
diff --git a/src/components/Profile/StatsPopup.vue b/src/components/Profile/StatsPopup.vue
new file mode 100644
index 0000000..944b43e
--- /dev/null
+++ b/src/components/Profile/StatsPopup.vue
@@ -0,0 +1,46 @@
+
+
+
+ 数据统计
+
+
+
+ 体重统计
+ 睡眠统计
+ 运动统计
+ 血压统计
+ 血糖统计
+ 体温统计
+
+
+
+
+ 取消
+
+
+ 保存
+
+
+
+
+
+
diff --git a/src/pages/stats/index.vue b/src/pages/stats/index.vue
index 9981e7c..2dab798 100644
--- a/src/pages/stats/index.vue
+++ b/src/pages/stats/index.vue
@@ -8,7 +8,7 @@
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
-
+
String(index + 1))
+
+ heartRateChartData.value = {
+ categories,
+ series: [
+ { name: '心率(bpm)', data: list.map((r) => r.heartRate) },
+ ],
+ }
+ } else {
+ heartRateChartData.value = {
+ categories: [], series: []
+ }
+ }
+}
+
function getBloodSugarChartData() {
const list = getRecentRecords('bloodSugar', 7)
@@ -256,10 +294,12 @@ function getTemperatureChartData() {
}
onShow(() => {
+ profileStore.statsList = getStats()
getWeightChartData()
getSleepChartData()
getSportChartData()
getBloodPressureChartData()
+ getHeartRateChartData()
getBloodSugarChartData()
getTemperatureChartData()
})
diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue
index c63ba03..d38bdb2 100644
--- a/src/pages/user/index.vue
+++ b/src/pages/user/index.vue
@@ -42,6 +42,7 @@
+
@@ -55,6 +56,8 @@
+
+
@@ -67,7 +70,7 @@ import StoragePopup from "@/components/Profile/StoragePopup.vue";
import OverviewPopup from "@/components/Profile/OverviewPopup.vue";
import PlanPopup from "@/components/Profile/PlanPopup.vue";
import { computed, ref, watch } from 'vue'
-import { getDefaultRecordValue, getOverview, getPlan, getProfile } from '@/utils/profile'
+import { getDefaultRecordValue, getOverview, getPlan, getProfile, getStats } from '@/utils/profile'
import { useProfileStore } from '@/store/profile'
import { useAppStore } from "@/store/app";
import type { IProfile } from "@/type/profile";
@@ -76,6 +79,7 @@ import DefaultPopup from "@/components/Profile/DefaultPopup.vue";
import { getAchievement, getPoints, getRecordCount } from "@/utils/points";
import { onShow } from "@dcloudio/uni-app";
import PointPopup from "@/components/Profile/PointPopup.vue";
+import StatsPopup from "@/components/Profile/StatsPopup.vue";
const profileStore = useProfileStore()
const appStore = useAppStore()
@@ -122,6 +126,11 @@ function openPlanPopup() {
profileStore.showPlanPopup = true
}
+function openStatsPopup() {
+ profileStore.statsList = getStats()
+ profileStore.showStatsPopup = true
+}
+
function openStoragePopup() {
profileStore.storageStats = countRecordsByMonth()
profileStore.storageTotal = getTotalCount()
diff --git a/src/store/profile.ts b/src/store/profile.ts
index da35105..4e4dc84 100644
--- a/src/store/profile.ts
+++ b/src/store/profile.ts
@@ -8,6 +8,7 @@ export const useProfileStore = defineStore('profile', {
showStoragePopup: false,
showOverviewPopup: false,
showPlanPopup: false,
+ showStatsPopup: false,
showDefaultRecordValuePopup: false,
showPointPopup: false,
profileForm: {
@@ -29,6 +30,7 @@ export const useProfileStore = defineStore('profile', {
storageMax: 1000,
overviewList: [] as string[],
planList: [] as string[],
+ statsList: [] as string[],
defaultList: [],
isRefresh: false,
}),
diff --git a/src/utils/profile.ts b/src/utils/profile.ts
index a6a76ad..9ff6bd0 100644
--- a/src/utils/profile.ts
+++ b/src/utils/profile.ts
@@ -3,6 +3,7 @@ import type {IDefaultRecordValue, IProfile} from "@/type/profile";
const PROFILE_KEY = 'user_profile'
const OVERVIEW_KEY = 'user_overview'
const PLAN_KEY = 'user_plan'
+const STATS_KEY = 'user_stats'
const DEFAULT_RECORD_VALUE_KEY = 'user_default_record_value'
function getEmptyProfile(): IProfile {
@@ -45,3 +46,11 @@ export function savePlan(data: string[]) {
wx.setStorageSync(PLAN_KEY, data)
}
+export function getStats(): string[] {
+ return wx.getStorageSync(STATS_KEY) || []
+}
+
+export function saveStats(data: string[]) {
+ wx.setStorageSync(STATS_KEY, data)
+}
+