Commit 998a14ac authored by 王炽's avatar 王炽

666666

parent 6ed1201b
...@@ -12,4 +12,8 @@ export const growthHome = (babyId) => api.post('/c/growth/home', { babyId }); ...@@ -12,4 +12,8 @@ export const growthHome = (babyId) => api.post('/c/growth/home', { babyId });
export const guideCompleted = () => api.post('/c/growth/guide/Completed'); export const guideCompleted = () => api.post('/c/growth/guide/Completed');
export const assessmentSave = (data) => api.post('/c/growth/assessment/save', data); export const assessmentSave = (data) => api.post('/c/growth/assessment/save', data);
export const getGrowthCurveData = (babyData) => api.post('/c/growth/curve/data', babyData);
export const getGrowthHistoryList = () => api.post('/c/growth/history/list');
// export const fetchHomeJSON = () => api.get('/c/front/content',{type:'home'}); // export const fetchHomeJSON = () => api.get('/c/front/content',{type:'home'});
\ No newline at end of file
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
<!-- <view class="back-btn" @click="backHandler"> <!-- <view class="back-btn" @click="backHandler">
<text class="back-text"></text> <text class="back-text"></text>
</view> --> </view> -->
<text class="title">生长测评</text>
<image @tap="backHandler" class="back-btn" :src="`/static/shengzhangTool/backBtn.png`"></image> <image @tap="backHandler" class="back-btn" :src="`/static/shengzhangTool/backBtn.png`"></image>
<text class="title">生长测评</text>
<view class="content-wrapper"> <view class="content-wrapper">
...@@ -177,6 +177,7 @@ ...@@ -177,6 +177,7 @@
<view class="legend-color normal"></view> <view class="legend-color normal"></view>
<text class="legend-text">正常</text> <text class="legend-text">正常</text>
</view> </view>
<view class="legend-item"> <view class="legend-item">
<view class="legend-color slightly-high"></view> <view class="legend-color slightly-high"></view>
<text class="legend-text">略高</text> <text class="legend-text">略高</text>
...@@ -263,7 +264,8 @@ ...@@ -263,7 +264,8 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useShengzhangStore } from '../../stores/shengzhangResult.js'; import { useShengzhangStore } from '../../stores/shengzhangResult.js';
import { formatDate } from '../../utils/index.js'; import { formatDate, jump, JumpType } from '../../utils/index.js';
import { getGrowthHistoryList } from '../../api/shengzhangTools';
// 导航标签状态 // 导航标签状态
const activeTab = ref('latest') // 默认显示最新内容 const activeTab = ref('latest') // 默认显示最新内容
...@@ -359,6 +361,9 @@ const curveData = ref([ ...@@ -359,6 +361,9 @@ const curveData = ref([
{ month: 7, height: 72 } { month: 7, height: 72 }
]) ])
const curveDataPostHeight = ref([]);
const curveDataPostWeight = ref([]);
const curveDataPostHead = ref([]);
// 生成0-36个月的数据点 // 生成0-36个月的数据点
/** /**
* @param {number} startValue - 起始值(0个月时的数值) * @param {number} startValue - 起始值(0个月时的数值)
...@@ -377,22 +382,40 @@ const generateCurveData = (startValue, endValue, type) => { ...@@ -377,22 +382,40 @@ const generateCurveData = (startValue, endValue, type) => {
return data return data
} }
//获取宝宝曲线数据范围4条线,用于绘制曲线
const generateCurveData1 = (lineData, type, arrayName, minOrMax) =>{
const data = [];
lineData.forEach(element => {
const point = { month: element.monthAge }
point[type] = minOrMax === 'min' ? element?.[arrayName]?.min : element?.[arrayName]?.max
data.push(point);
});
console.log('data888888=', data);
return data;
}
// slightHighRange
// slightLowRange
// 标准生长曲线数据(多条线,延长到36个月) // 标准生长曲线数据(多条线,延长到36个月)
const standardCurves = ref({ const standardCurves = ref({
height: { height: {
slightlyLow: generateCurveData(45, 105, 'height'), slightlyLow: generateCurveData1(curveDataPostHeight.value, 'height', 'slightLowRange', 'min'),
normal: generateCurveData(50, 110, 'height'), // normal: generateCurveData(50, 110, 'height'),
slightlyHigh: generateCurveData(55, 115, 'height') normal: generateCurveData1(curveDataPostHeight.value, 'height', 'normalRange', 'min'),
normal2: generateCurveData1(curveDataPostHeight.value, 'height', 'normalRange', 'max'), // 新增的a8e6cf颜色曲线
slightlyHigh: generateCurveData1(curveDataPostHeight.value, 'height', 'slightHighRange', 'max')
}, },
weight: { weight: {
slightlyLow: generateCurveData(2.5, 15.0, 'weight'), slightlyLow: generateCurveData1(curveDataPostWeight.value, 'weight', 'slightLowRange', 'min'),
normal: generateCurveData(3.0, 16.5, 'weight'), normal: generateCurveData1(curveDataPostWeight.value, 'weight', 'normalRange', 'min'),
slightlyHigh: generateCurveData(3.5, 18.0, 'weight') normal2: generateCurveData1(curveDataPostWeight.value, 'weight', 'normalRange', 'max'), // 新增的a8e6cf颜色曲线
slightlyHigh: generateCurveData1(curveDataPostWeight.value, 'weight', 'slightHighRange', 'max')
}, },
head: { head: {
slightlyLow: generateCurveData(32, 52, 'head'), slightlyLow: generateCurveData1(curveDataPostHead.value, 'head', 'slightLowRange', 'min'),
normal: generateCurveData(34, 54, 'head'), normal: generateCurveData1(curveDataPostHead.value, 'head', 'normalRange', 'min'),
slightlyHigh: generateCurveData(36, 56, 'head') normal2: generateCurveData1(curveDataPostHead.value, 'head', 'normalRange', 'max'), // 新增的a8e6cf颜色曲线
slightlyHigh: generateCurveData1(curveDataPostHead.value, 'head', 'slightHighRange', 'max')
} }
}) })
...@@ -461,6 +484,17 @@ const switchCurveTab = (tab) => { ...@@ -461,6 +484,17 @@ const switchCurveTab = (tab) => {
}, 100) }, 100)
} }
//获取当前宝宝曲线数据,用于绘制曲线
const generateCurveData2 = (lineData, type, arrayName, minOrMax) =>{
const data = [];
lineData.forEach(element => {
const point = { month: element.monthAge }
point[type] = minOrMax === 'min' ? element?.[arrayName]?.min : element?.[arrayName]?.max
data.push(point);
});
return data;
}
// 获取Y轴标签 // 获取Y轴标签
/** /**
* @returns {string} 根据当前曲线类型返回对应的Y轴标签 * @returns {string} 根据当前曲线类型返回对应的Y轴标签
...@@ -521,6 +555,7 @@ const consultExpert = () => { ...@@ -521,6 +555,7 @@ const consultExpert = () => {
* 处理返回按钮点击事件,尝试返回上一页或跳转到首页 * 处理返回按钮点击事件,尝试返回上一页或跳转到首页
*/ */
const backHandler = () => { const backHandler = () => {
console.log('backHandler');
try { try {
uni.navigateBack({ uni.navigateBack({
success: () => { success: () => {
...@@ -537,12 +572,17 @@ const backHandler = () => { ...@@ -537,12 +572,17 @@ const backHandler = () => {
} }
} }
onMounted(() => { const backFailHandler = () => {
console.log('backFailHandler');
}
onMounted(async () => {
// 初始化绘制曲线 // 初始化绘制曲线
setTimeout(() => { setTimeout(() => {
drawGrowthCurve() drawGrowthCurve()
}, 100) }, 100)
//分析结果处理
const shengzhangStore = useShengzhangStore(); const shengzhangStore = useShengzhangStore();
const data = {...shengzhangStore.shengzhangInfo.babyInfo}; const data = {...shengzhangStore.shengzhangInfo.babyInfo};
data.assessmentDate = formatDate(shengzhangStore.shengzhangInfo.assessmentDate); data.assessmentDate = formatDate(shengzhangStore.shengzhangInfo.assessmentDate);
...@@ -554,6 +594,50 @@ onMounted(() => { ...@@ -554,6 +594,50 @@ onMounted(() => {
contentText.value = shengzhangStore.shengzhangInfo.content; contentText.value = shengzhangStore.shengzhangInfo.content;
//生长曲线处理
curveDataPostHeight.value = shengzhangStore.getGrowthCurveDataInfoHeight.curveData;
curveDataPostWeight.value = shengzhangStore.getGrowthCurveDataInfoWeight.curveData;
curveDataPostHead.value = shengzhangStore.getGrowthCurveDataInfoHead.curveData;
console.log('curveDataPostHeight.value=', curveDataPostHeight.value);
standardCurves.value = {
height: {
// slightlyLow: generateCurveData(45, 105, 'height'),
// normal: generateCurveData(50, 110, 'height'),
slightlyLow: generateCurveData1(curveDataPostHeight.value, 'height', 'slightLowRange', 'min'),
normal: generateCurveData1(curveDataPostHeight.value, 'height', 'normalRange', 'min'),
normal2: generateCurveData1(curveDataPostHeight.value, 'height', 'normalRange', 'max'), // 新增的a8e6cf颜色曲线
slightlyHigh: generateCurveData1(curveDataPostHeight.value, 'height', 'slightHighRange', 'max'),
// slightlyHigh: generateCurveData(55, 115, 'height')slightHighRange
},
weight: {
// slightlyLow: generateCurveData(2.5, 15.0, 'weight'),
// normal: generateCurveData(3.0, 16.5, 'weight'),
// normal2: generateCurveData(3.2, 17.0, 'weight'), // 新增的a8e6cf颜色曲线
// slightlyHigh: generateCurveData(3.5, 18.0, 'weight')
slightlyLow: generateCurveData1(curveDataPostWeight.value, 'weight', 'slightLowRange', 'min'),
normal: generateCurveData1(curveDataPostWeight.value, 'weight', 'normalRange', 'min'),
normal2: generateCurveData1(curveDataPostWeight.value, 'weight', 'normalRange', 'max'), // 新增的a8e6cf颜色曲线
slightlyHigh: generateCurveData1(curveDataPostWeight.value, 'weight', 'slightHighRange', 'max'),
},
head: {
// slightlyLow: generateCurveData(32, 52, 'head'),
// normal: generateCurveData(34, 54, 'head'),
// normal2: generateCurveData(35, 55, 'head'), // 新增的a8e6cf颜色曲线
// slightlyHigh: generateCurveData(36, 56, 'head')
slightlyLow: generateCurveData1(curveDataPostHead.value, 'head', 'slightLowRange', 'min'),
normal: generateCurveData1(curveDataPostHead.value, 'head', 'normalRange', 'min'),
normal2: generateCurveData1(curveDataPostHead.value, 'head', 'normalRange', 'max'), // 新增的a8e6cf颜色曲线
slightlyHigh: generateCurveData1(curveDataPostHead.value, 'head', 'slightHighRange', 'max'),
}
};
debugger;
const historyListData = await getGrowthHistoryList();
console.log('historyListData=', historyListData);
}) })
// 绘制生长曲线 // 绘制生长曲线
...@@ -727,6 +811,9 @@ const drawStandardCurves = (ctx, curves, margin, chartWidth, chartHeight, type) ...@@ -727,6 +811,9 @@ const drawStandardCurves = (ctx, curves, margin, chartWidth, chartHeight, type)
// 绘制正常曲线 - 浅绿色 // 绘制正常曲线 - 浅绿色
drawCurve(ctx, curves.normal, margin, chartWidth, chartHeight, type, '#a8e6cf', 2) drawCurve(ctx, curves.normal, margin, chartWidth, chartHeight, type, '#a8e6cf', 2)
// 绘制新增的正常曲线2 - 浅绿色(不重合)
drawCurve(ctx, curves.normal2, margin, chartWidth, chartHeight, type, '#a8e6cf', 2)
// 绘制略高曲线 - 紫色 // 绘制略高曲线 - 紫色
drawCurve(ctx, curves.slightlyHigh, margin, chartWidth, chartHeight, type, '#d4a5f5', 2) drawCurve(ctx, curves.slightlyHigh, margin, chartWidth, chartHeight, type, '#d4a5f5', 2)
} }
...@@ -1437,6 +1524,10 @@ const onScroll = (e) => { ...@@ -1437,6 +1524,10 @@ const onScroll = (e) => {
background-color: #89caa2; // 浅绿色 background-color: #89caa2; // 浅绿色
} }
&.normal2 {
background-color: #a8e6cf; // 浅绿色(第二条线)
}
&.slightly-high { &.slightly-high {
background-color: #f3d1e9; // 紫色 background-color: #f3d1e9; // 紫色
} }
......
...@@ -227,7 +227,7 @@ import BabySwitchPopup from '@/components/BabySwitchPopup.vue' ...@@ -227,7 +227,7 @@ import BabySwitchPopup from '@/components/BabySwitchPopup.vue'
import BabyFeedSwitchPopup from '@/components/BabyFeedSwitchPopup.vue' import BabyFeedSwitchPopup from '@/components/BabyFeedSwitchPopup.vue'
import DatePickerPopup from '@/components/DatePickerPopup.vue' import DatePickerPopup from '@/components/DatePickerPopup.vue'
import BabyTestTipsPopup from '@/components/BabyTestTipsPopup.vue' import BabyTestTipsPopup from '@/components/BabyTestTipsPopup.vue'
import { growthHome, guideCompleted } from '../../api/shengzhangTools' import { growthHome, guideCompleted, getGrowthCurveData } from '../../api/shengzhangTools'
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import { throttleTap,jump, JumpType, formatDate } from '../../utils/index.js'; import { throttleTap,jump, JumpType, formatDate } from '../../utils/index.js';
import { useShengzhangStore } from '../../stores/shengzhangResult.js'; import { useShengzhangStore } from '../../stores/shengzhangResult.js';
...@@ -391,8 +391,35 @@ const submitData = throttleTap(async () => { ...@@ -391,8 +391,35 @@ const submitData = throttleTap(async () => {
await shengzhangStore.assessmentSave(submitData); await shengzhangStore.assessmentSave(submitData);
console.log('shengzhangStore=', shengzhangStore.shengzhangInfo);
const babyDataHeight = {
babyId: babyId.value,
curveType: 'HEIGHT',
startMonth: 0,
endMonth: 36,
};
await shengzhangStore.getGrowthCurveData(babyDataHeight);
const babyDataWeight = {
babyId: babyId.value,
curveType: 'WEIGHT',
startMonth: 0,
endMonth: 36,
};
await shengzhangStore.getGrowthCurveData(babyDataWeight);
const babyDataHead = {
babyId: babyId.value,
curveType: 'HEAD',
startMonth: 0,
endMonth: 36,
};
await shengzhangStore.getGrowthCurveData(babyDataHead);
//跳转测评结果页
if(shengzhangStore.shengzhangInfo.success){ if(shengzhangStore.shengzhangInfo.success){
jump({ jump({
type: JumpType.INNER, type: JumpType.INNER,
......
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { import {
assessmentSave assessmentSave,
getGrowthCurveData
} from "../api/shengzhangTools.js"; } from "../api/shengzhangTools.js";
export const useShengzhangStore = defineStore("shengzhangInfo", { export const useShengzhangStore = defineStore("shengzhangInfo", {
state: () => { state: () => {
return { return {
shengzhangInfo: null, shengzhangInfo: null,
getGrowthCurveDataInfoHeight: null,
getGrowthCurveDataInfoWeight: null,
getGrowthCurveDataInfoHead: null,
getGrowthCurveDataInfoBmi: null,
}; };
}, },
actions: { actions: {
...@@ -27,5 +32,43 @@ export const useShengzhangStore = defineStore("shengzhangInfo", { ...@@ -27,5 +32,43 @@ export const useShengzhangStore = defineStore("shengzhangInfo", {
} }
}, },
setGetGrowthCurveDataHeightInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoHeight = getGrowthCurveDataInfo;
},
setGetGrowthCurveDataWeightInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoWeight = getGrowthCurveDataInfo;
},
setGetGrowthCurveDataHeadInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoHead = getGrowthCurveDataInfo;
},
setGetGrowthCurveDataBmiInfo(getGrowthCurveDataInfo) {
this.getGrowthCurveDataInfoBmi = getGrowthCurveDataInfo;
},
async getGrowthCurveData(babyData) {
const data = await getGrowthCurveData(babyData);
if(data.success){
data.data.success = data.success;
switch(babyData.curveType){
case 'HEIGHT':
this.setGetGrowthCurveDataHeightInfo(data.data);
break;
case 'WEIGHT':
this.setGetGrowthCurveDataWeightInfo(data.data);
break;
case 'HEAD':
this.setGetGrowthCurveDataHeadInfo(data.data);
break;
case 'BMI':
this.setGetGrowthCurveDataBmiInfo(data.data);
break;
}
}
},
}, },
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment