diff --git a/env/.env b/env/.env index 3d5d4c3..ad154ff 100644 --- a/env/.env +++ b/env/.env @@ -1,4 +1,4 @@ -VITE_APP_TITLE = 'unibest' +VITE_APP_TITLE = '健康记' VITE_APP_PORT = 9000 VITE_UNI_APPID = '__UNI__D1E5001' diff --git a/favicon.ico b/favicon.ico index 47c577c..9295cbd 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/package.json b/package.json index b4242da..545a82f 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "description": "unibest - 最好的 uniapp 开发模板", "generate-time": "用户创建项目时生成", "author": { - "name": "feige996", - "zhName": "菲鸽", - "email": "1020103647@qq.com", - "github": "https://github.com/feige996", - "gitee": "https://gitee.com/feige996" + "name": "Cxx0822", + "zhName": "Cxx", + "email": "", + "github": "", + "gitee": "" }, "license": "MIT", "homepage": "https://unibest.tech", diff --git a/src/components/Profile/ProfilePopup.vue b/src/components/Profile/ProfilePopup.vue new file mode 100644 index 0000000..fac1c5a --- /dev/null +++ b/src/components/Profile/ProfilePopup.vue @@ -0,0 +1,65 @@ + + + diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 6cc2f6e..54b9475 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -10,11 +10,8 @@ {{ today }} - - - 🩺 - - + + @@ -53,12 +50,13 @@ {{ plan.icon }} {{ plan.label }} - - - + + + 已完成 + + + 未完成 + @@ -79,8 +77,9 @@ diff --git a/src/pages/record/record.vue b/src/pages/record/record.vue index c58e71b..fac415d 100644 --- a/src/pages/record/record.vue +++ b/src/pages/record/record.vue @@ -18,10 +18,7 @@ - - 📭 - 暂无记录 - + @@ -54,8 +51,8 @@ {{ item.time }} - - {{ getRecordStatus(item) }} + + {{ getRecordStatus(item).label }} @@ -80,36 +77,6 @@ - - - - - - - 🤖 - AI 健康分析 - - {{ aiSummary.dateRange }} - - - - - {{ aiSummary.text }} - - - - - - {{ tag }} - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/store/profile.ts b/src/store/profile.ts new file mode 100644 index 0000000..7c15bb7 --- /dev/null +++ b/src/store/profile.ts @@ -0,0 +1,18 @@ +import { defineStore } from 'pinia' +import type { IProfile } from '@/utils/profile' + +export const useProfileStore = defineStore('profile', { + state: () => ({ + showProfilePopup: false, + profileForm: { + gender: '', + height: 0, + name: '', + weight: 0, + } as IProfile, + isRefresh: false, + }), + actions: { + + }, +}) diff --git a/src/utils/profile.ts b/src/utils/profile.ts new file mode 100644 index 0000000..9572c74 --- /dev/null +++ b/src/utils/profile.ts @@ -0,0 +1,25 @@ +export interface IProfile { + name: string + gender: 'male' | 'female' | '' + height: number | null + weight: number | null +} + +const PROFILE_KEY = 'user_profile' + +function getEmptyProfile(): IProfile { + return { + gender: '', + height: null, + name: '', + weight: null, + } +} + +export function getProfile(): IProfile { + return wx.getStorageSync(PROFILE_KEY) || getEmptyProfile() +} + +export function saveProfile(data: IProfile) { + wx.setStorageSync(PROFILE_KEY, data) +} diff --git a/src/utils/record.ts b/src/utils/record.ts index 41248da..6141370 100644 --- a/src/utils/record.ts +++ b/src/utils/record.ts @@ -1,4 +1,23 @@ -import type { IHealthRecord, IRecordMeta } from '@/types/record' +import { getProfile } from '@/utils/profile' + +export interface IHealthRecord { + id: string + type: string + time: string + date?: string + [key: string]: any +} + +export interface IRecordMeta { + icon: string + label: string + color: string +} + +export interface IRecordStats { + label: string + type: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'volcano' | 'lightblue' | 'cyan' | 'pink' | 'purple' +} const MONTH_KEEP = 12 @@ -161,48 +180,78 @@ export function getRecordValue(record: IHealthRecord): string { } } -export function getRecordStatus(record: IHealthRecord): string { +export function getRecordStatus(record: IHealthRecord): IRecordStats { + const profile = getProfile() + switch (record.type) { case 'bloodPressure': - if (record.systolic >= 140 || record.diastolic >= 90) - return '偏高' - if (record.systolic < 90 || record.diastolic < 60) - return '偏低' - return '正常' - - case 'bloodSugar': - if (record.period.includes('空腹')) { - return record.value >= 6.1 ? '偏高' : '正常' + if (record.systolic >= 140 || record.diastolic >= 90) { + return { label: '偏高', type: 'danger' } } - // 餐后 - return record.value >= 7.8 ? '偏高' : '正常' + if (record.systolic < 90 || record.diastolic < 60) { + return { label: '偏低', type: 'danger' } + } + return { label: '正常', type: 'primary' } + + case 'weight': { + if (!profile.height) { + return { label: '身高未知', type: 'default' } + } + const bmi = (record.value * 10000) / (profile.height * profile.height) + if (bmi < 18.5) + return { label: '偏瘦', type: 'warning' } + if (bmi < 24) + return { label: '正常', type: 'primary' } + if (bmi < 28) + return { label: '偏重', type: 'danger' } + return { label: '肥胖', type: 'danger' } + } + + case 'bloodSugar': { + const period = record.period || '' + let limit = 11.1 + if (period.includes('空腹') || period.includes('睡前')) + limit = 6.1 + else if (period.includes('餐后1h')) + limit = 11.1 + else if (period.includes('餐后2h')) + limit = 7.8 + + if (record.value < 3.9) + return { label: '偏低', type: 'danger' } + if (record.value >= limit) + return { label: '偏高', type: 'danger' } + return { label: '正常', type: 'primary' } + } case 'heartRate': if (record.value < 60) - return '偏慢' + return { label: '偏慢', type: 'warning' } if (record.value <= 100) - return '正常' - return '偏快' + return { label: '正常', type: 'primary' } + return { label: '偏快', type: 'warning' } case 'temperature': if (record.value < 36.1) - return '偏低' + return { label: '偏低', type: 'warning' } if (record.value <= 37.2) - return '正常' - return '偏高' + return { label: '正常', type: 'primary' } + return { label: '偏高', type: 'danger' } case 'sport': - return record.duration >= 30 ? '达标' : '偏少' + return record.duration >= 30 + ? { label: '达标', type: 'success' } + : { label: '偏少', type: 'warning' } case 'sleep': if (record.duration >= 7) - return '充足' + return { label: '充足', type: 'success' } if (record.duration >= 6) - return '良好' - return '不足' + return { label: '良好', type: 'primary' } + return { label: '不足', type: 'warning' } default: - return '未知' + return { label: '未知', type: 'default' } } }