feat: 增加数据统计自定义功能
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<wd-card title="体重">
|
||||
<wd-card v-if="profileStore.statsList.includes('weight')" title="体重">
|
||||
<qiun-data-charts
|
||||
v-if="weightChartData.categories?.length"
|
||||
type="line"
|
||||
@@ -19,7 +19,7 @@
|
||||
<wd-empty v-else icon="no-content" tip="暂无记录" />
|
||||
</wd-card>
|
||||
|
||||
<wd-card title="睡眠">
|
||||
<wd-card v-if="profileStore.statsList.includes('sleep')" title="睡眠">
|
||||
<qiun-data-charts
|
||||
v-if="sleepChartData.categories?.length"
|
||||
type="line"
|
||||
@@ -30,7 +30,7 @@
|
||||
<wd-empty v-else icon="no-content" tip="暂无记录" />
|
||||
</wd-card>
|
||||
|
||||
<wd-card title="运动">
|
||||
<wd-card v-if="profileStore.statsList.includes('sport')" title="运动">
|
||||
<qiun-data-charts
|
||||
v-if="sportChartData.categories?.length"
|
||||
type="line"
|
||||
@@ -41,7 +41,7 @@
|
||||
<wd-empty v-else icon="no-content" tip="暂无记录" />
|
||||
</wd-card>
|
||||
|
||||
<wd-card title="血压">
|
||||
<wd-card v-if="profileStore.statsList.includes('bloodPressure')" title="血压">
|
||||
<qiun-data-charts
|
||||
v-if="bloodPressureChartData.categories?.length"
|
||||
type="line"
|
||||
@@ -52,7 +52,18 @@
|
||||
<wd-empty v-else icon="no-content" tip="暂无记录" />
|
||||
</wd-card>
|
||||
|
||||
<wd-card title="血糖">
|
||||
<wd-card v-if="profileStore.statsList.includes('bloodPressure')" title="心率">
|
||||
<qiun-data-charts
|
||||
v-if="heartRateChartData.categories?.length"
|
||||
type="line"
|
||||
:opts="chartOpts"
|
||||
:chartData="heartRateChartData"
|
||||
/>
|
||||
|
||||
<wd-empty v-else icon="no-content" tip="暂无记录" />
|
||||
</wd-card>
|
||||
|
||||
<wd-card v-if="profileStore.statsList.includes('bloodSugar')" title="血糖">
|
||||
<qiun-data-charts
|
||||
v-if="bloodSugarChartData.categories?.length"
|
||||
type="line"
|
||||
@@ -63,7 +74,7 @@
|
||||
<wd-empty v-else icon="no-content" tip="暂无记录" />
|
||||
</wd-card>
|
||||
|
||||
<wd-card title="体温">
|
||||
<wd-card v-if="profileStore.statsList.includes('temperature')" title="体温">
|
||||
<qiun-data-charts
|
||||
v-if="temperatureChartData.categories?.length"
|
||||
type="line"
|
||||
@@ -80,6 +91,10 @@
|
||||
import { ref } from 'vue'
|
||||
import { getRecentRecords } from '@/utils/record'
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { useProfileStore } from '@/store/profile'
|
||||
import { getStats } from "@/utils/profile";
|
||||
|
||||
const profileStore = useProfileStore()
|
||||
|
||||
const weightChartData = ref({
|
||||
categories: [] as string[],
|
||||
@@ -97,6 +112,10 @@ const bloodPressureChartData = ref({
|
||||
categories: [] as string[],
|
||||
series: [] as any[]
|
||||
})
|
||||
const heartRateChartData = ref({
|
||||
categories: [] as string[],
|
||||
series: [] as any[]
|
||||
})
|
||||
const bloodSugarChartData = ref({
|
||||
categories: [] as string[],
|
||||
series: [] as any[]
|
||||
@@ -211,6 +230,25 @@ function getBloodPressureChartData() {
|
||||
}
|
||||
}
|
||||
|
||||
function getHeartRateChartData() {
|
||||
const list = getRecentRecords('bloodPressure', 7)
|
||||
|
||||
if (list.length) {
|
||||
const categories = list.map((_, index) => 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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user