From dd5e4a255a451e1c69ad12009572adaed60ddc73 Mon Sep 17 00:00:00 2001
From: Cxx0822 <1556464090@qq.com>
Date: Mon, 31 Aug 2026 19:50:25 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BB=8A=E6=97=A5?=
=?UTF-8?q?=E8=B5=84=E8=AE=AF=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Home/TipPopup.vue | 33 +++++++++++++++++++++++
src/pages/index/index.vue | 45 ++++++++++++++++++++++++++++++++
src/store/app.ts | 10 ++++++-
src/type/index.ts | 9 ++++++-
4 files changed, 95 insertions(+), 2 deletions(-)
create mode 100644 src/components/Home/TipPopup.vue
diff --git a/src/components/Home/TipPopup.vue b/src/components/Home/TipPopup.vue
new file mode 100644
index 0000000..8e5476d
--- /dev/null
+++ b/src/components/Home/TipPopup.vue
@@ -0,0 +1,33 @@
+
+
+
+
+ {{ appStore.currentTip.title }}
+
+
+
+
+
+
+
+
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 3961486..a337077 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -68,6 +68,27 @@
+
+
+
+ {{ item.category }}
+
+ {{ item.title }}
+
+
+
+
+
+ {{ item.summary }}
+
+
+
+
@@ -76,6 +97,7 @@
+
@@ -93,6 +115,7 @@ 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 { useAppStore } from '@/store/app'
import { getDateStr, getDayRecords, getTimeStr } from '@/utils/record'
import type { IHealthRecord } from "@/type/record";
import { onShow } from "@dcloudio/uni-app";
@@ -100,6 +123,8 @@ 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 TipPopup from "@/components/Home/TipPopup.vue";
defineOptions({
name: 'Home',
@@ -108,8 +133,10 @@ defineOptions({
const imgURL = appLogo
const recordStore = useRecordStore()
+const appStore = useAppStore()
const todayRecords = ref([])
+const tipList = ref([])
const hasSignedToday = ref(checkSignedToday())
const now = new Date()
@@ -144,12 +171,30 @@ const today = computed(() => {
onShow(() => {
todayRecords.value = getDayRecords(getDateStr(Date.now()))
hasSignedToday.value = checkSignedToday()
+
+ wx.request({
+ url: 'https://cxx0822.s.3q.hair/health-api/agent/tip/latest',
+ method: 'GET',
+ header: { 'Content-Type': 'application/json' },
+ success: (res) => {
+ tipList.value = res.data as ITip[]
+ },
+ fail: (err) => {
+ console.error('请求失败:', err);
+ }
+ });
})
watch(() => recordStore.isRecord, () => {
todayRecords.value = getDayRecords(getDateStr(Date.now()))
})
+const viewTipClick = (item: ITip) => {
+ appStore.currentTip = item
+ appStore.showTipPopup = true
+ recordStore.showFab = false
+}
+
// 今日概览
const overviewItems = computed(() => {
const list = todayRecords.value
diff --git a/src/store/app.ts b/src/store/app.ts
index 13238af..44accc2 100644
--- a/src/store/app.ts
+++ b/src/store/app.ts
@@ -1,4 +1,5 @@
import { defineStore } from 'pinia'
+import type { ITip } from "@/type";
export const useAppStore = defineStore('app', {
state: () => ({
@@ -6,7 +7,14 @@ export const useAppStore = defineStore('app', {
viewRecordType: 'calendar',
points: 0,
recordCount: 0,
- achievement: ''
+ achievement: '',
+ showTipPopup: false,
+ currentTip: {
+ title: '',
+ summary: '',
+ category: '',
+ content: '',
+ } as ITip
}),
actions: {
diff --git a/src/type/index.ts b/src/type/index.ts
index 07d5665..c181d2a 100644
--- a/src/type/index.ts
+++ b/src/type/index.ts
@@ -1,4 +1,11 @@
export interface IStats {
name: string;
- value: number
+ value: number;
+}
+
+export interface ITip {
+ title: string;
+ summary: string;
+ category: string;
+ content: string;
}