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
b3de8baa
Commit
b3de8baa
authored
Aug 11, 2025
by
weishengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(components): 优化弹窗组件功能和逻辑
- 在 popup-tip 组件中添加关闭弹窗的事件 - 优化宝宝状态切换和修改逻辑 - 修复一些潜在的 bug 和性能问题
parent
0bf6541a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
23 deletions
+35
-23
popup-tip.vue
components/popup-tip/popup-tip.vue
+33
-21
postnatalCheckUp.vue
pages/postnatalCheckUp/postnatalCheckUp.vue
+1
-1
shengzhangTools.vue
pages/shengzhangTools/shengzhangTools.vue
+1
-1
No files found.
components/popup-tip/popup-tip.vue
View file @
b3de8baa
...
...
@@ -56,6 +56,7 @@ import {
defineEmits
}
from
'vue'
import
{
useUserStore
}
from
"@/stores/user"
;
import
{
console
}
from
'inspector'
;
// 接受父组件参数
const
props
=
defineProps
({
type
:
{
...
...
@@ -68,7 +69,7 @@ const userStore = useUserStore();
const
babyInfo
=
ref
(
userStore
.
babyInfo
)
// 回调函数
const
emit
=
defineEmits
([
'statusChange'
])
const
emit
=
defineEmits
([
'statusChange'
,
'close'
])
const
isType
=
ref
(
'0'
)
// 0 添加状态或者宝宝 1 切换状态 2 修改状态 3 宝宝已达上限
...
...
@@ -79,18 +80,20 @@ const babyBaseId = ref('')
const
pregnancyStatus
=
computed
(()
=>
{
return
isType
.
value
==
'0'
?
'新增孕中'
:
isType
.
value
==
'1'
?
'切换孕中'
:
isType
.
value
==
'2'
?
'修改备孕'
:
isType
.
value
==
'2'
?
'修改备孕'
:
''
;
})
// 生长曲线和喂养记录
const
babyStatus
=
computed
(()
=>
{
return
isType
.
value
==
'0'
?
'新增宝宝'
:
isType
.
value
==
'1'
?
'切换宝宝'
:
isType
.
value
==
'2'
?
'修改备孕'
:
isType
.
value
==
'2'
?
(
babyInfo
.
value
.
babyStage
==
0
?
'修改备孕'
:
babyInfo
.
value
.
babyStage
==
1
?
'修改孕中'
:
''
)
:
''
;
})
// 跳转新增宝宝状态页面
const
navigateToFn
=
()
=>
{
emit
(
'close'
)
const
type
=
'add'
uni
.
navigateTo
({
url
:
`/pages/person/person?type=
${
type
}
`
...
...
@@ -106,6 +109,7 @@ const switchState = async () => {
}
// 修改状态 需要对应备胎的id 跳转到编辑页面
const
modifyState
=
async
()
=>
{
emit
(
'close'
)
console
.
log
(
'修改状态'
,
babyBaseId
.
value
)
await
userStore
.
changeBabySelected
(
babyBaseId
.
value
);
const
type
=
"edit"
...
...
@@ -143,7 +147,7 @@ onMounted(() => {
// 有宝宝状态
if
(
babyBaseInfo
)
{
// 2 判断宝宝信息是否达到上限 3个
if
(
babyBaseInfo
.
length
=
=
3
)
{
if
(
babyBaseInfo
.
length
>
=
3
)
{
// 产检提醒和喂养记录
if
(
props
.
type
==
'1'
)
{
// 判断有没有宝宝状态切换到宝宝状态
...
...
@@ -154,15 +158,18 @@ onMounted(() => {
// 如果找到符合条件的 baby,取出它的 id 并赋值
babyBaseId
.
value
=
stageOneBaby
.
id
;
}
else
{
// 修改
// 判断没有备孕的状态
if
(
!
babyBaseInfo
.
some
(
baby
=>
baby
.
babyStage
==
0
))
{
isType
.
value
=
'3'
}
else
{
const
stageZeroBaby
=
babyBaseInfo
.
find
(
baby
=>
baby
.
babyStage
==
0
);
babyBaseId
.
value
=
stageZeroBaby
.
id
;
isType
.
value
=
'2'
;
}
console
.
log
(
'没有找到符合条件的 baby'
);
// // 判断没有备孕的状态
// if (!babyBaseInfo.some(baby => baby.babyStage == 0)) {
// isType.value = '3'
// } else {
// const stageZeroBaby = babyBaseInfo.find(baby => baby.babyStage == 0);
// babyBaseId.value = stageZeroBaby.id;
// isType.value = '2';
// }
babyBaseId
.
value
=
babyInfo
.
value
.
content
.
id
;
isType
.
value
=
'2'
;
}
}
// 产检提醒
...
...
@@ -175,7 +182,7 @@ onMounted(() => {
// 如果找到符合条件的 baby,取出它的 id 并赋值
babyBaseId
.
value
=
stageOneBaby
.
id
;
}
else
{
// 修改
// 判断没有备孕的状态
//
//
判断没有备孕的状态
if
(
!
babyBaseInfo
.
some
(
baby
=>
baby
.
babyStage
==
0
))
{
isType
.
value
=
'3'
}
else
{
...
...
@@ -183,6 +190,8 @@ onMounted(() => {
babyBaseId
.
value
=
stageZeroBaby
.
id
;
isType
.
value
=
'2'
;
}
// babyBaseId.value = babyInfo.value.content.id;
// isType.value = '2';
}
}
}
else
{
...
...
@@ -197,14 +206,15 @@ onMounted(() => {
// 如果找到符合条件的 baby,取出它的 id 并赋值
babyBaseId
.
value
=
stageOneBaby
.
id
;
}
else
{
// 修改
// 判断没有备孕的状态
if
(
!
babyBaseInfo
.
some
(
baby
=>
baby
.
babyStage
==
0
))
{
isType
.
value
=
'0'
}
else
{
const
stageZeroBaby
=
babyBaseInfo
.
find
(
baby
=>
baby
.
babyStage
==
0
);
babyBaseId
.
value
=
stageZeroBaby
.
id
;
console
.
log
(
'没有找到符合条件的 baby'
,
babyInfo
.
value
);
// // 判断没有备孕的状态
// if (!babyBaseInfo.some(baby => baby.babyStage == 0)) {
// isType.value = '0'
// } else {
// const stageZeroBaby = babyBaseInfo.find(baby => baby.babyStage == 0);
babyBaseId
.
value
=
babyInfo
.
value
.
content
.
id
;
isType
.
value
=
'2'
;
}
//
}
}
}
...
...
@@ -226,6 +236,8 @@ onMounted(() => {
babyBaseId
.
value
=
stageZeroBaby
.
id
;
isType
.
value
=
'2'
;
}
// babyBaseId.value = babyInfo.value.content.id;
// isType.value = '2';
}
}
}
...
...
pages/postnatalCheckUp/postnatalCheckUp.vue
View file @
b3de8baa
...
...
@@ -114,7 +114,7 @@
</view>
<!-- 提示弹窗 -->
<popup-tip
v-if=
"isTip"
type=
"2"
@
statusChange=
"onBabyChange"
></popup-tip>
<popup-tip
v-if=
"isTip"
type=
"2"
@
statusChange=
"onBabyChange"
@
close=
"isTip = false"
></popup-tip>
<!-- 使用封装后的日期选择器组件 -->
<DatePicker
v-model:visible=
"visible"
:default-date=
"time"
@
confirm=
"handleDateConfirm"
/>
...
...
pages/shengzhangTools/shengzhangTools.vue
View file @
b3de8baa
...
...
@@ -253,7 +253,7 @@
<BabyTestTipsPopup
v-model:visible=
"showBabyTestTipsPopup"
/>
<popup-tip
v-if=
"isTip"
type=
"1"
@
statusChange=
"onBabyChange1"
></popup-tip>
<popup-tip
v-if=
"isTip"
type=
"1"
@
statusChange=
"onBabyChange1"
@
close=
"isTip = false"
></popup-tip>
</
template
>
<
script
setup
>
...
...
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