Commit 59557367 authored by 王炽's avatar 王炽

问题修复

parent 48329f8d
...@@ -48,7 +48,13 @@ const request = (options = {}) => { ...@@ -48,7 +48,13 @@ const request = (options = {}) => {
title: data.errMsg, title: data.errMsg,
icon: 'none' icon: 'none'
}); });
reject(data); // 返回完整的响应数据,包括状态码和错误信息
reject({
statusCode: data.statusCode,
errMsg: data.errMsg,
data: data.data,
success: false
});
globalStore.setIsShowLoading(false); globalStore.setIsShowLoading(false);
} }
else if (!data.data?.ok) { else if (!data.data?.ok) {
...@@ -56,7 +62,12 @@ const request = (options = {}) => { ...@@ -56,7 +62,12 @@ const request = (options = {}) => {
title: data.data?.message, title: data.data?.message,
icon: 'none' icon: 'none'
}); });
reject(data.data); // 返回业务逻辑错误的数据
reject({
...data.data,
statusCode: data.statusCode,
success: false
});
globalStore.setIsShowLoading(false); globalStore.setIsShowLoading(false);
} }
else { else {
...@@ -64,25 +75,43 @@ const request = (options = {}) => { ...@@ -64,25 +75,43 @@ const request = (options = {}) => {
} }
}) })
.catch((error) => { .catch((error) => {
reject(error); // 网络错误或其他异常
reject({
statusCode: -1,
errMsg: error.errMsg || '网络请求失败',
data: null,
success: false,
error: error
});
globalStore.setIsShowLoading(false); globalStore.setIsShowLoading(false);
}); });
}); });
}; };
const get = (url, data, options = {}) => { const get = async (url, data, options = {}) => {
options.type = "GET"; options.type = "GET";
options.data = data; options.data = data;
options.url = url; options.url = url;
return request(options);
try {
return await request(options);
} catch (error) {
// 返回错误数据,让调用方可以处理
return error;
}
}; };
const post = (url, data, options = {}) => { const post = async (url, data, options = {}) => {
options.type = "POST"; options.type = "POST";
options.data = data; options.data = data;
options.url = url; options.url = url;
return request(options);
try {
return await request(options);
} catch (error) {
// 返回错误数据,让调用方可以处理
return error;
}
}; };
export default { export default {
......
...@@ -17,5 +17,5 @@ export const getGrowthCurveData = (babyData) => api.post('/c/growth/curve/data', ...@@ -17,5 +17,5 @@ export const getGrowthCurveData = (babyData) => api.post('/c/growth/curve/data',
export const getGrowthHistoryList = () => api.post('/c/growth/history/list'); export const getGrowthHistoryList = () => api.post('/c/growth/history/list');
export const getGrowthAssessmentDetail = (assessmentId) => api.post('/c/growth/assessment/detail', { assessmentId }); export const getGrowthAssessmentDetail = (assessmentId) => api.get('/c/growth/assessment/detail', { assessmentId });
// 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
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<view class="baby-basic-info"> <view class="baby-basic-info">
<text class="gender">{{babyInfo.gender == 'M' ? '男' : '女'}}</text> <text class="gender">{{babyInfo.gender == 'M' ? '男' : '女'}}</text>
<text class="age">{{babyInfo.monthAge}}月龄</text> <text class="age">{{babyInfo.monthAge}}月龄</text>
<text class="test-date">测评于{{babyInfo.assessmentDate}}</text> <text class="test-date">测评于{{dateConvert(babyInfo.assessmentDate)}}</text>
</view> </view>
<view class="measurement-summary"> <view class="measurement-summary">
<view class="values-row"> <view class="values-row">
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
<view class="baby-basic-info"> <view class="baby-basic-info">
<text class="gender">{{item.gender == 'M' ? '男' : '女'}}</text> <text class="gender">{{item.gender == 'M' ? '男' : '女'}}</text>
<text class="age">{{item.age}}月龄</text> <text class="age">{{item.age}}月龄</text>
<text class="test-date">测评于{{item.testDate}}</text> <text class="test-date">测评于{{dateConvert(item.testDate)}}</text>
</view> </view>
<view class="measurement-summary"> <view class="measurement-summary">
<view class="values-row"> <view class="values-row">
...@@ -294,14 +294,18 @@ ...@@ -294,14 +294,18 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { onLoad } from "@dcloudio/uni-app"; import { onLoad, onShareAppMessage } from "@dcloudio/uni-app";
import { useShengzhangStore } from '../../stores/shengzhangResult.js'; import { useShengzhangStore } from '../../stores/shengzhangResult.js';
import { formatDate, jump, JumpType } from '../../utils/index.js'; import { formatDate, jump, JumpType } from '../../utils/index.js';
import { getGrowthHistoryList,getGrowthAssessmentDetail } from '../../api/shengzhangTools'; import { getGrowthHistoryList,getGrowthAssessmentDetail } from '../../api/shengzhangTools';
import ShengzhangQuxianTipsPopup from '../../components/shengzhangQuxianTipsPopup.vue'; import ShengzhangQuxianTipsPopup from '../../components/shengzhangQuxianTipsPopup.vue';
import { useUserStore } from "@/stores/user";
import { getHealthField } from "@/api/common";
const isRecords = ref(false); const isRecords = ref(false);
const shareText = ref('')
onLoad((options) => { onLoad((options) => {
isRecords.value = options.isRecords; isRecords.value = options.isRecords;
activeTab.value = isRecords.value ? 'history' : 'latest'; activeTab.value = isRecords.value ? 'history' : 'latest';
...@@ -396,6 +400,11 @@ const historyList = ref([ ...@@ -396,6 +400,11 @@ const historyList = ref([
]) ])
const dateConvert = (date) => {
const dateArray = date.split('-');
return dateArray[0] + '年' + dateArray[1] + '月' + dateArray[2] + '日';
}
// 生长曲线数据 // 生长曲线数据
const curveData = ref([ const curveData = ref([
...@@ -475,6 +484,9 @@ const statusMap = { ...@@ -475,6 +484,9 @@ const statusMap = {
const switchTab = (tab) => { const switchTab = (tab) => {
activeTab.value = tab activeTab.value = tab
console.log('切换到标签:', tab) console.log('切换到标签:', tab)
if(tab === 'latest' && isRecords.value){
switchCurveTab('height');
}
} }
// 选择历史记录项 // 选择历史记录项
...@@ -587,12 +599,36 @@ const closeTipsPopup = () => { ...@@ -587,12 +599,36 @@ const closeTipsPopup = () => {
/** /**
* 处理专家咨询按钮点击事件 * 处理专家咨询按钮点击事件
*/ */
const consultExpert = () => { const consultExpert = async () => {
console.log('专家在线咨询') console.log('专家在线咨询')
uni.showToast({ const res = await getHealthField();
title: '正在连接专家...',
icon: 'loading' if (!res.success) {
}) uni.showToast({
title: "获取健康字段失败",
icon: "none",
});
return;
}
const { sign, timestamp, appId, partnerUserId, env } = res.data;
jump({
type: JumpType.MINI,
url: "/pages/partner/redirect",
extra: {
appId: "wx81ecfb5aa3fb512f",
envVersion: env,
extraData: {
sign, // 参考 4.请求参数
timestamp, // 参考 4.请求参数
appId, // 参考 4.请求参数
partnerUserId, // 参考 4.请求参数
targetApp:
"/h5/partner/shining-like-a-start/landing-free-consult?sysType=CRF",
},
},
});
} }
// 首页组件逻辑 // 首页组件逻辑
...@@ -621,11 +657,15 @@ const backFailHandler = () => { ...@@ -621,11 +657,15 @@ const backFailHandler = () => {
console.log('backFailHandler'); console.log('backFailHandler');
} }
onShareAppMessage(() => {
return {
title: shareText.value,
path: `/pages/shengzhangTestResult/shengzhangTestResult`,
imageUrl: undefined
}
})
onMounted(async () => { onMounted(async () => {
// 初始化绘制曲线
setTimeout(() => {
drawGrowthCurve()
}, 100)
//获取历史记录 //获取历史记录
const historyListData = await getGrowthHistoryList(); const historyListData = await getGrowthHistoryList();
...@@ -670,9 +710,11 @@ onMounted(async () => { ...@@ -670,9 +710,11 @@ onMounted(async () => {
} }
} }
const userStore = useUserStore();
const babyId = userStore.babyInfo?.content?.id;
const babyDataHeight = { const babyDataHeight = {
babyId: shengzhangInfo.babyInfo.babyId, babyId: babyId,
curveType: 'HEIGHT', curveType: 'HEIGHT',
startMonth: 0, startMonth: 0,
endMonth: 36, endMonth: 36,
...@@ -681,7 +723,7 @@ onMounted(async () => { ...@@ -681,7 +723,7 @@ onMounted(async () => {
await shengzhangStore.getGrowthCurveData(babyDataHeight); await shengzhangStore.getGrowthCurveData(babyDataHeight);
const babyDataWeight = { const babyDataWeight = {
babyId: shengzhangInfo.babyInfo.babyId, babyId: babyId,
curveType: 'WEIGHT', curveType: 'WEIGHT',
startMonth: 0, startMonth: 0,
endMonth: 36, endMonth: 36,
...@@ -689,18 +731,26 @@ onMounted(async () => { ...@@ -689,18 +731,26 @@ onMounted(async () => {
await shengzhangStore.getGrowthCurveData(babyDataWeight); await shengzhangStore.getGrowthCurveData(babyDataWeight);
const babyDataHead = { const babyDataHead = {
babyId: shengzhangInfo.babyInfo.babyId, babyId: babyId,
curveType: 'HEAD', curveType: 'HEAD',
startMonth: 0, startMonth: 0,
endMonth: 36, endMonth: 36,
}; };
await shengzhangStore.getGrowthCurveData(babyDataHead); await shengzhangStore.getGrowthCurveData(babyDataHead);
// 初始化绘制曲线
// setTimeout(() => {
// drawGrowthCurve()
// }, 100)
}else{ }else{
shengzhangInfo = {...shengzhangStore.shengzhangInfo}; shengzhangInfo = {...shengzhangStore.shengzhangInfo};
} }
shareText.value = shengzhangInfo?.content?.shareText;
console.log('shareText.value=', shareText.value);
//分析结果处理 //分析结果处理
const data = {...shengzhangInfo.babyInfo}; const data = {...shengzhangInfo.babyInfo};
...@@ -753,10 +803,15 @@ onMounted(async () => { ...@@ -753,10 +803,15 @@ onMounted(async () => {
slightlyHigh: generateCurveData1(curveDataPostHead.value, 'head', 'slightHighRange', 'max'), slightlyHigh: generateCurveData1(curveDataPostHead.value, 'head', 'slightHighRange', 'max'),
} }
}; };
// 初始化绘制曲线
setTimeout(() => {
drawGrowthCurve()
}, 100)
}) })
// 绘制生长曲线 // 绘制生长曲线
...@@ -1054,6 +1109,7 @@ const drawBabyCurve = (ctx, data, margin, chartWidth, chartHeight, type) => { ...@@ -1054,6 +1109,7 @@ const drawBabyCurve = (ctx, data, margin, chartWidth, chartHeight, type) => {
const onScroll = (e) => { const onScroll = (e) => {
scrollLeft.value = e.detail.scrollLeft scrollLeft.value = e.detail.scrollLeft
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -300,12 +300,14 @@ const generateRange = (min, max, step = 0.1) => { ...@@ -300,12 +300,14 @@ const generateRange = (min, max, step = 0.1) => {
range.push(parseFloat(i.toFixed(1))) range.push(parseFloat(i.toFixed(1)))
} }
} }
console.log('range=', range)
return range return range
} }
// 日期选择器相关状态 // 日期选择器相关状态
const showDatePickerPopup = ref(false) const showDatePickerPopup = ref(false)
const selectedDate = ref('2025-06-06') const selectedDate = ref()
const showDatePicker = () => { const showDatePicker = () => {
console.log('显示日期选择器') console.log('显示日期选择器')
...@@ -326,15 +328,15 @@ const showFeedingPopup = () => { ...@@ -326,15 +328,15 @@ const showFeedingPopup = () => {
} }
// 身高范围 (40-80cm) // 身高范围 (40-80cm)
const heightRange = generateRange(40, 80, 0.1) const heightRange = generateRange(40, 170, 0.1)
const heightPickerValue = ref([heightRange.indexOf(parseFloat(height.value))]) const heightPickerValue = ref([heightRange.indexOf(parseFloat(height.value))])
// 体重范围 (2-10kg) // 体重范围 (2-10kg)
const weightRange = generateRange(2, 10, 0.01) const weightRange = generateRange(0, 50, 0.01)
const weightPickerValue = ref([weightRange.indexOf(parseFloat(weight.value))]) const weightPickerValue = ref([weightRange.indexOf(parseFloat(weight.value))])
// 头围范围 (30-50cm) // 头围范围 (30-50cm)
const headRange = generateRange(30, 50, 0.1) const headRange = generateRange(20, 60.1, 0.1)
const headPickerValue = ref([headRange.indexOf(parseFloat(headCircumference.value))]) const headPickerValue = ref([headRange.indexOf(parseFloat(headCircumference.value))])
// picker-view change事件处理 // picker-view change事件处理
...@@ -397,8 +399,13 @@ const submitData = throttleTap(async () => { ...@@ -397,8 +399,13 @@ const submitData = throttleTap(async () => {
const data11 = await shengzhangStore.assessmentSave(submitData); await shengzhangStore.assessmentSave(submitData);
console.log('data11=', data11); if(shengzhangStore.shengzhangInfo.success){
babyId.value = shengzhangStore.shengzhangInfo.babyId;
}else{
showLoading.value = false;
return;
}
const babyDataHeight = { const babyDataHeight = {
babyId: babyId.value, babyId: babyId.value,
...@@ -582,6 +589,7 @@ onMounted(async () => { ...@@ -582,6 +589,7 @@ onMounted(async () => {
console.log('babyId.value=', babyId.value); console.log('babyId.value=', babyId.value);
const {data} = await growthHome(babyId.value); const {data} = await growthHome(babyId.value);
selectedDate.value = formatDate(new Date());
// const data = {"babyId":1234,"babyName":"小强","gender":"M","monthAge":3,"avatar":"https://momclub.feihe.com/pmall/momclub-picture/integral/1009/yuerBtn.png","birthDate":"2018-10-28 14:06:45","guideFlag":false}; // const data = {"babyId":1234,"babyName":"小强","gender":"M","monthAge":3,"avatar":"https://momclub.feihe.com/pmall/momclub-picture/integral/1009/yuerBtn.png","birthDate":"2018-10-28 14:06:45","guideFlag":false};
babyName.value = data.babyName babyName.value = data.babyName
......
...@@ -24,11 +24,16 @@ export const useShengzhangStore = defineStore("shengzhangInfo", { ...@@ -24,11 +24,16 @@ export const useShengzhangStore = defineStore("shengzhangInfo", {
}, },
async assessmentSave(submitData) { async assessmentSave(submitData) {
const data = await assessmentSave(submitData)
if(data.data){
data.data.success = data.success;
}
const data = await assessmentSave(submitData);
data.data.success = data.success;
if(data.success){ if(data.success){
this.setShengzhangInfo(data.data); this.setShengzhangInfo(data.data);
}else{
this.setShengzhangInfo(data);
} }
}, },
......
...@@ -309,7 +309,7 @@ const handleToolClick = async (item) => { ...@@ -309,7 +309,7 @@ const handleToolClick = async (item) => {
const hasPregnancy = listData.some(item => item.typeName === "孕中" && item.selected === true ) const hasPregnancy = listData.some(item => item.typeName === "孕中" && item.selected === true )
console.log(hasPregnancy, 'hasPregnancy') console.log(hasPregnancy, 'hasPregnancy')
if(hasPregnancy){ if(hasPregnancy){
jump({ type: item.link.type, url: item.link.url}); jump({ type: item.link.type, url: item.link.url});
} else{ } else{
uni.showToast({ uni.showToast({
title: "需要是孕中状态哦", title: "需要是孕中状态哦",
...@@ -317,13 +317,29 @@ const handleToolClick = async (item) => { ...@@ -317,13 +317,29 @@ const handleToolClick = async (item) => {
}); });
} }
} }
} else { } else if(item.title === '生长测评'){
const extra = item.link.extra; if(listData.length > 0){
if(extra && extra.babyId){ const hasPregnancy = listData.some(item => item.typeName !== "孕中" && item.typeName !== "备孕" && item.selected === true )
jump({ type: item.link.type, url: item.link.url+'?babyId='+extra.babyId});
}else{ if(hasPregnancy){
jump({ type: item.link.type, url: item.link.url}); jump({ type: item.link.type, url: item.link.url});
} else{
uni.showToast({
title: "需要已生育的宝宝状态哦",
icon: "none",
});
}
} }
jump({ type: item.link.type, url: item.link.url});
} else {
jump({ type: item.link.type, url: item.link.url});
// const extra = item.link.extra;
// if(extra && extra.babyId){
// jump({ type: item.link.type, url: item.link.url+'?babyId='+extra.babyId});
// }else{
// jump({ type: item.link.type, url: item.link.url});
// }
} }
}; };
......
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