Files
health-mp/src/pages/user/index.vue

94 lines
2.8 KiB
Vue

<template>
<view class="min-h-screen bg-[#f2f4f3] pb-10">
<wd-card title="个人信息" type="rectangle">
<view class="flex items-center gap-4">
<wd-avatar :text="profile.name ? profile.name.charAt(0).toUpperCase() : '我'" bg-color="#8b5cf6" />
<view class="flex flex-col">
<text class="text-lg text-gray-800 font-semibold">
{{ profile.name || '未设置姓名' }}
</text>
<text class="mt-0.5 text-xs text-gray-400">
{{ genderText }} · {{ profile.height ? `${profile.height} cm` : '身高未填' }}
</text>
</view>
<view class="ml-auto">
<wd-button size="small" plain type="primary" @click="openProfile">
编辑
</wd-button>
</view>
</view>
</wd-card>
<wd-cell-group>
<wd-cell size="large" title="今日概览" is-link @click="openOverviewPopup"/>
<wd-cell size="large" title="今日计划" is-link @click="openPlanPopup"/>
<wd-cell size="large" title="存储详情" is-link @click="openStoragePopup"/>
</wd-cell-group>
<wd-text :text="`版本号:${appStore.version}`" custom-style="margin-top: 5px;display:block; text-align:center;"></wd-text>
<profile-popup />
<storage-popup />
<overview-popup />
<plan-popup />
</view>
</template>
<script lang="ts" setup>
import ProfilePopup from "@/components/Profile/ProfilePopup.vue";
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 { getOverview, getPlan, getProfile } from '@/utils/profile'
import { useProfileStore } from '@/store/profile'
import { useAppStore } from "@/store/app";
import type { IProfile } from "@/type/profile";
import { countRecordsByMonth, getMaxRecord, getTotalCount } from "@/utils/record";
const profileStore = useProfileStore()
const appStore = useAppStore()
const profile = ref<IProfile>(getProfile())
const genderText = computed(() => {
if (profile.value.gender === 'male')
return '男'
if (profile.value.gender === 'female')
return '女'
return '性别未填'
})
watch(() => profileStore.isRefresh, () => {
profile.value = getProfile()
})
function openProfile() {
Object.assign(profileStore.profileForm, profile.value)
profileStore.showProfilePopup = true
}
function openOverviewPopup() {
profileStore.overviewList = getOverview()
profileStore.showOverviewPopup = true
}
function openPlanPopup() {
profileStore.planList = getPlan()
profileStore.showPlanPopup = true
}
function openStoragePopup() {
profileStore.storageStats = countRecordsByMonth()
profileStore.storageTotal = getTotalCount()
profileStore.storageMax = getMaxRecord()
profileStore.showStoragePopup = true
}
</script>