Commit 85c42be1 authored by 王炽's avatar 王炽

提交接口处理

parent 21ec5c3f
......@@ -239,7 +239,7 @@ const closePopup = () => {
// 发送事件通知主页面
emit('change', formattedDate)
emit('update:selectedDate', formattedDate);
// emit('update:visible', false)
emit('update:visible', false)
}
</script>
......
......@@ -37,7 +37,7 @@
<image class="gender-icon" :src="babyGender == 'M' ? '/static/shengzhangTool/sex1.png' : '/static/shengzhangTool/sex0.png'" mode="aspectFit"></image>
<text class="age-text">{{ babyAge }}</text>
</view>
<text class="birth-date">{{ babyBirthday }}</text>
<text class="birth-date">{{ formatDate(babyBirthday) }}</text>
</view>
</view>
<view class="record-btn" @click="viewRecords">
......@@ -218,6 +218,7 @@ import DatePickerPopup from '@/components/DatePickerPopup.vue'
import BabyTestTipsPopup from '@/components/BabyTestTipsPopup.vue'
import { growthHome, guideCompleted, assessmentSave } from '../../api/shengzhangTools'
import { onLoad } from "@dcloudio/uni-app";
import { throttleTap } from '../../utils/index.js';
const swiperData = ref([
{ bannerImg: '/static/shengzhangTool/banner1.png' },
......@@ -351,15 +352,27 @@ const viewRecords = () => {
console.log('查看测评记录')
}
const submitData = async () => {
const convertFeedingType = (type) => {
if(type == '纯母乳'){
return 'BREAST_MILK'
}else if(type == '母乳+奶粉混合喂养'){
return 'MIXED'
}else if(type == '奶粉'){
return 'FORMULA'
}else if(type == '母乳+辅食'){
return 'BREAST_MILK_CF'
}else if(type == '奶粉+辅食'){
return 'FORMULA_CF'
}
}
const submitData = throttleTap(async () => {
const submitData = {
babyId: babyId.value,
height: height.value,
weight: weight.value,
headCircumference: headCircumference.value,
assessmentDate: assessmentDate.value,
feedingType: selectedFeedText.value
feedingType: convertFeedingType(selectedFeedText.value)
};
console.log('提交数据', submitData);
......@@ -371,7 +384,7 @@ const submitData = async () => {
icon: 'success'
})
}
}
}, 1000)
// 添加以下数据
const showBabySwitchPopup = ref(false)
......@@ -487,22 +500,19 @@ const guideHandler = async () => {
guideIndex.value++
if (guideIndex.value > 2) {
// const data = await guideCompleted();
// if(data.success){
// guideFlag.value = true;
// guideIndex.value = -1;
// }else{
// //引导页完成失败,提示用户
// }
const data = await guideCompleted();
if(data.success){
guideFlag.value = true;
guideIndex.value = -1;
}else{
//引导页完成失败,提示用户
}
}
}
// 获取页面参数
onLoad((options) => {
console.log('页面参数:', options.toString())
console.log('options.babyId=', options.babyId);
if (options.babyId) {
babyId.value = parseInt(options.babyId)
console.log('获取到的babyId:', babyId.value)
......@@ -510,28 +520,40 @@ onLoad((options) => {
})
onMounted(async () => {
const {data} = await growthHome();
console.log('data666666=', data);
const {data} = await growthHome(babyId.value);
// 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
// babyAge.value = data.monthAge + '月龄'
// babyBirthday.value = data.birthDate
// babyGender.value = data.gender
// console.log('data.avatar=', data.avatar);
// babyAvatar.value = data.avatar
// assessmentDate.value = selectedDate.value;
// feedingType.value = selectedFeedText.value;
// guideFlag.value = data.guideFlag;
// if (guideFlag.value) {
// guideIndex.value = -1;
// }else{
// guideIndex.value = 0;
// }
babyName.value = data.babyName
babyAge.value = data.monthAge + '月龄'
babyBirthday.value = data.birthDate
babyGender.value = data.gender;
babyAvatar.value = data.avatar
assessmentDate.value = selectedDate.value;
feedingType.value = selectedFeedText.value;
guideFlag.value = data.guideFlag;
if (guideFlag.value) {
guideIndex.value = -1;
}else{
guideIndex.value = 0;
}
})
const formatDate = (timestamp) => {
const date = new Date(timestamp);
if (isNaN(date.getTime())) {
console.error('无效的时间戳:', timestamp);
return '';
}
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
</script>
<style lang="less" scoped>
......
......@@ -21,6 +21,7 @@ export const useUserStore = defineStore("userInfo", {
babyInfo: null,
memberInfo: null,
babyNickCache: [],
cepingjieguoInfo:null,
};
},
actions: {
......
......@@ -302,7 +302,13 @@ const handleToolClick = async (item) => {
},
});
} 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});
}
}
};
......@@ -326,9 +332,8 @@ const handleEditProfile = (e) => {
md.sensorLog(e);
const type =
userStore.babyInfo?.allBabyBaseInfo?.length == 0 ? "add" : "edit";
babyId.value = userStore.babyInfo?.allBabyBaseInfo.find(
const type = userStore.babyInfo?.allBabyBaseInfo?.length == 0 ? "add" : "edit";
babyId.value = userStore.babyInfo?.allBabyBaseInfo.find(
(item) => item.selected
)?.id;
......@@ -440,6 +445,10 @@ onMounted(async () => {
initData();
hideLoading();
babyId.value = userStore.babyInfo?.allBabyBaseInfo.find(
(item) => item.selected
)?.id;
console.log('babyIdsdfsdfsdfsdfsdfsdfdsfsdf=', babyId.value);
const a = {
"bgUrl": "my/babytest.png",
......
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