Commit b096e1ef authored by weishengfei's avatar weishengfei

Merge branch 'dev' of gitlab2.dui88.com:fh/20250528_FHQ1 into dev

parents 59e6db41 3cf81339
This diff is collapsed.
......@@ -8,9 +8,13 @@
<view class="nav-left">
<image :src="feedingRecordRes.icon_return" class="back-btn" @click="goBack" />
<image :src="feedingRecordRes.icon_star" class="baby-icon-star" />
<view class="baby-info" @click="showBabySwitch">
<text class="baby-name">{{ babyList[currentBabyIndex].name }}</text>
<text class="baby-age">{{ calculateBabyAge(babyList[currentBabyIndex].birthday) }}</text>
<view class="baby-info" @click="showBabySwitch" v-if="babyList.length > 1">
<text class="baby-name">{{ getCurrentBabyName() }}</text>
<text class="baby-age">{{ getCurrentBabyAge() }}</text>
</view>
<view class="baby-info" v-else>
<text class="baby-name">{{ getCurrentBabyName() }}</text>
<text class="baby-age">{{ getCurrentBabyAge() }}</text>
</view>
<image :src="feedingRecordRes.icon_baby_change" class="baby-icon-change" />
</view>
......@@ -206,6 +210,7 @@
:baby-list="babyList"
:selected-index="currentBabyIndex"
@change="onBabyChange"
v-if="babyList.length > 1"
/>
</template>
......@@ -715,7 +720,10 @@ function goBack() {
// 宝宝切换相关方法
function showBabySwitch() {
showBabySwitchPopup.value = true
// 只有当有多个宝宝时才显示切换弹窗
if (babyList.value.length > 1) {
showBabySwitchPopup.value = true
}
}
function onBabyChange(baby, index) {
......@@ -737,18 +745,69 @@ function onBabyChange(baby, index) {
}
function calculateBabyAge(birthday) {
const birthDate = new Date(birthday)
const today = new Date()
const diffTime = Math.abs(today - birthDate)
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
const years = Math.floor(diffDays / 365)
const days = diffDays % 365
// 检查生日参数是否有效
if (!birthday) {
return '0天'
}
if (years > 0) {
return `${years}${days}天`
} else {
return `${days}天`
try {
const birthDate = new Date(birthday)
const today = new Date()
// 检查日期是否有效
if (isNaN(birthDate.getTime()) || isNaN(today.getTime())) {
console.warn('无效的日期格式:', birthday)
return '0天'
}
const diffTime = Math.abs(today - birthDate)
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
// 检查计算结果是否有效
if (isNaN(diffDays) || diffDays < 0) {
console.warn('日期计算错误:', { birthday, diffDays })
return '0天'
}
const years = Math.floor(diffDays / 365)
const days = diffDays % 365
if (years > 0) {
return `${years}${days}天`
} else {
return `${days}天`
}
} catch (error) {
console.error('计算宝宝年龄时出错:', error, birthday)
return '0天'
}
}
// 安全获取当前宝宝姓名
function getCurrentBabyName() {
try {
const currentBaby = babyList.value[currentBabyIndex.value]
if (currentBaby && currentBaby.name) {
return currentBaby.name
}
return '宝宝'
} catch (error) {
console.error('获取宝宝姓名时出错:', error)
return '宝宝'
}
}
// 安全获取当前宝宝年龄
function getCurrentBabyAge() {
try {
const currentBaby = babyList.value[currentBabyIndex.value]
if (currentBaby && currentBaby.birthday) {
return calculateBabyAge(currentBaby.birthday)
}
return '0天'
} catch (error) {
console.error('获取宝宝年龄时出错:', error)
return '0天'
}
}
......
......@@ -415,7 +415,6 @@ const generateCurveData1 = (lineData, type, arrayName, minOrMax) =>{
data.push(point);
});
console.log('data888888=', data);
return data;
}
// slightHighRange
......@@ -963,7 +962,7 @@ const onScroll = (e) => {
<style lang="less" scoped>
.shengzhang-test-result-container {
width: 100%;
// height: 2700rpx;
height: 2700rpx;
// box-sizing: border-box;
position: relative;
overflow-x: hidden;
......
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