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

提交接口处理

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