feat:更新运动健康模块
This commit is contained in:
@@ -4,21 +4,19 @@
|
||||
@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 { onMounted, reactive, watch } from 'vue'
|
||||
import { useHealthStore } from '@/store/health'
|
||||
import { useAppStore } from '@/store/app.ts'
|
||||
import { IExercise, IWeight } from '@/types/health'
|
||||
import { IHealth } from '@/types/health'
|
||||
|
||||
const healthStore = useHealthStore()
|
||||
const appStore = useAppStore()
|
||||
@@ -28,24 +26,22 @@ const dailyInfo = reactive({
|
||||
attrs: [] as any[]
|
||||
})
|
||||
|
||||
watch(() => healthStore.isRefresh, () => {
|
||||
dailyInfo.attrs = []
|
||||
updateRecordList()
|
||||
})
|
||||
|
||||
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()))
|
||||
healthStore.selectDate = formatDate(new Date())
|
||||
healthStore.currentHealth = 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) => {
|
||||
healthStore.healthRecordList.forEach((item: IHealth) => {
|
||||
dailyInfo.attrs.push({
|
||||
dot: 'green',
|
||||
dates: item.date
|
||||
@@ -55,7 +51,7 @@ const updateRecordList = () => {
|
||||
|
||||
const dateClick = (day: CalendarDay) => {
|
||||
healthStore.selectDate = formatDate(day.date)
|
||||
healthStore.getHealthDay(formatDate(day.date))
|
||||
healthStore.currentHealth = healthStore.getHealthDay(formatDate(day.date))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user