Commit b070e06a authored by spc's avatar spc

feedingIndex

parent 7dd34561
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
<!-- 喂养时间 --> <!-- 喂养时间 -->
<view class="feeding-time"> <view class="feeding-time">
<text class="time-label">喂养时间</text> <text class="time-label">喂养时间</text>
<text class="time-value">2025-06-01 22:22</text> <text class="time-value">2025-06-01 22:22</text>
<image class="edit-icon" src="/static/feedingIndex/v1/icon_modify.png" mode="aspectFit" /> <image class="edit-icon" src="/static/feedingIndex/v1/icon_modify.png" mode="aspectFit" />
<text class="records-link">喂养记录</text> <text class="records-link">喂养记录</text>
<image class="arrow-right" src="/static/feedingIndex/v1/icon_arrow_yellow.png"></image> <image class="arrow-right" src="/static/feedingIndex/v1/icon_arrow_yellow.png"></image>
</view> </view>
...@@ -24,8 +27,11 @@ ...@@ -24,8 +27,11 @@
<view class="feeding-types"> <view class="feeding-types">
<view class="type-item" v-for="(type, index) in feedingTypes" :key="index" <view class="type-item" v-for="(type, index) in feedingTypes" :key="index"
:class="{ active: selectedType === type.value }" @click="selectType(type.value)"> :class="{ active: selectedType === type.value }" @click="selectType(type.value)">
<view class="type-icon" :style="{ backgroundColor: type.color }"> <image class="icon-bg" src="/static/feedingIndex/v1/icon_bg.png" mode="aspectFit"
<image class="icon-img" :src="type.icon" mode="aspectFit" /> v-if="selectedType === type.value" />
<view class="type-icon-wrapper">
<image class="type-icon" :src="type.icon" mode="aspectFit" />
</view> </view>
<text class="type-label">{{ type.label }}</text> <text class="type-label">{{ type.label }}</text>
</view> </view>
...@@ -39,31 +45,45 @@ ...@@ -39,31 +45,45 @@
<!-- 动态表单区域 --> <!-- 动态表单区域 -->
<view class="form-section"> <view class="form-section">
<!-- 母乳亲喂表单 --> <!-- 母乳亲喂表单 -->
<view v-if="selectedType === 'breastfeeding'" class="breastfeeding-form"> <view v-if="selectedType === 'breastfeeding' && shouldShowForm" class="breastfeeding-form">
<view class="duration-controls"> <view class="duration-controls">
<view class="duration-item"> <view class="duration-item">
<view class="duration-circle"> <view class="duration-circle">
<text class="duration-number">{{ leftDuration }}</text> <image class="circle-bg" src="/static/feedingIndex/v1/iconBg.png" mode="aspectFit" />
<text class="duration-unit">分钟</text> <view class="circle-content">
<text class="duration-number">{{ feedingData.breastfeeding.leftDuration }}</text>
<text class="duration-unit">分钟</text>
</view>
</view> </view>
<view class="duration-buttons"> <view class="duration-buttons">
<image class="btn-minus" src="/static/feedingIndex/v1/icon-L.png" mode="aspectFit" <image class="btn-minus"
@click="adjustDuration('left', -1)" /> :src="feedingData.breastfeeding.leftDuration <= 0 ? '/static/feedingIndex/v1/icon-G.png' : '/static/feedingIndex/v1/icon-L.png'"
<image class="btn-plus" src="/static/feedingIndex/v1/icon+L.png" mode="aspectFit" mode="aspectFit" @click="adjustDuration('left', -1)"
@click="adjustDuration('left', 1)" /> :class="{ disabled: feedingData.breastfeeding.leftDuration <= 0 }" />
<image class="btn-plus"
:src="feedingData.breastfeeding.leftDuration >= 60 ? '/static/feedingIndex/v1/icon+G.png' : '/static/feedingIndex/v1/icon+L.png'"
mode="aspectFit" @click="adjustDuration('left', 1)"
:class="{ disabled: feedingData.breastfeeding.leftDuration >= 60 }" />
</view> </view>
<text class="duration-label">左侧哺乳时长</text> <text class="duration-label">左侧哺乳时长</text>
</view> </view>
<view class="duration-item"> <view class="duration-item">
<view class="duration-circle"> <view class="duration-circle">
<text class="duration-number">{{ rightDuration }}</text> <image class="circle-bg" src="/static/feedingIndex/v1/iconBg.png" mode="aspectFit" />
<text class="duration-unit">分钟</text> <view class="circle-content">
<text class="duration-number">{{ feedingData.breastfeeding.rightDuration }}</text>
<text class="duration-unit">分钟</text>
</view>
</view> </view>
<view class="duration-buttons"> <view class="duration-buttons">
<image class="btn-minus" src="/static/feedingIndex/v1/icon-L.png" mode="aspectFit" <image class="btn-minus"
@click="adjustDuration('right', -1)" /> :src="feedingData.breastfeeding.rightDuration <= 0 ? '/static/feedingIndex/v1/icon-G.png' : '/static/feedingIndex/v1/icon-L.png'"
<image class="btn-plus" src="/static/feedingIndex/v1/icon+L.png" mode="aspectFit" mode="aspectFit" @click="adjustDuration('right', -1)"
@click="adjustDuration('right', 1)" /> :class="{ disabled: feedingData.breastfeeding.rightDuration <= 0 }" />
<image class="btn-plus"
:src="feedingData.breastfeeding.rightDuration >= 60 ? '/static/feedingIndex/v1/icon+G.png' : '/static/feedingIndex/v1/icon+L.png'"
mode="aspectFit" @click="adjustDuration('right', 1)"
:class="{ disabled: feedingData.breastfeeding.rightDuration >= 60 }" />
</view> </view>
<text class="duration-label">右侧哺乳时长</text> <text class="duration-label">右侧哺乳时长</text>
</view> </view>
...@@ -71,10 +91,12 @@ ...@@ -71,10 +91,12 @@
</view> </view>
<!-- 母乳瓶喂/奶粉喂养表单 --> <!-- 母乳瓶喂/奶粉喂养表单 -->
<view v-if="selectedType === 'bottle' || selectedType === 'formula'" class="bottle-form"> <view v-if="(selectedType === 'bottle' || selectedType === 'formula') && shouldShowForm"
class="bottle-form">
<view class="bottle-graphic"> <view class="bottle-graphic">
<view class="bottle-container"> <view class="bottle-container">
<view class="bottle-liquid" :style="{ height: `${(amount / 100) * 200}%` }"></view> <view class="bottle-liquid"
:style="{ height: `${(feedingData[selectedType].amount / 100) * 200}%` }"></view>
<view class="bottle-scale"> <view class="bottle-scale">
<text class="scale-mark">80</text> <text class="scale-mark">80</text>
<text class="scale-mark">85</text> <text class="scale-mark">85</text>
...@@ -85,7 +107,7 @@ ...@@ -85,7 +107,7 @@
</view> </view>
<view class="amount-bubble"> <view class="amount-bubble">
<text class="bubble-label">喂奶量</text> <text class="bubble-label">喂奶量</text>
<text class="bubble-value">{{ amount }}ml</text> <text class="bubble-value">{{ feedingData[selectedType].amount }}ml</text>
</view> </view>
<view class="adjust-arrows"> <view class="adjust-arrows">
<image class="arrow-up" src="/static/feedingIndex/v1/icon+G.png" mode="aspectFit" <image class="arrow-up" src="/static/feedingIndex/v1/icon+G.png" mode="aspectFit"
...@@ -97,9 +119,9 @@ ...@@ -97,9 +119,9 @@
</view> </view>
<!-- 辅食表单 --> <!-- 辅食表单 -->
<view v-if="selectedType === 'food'" class="food-form"> <view v-if="selectedType === 'food' && shouldShowForm" class="food-form">
<view class="selected-items"> <view class="selected-items">
<text>米粉,面条,苹果,土豆</text> <text>{{ feedingData.food.selectedItems.join(',') }}</text>
</view> </view>
<view class="food-categories"> <view class="food-categories">
<text class="category-title">辅食分类</text> <text class="category-title">辅食分类</text>
...@@ -146,17 +168,8 @@ ...@@ -146,17 +168,8 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 记录方式选择 -->
<view class="record-methods">
<image class="tab-image" :src="getTabImage()" mode="aspectFill" />
<view class="click-area left" @click="setRecordMethod('manual')"></view>
<view class="click-area center" @click="setRecordMethod('timer')"></view>
<view class="click-area right" @click="setRecordMethod('voice')"></view>
</view>
<!-- 录音控制区域 --> <!-- 录音控制区域 -->
<view v-if="recordMethod === 'voice'" class="voice-controls"> <view v-if="recordMethods[selectedType] === 'voice'" class="voice-controls">
<view class="voice-status"> <view class="voice-status">
<image class="voice-icon" <image class="voice-icon"
:src="isRecording ? '/static/feedingIndex/v1/icon_luyining.png' : '/static/feedingIndex/v1/icon_luyin.png'" :src="isRecording ? '/static/feedingIndex/v1/icon_luyining.png' : '/static/feedingIndex/v1/icon_luyin.png'"
...@@ -165,14 +178,39 @@ ...@@ -165,14 +178,39 @@
</view> </view>
<view class="voice-buttons"> <view class="voice-buttons">
<image class="voice-btn" <image class="voice-btn"
:src="isRecording ? '/static/feedingIndex/v1/icon_stop.png' : '/static/feedingIndex/v1/icon_start.png'" :src="isRecording ? '/static/feedingIndex/v1/icon_luyin_stop.png' : '/static/feedingIndex/v1/icon_luyin_start.png'"
mode="aspectFit" @click="toggleRecording" /> mode="aspectFit" @click="toggleRecording" />
</view> </view>
</view> </view>
<!-- 计时器控制区域 -->
<view v-if="recordMethods[selectedType] === 'timer'" class="timer-controls">
<view class="timer-status">
<image class="timer-icon"
:src="isTimerRunning ? '/static/feedingIndex/v1/icon_timer_running.png' : '/static/feedingIndex/v1/icon_timer_stopped.png'"
mode="aspectFit" />
<text class="timer-text">{{ isTimerRunning ? '计时中...' : '点击开始计时' }}</text>
</view>
<view class="timer-buttons">
<image class="timer-btn"
:src="isTimerRunning ? '/static/feedingIndex/v1/icon_stop.png' : '/static/feedingIndex/v1/icon_start.png'"
mode="aspectFit" @click="toggleTimer" />
</view>
</view>
<!-- 记录方式选择 -->
<view class="record-methods">
<image class="tab-image" :src="getTabImage()" mode="aspectFill" />
<view class="click-area left" @click="setRecordMethod('manual')"></view>
<view class="click-area center" @click="setRecordMethod('timer')"></view>
<view class="click-area right" @click="setRecordMethod('voice')"></view>
</view>
<!-- 底部完成按钮 --> <!-- 底部完成按钮 -->
<view class="complete-btn" @click="completeRecord"> <view class="bottom_complete-btn" @click="completeRecord">
<image class="complete-btn-bg" src="/static/feedingIndex/v1/complete_btn.png" mode="aspectFit" /> <image class="complete-btn-bg" src="/static/feedingIndex/v1/complete_btn.png" />
</view> </view>
</view> </view>
</template> </template>
...@@ -187,22 +225,45 @@ const bannerHandler = (item) => { ...@@ -187,22 +225,45 @@ const bannerHandler = (item) => {
} }
const feedingTypes = ref([ const feedingTypes = ref([
{ value: 'breastfeeding', label: '母乳亲喂', color: '#FFD0D0', icon: '/static/feedingIndex/v1/icon_muruqinwei.png' }, { value: 'breastfeeding', label: '母乳亲喂', icon: '/static/feedingIndex/v1/icon_muruqinwei.png' },
{ value: 'bottle', label: '母乳瓶喂', color: '#D0D0FF', icon: '/static/feedingIndex/v1/icon_murupinwei.png' }, { value: 'bottle', label: '母乳瓶喂', icon: '/static/feedingIndex/v1/icon_murupinwei.png' },
{ value: 'formula', label: '奶粉喂养', color: '#FFE4B5', icon: '/static/feedingIndex/v1/icon_naifen.png' }, { value: 'formula', label: '奶粉喂养', icon: '/static/feedingIndex/v1/icon_naifen.png' },
{ value: 'food', label: '辅食', color: '#D0FFD0', icon: '/static/feedingIndex/v1/icon_fushi.png' } { value: 'food', label: '辅食', icon: '/static/feedingIndex/v1/icon_fushi.png' }
]) ])
const selectedType = ref('breastfeeding') const selectedType = ref('breastfeeding')
const recordMethod = ref('timer') // 为每种喂养方式设置独立的记录方法
const recordMethods = ref({
breastfeeding: 'timer',
bottle: 'timer',
formula: 'timer',
food: 'timer'
})
const isRecording = ref(false) const isRecording = ref(false)
const isTimerRunning = ref(false)
// 为每种喂养方式设置独立的数据
const feedingData = ref({
breastfeeding: {
leftDuration: 5,
rightDuration: 5
},
bottle: {
amount: 90
},
formula: {
amount: 90
},
food: {
selectedItems: ['米粉', '面条', '苹果', '土豆']
}
})
// 母乳亲喂时长 // 计算属性 - 判断是否显示表单
const leftDuration = ref(60) const shouldShowForm = computed(() => {
const rightDuration = ref(5) const currentMethod = recordMethods.value[selectedType.value]
return currentMethod === 'timer' // 只有计时模式显示表单
// 奶量 })
const amount = ref(90)
// 方法 // 方法
function selectType(type) { function selectType(type) {
...@@ -210,25 +271,42 @@ function selectType(type) { ...@@ -210,25 +271,42 @@ function selectType(type) {
} }
function adjustDuration(side, value) { function adjustDuration(side, value) {
const currentData = feedingData.value.breastfeeding
if (side === 'left') { if (side === 'left') {
leftDuration.value = Math.max(0, leftDuration.value + value) // 限制在0-60分钟范围内
const newValue = currentData.leftDuration + value
if (newValue >= 0 && newValue <= 60) {
currentData.leftDuration = newValue
}
} else { } else {
rightDuration.value = Math.max(0, rightDuration.value + value) // 限制在0-60分钟范围内
const newValue = currentData.rightDuration + value
if (newValue >= 0 && newValue <= 60) {
currentData.rightDuration = newValue
}
} }
} }
function adjustAmount(value) { function adjustAmount(value) {
amount.value = Math.max(0, Math.min(100, amount.value + value)) const currentType = selectedType.value
if (currentType === 'bottle' || currentType === 'formula') {
const currentData = feedingData.value[currentType]
currentData.amount = Math.max(0, Math.min(100, currentData.amount + value))
}
} }
function setRecordMethod(method) { function setRecordMethod(method) {
recordMethod.value = method recordMethods.value[selectedType.value] = method
} }
function toggleRecording() { function toggleRecording() {
isRecording.value = !isRecording.value isRecording.value = !isRecording.value
} }
function toggleTimer() {
isTimerRunning.value = !isTimerRunning.value
}
function completeRecord() { function completeRecord() {
console.log('完成记录') console.log('完成记录')
uni.navigateBack() uni.navigateBack()
...@@ -239,9 +317,10 @@ function goBack() { ...@@ -239,9 +317,10 @@ function goBack() {
} }
function getTabImage() { function getTabImage() {
if (recordMethod.value === 'manual') { const currentMethod = recordMethods.value[selectedType.value]
if (currentMethod === 'manual') {
return '/static/feedingIndex/v1/Tab_bottom_write.png' return '/static/feedingIndex/v1/Tab_bottom_write.png'
} else if (recordMethod.value === 'timer') { } else if (currentMethod === 'timer') {
return '/static/feedingIndex/v1/Tab_bottom_timer.png' return '/static/feedingIndex/v1/Tab_bottom_timer.png'
} else { } else {
return '/static/feedingIndex/v1/Tab_bottom_voice.png' return '/static/feedingIndex/v1/Tab_bottom_voice.png'
...@@ -271,7 +350,7 @@ function getTabImage() { ...@@ -271,7 +350,7 @@ function getTabImage() {
.feeding-time { .feeding-time {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 20rpx 30rpx; padding: 20rpx 30rpx 5rpx 30rpx;
background: #FFF8F1; background: #FFF8F1;
.time-label { .time-label {
...@@ -308,39 +387,57 @@ function getTabImage() { ...@@ -308,39 +387,57 @@ function getTabImage() {
.feeding-types { .feeding-types {
display: flex; display: flex;
justify-content: space-around; justify-content: space-between;
padding: 30rpx; padding: 0rpx 30rpx;
background: #FFF8F1; gap: 15rpx;
.type-item { .type-item {
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: 10rpx; gap: 8rpx;
padding: 15rpx 10rpx;
border-radius: 12rpx;
background: transparent;
transition: all 0.3s ease;
.type-icon { .icon-bg {
width: 228rpx;
height: 144rpx;
position: absolute;
}
.type-icon-wrapper {
position: relative;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
border-radius: 20rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative;
.icon-img {
width: 60rpx;
height: 60rpx; .type-icon {
width: 48rpx;
height: 48rpx;
position: relative;
} }
} }
.type-label { .type-label {
font-size: 24rpx; font-size: 26rpx;
color: #333; color: #6f6d67;
font-weight: 500;
z-index: 2;
} }
&.active .type-icon { &.active {
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2); .type-label {
transform: scale(1.05); color: #1d1e25;
font-weight: 800;
}
} }
} }
} }
...@@ -372,37 +469,63 @@ function getTabImage() { ...@@ -372,37 +469,63 @@ function getTabImage() {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: 20rpx; gap: 20rpx;
position: relative;
.duration-circle { .duration-circle {
width: 200rpx; width: 278rpx;
height: 200rpx; height: 278rpx;
// border-radius: 50%; position: relative;
// background: linear-gradient(135deg, #FFE4B5, #FFD700);
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
.duration-number { .circle-bg {
font-size: 48rpx; position: absolute;
color: #333; width: 100%;
font-weight: bold; height: 100%;
} }
.duration-unit { .circle-content {
font-size: 24rpx; position: relative;
color: #666; display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.duration-number {
font-size: 48rpx;
color: #333;
font-weight: bold;
}
.duration-unit {
font-size: 24rpx;
color: #666;
}
} }
} }
.duration-buttons { .duration-buttons {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex; display: flex;
gap: 40rpx; justify-content: space-between;
align-items: center;
pointer-events: none;
.btn-minus, .btn-minus,
.btn-plus { .btn-plus {
width: 60rpx; width: 78rpx;
height: 60rpx; height: 180rpx;
margin-top: -45rpx;
pointer-events: auto;
&.disabled {
pointer-events: none;
}
} }
} }
...@@ -591,7 +714,8 @@ function getTabImage() { ...@@ -591,7 +714,8 @@ function getTabImage() {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 120rpx; // 调整为图片高度 width: 468rpx;
height: 180rpx; // 调整为图片高度
background: #F8F8F8; // 背景色根据需要 background: #F8F8F8; // 背景色根据需要
.tab-image { .tab-image {
...@@ -652,12 +776,45 @@ function getTabImage() { ...@@ -652,12 +776,45 @@ function getTabImage() {
} }
} }
.complete-btn { .timer-controls {
position: fixed; padding: 30rpx;
bottom: 40rpx; background: #FFF8F1;
left: 40rpx; display: flex;
right: 40rpx; flex-direction: column;
height: 100rpx; align-items: center;
gap: 30rpx;
.timer-status {
display: flex;
flex-direction: column;
align-items: center;
gap: 20rpx;
.timer-icon {
width: 468rpx;
height: 180rpx;
}
.timer-text {
font-size: 28rpx;
color: #333;
}
}
.timer-buttons {
.timer-btn {
width: 100rpx;
height: 100rpx;
}
}
}
.bottom_complete-btn {
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 686rpx;
height: 94rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -671,12 +828,6 @@ function getTabImage() { ...@@ -671,12 +828,6 @@ function getTabImage() {
height: 100%; height: 100%;
} }
.complete-text {
position: relative;
z-index: 2;
color: white;
font-size: 32rpx;
font-weight: bold;
}
} }
</style> </style>
\ No newline at end of file
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