Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
a8babdb1
Commit
a8babdb1
authored
Jul 30, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feeding
parent
bbc2edb5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
483 additions
and
323 deletions
+483
-323
feedingAnalysis.vue
pages/feedingAnalysis/feedingAnalysis.vue
+259
-202
feedingIndex.vue
pages/feedingIndex/feedingIndex.vue
+69
-48
feedingRecord.vue
pages/feedingRecord/feedingRecord.vue
+153
-72
feed.js
stores/feed.js
+2
-1
No files found.
pages/feedingAnalysis/feedingAnalysis.vue
View file @
a8babdb1
...
...
@@ -49,7 +49,7 @@
<view
class=
"bar-count"
v-if=
"day.dateString === selectedDate && day.totalCount > 0"
>
{{
day
.
totalCount
}}
次
</view>
<view
class=
"bar-date"
>
{{
day
.
date
}}
</view>
<view
class=
"bar-date"
:class=
"
{ 'selected': day.dateString === selectedDate }"
>
{{
day
.
date
}}
</view>
<!-- 选中背景图 -->
<image
v-if=
"day.dateString === selectedDate"
:src=
"feedingAnalysisRes.icon_sel_tag_bg"
class=
"selected-bg"
/>
...
...
@@ -65,7 +65,7 @@
<view
class=
"gap-bg"
></view>
<!-- 宝宝年龄 -->
<view
class=
"baby-age"
>
<text>
宝宝
{{
calculateBabyAge
(
babyInfo
.
birthday
)
}}
</text>
<text>
宝宝
{{
userStore
.
babyInfo
?.
babyAge
||
'0天'
}}
</text>
</view>
<!-- 喂养记录列表 -->
...
...
@@ -144,29 +144,28 @@
<!-- 编辑记录弹窗 -->
<view
class=
"popup-mask"
v-if=
"showEditPopup"
@
click=
"closeEditPopup"
@
touchmove
.
prevent
>
<view
class=
"popup-content"
@
click
.
stop
@
touchmove
.
stop
>
<view
class=
"popup-title"
>
修改喂养记录
</view>
<view
class=
"popup-title"
>
确认修改内容
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
时间:
</text>
<text
class=
"label"
>
喂养时间
</text>
<picker
mode=
"time"
:value=
"editForm.time"
@
change=
"onEditTimeChange"
>
<view
class=
"picker"
>
{{ editForm.time || '请选择时间' }}
</view>
</picker>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
类型:
</text>
<text
class=
"label"
>
喂养方式
</text>
<picker
:range=
"feedingTypes"
@
change=
"onEditTypeChange"
>
<view
class=
"picker"
>
{{ editForm.type || '请选择类型' }}
</view>
</picker>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
喂养详情
:
</text>
<text
class=
"label"
>
喂养详情
</text>
<view
class=
"input-container"
>
<input
class=
"input"
v-model=
"editForm.content"
placeholder=
"请输入具体内容"
maxlength=
"20"
/>
<text
class=
"char-count"
>
{{ editForm.content.length }}/20
</text>
<input
class=
"input"
v-model=
"editForm.content"
:placeholder=
"getEditFormPlaceholder()"
maxlength=
"20"
/>
</view>
</view>
<view
class=
"popup-buttons"
>
<
button
class=
"cancel-btn"
@
click=
"closeEditPopup"
>
取消
</button
>
<
button
class=
"confirm-btn"
@
click=
"saveEditRecord"
>
保存
</button
>
<
image
:src=
"feedingAnalysisRes.icon_change_btn_cancel"
class=
"cancel-btn"
@
click=
"closeEditPopup"
/
>
<
image
:src=
"feedingAnalysisRes.icon_change_btn_confirm"
class=
"confirm-btn"
@
click=
"saveEditRecord"
/
>
</view>
</view>
</view>
...
...
@@ -176,7 +175,7 @@
import
{
ref
,
computed
,
onMounted
,
onUnmounted
,
watch
,
nextTick
,
getCurrentInstance
}
from
'vue'
import
{
onLoad
,
onShow
}
from
'@dcloudio/uni-app'
import
{
feedingRecordsStatisticsPeriod
,
feedingRecordsByDate
,
feedingRecords
as
feedingRecordsAPI
}
from
'@/api/feeding.js'
import
{
use
FeedStore
}
from
'@/stores/feed
.js'
import
{
use
UserStore
}
from
'@/stores/user
.js'
// API 集成说明:
// 1. 使用 /c/feeding/statistics/period GET 方法查询统计图表数据
...
...
@@ -223,6 +222,9 @@ const feedingAnalysisRes = {
icon_r_arrow
:
$baseUrl
+
`feedingAnalysis/
${
version
}
/icon_r_arrow.png`
,
icon_sel_tag_bg
:
$baseUrl
+
`feedingAnalysis/
${
version
}
/icon_sel_tag_bg.png`
,
icon_change_btn_confirm
:
$baseUrl
+
`feedingRecord/
${
version
}
/icon_change_btn_confirm.png`
,
icon_change_btn_cancel
:
$baseUrl
+
`feedingRecord/
${
version
}
/icon_change_btn_cancel.png`
,
}
...
...
@@ -241,10 +243,11 @@ const selectedDate = ref(formatDateString(new Date())) // 当前选中的日期
const
chartData
=
ref
([])
// 全局状态管理
const
feedStore
=
useFeedStore
()
const
userStore
=
useUserStore
()
const
babyId
=
computed
(()
=>
userStore
.
babyInfo
?.
content
?.
id
)
// 计算属性 - 获取宝宝信息
const
babyInfo
=
computed
(()
=>
feedStore
.
getCurrentBaby
()
)
const
babyInfo
=
computed
(()
=>
userStore
.
babyInfo
?.
content
)
// 修改记录相关状态
const
showEditPopup
=
ref
(
false
)
...
...
@@ -331,7 +334,7 @@ function getRecordIconClass(type) {
// API 调用函数
async
function
loadStatisticsPeriod
(
startDate
,
endDate
)
{
const
cacheKey
=
`
${
startDate
}
_
${
endDate
}
_
${
feedStore
.
getCurrentBabyId
()
}
`
const
cacheKey
=
`
${
startDate
}
_
${
endDate
}
_
${
babyId
.
value
}
`
// 避免重复请求
if
(
loadingStatistics
.
value
.
has
(
cacheKey
))
{
...
...
@@ -362,7 +365,7 @@ async function loadStatisticsPeriod(startDate, endDate) {
})
const
apiPromise
=
feedingRecordsStatisticsPeriod
({
babyId
:
feedStore
.
getCurrentBabyId
()
,
babyId
:
babyId
.
value
,
sdate
:
startDate
,
edate
:
endDate
})
...
...
@@ -488,7 +491,7 @@ async function loadRecordsByDate(date) {
})
const
apiPromise
=
feedingRecordsByDate
({
babyId
:
feedStore
.
getCurrentBabyId
()
,
babyId
:
babyId
.
value
,
date
:
date
})
...
...
@@ -719,14 +722,33 @@ function editRecord(index) {
return
}
// 根据记录类型设置不同的字段
let
content
=
''
if
(
record
.
type
===
'母乳亲喂'
)
{
// 母乳亲喂:优先显示 foodDetails,如果没有则从左右时间构建
if
(
record
.
foodDetails
)
{
content
=
record
.
foodDetails
}
else
{
const
leftTime
=
record
.
leftDuration
||
''
const
rightTime
=
record
.
rightDuration
||
''
content
=
`
${
leftTime
}
${
rightTime
}
`
.
trim
()
}
}
else
if
(
record
.
type
===
'母乳瓶喂'
)
{
// 母乳瓶喂:优先显示 foodDetails,如果没有则显示 amount
content
=
record
.
foodDetails
||
record
.
amount
||
''
}
else
if
(
record
.
type
===
'奶粉喂养'
)
{
// 奶粉喂养:优先显示 foodDetails,如果没有则显示 amount
content
=
record
.
foodDetails
||
record
.
amount
||
''
}
else
if
(
record
.
type
===
'辅食'
)
{
// 辅食:显示食物详情
content
=
record
.
foodDetails
||
record
.
content
||
''
}
// 设置编辑表单数据
editForm
.
value
=
{
time
:
record
.
time
||
getCurrentTime
(),
// 使用记录的原始时间,如果没有则使用当前时间
type
:
record
.
type
||
''
,
content
:
record
.
foodDetails
||
record
.
content
||
''
,
// 优先使用foodDetails
leftDuration
:
record
.
leftDuration
||
''
,
rightDuration
:
record
.
rightDuration
||
''
,
amount
:
record
.
amount
||
''
content
:
content
}
// 保存当前编辑的记录
...
...
@@ -760,7 +782,7 @@ function generateWeekData(weekOffset = 0, targetDate = null) {
const
endDateString
=
formatDateString
(
endDate
)
// 获取统计数据的缓存键
const
cacheKey
=
`
${
startDateString
}
_
${
endDateString
}
_
${
feedStore
.
getCurrentBabyId
()
}
`
const
cacheKey
=
`
${
startDateString
}
_
${
endDateString
}
_
${
babyId
.
value
}
`
const
statisticsData
=
apiStatistics
.
value
[
cacheKey
]
||
[]
// 确定要选中的日期
...
...
@@ -907,10 +929,7 @@ function closeEditPopup() {
editForm
.
value
=
{
time
:
''
,
type
:
''
,
content
:
''
,
leftDuration
:
''
,
rightDuration
:
''
,
amount
:
''
content
:
''
}
}
...
...
@@ -951,24 +970,37 @@ function saveEditRecord() {
// 构建API请求数据
const
{
index
,
record
}
=
editingRecord
.
value
const
apiData
=
{
// 根据记录类型处理不同的数据
let
apiData
=
{
recordId
:
record
.
recordId
,
babyId
:
feedStore
.
getCurrentBabyId
()
,
babyId
:
babyId
.
value
,
recordTime
:
formatDateTimeString
(
selectedDate
.
value
,
editForm
.
value
.
time
),
feedingType
:
getFeedingTypeId
(
editForm
.
value
.
type
)
}
// 根据喂养类型添加相应字段
// 所有类型都使用 foodDetails 字段保存
apiData
.
foodDetails
=
editForm
.
value
.
content
||
''
// 根据记录类型设置其他字段
if
(
editForm
.
value
.
type
===
'母乳亲喂'
)
{
apiData
.
durationLeftSeconds
=
parseDurationToSeconds
(
editForm
.
value
.
leftDuration
)
apiData
.
durationRightSeconds
=
parseDurationToSeconds
(
editForm
.
value
.
rightDuration
)
// 母乳亲喂:解析时间(格式:时间1 时间2)
const
content
=
editForm
.
value
.
content
||
''
const
timeParts
=
content
.
trim
().
split
(
/
\s
+/
)
if
(
timeParts
.
length
>=
1
&&
timeParts
[
0
])
{
apiData
.
durationLeftSeconds
=
parseTimeToSeconds
(
timeParts
[
0
])
}
if
(
timeParts
.
length
>=
2
&&
timeParts
[
1
])
{
apiData
.
durationRightSeconds
=
parseTimeToSeconds
(
timeParts
[
1
])
}
}
else
if
(
editForm
.
value
.
type
===
'母乳瓶喂'
||
editForm
.
value
.
type
===
'奶粉喂养'
)
{
apiData
.
volume
=
parseVolumeToNumber
(
editForm
.
value
.
amount
)
// 母乳瓶喂和奶粉喂养:解析奶量
const
content
=
editForm
.
value
.
content
||
''
const
volumeMatch
=
content
.
match
(
/
(\d
+
)
ml/
)
if
(
volumeMatch
)
{
apiData
.
volume
=
parseInt
(
volumeMatch
[
1
])
}
// 统一添加 foodDetails 字段
if
(
editForm
.
value
.
content
)
{
apiData
.
foodDetails
=
editForm
.
value
.
content
}
// 调用API保存修改
...
...
@@ -1093,7 +1125,11 @@ function getBarSegments(day) {
}
// 页面加载
onLoad
(()
=>
{
onLoad
(
async
()
=>
{
// 加载宝宝信息
await
userStore
.
loadBabyInfo
()
console
.
log
(
'宝宝信息加载完成:'
,
userStore
.
babyInfo
)
updateChartData
(
false
)
// 初始化时使用默认选择
// 初始化API数据
initializeApiData
()
...
...
@@ -1137,12 +1173,20 @@ async function initializeApiData() {
// 页面挂载时初始化数据
onMounted
(
async
()
=>
{
// 加载宝宝信息
await
userStore
.
loadBabyInfo
()
console
.
log
(
'宝宝信息加载完成:'
,
userStore
.
babyInfo
)
// 先加载统计数据,然后更新图表(updateChartData 中已经包含了加载记录的逻辑)
await
initializeChartData
()
})
// 页面显示时刷新数据
onShow
(()
=>
{
onShow
(
async
()
=>
{
// 加载宝宝信息
await
userStore
.
loadBabyInfo
()
console
.
log
(
'宝宝信息加载完成:'
,
userStore
.
babyInfo
)
// 如果已经有选中日期,刷新当前日期的记录
if
(
selectedDate
.
value
)
{
loadRecordsByDate
(
selectedDate
.
value
)
...
...
@@ -1161,6 +1205,25 @@ function formatMonthString(date) {
return
`
${
year
}
-
${
month
}
`
}
// 解析时间格式为秒数
function
parseTimeToSeconds
(
timeString
)
{
if
(
!
timeString
)
return
0
const
parts
=
timeString
.
split
(
':'
)
if
(
parts
.
length
===
2
)
{
const
minutes
=
parseInt
(
parts
[
0
],
10
)
const
seconds
=
parseInt
(
parts
[
1
],
10
)
return
minutes
*
60
+
seconds
}
return
0
}
// 获取编辑表单的占位符
function
getEditFormPlaceholder
()
{
return
'输入具体内容'
}
// 清空缓存函数
function
clearCache
()
{
console
.
log
(
'清空缓存...'
)
...
...
@@ -1183,7 +1246,7 @@ function testApiIntegration() {
console
.
log
(
'=== 测试API集成 ==='
)
console
.
log
(
'当前选中日期:'
,
selectedDate
.
value
)
console
.
log
(
'当前周数:'
,
currentWeek
.
value
)
console
.
log
(
'当前宝宝ID:'
,
feedStore
.
getCurrentBabyId
()
)
console
.
log
(
'当前宝宝ID:'
,
babyId
.
value
)
console
.
log
(
'API统计数据:'
,
apiStatistics
.
value
)
console
.
log
(
'API记录数据:'
,
apiRecords
.
value
)
console
.
log
(
'缓存状态:'
,
{
...
...
@@ -1418,6 +1481,10 @@ function testApiIntegration() {
position
:
relative
;
z-index
:
2
;
pointer-events
:
none
;
// 确保不拦截点击事件
&
.selected
{
color
:
#1d1e25
;
}
}
// 确保点击时没有任何背景色变化
...
...
@@ -1453,9 +1520,9 @@ function testApiIntegration() {
margin-top
:
-43rpx
;
border-radius
:
30rpx
30rpx
0
0
;
background
:
#ffffff
;
}
}
.baby-age
{
.baby-age
{
text-align
:
left
;
padding
:
25rpx
0
0
40rpx
;
background
:
#ffffff
;
...
...
@@ -1465,6 +1532,7 @@ function testApiIntegration() {
font-size
:
26rpx
;
color
:
#000000
;
// 黑色文字
font-weight
:
bold
;
// 加粗
line-height
:
80rpx
;
}
}
...
...
@@ -1681,7 +1749,7 @@ function testApiIntegration() {
}
.popup-content
{
background
:
#f
ff
;
background
:
#f
6f8fa
;
width
:
100%
;
border-radius
:
20rpx
20rpx
0
0
;
padding
:
40rpx
30rpx
;
...
...
@@ -1693,7 +1761,7 @@ function testApiIntegration() {
font-size
:
36rpx
;
font-weight
:
600
;
color
:
#333
;
text-align
:
center
;
text-align
:
left
;
margin-bottom
:
40rpx
;
}
...
...
@@ -1702,10 +1770,14 @@ function testApiIntegration() {
position
:
relative
;
.label
{
position
:
absolute
;
left
:
24rpx
;
top
:
50%
;
transform
:
translateY
(
-50%
);
font-size
:
28rpx
;
color
:
#333
;
margin-bottom
:
12rpx
;
display
:
block
;
z-index
:
2
;
pointer-events
:
none
;
}
.input-container
{
...
...
@@ -1716,10 +1788,11 @@ function testApiIntegration() {
.picker
,
.input
{
width
:
100%
;
padding
:
24rpx
;
background
:
#f
8f9fa
;
padding
:
24rpx
24rpx
24rpx
120rpx
;
background
:
#f
fffff
;
border-radius
:
12rpx
;
font-size
:
28rpx
;
text-align
:
right
;
color
:
#333
;
min-height
:
88rpx
;
border
:
1rpx
solid
#e9ecef
;
...
...
@@ -1729,22 +1802,11 @@ function testApiIntegration() {
.picker
{
display
:
flex
;
align-items
:
center
;
justify-content
:
flex-end
;
min-height
:
88rpx
;
}
.char-count
{
position
:
absolute
;
right
:
20rpx
;
top
:
50%
;
transform
:
translateY
(
-50%
);
font-size
:
24rpx
;
color
:
#999
;
pointer-events
:
none
;
z-index
:
1
;
background
:
rgba
(
248
,
249
,
250
,
0
.8
);
padding
:
2rpx
8rpx
;
border-radius
:
4rpx
;
}
}
.popup-buttons
{
...
...
@@ -1752,25 +1814,20 @@ function testApiIntegration() {
gap
:
20rpx
;
margin-top
:
50rpx
;
button
{
flex
:
1
;
height
:
88rpx
;
border-radius
:
12rpx
;
font-size
:
32rpx
;
border
:
none
;
font-weight
:
600
;
&
.cancel-btn
{
background
:
#f8f9fa
;
color
:
#6c757d
;
border
:
1rpx
solid
#e9ecef
;
.cancel-btn
,
.confirm-btn
{
width
:
331rpx
;
height
:
94rpx
;
flex
:
none
;
}
&
.confirm-btn
{
background
:
#D4A574
;
color
:
#fff
;
.cancel-btn
{
&
:active
{
opacity
:
0
.8
;
}
}
.confirm-btn
{
&
:active
{
opacity
:
0
.8
;
}
...
...
pages/feedingIndex/feedingIndex.vue
View file @
a8babdb1
...
...
@@ -15,18 +15,18 @@
<!-- 喂养时间 -->
<view
class=
"feeding-time"
>
<view
class=
"baby-info"
@
click=
"showBabySwitch"
v-if=
"babyList.length > 1"
>
<image
class=
"avatar-img"
:src=
"
babyList[currentBabyIndex]?.a
vatar || feedingIndexRes.avatar"
>
<image
class=
"avatar-img"
:src=
"
userStore.babyInfo?.babyA
vatar || feedingIndexRes.avatar"
>
</image>
<view
class=
"baby-name-section"
>
<text
class=
"baby-name"
>
{{
babyList
[
currentBabyIndex
]?.
n
ame
||
'加载中...'
}}
</text>
<text
class=
"baby-name"
>
{{
userStore
.
babyInfo
?.
babyN
ame
||
'加载中...'
}}
</text>
<image
class=
"dropdown-icon"
:src=
"feedingIndexRes.icon_arrow_yellow_drop"
/>
</view>
</view>
<view
class=
"baby-info"
v-else-if=
"babyList.length === 1"
>
<image
class=
"avatar-img"
:src=
"
babyList[currentBabyIndex]?.a
vatar || feedingIndexRes.avatar"
>
<image
class=
"avatar-img"
:src=
"
userStore.babyInfo?.babyA
vatar || feedingIndexRes.avatar"
>
</image>
<view
class=
"baby-name-section"
>
<text
class=
"baby-name"
>
{{
babyList
[
currentBabyIndex
]?.
n
ame
||
'加载中...'
}}
</text>
<text
class=
"baby-name"
>
{{
userStore
.
babyInfo
?.
babyN
ame
||
'加载中...'
}}
</text>
</view>
</view>
<view
class=
"baby-info"
v-else
>
...
...
@@ -405,10 +405,10 @@
<
script
setup
>
import
{
ref
,
computed
,
onMounted
,
onUnmounted
,
getCurrentInstance
}
from
'vue'
import
{
onShow
,
onLoad
}
from
'@dcloudio/uni-app'
import
{
onShow
,
onLoad
,
onHide
}
from
'@dcloudio/uni-app'
import
BabySwitchPopup
from
'@/components/BabySwitchPopup.vue'
import
{
feedingHome
,
feedingRecords
,
feedingFoodsCustom
,
feedingFoodsCustomAdd
,
feedingFoodsCustomDelete
,
feedingTimerStart
,
feedingTimerStop
,
feedingVoiceUpload
,
feedingVoiceResult
}
from
'@/api/feeding.js'
import
{
use
FeedStore
}
from
'@/stores/feed
.js'
import
{
use
UserStore
}
from
'@/stores/user
.js'
import
{
jump
,
JumpType
}
from
'../../utils'
import
{
getHealthField
}
from
"@/api/common"
;
...
...
@@ -517,6 +517,7 @@ const currentRecordId = ref(null) // 当前记录ID,用于区分新增和修
const
isSubmitting
=
ref
(
false
)
// 提交状态
const
bannerHandler
=
(
item
)
=>
{
console
.
log
(
item
);
jump
({
type
:
item
.
JumpType
,
url
:
item
.
url
})
}
const
feedingTypes
=
ref
([
...
...
@@ -606,7 +607,8 @@ const voiceRecognitionState = ref({
const
recorderManager
=
uni
.
getRecorderManager
()
// 全局状态管理
const
feedStore
=
useFeedStore
()
const
userStore
=
useUserStore
()
const
babyId
=
computed
(()
=>
userStore
.
babyInfo
?.
content
?.
id
)
// 宝宝切换相关状态
const
showBabySwitchPopup
=
ref
(
false
)
...
...
@@ -673,22 +675,25 @@ const isVoiceMode = computed(() => {
})
// 计算属性 - 获取宝宝信息
const
babyList
=
computed
(()
=>
feedStore
.
babyList
)
const
currentBabyIndex
=
computed
(()
=>
feedStore
.
currentBabyIndex
)
const
currentBaby
=
computed
(()
=>
feedStore
.
getCurrentBaby
())
const
currentBabyId
=
computed
(()
=>
feedStore
.
getCurrentBabyId
())
const
babyList
=
computed
(()
=>
userStore
.
babyInfo
?.
allBabyBaseInfo
||
[])
const
currentBabyIndex
=
computed
(()
=>
{
if
(
!
babyList
.
value
||
!
currentBaby
.
value
)
return
0
return
babyList
.
value
.
findIndex
(
baby
=>
baby
.
id
===
currentBaby
.
value
.
id
)
})
const
currentBaby
=
computed
(()
=>
userStore
.
babyInfo
?.
content
)
const
currentBabyId
=
computed
(()
=>
userStore
.
babyInfo
?.
content
?.
id
)
// 页面加载时获取数据
onMounted
(()
=>
{
onMounted
(
async
()
=>
{
console
.
warn
(
'页面加载,开始初始化数据...'
)
loadBabyInfo
()
await
loadBabyInfo
()
loadFoodsData
()
})
// 页面显示时刷新数据
onShow
(()
=>
{
// 刷新宝宝信息和首页数据
load
BabyInfo
()
load
HomeData
()
// 重置计时器状态,确保状态正确
resetTimerStatus
()
...
...
@@ -703,6 +708,20 @@ onShow(() => {
}
})
// 页面隐藏时同步计时器状态
onHide
(()
=>
{
// 如果页面隐藏时有计时器在运行,需要同步到后端
if
(
isLeftTimerRunning
.
value
&&
leftTimerInterval
)
{
console
.
log
(
'页面隐藏时同步左侧计时器状态'
)
// 这里可以选择是否调用后端接口同步状态
// 由于页面隐藏时通常不需要立即同步,可以等到页面显示时再同步
}
if
(
isRightTimerRunning
.
value
&&
rightTimerInterval
)
{
console
.
log
(
'页面隐藏时同步右侧计时器状态'
)
// 这里可以选择是否调用后端接口同步状态
}
})
// 页面卸载时清理计时器
onUnmounted
(()
=>
{
// 清理左侧计时器
...
...
@@ -741,10 +760,7 @@ onLoad(async (options) => {
// 如果有其他参数,可以在这里处理
if
(
options
.
babyId
)
{
// 设置选中的宝宝
const
babyIndex
=
feedStore
.
babyList
.
findIndex
(
baby
=>
baby
.
id
==
options
.
babyId
)
if
(
babyIndex
>
-
1
)
{
feedStore
.
switchBaby
(
babyIndex
)
}
await
userStore
.
changeBabySelected
(
options
.
babyId
)
}
if
(
options
.
feedingType
)
{
...
...
@@ -808,7 +824,9 @@ async function loadBabyInfo() {
console
.
log
(
'开始加载宝宝信息...'
)
// 使用全局状态管理加载宝宝信息
await
feedStore
.
loadBabyInfo
()
// 加载宝宝信息 - 由 userStore 管理
await
userStore
.
loadBabyInfo
()
console
.
log
(
'宝宝信息加载完成:'
,
userStore
.
babyInfo
)
console
.
log
(
'宝宝信息加载完成'
)
...
...
@@ -830,7 +848,7 @@ async function loadBabyInfo() {
// 获取首页数据
async
function
loadHomeData
()
{
try
{
const
response
=
await
feedingHome
(
feedStore
.
getCurrentBabyId
()
)
const
response
=
await
feedingHome
(
babyId
.
value
)
console
.
log
(
'首页数据:'
,
response
)
if
(
response
&&
response
.
data
)
{
...
...
@@ -909,12 +927,13 @@ function initializePageData() {
timerData
.
value
.
leftDuration
=
Math
.
floor
(
data
.
leftTimerDuration
/
1000
)
// 转换为秒
startLeftTimer
()
}
else
{
// 如果接口显示没有左侧计时器在运行,但当前有计时器数据,则清空
if
(
timerData
.
value
.
leftDuration
>
0
)
{
console
.
log
(
'接口显示左侧计时器未运行,清空左侧计时器数据'
)
// 如果接口显示没有左侧计时器在运行,但当前有计时器数据,则清空
并停止定时器
if
(
timerData
.
value
.
leftDuration
>
0
||
isLeftTimerRunning
.
value
)
{
console
.
log
(
'接口显示左侧计时器未运行,清空左侧计时器数据
并停止定时器
'
)
timerData
.
value
.
leftDuration
=
0
}
isLeftTimerRunning
.
value
=
false
stopLeftTimer
()
}
}
if
(
data
.
rightTimerRunning
)
{
...
...
@@ -922,12 +941,13 @@ function initializePageData() {
timerData
.
value
.
rightDuration
=
Math
.
floor
(
data
.
rightTimerDuration
/
1000
)
// 转换为秒
startRightTimer
()
}
else
{
// 如果接口显示没有右侧计时器在运行,但当前有计时器数据,则清空
if
(
timerData
.
value
.
rightDuration
>
0
)
{
console
.
log
(
'接口显示右侧计时器未运行,清空右侧计时器数据'
)
// 如果接口显示没有右侧计时器在运行,但当前有计时器数据,则清空
并停止定时器
if
(
timerData
.
value
.
rightDuration
>
0
||
isRightTimerRunning
.
value
)
{
console
.
log
(
'接口显示右侧计时器未运行,清空右侧计时器数据
并停止定时器
'
)
timerData
.
value
.
rightDuration
=
0
}
isRightTimerRunning
.
value
=
false
stopRightTimer
()
}
}
// 如果有计时器在运行,切换到计时器模式
...
...
@@ -1225,7 +1245,7 @@ function toggleRecording() {
}
async
function
toggleTimer
(
side
)
{
const
babyId
=
feedStore
.
getCurrentBabyId
()
const
currentBabyId
=
babyId
.
value
if
(
side
===
'left'
)
{
// 检查是否已达到上限
...
...
@@ -1242,7 +1262,7 @@ async function toggleTimer(side) {
// 开始左侧计时
try
{
const
response
=
await
feedingTimerStart
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
side
:
'left'
})
console
.
log
(
'开始左侧计时成功:'
,
response
)
...
...
@@ -1259,7 +1279,7 @@ async function toggleTimer(side) {
// 停止左侧计时
try
{
const
response
=
await
feedingTimerStop
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
side
:
'left'
})
console
.
log
(
'停止左侧计时成功:'
,
response
)
...
...
@@ -1288,7 +1308,7 @@ async function toggleTimer(side) {
// 开始右侧计时
try
{
const
response
=
await
feedingTimerStart
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
side
:
'right'
})
console
.
log
(
'开始右侧计时成功:'
,
response
)
...
...
@@ -1305,7 +1325,7 @@ async function toggleTimer(side) {
// 停止右侧计时
try
{
const
response
=
await
feedingTimerStop
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
side
:
'right'
})
console
.
log
(
'停止右侧计时成功:'
,
response
)
...
...
@@ -1384,8 +1404,8 @@ function stopRightTimer() {
// 自动停止左侧计时器(调用后端接口)
async
function
autoStopLeftTimer
()
{
const
babyId
=
feedStore
.
getCurrentBabyId
()
if
(
!
b
abyId
)
{
const
currentBabyId
=
babyId
.
value
if
(
!
currentB
abyId
)
{
console
.
warn
(
'没有选择宝宝,无法停止计时器'
)
return
}
...
...
@@ -1393,7 +1413,7 @@ async function autoStopLeftTimer() {
try
{
console
.
log
(
'自动停止左侧计时器'
)
const
response
=
await
feedingTimerStop
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
side
:
'left'
})
console
.
log
(
'自动停止左侧计时器成功:'
,
response
)
...
...
@@ -1405,8 +1425,8 @@ async function autoStopLeftTimer() {
// 自动停止右侧计时器(调用后端接口)
async
function
autoStopRightTimer
()
{
const
babyId
=
feedStore
.
getCurrentBabyId
()
if
(
!
b
abyId
)
{
const
currentBabyId
=
babyId
.
value
if
(
!
currentB
abyId
)
{
console
.
warn
(
'没有选择宝宝,无法停止计时器'
)
return
}
...
...
@@ -1414,7 +1434,7 @@ async function autoStopRightTimer() {
try
{
console
.
log
(
'自动停止右侧计时器'
)
const
response
=
await
feedingTimerStop
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
side
:
'right'
})
console
.
log
(
'自动停止右侧计时器成功:'
,
response
)
...
...
@@ -1426,8 +1446,8 @@ async function autoStopRightTimer() {
// 停止所有计时器
async
function
stopAllTimers
()
{
const
currentBaby
=
feedStore
.
getCurrentBaby
()
if
(
!
currentBaby
||
!
currentBaby
.
i
d
)
{
const
currentBaby
Id
=
babyId
.
value
if
(
!
currentBaby
I
d
)
{
console
.
warn
(
'没有选择宝宝,无法停止计时器'
)
return
}
...
...
@@ -1437,7 +1457,7 @@ async function stopAllTimers() {
if
(
isLeftTimerRunning
.
value
)
{
console
.
log
(
'保存记录前停止左侧计时器'
)
const
leftResponse
=
await
feedingTimerStop
({
babyId
:
currentBaby
.
i
d
,
babyId
:
currentBaby
I
d
,
side
:
'left'
})
console
.
log
(
'停止左侧计时器成功:'
,
leftResponse
)
...
...
@@ -1449,7 +1469,7 @@ async function stopAllTimers() {
if
(
isRightTimerRunning
.
value
)
{
console
.
log
(
'保存记录前停止右侧计时器'
)
const
rightResponse
=
await
feedingTimerStop
({
babyId
:
currentBaby
.
i
d
,
babyId
:
currentBaby
I
d
,
side
:
'right'
})
console
.
log
(
'停止右侧计时器成功:'
,
rightResponse
)
...
...
@@ -1546,7 +1566,7 @@ async function completeRecord() {
// 验证记录数据
function
validateRecordData
()
{
const
currentBaby
=
feedStore
.
getCurrentBaby
()
const
currentBaby
=
userStore
.
babyInfo
?.
content
// 验证宝宝信息
if
(
!
currentBaby
||
!
currentBaby
.
id
)
{
...
...
@@ -1617,7 +1637,7 @@ function validateRecordData() {
// 构建记录数据
function
buildRecordData
()
{
const
currentBaby
=
feedStore
.
getCurrentBaby
()
const
currentBaby
=
userStore
.
babyInfo
?.
content
const
recordTime
=
formatCurrentTime
()
// 基础数据
...
...
@@ -2777,9 +2797,10 @@ function showBabySwitch() {
}
}
function
onBabyChange
(
baby
,
index
)
{
feedStore
.
switchBaby
(
index
)
console
.
log
(
'切换到宝宝:'
,
baby
.
name
,
'索引:'
,
index
)
async
function
onBabyChange
(
baby
,
index
)
{
// 切换宝宝
await
userStore
.
changeBabySelected
(
baby
.
id
)
console
.
log
(
'切换到宝宝:'
,
baby
.
babyName
,
'索引:'
,
index
)
// 切换宝宝后重新加载该宝宝的喂养数据
loadHomeData
()
...
...
pages/feedingRecord/feedingRecord.vue
View file @
a8babdb1
...
...
@@ -8,7 +8,7 @@
<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"
v-if=
"
babyList.length > 1
"
>
<view
class=
"baby-info"
@
click=
"showBabySwitch"
v-if=
"
hasMultipleStage2Babies
"
>
<text
class=
"baby-name"
>
{{
getCurrentBabyName
()
}}
</text>
<text
class=
"baby-age"
>
{{
getCurrentBabyAge
()
}}
</text>
</view>
...
...
@@ -152,29 +152,28 @@
<!-- 编辑弹窗 -->
<view
class=
"popup-mask"
v-if=
"showEditPopup"
@
click=
"closeEditPopup"
@
touchmove
.
prevent
>
<view
class=
"popup-content"
@
click
.
stop
@
touchmove
.
stop
>
<view
class=
"popup-title"
>
修改喂养记录
</view>
<view
class=
"popup-title"
>
确认修改内容
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
时间:
</text>
<text
class=
"label"
>
喂养时间
</text>
<picker
mode=
"time"
:value=
"editForm.time"
@
change=
"onEditTimeChange"
>
<view
class=
"picker"
>
{{ editForm.time || '请选择时间' }}
</view>
</picker>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
类型:
</text>
<text
class=
"label"
>
喂养方式
</text>
<picker
:range=
"feedingTypes"
@
change=
"onEditTypeChange"
>
<view
class=
"picker"
>
{{ editForm.type || '请选择类型' }}
</view>
</picker>
</view>
<view
class=
"form-item"
>
<text
class=
"label"
>
喂养详情
:
</text>
<text
class=
"label"
>
喂养详情
</text>
<view
class=
"input-container"
>
<input
class=
"input"
v-model=
"editForm.content"
placeholder=
"请输入具体内容"
maxlength=
"20"
/>
<text
class=
"char-count"
>
{{ editForm.content.length }}/20
</text>
<input
class=
"input"
v-model=
"editForm.content"
:placeholder=
"getEditFormPlaceholder()"
maxlength=
"20"
/>
</view>
</view>
<view
class=
"popup-buttons"
>
<
button
class=
"cancel-btn"
@
click=
"closeEditPopup"
>
取消
</button
>
<
button
class=
"confirm-btn"
@
click=
"saveEditRecord"
>
保存修改
</button
>
<
image
:src=
"feedingRecordRes.icon_change_btn_cancel"
class=
"cancel-btn"
@
click=
"closeEditPopup"
/
>
<
image
:src=
"feedingRecordRes.icon_change_btn_confirm"
class=
"confirm-btn"
@
click=
"saveEditRecord"
/
>
</view>
</view>
</view>
...
...
@@ -195,7 +194,7 @@ import { ref, computed, onMounted, onUnmounted, watch, nextTick,getCurrentInstan
import
{
onLoad
,
onShow
}
from
'@dcloudio/uni-app'
import
BabySwitchPopup
from
'@/components/BabySwitchPopup.vue'
import
{
feedingRecordsByDate
,
feedingRecordsCalendarStatus
,
feedingRecords
as
feedingRecordsAPI
}
from
'@/api/feeding.js'
import
{
use
FeedStore
}
from
'@/stores/feed
.js'
import
{
use
UserStore
}
from
'@/stores/user
.js'
// API 集成说明:
// 1. 使用 /c/feeding/records GET 方法查询指定日期的喂养记录列表
...
...
@@ -230,6 +229,9 @@ const feedingRecordRes = {
icon_return
:
$baseUrl
+
`feedingRecord/
${
version
}
/icon_return.png`
,
icon_baby_change
:
$baseUrl
+
`feedingRecord/
${
version
}
/icon_baby_change.png`
,
add_btn
:
$baseUrl
+
`feedingRecord/
${
version
}
/addBtn.png`
,
icon_change_btn_confirm
:
$baseUrl
+
`feedingRecord/
${
version
}
/icon_change_btn_confirm.png`
,
icon_change_btn_cancel
:
$baseUrl
+
`feedingRecord/
${
version
}
/icon_change_btn_cancel.png`
,
}
...
...
@@ -246,7 +248,8 @@ const forceUpdate = ref(0)
const
currentMonthKey
=
ref
(
''
)
// 全局状态管理
const
feedStore
=
useFeedStore
()
const
userStore
=
useUserStore
()
const
babyId
=
computed
(()
=>
userStore
.
babyInfo
?.
content
?.
id
)
// 宝宝切换相关状态
const
showBabySwitchPopup
=
ref
(
false
)
...
...
@@ -288,10 +291,20 @@ const recordsCache = ref(new Map()) // 记录数据缓存,避免重复请求
const
calendarCache
=
ref
(
new
Map
())
// 日历状态缓存,避免重复请求
// 计算属性 - 获取宝宝信息
const
babyList
=
computed
(()
=>
feedStore
.
babyList
)
const
currentBabyIndex
=
computed
(()
=>
feedStore
.
currentBabyIndex
)
const
currentBaby
=
computed
(()
=>
feedStore
.
getCurrentBaby
())
const
currentBabyId
=
computed
(()
=>
feedStore
.
getCurrentBabyId
())
const
babyList
=
computed
(()
=>
userStore
.
babyInfo
?.
allBabyBaseInfo
||
[])
const
currentBabyIndex
=
computed
(()
=>
{
if
(
!
babyList
.
value
||
!
currentBaby
.
value
)
return
0
return
babyList
.
value
.
findIndex
(
baby
=>
baby
.
id
===
currentBaby
.
value
.
id
)
})
const
currentBaby
=
computed
(()
=>
userStore
.
babyInfo
?.
content
)
const
currentBabyId
=
computed
(()
=>
userStore
.
babyInfo
?.
content
?.
id
)
// 检查是否有多个 stage == 2 的宝宝
const
hasMultipleStage2Babies
=
computed
(()
=>
{
if
(
!
babyList
.
value
||
babyList
.
value
.
length
===
0
)
return
false
const
stage2Babies
=
babyList
.
value
.
filter
(
baby
=>
baby
.
babyStage
===
2
)
return
stage2Babies
.
length
>
1
})
// 计算属性 - 当前选中日期的记录
const
todayRecords
=
computed
(()
=>
{
...
...
@@ -606,10 +619,32 @@ function editRecord(index) {
console
.
log
(
'record.foodDetails:'
,
record
.
foodDetails
)
console
.
log
(
'record.content:'
,
record
.
content
)
// 根据记录类型设置不同的字段
let
content
=
''
if
(
record
.
type
===
'母乳亲喂'
)
{
// 母乳亲喂:优先显示 foodDetails,如果没有则从左右时间构建
if
(
record
.
foodDetails
)
{
content
=
record
.
foodDetails
}
else
{
const
leftTime
=
record
.
leftDuration
||
''
const
rightTime
=
record
.
rightDuration
||
''
content
=
`
${
leftTime
}
${
rightTime
}
`
.
trim
()
}
}
else
if
(
record
.
type
===
'母乳瓶喂'
)
{
// 母乳瓶喂:优先显示 foodDetails,如果没有则显示 amount
content
=
record
.
foodDetails
||
record
.
amount
||
''
}
else
if
(
record
.
type
===
'奶粉喂养'
)
{
// 奶粉喂养:优先显示 foodDetails,如果没有则显示 amount
content
=
record
.
foodDetails
||
record
.
amount
||
''
}
else
if
(
record
.
type
===
'辅食'
)
{
// 辅食:显示食物详情
content
=
record
.
foodDetails
||
record
.
content
||
''
}
editForm
.
value
=
{
time
:
record
.
time
||
getCurrentTime
(),
// 使用记录的原始时间,如果没有则使用当前时间
type
:
record
.
type
||
''
,
content
:
record
.
foodDetails
||
record
.
content
||
''
// 优先使用foodDetails
content
:
content
}
console
.
log
(
'设置后的editForm:'
,
editForm
.
value
)
...
...
@@ -652,12 +687,37 @@ async function saveEditRecord() {
})
const
{
index
,
record
}
=
editingRecord
.
value
const
apiData
=
{
// 根据记录类型处理不同的数据
let
apiData
=
{
recordId
:
record
.
recordId
,
babyId
:
feedStore
.
getCurrentBabyId
()
,
babyId
:
babyId
.
value
,
recordTime
:
formatDateTimeString
(
currentSelectedDate
.
value
,
editForm
.
value
.
time
),
feedingType
:
getFeedingTypeId
(
editForm
.
value
.
type
),
foodDetails
:
editForm
.
value
.
content
// 统一使用foodDetails字段
feedingType
:
getFeedingTypeId
(
editForm
.
value
.
type
)
}
// 所有类型都使用 foodDetails 字段保存
apiData
.
foodDetails
=
editForm
.
value
.
content
||
''
// 根据记录类型设置其他字段
if
(
editForm
.
value
.
type
===
'母乳亲喂'
)
{
// 母乳亲喂:解析时间(格式:时间1 时间2)
const
content
=
editForm
.
value
.
content
||
''
const
timeParts
=
content
.
trim
().
split
(
/
\s
+/
)
if
(
timeParts
.
length
>=
1
&&
timeParts
[
0
])
{
apiData
.
durationLeftSeconds
=
parseTimeToSeconds
(
timeParts
[
0
])
}
if
(
timeParts
.
length
>=
2
&&
timeParts
[
1
])
{
apiData
.
durationRightSeconds
=
parseTimeToSeconds
(
timeParts
[
1
])
}
}
else
if
(
editForm
.
value
.
type
===
'母乳瓶喂'
||
editForm
.
value
.
type
===
'奶粉喂养'
)
{
// 母乳瓶喂和奶粉喂养:解析奶量
const
content
=
editForm
.
value
.
content
||
''
const
volumeMatch
=
content
.
match
(
/
(\d
+
)
ml/
)
if
(
volumeMatch
)
{
apiData
.
volume
=
parseInt
(
volumeMatch
[
1
])
}
}
const
response
=
await
feedingRecordsAPI
(
apiData
)
...
...
@@ -714,9 +774,10 @@ function showBabySwitch() {
}
}
function
onBabyChange
(
baby
,
index
)
{
feedStore
.
switchBaby
(
index
)
console
.
log
(
'切换到宝宝:'
,
baby
.
name
,
'索引:'
,
index
)
async
function
onBabyChange
(
baby
,
index
)
{
// 切换宝宝
await
userStore
.
changeBabySelected
(
baby
.
id
)
console
.
log
(
'切换到宝宝:'
,
baby
.
babyName
,
'索引:'
,
index
)
// 切换宝宝后清空缓存,重新加载数据
clearCache
()
...
...
@@ -774,9 +835,8 @@ function calculateBabyAge(birthday) {
// 安全获取当前宝宝姓名
function
getCurrentBabyName
()
{
try
{
const
currentBaby
=
babyList
.
value
[
currentBabyIndex
.
value
]
if
(
currentBaby
&&
currentBaby
.
name
)
{
return
currentBaby
.
name
if
(
userStore
.
babyInfo
&&
userStore
.
babyInfo
.
babyName
)
{
return
userStore
.
babyInfo
.
babyName
}
return
'宝宝'
}
catch
(
error
)
{
...
...
@@ -788,9 +848,8 @@ function getCurrentBabyName() {
// 安全获取当前宝宝年龄
function
getCurrentBabyAge
()
{
try
{
const
currentBaby
=
babyList
.
value
[
currentBabyIndex
.
value
]
if
(
currentBaby
&&
currentBaby
.
birthday
)
{
return
calculateBabyAge
(
currentBaby
.
birthday
)
if
(
userStore
.
babyInfo
&&
userStore
.
babyInfo
.
babyAge
)
{
return
userStore
.
babyInfo
.
babyAge
}
return
'0天'
}
catch
(
error
)
{
...
...
@@ -808,7 +867,7 @@ async function loadRecordsByDate(date) {
}
// 检查缓存
const
cacheKey
=
`
${
date
}
_
${
feedStore
.
getCurrentBabyId
()
}
`
const
cacheKey
=
`
${
date
}
_
${
babyId
.
value
}
`
const
cachedData
=
recordsCache
.
value
.
get
(
cacheKey
)
if
(
cachedData
&&
Date
.
now
()
-
cachedData
.
timestamp
<
5
*
60
*
1000
)
{
// 5分钟缓存
console
.
log
(
'使用缓存的记录数据:'
,
date
)
...
...
@@ -823,7 +882,7 @@ async function loadRecordsByDate(date) {
if
(
loadingRecords
.
value
.
size
===
1
)
{
isLoading
.
value
=
true
}
const
babyId
=
feedStore
.
getCurrentBabyId
()
const
currentBabyId
=
babyId
.
value
// 添加超时处理
const
timeoutPromise
=
new
Promise
((
_
,
reject
)
=>
{
...
...
@@ -831,7 +890,7 @@ async function loadRecordsByDate(date) {
})
const
apiPromise
=
feedingRecordsByDate
({
babyId
:
b
abyId
,
babyId
:
currentB
abyId
,
date
:
date
})
...
...
@@ -957,7 +1016,7 @@ async function loadCalendarStatus(month) {
try {
const startTime = Date.now()
loadingCalendar.value.add(month)
const
babyId = feedStore.getCurrentBabyId()
const
currentBabyId = babyId.value
// 添加超时处理
const timeoutPromise = new Promise((_, reject) => {
...
...
@@ -965,7 +1024,7 @@ async function loadCalendarStatus(month) {
})
const apiPromise = feedingRecordsCalendarStatus({
babyId:
b
abyId,
babyId:
currentB
abyId,
month: month // 格式:YYYY-MM
})
...
...
@@ -1118,6 +1177,25 @@ function formatDuration(seconds) {
}
}
// 解析时间格式为秒数
function
parseTimeToSeconds
(
timeString
)
{
if
(
!
timeString
)
return
0
const
parts
=
timeString
.
split
(
':'
)
if
(
parts
.
length
===
2
)
{
const
minutes
=
parseInt
(
parts
[
0
],
10
)
const
seconds
=
parseInt
(
parts
[
1
],
10
)
return
minutes
*
60
+
seconds
}
return
0
}
// 获取编辑表单的占位符
function
getEditFormPlaceholder
()
{
return
'输入具体内容'
}
function
getFeedingTypeLabel
(
type
)
{
const
typeMap
=
{
1
:
'母乳亲喂'
,
...
...
@@ -1302,8 +1380,11 @@ watch(currentDate, (newDate, oldDate) => {
}
},
{
immediate
:
false
})
onMounted
(()
=>
{
onMounted
(
async
()
=>
{
// 组件挂载后的操作
// 加载宝宝信息
await
userStore
.
loadBabyInfo
()
console
.
log
(
'宝宝信息加载完成:'
,
userStore
.
babyInfo
)
})
// 页面卸载时清理资源
...
...
@@ -1316,7 +1397,11 @@ onUnmounted(() => {
})
// 页面显示时刷新数据
onShow
(()
=>
{
onShow
(
async
()
=>
{
// 加载宝宝信息
await
userStore
.
loadBabyInfo
()
console
.
log
(
'宝宝信息加载完成:'
,
userStore
.
babyInfo
)
// 如果已经有选中日期,刷新当前日期的记录
if
(
currentSelectedDate
.
value
)
{
loadRecordsByDate
(
currentSelectedDate
.
value
)
...
...
@@ -1920,7 +2005,7 @@ function testApiIntegration() {
}
.popup-content
{
background
:
#f
ff
;
background
:
#f
6f8fa
;
width
:
100%
;
border-radius
:
20rpx
20rpx
0
0
;
padding
:
40rpx
30rpx
;
...
...
@@ -1932,18 +2017,23 @@ function testApiIntegration() {
font-size
:
36rpx
;
font-weight
:
600
;
color
:
#333
;
text-align
:
center
;
text-align
:
left
;
margin-bottom
:
40rpx
;
}
.form-item
{
margin-bottom
:
30rpx
;
position
:
relative
;
.label
{
position
:
absolute
;
left
:
24rpx
;
top
:
50%
;
transform
:
translateY
(
-50%
);
font-size
:
28rpx
;
color
:
#333
;
margin-bottom
:
12rpx
;
display
:
block
;
z-index
:
2
;
pointer-events
:
none
;
}
.input-container
{
...
...
@@ -1954,10 +2044,11 @@ function testApiIntegration() {
.picker
,
.input
{
width
:
100%
;
padding
:
24rpx
;
background
:
#f
8f9fa
;
padding
:
24rpx
24rpx
24rpx
120rpx
;
background
:
#f
fffff
;
border-radius
:
12rpx
;
font-size
:
28rpx
;
text-align
:
right
;
min-height
:
88rpx
;
color
:
#333
;
...
...
@@ -1965,20 +2056,15 @@ function testApiIntegration() {
box-sizing
:
border-box
;
}
.char-count
{
position
:
absolute
;
right
:
20rpx
;
top
:
50%
;
transform
:
translateY
(
-50%
);
font-size
:
24rpx
;
color
:
#999
;
pointer-events
:
none
;
z-index
:
1
;
background
:
rgba
(
248
,
249
,
250
,
0
.8
);
padding
:
2rpx
8rpx
;
border-radius
:
4rpx
;
.picker
{
display
:
flex
;
align-items
:
center
;
justify-content
:
flex-end
;
min-height
:
88rpx
;
}
.picker
{
display
:
flex
;
align-items
:
center
;
...
...
@@ -1991,25 +2077,20 @@ function testApiIntegration() {
gap
:
20rpx
;
margin-top
:
50rpx
;
button
{
flex
:
1
;
height
:
88rpx
;
border-radius
:
50rpx
;
font-size
:
32rpx
;
border
:
none
;
font-weight
:
600
;
&
.cancel-btn
{
background
:
#f8f9fa
;
color
:
#6c757d
;
border
:
1rpx
solid
#e9ecef
;
.cancel-btn
,
.confirm-btn
{
width
:
331rpx
;
height
:
94rpx
;
flex
:
none
;
}
&
.confirm-btn
{
background
:
#D4A574
;
color
:
#fff
;
.cancel-btn
{
&
:active
{
opacity
:
0
.8
;
}
}
.confirm-btn
{
&
:active
{
opacity
:
0
.8
;
}
...
...
stores/feed.js
View file @
a8babdb1
...
...
@@ -26,12 +26,13 @@ export const useFeedStore = defineStore("feed", {
* 处理宝宝列表数据
*/
processBabyList
(
data
)
{
if
(
data
.
allBabyBaseInfo
&&
Array
.
isArray
(
data
.
allBabyBaseInfo
))
{
// 转换接口数据格式为组件需要的格式
this
.
babyList
=
data
.
allBabyBaseInfo
.
map
(
baby
=>
({
id
:
baby
.
id
,
name
:
baby
.
babyName
||
baby
.
content
?.
babyName
||
'未命名'
,
avatar
:
baby
.
content
?.
babyAvatar
||
'/static/feedingIndex/v1/avatar.png'
,
avatar
:
baby
.
content
?.
babyAvatar
,
gender
:
baby
.
content
?.
babyGender
,
birthday
:
baby
.
content
?.
babyBirthday
,
babyStage
:
baby
.
babyStage
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment