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
f20cb107
Commit
f20cb107
authored
Jun 11, 2025
by
tao.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复选择器问题
parent
6648ae8f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
48 deletions
+84
-48
PickerCustom.vue
components/PickerCustom.vue
+12
-1
RegisterLayer.vue
components/RegisterLayer.vue
+28
-19
user.js
stores/user.js
+1
-0
index.js
utils/index.js
+43
-28
No files found.
components/PickerCustom.vue
View file @
f20cb107
...
...
@@ -156,6 +156,7 @@ function getDays(selectedYear, selectedMonth) {
if
(
selectedYear
===
futureYear
&&
selectedMonth
===
futureMonth
)
{
endDay
=
futureDay
;
}
const
arr
=
[
"请选择"
];
for
(
let
i
=
startDay
;
i
<=
endDay
;
i
++
)
{
arr
.
push
(
i
);
...
...
@@ -239,7 +240,7 @@ const months = computed(() => {
const
days
=
computed
(()
=>
{
const
[
yearIdx
,
monthIdx
]
=
pickerValue
.
value
;
const
selectedYear
=
years
.
value
[
yearIdx
];
const
selectedMonth
=
months
.
value
[
monthIdx
];
const
selectedMonth
=
months
.
value
[
monthIdx
]
||
1
;
return
getDays
(
selectedYear
,
selectedMonth
);
}
);
...
...
@@ -328,6 +329,16 @@ function onChange(e) {
let
val
=
e
.
detail
.
value
;
console
.
log
(
'onChange'
,
val
);
if
(
props
.
mode
===
"date"
)
{
// 记录上一次的 pickerValue
const
prevValue
=
[...
pickerValue
.
value
];
// 如果年份变化,月份和日都重置为0
if
(
val
[
0
]
!==
prevValue
[
0
])
{
val
[
1
]
=
0
;
val
[
2
]
=
0
;
}
else
if
(
val
[
1
]
!==
prevValue
[
1
])
{
// 如果月份变化,日重置为0
val
[
2
]
=
0
;
}
// 如果天数溢出,自动修正到最大天数
const
maxDay
=
days
.
value
.
length
;
if
(
val
[
2
]
>=
maxDay
)
val
[
2
]
=
maxDay
-
1
;
...
...
components/RegisterLayer.vue
View file @
f20cb107
...
...
@@ -128,8 +128,16 @@
@
click=
"checked.option1 = !checked.option1"
/>
<view
class=
"register-baby-info-hot"
@
click=
"openAgreement"
data-type=
"member"
/>
<view
class=
"register-baby-info-hot2"
@
click=
"openAgreement"
data-type=
"privacy"
/>
<view
class=
"register-baby-info-hot"
@
click=
"openAgreement"
data-type=
"member"
/>
<view
class=
"register-baby-info-hot2"
@
click=
"openAgreement"
data-type=
"privacy"
/>
</view>
<view
class=
"register-baby-info-btn"
...
...
@@ -203,7 +211,7 @@ const fetusOptions = [
];
// date picker
const
dateValue
=
ref
([]);
const
dateValue
=
ref
([]);
const
dateDisplay
=
ref
(
""
);
function
onDateChange
(
val
)
{
dateDisplay
.
value
=
val
;
...
...
@@ -237,7 +245,6 @@ function openAgreement(e) {
}
}
function
onStatusChange
(
v
)
{
status
.
value
=
v
;
return
true
;
...
...
@@ -263,7 +270,7 @@ const handleBabyInfoConfirm = throttleTap(async () => {
if
(
!
isBtnActive
.
value
)
{
return
;
}
console
.
log
(
'handleBabyInfoConfirm'
);
console
.
log
(
"handleBabyInfoConfirm"
);
showLoading
();
...
...
@@ -276,20 +283,22 @@ const handleBabyInfoConfirm = throttleTap(async () => {
req
.
babyGender
=
gender
.
value
;
req
.
babyType
=
fetus
.
value
;
}
const
success
=
await
userStore
.
createBabyInfo
(
req
);
console
.
log
(
'success:'
,
success
);
hideLoading
();
visible
.
value
=
false
;
if
(
success
)
{
emit
(
"confirm"
,
{
date
:
date
.
value
,
gender
:
gender
.
value
,
fetus
:
fetus
.
value
,
status
:
status
.
value
,
});
}
try
{
const
success
=
await
userStore
.
createBabyInfo
(
req
);
console
.
log
(
"success:"
,
success
);
visible
.
value
=
false
;
hideLoading
();
if
(
success
)
{
emit
(
"confirm"
,
{
date
:
date
.
value
,
gender
:
gender
.
value
,
fetus
:
fetus
.
value
,
status
:
status
.
value
,
});
}
}
catch
(
error
)
{
hideLoading
();
}
},
5000
);
function
toggleStatus
(
val
)
{
...
...
stores/user.js
View file @
f20cb107
...
...
@@ -169,6 +169,7 @@ export const useUserStore = defineStore("userInfo", {
},
async
createBabyInfo
(
babyInfo
)
{
console
.
log
(
"createBabyInfo:"
,
babyInfo
);
const
res
=
await
updateBabyInfo
(
babyInfo
);
if
(
res
.
success
)
{
await
this
.
loadBabyInfo
();
...
...
utils/index.js
View file @
f20cb107
// 跳转类型枚举
export
const
JumpType
=
{
INNER
:
1
,
// 内部小程序页面跳转
MINI
:
2
,
// 其他小程序页面跳转
H5
:
3
// https 网络连接跳转
}
INNER
:
1
,
// 内部小程序页面跳转
MINI
:
2
,
// 其他小程序页面跳转
H5
:
3
,
// https 网络连接跳转
}
;
/**
* 通用跳转方法
...
...
@@ -18,43 +18,42 @@ export function jump({ type, url, extra = {} }) {
// 内部小程序页面跳转
uni
.
navigateTo
({
url
,
...
extra
})
...
extra
,
})
;
break
;
case
JumpType
.
MINI
:
// 跳转到其他小程序页面
console
.
log
(
'extra:'
,
url
,
extra
);
console
.
log
(
"extra:"
,
url
,
extra
);
const
jumpParams
=
{
appId
:
extra
.
appId
||
''
,
appId
:
extra
.
appId
||
""
,
path
:
url
,
extraData
:
extra
.
extraData
||
{},
envVersion
:
extra
.
envVersion
||
'trial'
,
envVersion
:
extra
.
envVersion
||
"trial"
,
success
:
extra
.
success
,
fail
:
extra
.
fail
}
fail
:
extra
.
fail
,
}
;
console
.
log
(
'jumpParams:'
,
jumpParams
);
console
.
log
(
"jumpParams:"
,
jumpParams
);
uni
.
navigateToMiniProgram
(
jumpParams
)
uni
.
navigateToMiniProgram
(
jumpParams
)
;
break
;
case
JumpType
.
H5
:
// 跳转到 https 网络链接
if
(
/^https
?
:
\/\/
/
.
test
(
url
))
{
// uni-app 推荐用 webview 页面承载 H5
uni
.
navigateTo
({
url
:
`/pages/webview/webview?url=
${
encodeURIComponent
(
url
)}
`
})
url
:
`/pages/webview/webview?url=
${
encodeURIComponent
(
url
)}
`
,
})
;
}
else
{
console
.
error
(
'H5 跳转地址必须为 https 链接'
)
console
.
error
(
"H5 跳转地址必须为 https 链接"
);
}
break
;
default
:
console
.
error
(
'不支持的跳转类型'
)
console
.
error
(
"不支持的跳转类型"
);
}
}
/**
* 防连点函数
* @param {Function} fn 需要防连点的函数
...
...
@@ -64,34 +63,50 @@ export function jump({ type, url, extra = {} }) {
export
function
throttleTap
(
fn
,
delay
=
1000
)
{
let
timer
=
null
;
let
lastTime
=
0
;
return
function
(...
args
)
{
const
now
=
Date
.
now
();
if
(
now
-
lastTime
<
delay
)
{
// 小于间隔时间,阻止执行
console
.
log
(
'防连点'
)
console
.
log
(
"防连点"
);
return
;
}
lastTime
=
now
;
clearTimeout
(
timer
);
// 立即执行一次
fn
.
apply
(
this
,
args
);
timer
=
setTimeout
(()
=>
{
lastTime
=
0
;
// 重置时间
},
delay
);
}
}
;
}
let
loadingCount
=
0
;
let
loadingTimer
=
null
;
export
function
showLoading
()
{
uni
.
showLoading
({
title
:
'加载中'
,
mask
:
true
,
});
if
(
loadingCount
==
0
)
{
uni
.
showLoading
({
title
:
"加载中"
,
mask
:
true
,
});
loadingTimer
=
setTimeout
(()
=>
{
uni
.
hideLoading
();
},
10000
);
}
loadingCount
++
;
}
export
function
hideLoading
()
{
uni
.
hideLoading
();
if
(
loadingCount
<=
0
)
return
;
loadingCount
--
;
if
(
loadingCount
==
0
)
{
loadingTimer
&&
clearTimeout
(
loadingTimer
);
uni
.
hideLoading
();
}
}
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