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) +} +