feat: 更新首页卡片功能
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="min-h-screen flex flex-col gap-3 bg-gradient-to-b from-[#a78bfa] to-[#f3e8ff]">
|
||||
<view class="self-center p-1 flex items-center gap-2 text-gray-800">
|
||||
<view class="min-h-screen flex flex-col bg-gradient-to-b from-[#a78bfa] to-[#f3e8ff]">
|
||||
<view class="self-center py-3 flex items-center gap-2 text-gray-800">
|
||||
<wd-img :width="40" :height="40" :src="imgURL" />
|
||||
|
||||
<view class="flex min-w-0 flex-col">
|
||||
@@ -25,7 +25,10 @@
|
||||
<text class="text-lg">{{ item.icon }}</text>
|
||||
<text class="text-sm text-gray-400 font-medium">{{ item.label }}</text>
|
||||
</view>
|
||||
<wd-button size="mini" round icon="plus" :plain="true" type="primary"/>
|
||||
<wd-button v-if="item.value === '未记录'"
|
||||
size="mini" round icon="plus"
|
||||
:plain="true" type="primary"
|
||||
@click="addClick(item.type)"/>
|
||||
</view>
|
||||
|
||||
<text class="mt-2 text-base text-gray-800 font-bold tracking-tight">
|
||||
@@ -66,9 +69,9 @@
|
||||
<weight-popup />
|
||||
<sleep-popup />
|
||||
<sport-popup />
|
||||
<bp-popup />
|
||||
<glucose-popup />
|
||||
<temp-popup />
|
||||
<blood-pressure-popup />
|
||||
<blood-sugar-popup />
|
||||
<temperature-popup />
|
||||
|
||||
<wd-fab v-if="recordStore.showFab" type="primary" :expandable="false" @click="handelFabClick" />
|
||||
</view>
|
||||
@@ -79,9 +82,9 @@ import RecordPopup from "@/components/Home/RecordPopup.vue";
|
||||
import WeightPopup from "@/components/Home/WeightPopup.vue";
|
||||
import SleepPopup from "@/components/Home/SleepPopup.vue";
|
||||
import SportPopup from "@/components/Home/SportPopup.vue";
|
||||
import BpPopup from "@/components/Home/BpPopup.vue";
|
||||
import GlucosePopup from "@/components/Home/GlucosePopup.vue";
|
||||
import TempPopup from "@/components/Home/TempPopup.vue";
|
||||
import BloodPressurePopup from "@/components/Home/BloodPressurePopup.vue";
|
||||
import BloodSugarPopup from "@/components/Home/BloodSugarPopup.vue";
|
||||
import TemperaturePopup from "@/components/Home/TemperaturePopup.vue";
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useRecordStore } from '@/store/record'
|
||||
import {getDateStr, getDayRecords, getTimeStr} from '@/utils/record'
|
||||
@@ -154,6 +157,7 @@ const overviewItems = computed(() => {
|
||||
if (item === 'weight') {
|
||||
const profile = getProfile()
|
||||
result.push({
|
||||
type: 'weight',
|
||||
icon: '⚖️',
|
||||
label: '体重',
|
||||
value: weight ? `${weight.value} kg` : '未记录',
|
||||
@@ -162,6 +166,7 @@ const overviewItems = computed(() => {
|
||||
}
|
||||
else if (item === 'sleep') {
|
||||
result.push({
|
||||
type: 'sleep',
|
||||
icon: '😴',
|
||||
label: '睡眠',
|
||||
value: sleep ? `${sleep.duration}h` : '未记录',
|
||||
@@ -170,14 +175,16 @@ const overviewItems = computed(() => {
|
||||
}
|
||||
else if (item === 'sport') {
|
||||
result.push({
|
||||
type: 'sport',
|
||||
icon: '🏃',
|
||||
label: '运动',
|
||||
value: sportTotal > 0 ? `${sportTotal}min` : '0min',
|
||||
value: sportTotal > 0 ? `${sportTotal}min` : '未记录',
|
||||
sub: sportTotal >= 30 ? '已达标' : '目标 30min',
|
||||
})
|
||||
}
|
||||
else if (item === 'bloodPressure') {
|
||||
result.push({
|
||||
type: 'bloodPressure',
|
||||
icon: '❤️',
|
||||
label: '血压',
|
||||
value: bloodPressure ? `${bloodPressure.systolic}/${bloodPressure.diastolic}` : '未记录',
|
||||
@@ -186,6 +193,7 @@ const overviewItems = computed(() => {
|
||||
}
|
||||
else if (item === 'bloodSugar') {
|
||||
result.push({
|
||||
type: 'bloodSugar',
|
||||
icon: '🩸',
|
||||
label: '血糖',
|
||||
value: bloodSugar ? `${bloodSugar.value}mmol/L` : '未记录',
|
||||
@@ -194,6 +202,7 @@ const overviewItems = computed(() => {
|
||||
}
|
||||
else if (item === 'temperature') {
|
||||
result.push({
|
||||
type: 'temperature',
|
||||
icon: '🌡️',
|
||||
label: '体温',
|
||||
value: temperature ? `${temperature.value}℃` : '未记录',
|
||||
@@ -247,14 +256,37 @@ const plans = computed(() => {
|
||||
return result
|
||||
})
|
||||
|
||||
function addClick(type: string) {
|
||||
switch (type) {
|
||||
case 'weight':
|
||||
recordStore.showFab = false
|
||||
recordStore.showWeightPopup = true
|
||||
break
|
||||
case 'sleep':
|
||||
recordStore.showFab = false
|
||||
recordStore.showSleepPopup = true
|
||||
break
|
||||
case 'sport':
|
||||
recordStore.showFab = false
|
||||
recordStore.showSportPopup = true
|
||||
break
|
||||
case 'bloodPressure':
|
||||
recordStore.showFab = false
|
||||
recordStore.showBloodPressurePopup = true
|
||||
break
|
||||
case 'bloodSugar':
|
||||
recordStore.showFab = false
|
||||
recordStore.showBloodSugarPopup = true
|
||||
break
|
||||
case 'temperature':
|
||||
recordStore.showFab = false
|
||||
recordStore.showTemperaturePopup = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function handelFabClick() {
|
||||
recordStore.showRecordPopup = true
|
||||
recordStore.showFab = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.wd-card:not(:last-child)) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user