feat: 更新AI报告接口路径
This commit is contained in:
@@ -124,10 +124,9 @@ function cancelClick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onShareAppMessage(() => {
|
onShareAppMessage(() => {
|
||||||
const id = 123
|
|
||||||
return {
|
return {
|
||||||
title: recordStore.aiResult?.title,
|
title: recordStore.aiResult?.title,
|
||||||
path: `/pages/report/index?reportId=${id}`,
|
path: `/pages/report/index?reportId=${recordStore.reportId}`,
|
||||||
imageUrl: '/static/tabs/record-active.png'
|
imageUrl: '/static/tabs/record-active.png'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -264,11 +264,13 @@ const AIClick = () => {
|
|||||||
.then(async () => {
|
.then(async () => {
|
||||||
try {
|
try {
|
||||||
recordStore.isAnalyzing = true
|
recordStore.isAnalyzing = true
|
||||||
// recordStore.aiResult = {}
|
recordStore.aiResult = {}
|
||||||
// const data = await getReport(report)
|
const data = await getReport(report)
|
||||||
// recordStore.aiResult = JSON.parse(data)
|
recordStore.aiResult = JSON.parse(data)
|
||||||
|
|
||||||
|
const id = await uploadReport(data)
|
||||||
|
recordStore.reportId = id
|
||||||
|
|
||||||
// TODO 结果上传到服务器 返回报告id
|
|
||||||
recordStore.showAIResultPopup = true
|
recordStore.showAIResultPopup = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
recordStore.showAIButton = true
|
recordStore.showAIButton = true
|
||||||
@@ -297,7 +299,7 @@ const AIClick = () => {
|
|||||||
async function getReport(query: string) {
|
async function getReport(query: string) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
wx.request({
|
wx.request({
|
||||||
url: 'http://127.0.0.1:8000/agent/report',
|
url: 'https://cxx0822.s.3q.hair/health-api/agent/report',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
header: { 'Content-Type': 'application/json' },
|
header: { 'Content-Type': 'application/json' },
|
||||||
data: JSON.stringify({ query: query }),
|
data: JSON.stringify({ query: query }),
|
||||||
@@ -312,6 +314,25 @@ async function getReport(query: string) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function uploadReport(report: string) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wx.request({
|
||||||
|
url: 'https://cxx0822.s.3q.hair/health-api/report',
|
||||||
|
method: 'POST',
|
||||||
|
header: { 'Content-Type': 'application/json' },
|
||||||
|
data: JSON.stringify({ content: report }),
|
||||||
|
success: (res) => {
|
||||||
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
|
resolve(res.data)
|
||||||
|
} else {
|
||||||
|
reject({ status: res.statusCode, data: res.data })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => reject(err),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -104,60 +104,37 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { IAiReport } from "@/type/report";
|
import type { IAiReport } from "@/type/report";
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
|
||||||
const report = ref<IAiReport>({
|
const report = ref<IAiReport>()
|
||||||
title: "Cxx的健康月报 · 2026年9月",
|
|
||||||
greeting: "Cxx你好!这个月你完成了3天的健康数据记录,虽然覆盖还不算全面,但坚持记录就是好的开始。当前体重约69.9kg,BMI约24.2,略高于标准上限,结合你的均衡饮食目标,可以先从调整饮食和增加活动入手。本月亮点是睡眠达标且空腹血糖正常,但血压呈现升高趋势,需要多加留意。",
|
onLoad(async (options) => {
|
||||||
sections: [
|
const reportId = options?.reportId
|
||||||
{
|
if (!reportId) return
|
||||||
type: "weight",
|
|
||||||
emoji: "⚖️",
|
const result = await getReport(reportId)
|
||||||
title: "体重",
|
report.value = result
|
||||||
hasAbnormal: false,
|
|
||||||
data: "体重从70kg降至69.7kg,整体平稳,平均69.9kg,波动幅度仅0.3kg。根据身高170cm计算,BMI约24.2,略超标准范围上限。",
|
|
||||||
suggestion: "结合均衡饮食目标,继续保持清淡饮食,减少高油高糖食物,并配合适量运动。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "sleep",
|
|
||||||
emoji: "😴",
|
|
||||||
title: "睡眠",
|
|
||||||
hasAbnormal: false,
|
|
||||||
data: "本月记录1次睡眠,时长8小时,达标率100%,睡眠质量表现很好。",
|
|
||||||
suggestion: "保持规律的作息时间,尽量在固定时间就寝和起床,让好习惯延续下去。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "sport",
|
|
||||||
emoji: "🏃",
|
|
||||||
title: "运动",
|
|
||||||
hasAbnormal: true,
|
|
||||||
data: "运动记录7次,实际运动1天,总时长30分钟,运动频率14.3%,最长连续不运动2天。考虑到你久坐少动的状态,运动量还需要提升。",
|
|
||||||
suggestion: "建议每周累计至少150分钟中等强度运动,可以从快走、跑步等开始,每小时起身活动5分钟。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "bloodPressure",
|
|
||||||
emoji: "❤️",
|
|
||||||
title: "血压",
|
|
||||||
hasAbnormal: true,
|
|
||||||
data: "收缩压从120升至145mmHg,舒张压从70升至97mmHg,平均血压约132.5/83.5mmHg,异常率50%;心率平均80次/分。血压升高明显,需要重视。",
|
|
||||||
suggestion: "请尽快复测血压并咨询医生,同时注意低盐饮食、避免熬夜、减轻压力,并坚持每日监测。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "bloodSugar",
|
|
||||||
emoji: "🩸",
|
|
||||||
title: "血糖",
|
|
||||||
hasAbnormal: false,
|
|
||||||
data: "空腹血糖5.4mmol/L,处于正常范围,餐前、餐后及睡前血糖暂无记录。",
|
|
||||||
suggestion: "继续保持均衡饮食,控制精制糖和甜食摄入,后续可完善餐后血糖记录。"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
tips: [
|
|
||||||
"血压是本月的重点预警项:高压和低压均有明显上升,建议尽快就医复测,并在医生指导下规律监测。",
|
|
||||||
"结合久坐少动的工作特点,每坐1小时就起身活动几分钟,下班后安排30分钟快走或慢跑,逐渐增加运动频率。",
|
|
||||||
"把均衡饮食落到实处:减少盐和油,多吃蔬菜水果,少吃腌制食品和外卖,帮助体重和血压一起改善。"
|
|
||||||
],
|
|
||||||
ending: "健康管理是一场长跑,不必追求完美,只要持续用心就好。下个月继续一起关注血压和运动,期待你更好的状态!"
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function getReport(reportId: number) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
wx.request({
|
||||||
|
url: `https://cxx0822.s.3q.hair/health-api/report/${reportId}`,
|
||||||
|
method: 'GET',
|
||||||
|
header: { 'Content-Type': 'application/json' },
|
||||||
|
data: JSON.stringify({ content: report }),
|
||||||
|
success: (res) => {
|
||||||
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
|
resolve(res.data)
|
||||||
|
} else {
|
||||||
|
reject({ status: res.statusCode, data: res.data })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => reject(err),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function goHome() {
|
function goHome() {
|
||||||
uni.switchTab({ url: '/pages/index/index' })
|
uni.switchTab({ url: '/pages/index/index' })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,58 +54,8 @@ export const useRecordStore = defineStore('record', {
|
|||||||
isAnalyzing: false,
|
isAnalyzing: false,
|
||||||
showAIResultPopup: false,
|
showAIResultPopup: false,
|
||||||
showAIButton: true,
|
showAIButton: true,
|
||||||
aiResult: {
|
aiResult: {} as IAiReport,
|
||||||
title: "Cxx的健康月报 · 2026年9月",
|
reportId: 0
|
||||||
greeting: "Cxx你好!这个月你完成了3天的健康数据记录,虽然覆盖还不算全面,但坚持记录就是好的开始。当前体重约69.9kg,BMI约24.2,略高于标准上限,结合你的均衡饮食目标,可以先从调整饮食和增加活动入手。本月亮点是睡眠达标且空腹血糖正常,但血压呈现升高趋势,需要多加留意。",
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
type: "weight",
|
|
||||||
emoji: "⚖️",
|
|
||||||
title: "体重",
|
|
||||||
hasAbnormal: false,
|
|
||||||
data: "体重从70kg降至69.7kg,整体平稳,平均69.9kg,波动幅度仅0.3kg。根据身高170cm计算,BMI约24.2,略超标准范围上限。",
|
|
||||||
suggestion: "结合均衡饮食目标,继续保持清淡饮食,减少高油高糖食物,并配合适量运动。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "sleep",
|
|
||||||
emoji: "😴",
|
|
||||||
title: "睡眠",
|
|
||||||
hasAbnormal: false,
|
|
||||||
data: "本月记录1次睡眠,时长8小时,达标率100%,睡眠质量表现很好。",
|
|
||||||
suggestion: "保持规律的作息时间,尽量在固定时间就寝和起床,让好习惯延续下去。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "sport",
|
|
||||||
emoji: "🏃",
|
|
||||||
title: "运动",
|
|
||||||
hasAbnormal: true,
|
|
||||||
data: "运动记录7次,实际运动1天,总时长30分钟,运动频率14.3%,最长连续不运动2天。考虑到你久坐少动的状态,运动量还需要提升。",
|
|
||||||
suggestion: "建议每周累计至少150分钟中等强度运动,可以从快走、跑步等开始,每小时起身活动5分钟。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "bloodPressure",
|
|
||||||
emoji: "❤️",
|
|
||||||
title: "血压",
|
|
||||||
hasAbnormal: true,
|
|
||||||
data: "收缩压从120升至145mmHg,舒张压从70升至97mmHg,平均血压约132.5/83.5mmHg,异常率50%;心率平均80次/分。血压升高明显,需要重视。",
|
|
||||||
suggestion: "请尽快复测血压并咨询医生,同时注意低盐饮食、避免熬夜、减轻压力,并坚持每日监测。"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "bloodSugar",
|
|
||||||
emoji: "🩸",
|
|
||||||
title: "血糖",
|
|
||||||
hasAbnormal: false,
|
|
||||||
data: "空腹血糖5.4mmol/L,处于正常范围,餐前、餐后及睡前血糖暂无记录。",
|
|
||||||
suggestion: "继续保持均衡饮食,控制精制糖和甜食摄入,后续可完善餐后血糖记录。"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
tips: [
|
|
||||||
"血压是本月的重点预警项:高压和低压均有明显上升,建议尽快就医复测,并在医生指导下规律监测。",
|
|
||||||
"结合久坐少动的工作特点,每坐1小时就起身活动几分钟,下班后安排30分钟快走或慢跑,逐渐增加运动频率。",
|
|
||||||
"把均衡饮食落到实处:减少盐和油,多吃蔬菜水果,少吃腌制食品和外卖,帮助体重和血压一起改善。"
|
|
||||||
],
|
|
||||||
ending: "健康管理是一场长跑,不必追求完美,只要持续用心就好。下个月继续一起关注血压和运动,期待你更好的状态!"
|
|
||||||
} as IAiReport
|
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
openWeight() {
|
openWeight() {
|
||||||
|
|||||||
Reference in New Issue
Block a user