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
dfb801a1
Commit
dfb801a1
authored
Jul 30, 2025
by
王炽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
切换宝宝处理
parent
472fa500
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
36 deletions
+73
-36
BabyFeedSwitchPopup.vue
components/BabyFeedSwitchPopup.vue
+5
-1
BabySwitchPopup.vue
components/BabySwitchPopup.vue
+43
-17
shengzhangTools.vue
pages/shengzhangTools/shengzhangTools.vue
+25
-18
No files found.
components/BabyFeedSwitchPopup.vue
View file @
dfb801a1
...
...
@@ -48,7 +48,7 @@
</
template
>
<
script
setup
>
import
{
ref
,
defineEmits
,
defineProps
}
from
'vue'
import
{
ref
,
defineEmits
,
defineProps
,
onMounted
}
from
'vue'
const
props
=
defineProps
({
visible
:
{
...
...
@@ -141,6 +141,10 @@ const onFeedChange = (feedOption, index) => {
const
closePopup
=
()
=>
{
emit
(
'update:visible'
,
false
)
}
onMounted
(()
=>
{
})
</
script
>
<
style
lang=
"less"
scoped
>
...
...
components/BabySwitchPopup.vue
View file @
dfb801a1
...
...
@@ -18,12 +18,12 @@
v-for=
"(baby, index) in babyList"
:key=
"index"
class=
"baby-item"
:class=
"
{ selected: select
ed
Index === index }"
:class=
"
{ selected: selectIndex === index }"
@click="selectBaby(index)"
>
<!-- 选中背景 -->
<image
v-if=
"select
ed
Index === index"
v-if=
"selectIndex === index"
class=
"baby-item-bg"
:src=
"`$
{$baseUrl}shengzhangTool/1001/changeBaby/babyItemBg.png`"
mode="aspectFit"
...
...
@@ -32,21 +32,21 @@
<!-- 宝宝头像 -->
<image
class=
"baby-avatar"
:src=
"baby.avatar || `
$
{$baseUrl}shengzhangTool/1001/
avatar.png`"
:src=
"baby.avatar || `
https://course.feihe.com/momclub-picture/common/default_
avatar.png`"
mode=
"aspectFill"
/>
<!-- 宝宝信息 -->
<view
class=
"baby-info"
>
<view
class=
"baby-name-row"
>
<text
class=
"baby-name"
>
{{
baby
.
n
ame
}}
</text>
<text
class=
"baby-name"
>
{{
baby
.
babyN
ame
}}
</text>
<image
class=
"gender-icon"
:src=
"baby.gender === 1 ? `$
{$baseUrl}shengzhangTool/1001/sex1.png` : `${$baseUrl}shengzhangTool/1001/sex0.png`"
mode="aspectFit"
/>
</view>
<text
class=
"baby-birthday"
>
宝宝生日:
{{
baby
.
birthday
}}
</text>
<text
class=
"baby-birthday"
>
宝宝生日:
{{
baby
.
b
abyB
irthday
}}
</text>
</view>
</view>
</view>
...
...
@@ -65,23 +65,33 @@
</
template
>
<
script
setup
>
import
{
ref
,
defineEmits
,
defineProps
}
from
'vue'
import
{
ref
,
defineEmits
,
defineProps
,
onMounted
}
from
'vue'
import
{
useUserStore
}
from
"@/stores/user"
;
// const props = defineProps({
// visible: {
// type: Boolean,
// default: false
// },
// babyList: {
// type: Array,
// default: () => []
// },
// selectedIndex: {
// type: Number,
// default: 0
// }
// })
const
props
=
defineProps
({
visible
:
{
type
:
Boolean
,
default
:
false
},
babyList
:
{
type
:
Array
,
default
:
()
=>
[]
},
selectedIndex
:
{
type
:
Number
,
default
:
0
}
})
const
userStore
=
useUserStore
();
const
emit
=
defineEmits
([
'update:visible'
,
'update:selectedIndex'
,
'change'
])
const
selectHandle
=
()
=>
{
...
...
@@ -93,14 +103,16 @@ const handleOkTouchStart = () => {
isOkPressed
.
value
=
true
}
const
handleOkTouchEnd
=
()
=>
{
const
handleOkTouchEnd
=
async
()
=>
{
isOkPressed
.
value
=
false
const
index
=
selectIndex
.
value
;
// 发送事件 通知主页面
emit
(
'change'
,
props
.
babyList
[
index
],
index
)
await
userStore
.
changeBabySelected
(
babyList
.
value
[
index
].
id
);
// 发送事件 通知主页面
emit
(
'change'
,
babyList
.
value
[
index
])
closePopup
();
}
const
closePopup
=
()
=>
{
...
...
@@ -112,6 +124,20 @@ const selectBaby = (index) => {
selectIndex
.
value
=
index
;
emit
(
'update:selectedIndex'
,
index
);
}
const
babyList
=
ref
([]);
onMounted
(()
=>
{
babyList
.
value
=
userStore
.
babyInfo
?.
allBabyBaseInfo
;
if
(
babyList
.
value
===
null
){
babyList
.
value
=
[];
}
const
selectedIndexInList
=
babyList
.
value
.
findIndex
(
item
=>
item
.
selected
===
true
)
console
.
log
(
'选中宝宝的索引:'
,
selectedIndexInList
)
selectIndex
.
value
=
selectedIndexInList
;
})
</
script
>
<
style
lang=
"less"
scoped
>
...
...
pages/shengzhangTools/shengzhangTools.vue
View file @
dfb801a1
...
...
@@ -273,7 +273,7 @@ const babyName = ref('宝宝名称')
const
babyAge
=
ref
(
'8月龄'
)
const
babyBirthday
=
ref
(
'2024-10-20'
)
const
babyGender
=
ref
(
'M'
)
const
babyAvatar
=
ref
(
`
shengzhangTool/1001/
avatar.png`
);
const
babyAvatar
=
ref
(
`
https://course.feihe.com/momclub-picture/common/default_
avatar.png`
);
const
shengzhangStore
=
useShengzhangStore
();
...
...
@@ -474,7 +474,7 @@ const onHeadBlur = (e) => {
const
changeBaby
=
()
=>
{
console
.
log
(
'切换宝宝'
)
showBabySwitchPopup
.
value
=
true
currentBabyIndex
.
value
=
0
// 默认选中第一个宝宝
//
currentBabyIndex.value = 0 // 默认选中第一个宝宝
}
const
viewRecords
=
()
=>
{
...
...
@@ -500,6 +500,9 @@ const convertFeedingType = (type) => {
const
submitData
=
throttleTap
(
async
()
=>
{
showLoading
.
value
=
true
;
if
(
headCircumference
.
value
==
0
){
headCircumference
.
value
=
null
;
}
const
submitData
=
{
babyId
:
babyId
.
value
,
height
:
height
.
value
,
...
...
@@ -566,25 +569,15 @@ const selectedFeedText = ref('母乳+奶粉混合喂养')
// 示例宝宝列表数据
const
babyList
=
ref
([
{
name
:
'宝宝名称'
,
gender
:
1
,
// 1: 男孩, 0: 女孩
birthday
:
'2024-10-20'
,
avatar
:
`shengzhangTool/1001/avatar.png`
},
{
name
:
'宝宝名称'
,
gender
:
0
,
birthday
:
'2022-04-20'
,
avatar
:
`shengzhangTool/1001/avatar.png`
}
])
// 处理宝宝选择变化
const
onBabyChange
=
(
baby
,
index
)
=>
{
console
.
log
(
'选择了宝宝:'
,
baby
,
index
)
const
onBabyChange
=
async
(
baby
)
=>
{
console
.
log
(
'选择了宝宝:'
,
baby
)
// 这里可以更新页面上的宝宝信息
// 比如更新宝宝名称、性别、生日等
await
refreshBabyInfo
();
}
// 处理喂养方式选择变化
...
...
@@ -696,9 +689,24 @@ onLoad((options) => {
})
onMounted
(
async
()
=>
{
await
refreshBabyInfo
();
})
const
refreshBabyInfo
=
async
()
=>
{
const
userStore
=
useUserStore
();
babyId
.
value
=
userStore
.
babyInfo
?.
content
?.
id
;
console
.
log
(
'babyId.value='
,
babyId
.
value
);
// babyList.value = userStore.babyInfo?.allBabyBaseInfo;
// if(babyList.value === null){
// babyList.value = [];
// }
//切换宝宝默认选中处理
// selectedIndex.value = userStore.babyInfo?.allBabyBaseInfo.findIndex(
// (item) => item.selected
// );
const
{
data
}
=
await
growthHome
(
babyId
.
value
);
selectedDate
.
value
=
formatDate
(
new
Date
());
...
...
@@ -719,8 +727,7 @@ onMounted(async () => {
}
else
{
guideIndex
.
value
=
0
;
}
})
}
</
script
>
...
...
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