diff --git a/src/components/Home/RecipePopup.vue b/src/components/Home/RecipePopup.vue
new file mode 100644
index 0000000..f3faf85
--- /dev/null
+++ b/src/components/Home/RecipePopup.vue
@@ -0,0 +1,33 @@
+
+
+
+
+ {{ appStore.currentRecipe.name }}
+
+
+
+
+
+
+
+
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 061d213..65826d1 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -100,6 +100,26 @@
+
+
+
+
+
+
+ {{ item.name }}
+
+ {{ tag }}
+
+
+
+
+
@@ -109,6 +129,7 @@
+
@@ -136,9 +157,10 @@ import { getOverview, getPlan, getProfile } from "@/utils/profile";
import appLogo from '@/static/logo.png'
import type { IOverview, IPlan } from "@/type/profile";
import { addSignInPoint } from "@/utils/points";
-import type { ITip } from "@/type";
+import type { IRecipe, ITip } from "@/type";
import TipPopup from "@/components/Home/TipPopup.vue";
import { getTheme, getThemePrimaryColor, getThemeStyle } from "@/utils/themes";
+import RecipePopup from "@/components/Home/RecipePopup.vue";
defineOptions({
name: 'Home',
@@ -151,6 +173,7 @@ const appStore = useAppStore()
const todayRecords = ref([])
const tipList = ref([])
+const recipeList = ref([])
const errorMessage = ref("")
const hasSignedToday = ref(checkSignedToday())
@@ -187,6 +210,7 @@ onShow(() => {
todayRecords.value = getDayRecords(getDateStr(Date.now()))
hasSignedToday.value = checkSignedToday()
getTipList()
+ getRecipeList()
})
watch(() => recordStore.isRecord, () => {
@@ -208,12 +232,33 @@ function getTipList() {
});
}
+function getRecipeList() {
+ wx.request({
+ url: 'https://cxx0822.s.3q.hair/health-api/agent/recipe/latest',
+ method: 'GET',
+ header: { 'Content-Type': 'application/json' },
+ success: (res) => {
+ recipeList.value = res.data as IRecipe[]
+ },
+ fail: (err) => {
+ console.error('请求失败:', err);
+ errorMessage.value = err.errMsg
+ }
+ });
+}
+
const viewTipClick = (item: ITip) => {
appStore.currentTip = item
appStore.showTipPopup = true
recordStore.showFab = false
}
+const viewRecipeClick = (item: IRecipe) => {
+ appStore.currentRecipe = item
+ appStore.showRecipePopup = true
+ recordStore.showFab = false
+}
+
// 今日概览
const overviewItems = computed(() => {
const list = todayRecords.value
diff --git a/src/pages/stats/index.vue b/src/pages/stats/index.vue
index 43bb6b9..9fbffe4 100644
--- a/src/pages/stats/index.vue
+++ b/src/pages/stats/index.vue
@@ -136,7 +136,8 @@ const currentPeriod = ref('空腹')
const periodColumns = [
{ label: '空腹', value: '空腹' },
{ label: '餐前', value: '餐前' },
- { label: '餐后2h', value: '餐后2h' }
+ { label: '餐后2h', value: '餐后2h' },
+ { label: '睡前', value: '睡前' }
]
const weightChartData = ref({
diff --git a/src/store/app.ts b/src/store/app.ts
index abf4ff3..08ba14f 100644
--- a/src/store/app.ts
+++ b/src/store/app.ts
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
-import type { ITip } from "@/type";
+import type {IRecipe, ITip} from "@/type";
export const useAppStore = defineStore('app', {
state: () => ({
@@ -9,13 +9,19 @@ export const useAppStore = defineStore('app', {
recordCount: 0,
achievement: '',
showTipPopup: false,
+ showRecipePopup: false,
themeColor: 'purple',
currentTip: {
title: '',
summary: '',
category: '',
content: '',
- } as ITip
+ } as ITip,
+ currentRecipe: {
+ name: '',
+ tags: [],
+ content: '',
+ } as IRecipe,
}),
actions: {
diff --git a/src/type/index.ts b/src/type/index.ts
index c181d2a..3a76a9a 100644
--- a/src/type/index.ts
+++ b/src/type/index.ts
@@ -9,3 +9,9 @@ export interface ITip {
category: string;
content: string;
}
+
+export interface IRecipe {
+ name: string;
+ tags: string[];
+ content: string;
+}