feat:增加运动健康模块
This commit is contained in:
84
src/views/health/calendar.vue
Normal file
84
src/views/health/calendar.vue
Normal file
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<div class="mobile-health-view common-mobile-view">
|
||||
<v-calendar ref="calendarRef" :attributes='dailyInfo.attrs'
|
||||
@dayclick="dateClick" @did-move="changeMonthClick"
|
||||
:is-dark="appStore.isDark"
|
||||
class="health-calendar card-item"/>
|
||||
<health-legend />
|
||||
|
||||
<health-form />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import HealthLegend from '@/components/Health/HealthLegend.vue'
|
||||
import HealthForm from '@/components/Health/HealthForm.vue'
|
||||
import { CalendarDay } from 'v-calendar/dist/types/src/utils/page'
|
||||
import { formatDate, getStartEndDate } from 'vue3-common/utils/dateUtil'
|
||||
import { onMounted, reactive } from 'vue'
|
||||
import { useHealthStore } from '@/store/health'
|
||||
import { useAppStore } from '@/store/app.ts'
|
||||
import { IExercise, IWeight } from '@/types/health'
|
||||
|
||||
const healthStore = useHealthStore()
|
||||
const appStore = useAppStore()
|
||||
|
||||
const dailyInfo = reactive({
|
||||
calendarDate: '',
|
||||
attrs: [] as any[]
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
const result = getStartEndDate(formatDate(new Date()), 'month')
|
||||
healthStore.queryInfo = { startDate: result[0], endDate: result[1] }
|
||||
|
||||
await healthStore.refreshInfo()
|
||||
updateRecordList()
|
||||
healthStore.getHealthDay(formatDate(new Date()))
|
||||
})
|
||||
|
||||
const updateRecordList = () => {
|
||||
healthStore.weightRecordList.forEach((item: IWeight) => {
|
||||
dailyInfo.attrs.push({
|
||||
dot: 'red',
|
||||
dates: item.date
|
||||
})
|
||||
})
|
||||
|
||||
healthStore.exerciseRecordList.forEach((item: IExercise) => {
|
||||
dailyInfo.attrs.push({
|
||||
dot: 'green',
|
||||
dates: item.date
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const dateClick = (day: CalendarDay) => {
|
||||
healthStore.selectDate = formatDate(day.date)
|
||||
healthStore.getHealthDay(formatDate(day.date))
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择月份事件
|
||||
*/
|
||||
const changeMonthClick = async (value) => {
|
||||
const result = getStartEndDate(value[0].id, 'month')
|
||||
healthStore.queryInfo = { startDate: result[0], endDate: result[1] }
|
||||
|
||||
await healthStore.refreshInfo()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.mobile-health-view {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1vh;
|
||||
|
||||
.health-calendar {
|
||||
justify-self: center;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -36,6 +36,10 @@
|
||||
title="物品记录" sub-title="收纳生活琐碎"
|
||||
router="/product/list"/>
|
||||
|
||||
<module-card icon="iconfont icon-yundongjiankang" color="#FD644C"
|
||||
title="运动健康" sub-title="乐享健康生活"
|
||||
router="/health/calendar"/>
|
||||
|
||||
<module-card icon="iconfont icon-paiban" color="#9933FF"
|
||||
title="日程安排" sub-title="规划每日时光"
|
||||
router="/plan/calendar"/>
|
||||
|
||||
@@ -29,7 +29,7 @@ export const mobileHomeMeta: IRouteMetaConfig = {
|
||||
},
|
||||
'/bill': {
|
||||
title: '收支记录',
|
||||
icon: 'home-bill',
|
||||
icon: '',
|
||||
order: 2,
|
||||
redirect: '/bill/data'
|
||||
},
|
||||
@@ -51,7 +51,7 @@ export const mobileHomeMeta: IRouteMetaConfig = {
|
||||
},
|
||||
'/travel': {
|
||||
title: '旅行记录',
|
||||
icon: 'home-food',
|
||||
icon: '',
|
||||
order: 4,
|
||||
redirect: '/travel/spot'
|
||||
},
|
||||
@@ -75,6 +75,16 @@ export const mobileHomeMeta: IRouteMetaConfig = {
|
||||
title: '记录表单',
|
||||
icon: ''
|
||||
},
|
||||
'/health': {
|
||||
title: '运动健康',
|
||||
icon: '',
|
||||
order: 4,
|
||||
redirect: '/health/calendar'
|
||||
},
|
||||
'/health/calendar': {
|
||||
title: '记录',
|
||||
icon: ''
|
||||
},
|
||||
'/plan': {
|
||||
title: '时光日程',
|
||||
icon: 'home-calendar',
|
||||
|
||||
Reference in New Issue
Block a user