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
24135ad8
Commit
24135ad8
authored
Aug 20, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
month
parent
cef01ba3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
19 deletions
+42
-19
monthGift.vue
components/pointRightsCom/monthGift.vue
+42
-19
No files found.
components/pointRightsCom/monthGift.vue
View file @
24135ad8
...
...
@@ -22,7 +22,8 @@
</view>
<!-- 精选好券按钮 -->
<view
class=
"coupon-button-container"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('diamond')"
@
click=
"handleCouponClick('diamond')"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('diamond')"
@
click=
"handleCouponClick('diamond')"
>
{{
getCouponButtonText
(
'diamond'
)
}}
</button>
<!-- 调试信息 -->
...
...
@@ -121,7 +122,8 @@
</view>
<!-- 精选好券按钮 -->
<view
class=
"coupon-button-container"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('starshine')"
@
click=
"handleCouponClick('starshine')"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('starshine')"
@
click=
"handleCouponClick('starshine')"
>
{{
getCouponButtonText
(
'starshine'
)
}}
</button>
</view>
...
...
@@ -215,7 +217,8 @@
</view>
<!-- 精选好券按钮 -->
<view
class=
"coupon-button-container"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('starlight')"
@
click=
"handleCouponClick('starlight')"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('starlight')"
@
click=
"handleCouponClick('starlight')"
>
{{
getCouponButtonText
(
'starlight'
)
}}
</button>
</view>
...
...
@@ -393,7 +396,8 @@
</view>
<!-- 精选好券按钮 -->
<view
class=
"coupon-button-container"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('platinum')"
@
click=
"handleCouponClick('platinum')"
>
<button
class=
"coupon-btn"
:class=
"getCouponButtonClass('platinum')"
@
click=
"handleCouponClick('platinum')"
>
{{
getCouponButtonText
(
'platinum'
)
}}
</button>
</view>
...
...
@@ -619,7 +623,7 @@ const handleCouponClick = async (level) => {
})
return
}
try
{
const
result
=
await
monthlyGiftDrawAll
()
console
.
log
(
'Coupon draw result:'
,
result
)
...
...
@@ -771,17 +775,17 @@ const getCouponButtonText = (level) => {
// 获取精选好券按钮样式类
const
getCouponButtonClass
=
(
level
)
=>
{
console
.
warn
(
"getCouponButtonClass level:"
,
level
,
"state.couponStatus:"
,
state
.
couponStatus
)
// 检查用户等级是否符合领取条件
const
levelOrder
=
[
0
,
1
,
2
,
3
,
4
];
// gold, platinum, diamond, starlight, starshine
const
userLevelIndex
=
levelOrder
.
indexOf
(
props
.
userLevel
*
1
)
const
levelIndex
=
levelOrder
.
indexOf
(
LEVEL_MAP
[
props
.
currentLevel
])
// 如果用户等级不够,显示锁定状态
if
(
userLevelIndex
<
levelIndex
)
{
return
'coupon-btn-locked'
}
// 根据当前等级的状态返回对应样式
if
(
state
.
couponStatus
[
level
]
===
'used'
)
{
return
'coupon-btn-purchased-'
+
level
...
...
@@ -915,6 +919,9 @@ const fetchMonthlyGiftData = async () => {
state
.
selectedTimeSlot
=
data
.
currentTimeSlot
}
console
.
warn
(
'next2810Countdown'
,
data
.
next2810Countdown
)
// 处理倒计时逻辑
if
(
data
.
next2810Countdown
!==
undefined
)
{
state
.
next2810Countdown
=
data
.
next2810Countdown
...
...
@@ -935,14 +942,30 @@ const startCountdown = (milliseconds) => {
clearTimeout
(
state
.
countdownTimer
)
}
console
.
warn
(
"milliseconds"
,
milliseconds
)
// 设置倒计时
state
.
countdownTimer
=
setTimeout
(()
=>
{
console
.
log
(
'倒计时结束,1秒后刷新页面'
)
// 延时1秒后刷新页面接口
setTimeout
(()
=>
{
fetchMonthlyGiftData
()
},
1000
)
},
milliseconds
)
// 修正:某些极大值(如 2609485287)会导致 setTimeout 立即执行(超出 32 位有符号整型最大值 2147483647)
// 需要将超出最大安全值的毫秒数限制为 2147483647(约24.8天)
const
MAX_TIMEOUT
=
100000000
let
timeoutMs
=
typeof
milliseconds
===
'number'
&&
milliseconds
>
0
?
milliseconds
:
0
if
(
timeoutMs
>
MAX_TIMEOUT
)
{
console
.
warn
(
'倒计时超出最大安全值,已自动截断为 2147483647 ms'
,
milliseconds
)
timeoutMs
=
MAX_TIMEOUT
}
if
(
timeoutMs
>
0
)
{
state
.
countdownTimer
=
setTimeout
(()
=>
{
console
.
log
(
'倒计时结束,1秒后刷新页面'
)
// 延时1秒后刷新页面接口
// setTimeout(() => {
// fetchMonthlyGiftData()
// }, 1000)
},
timeoutMs
)
}
else
{
console
.
warn
(
'倒计时参数异常,milliseconds:'
,
milliseconds
)
// 可选:立即刷新或忽略
// fetchMonthlyGiftData()
}
}
// 清理定时器
...
...
@@ -955,7 +978,7 @@ onUnmounted(() => {
// 初始化
onMounted
(
async
()
=>
{
console
.
log
(
'MonthGift component mounted, current level:'
,
props
.
currentLevel
,
props
.
userLevel
)
//
await fetchMonthlyGiftData()
await
fetchMonthlyGiftData
()
})
// 调试函数:打印当前状态
...
...
@@ -971,7 +994,7 @@ const debugState = () => {
// 根据 equityCouponList 更新精选好券状态
const
updateCouponStatus
=
(
equityCouponList
)
=>
{
console
.
warn
(
"updateCouponStatus"
,
equityCouponList
,
state
.
couponStatus
)
// 重置所有等级的状态为锁定
Object
.
keys
(
state
.
couponStatus
).
forEach
(
level
=>
{
state
.
couponStatus
[
level
]
=
'locked'
...
...
@@ -1006,7 +1029,7 @@ const updateCouponStatus = (equityCouponList) => {
state
.
couponStatus
[
level
]
=
'used'
})
}
console
.
warn
(
"Updated couponStatus:"
,
state
.
couponStatus
)
}
...
...
@@ -1163,7 +1186,7 @@ watch(() => props.userLevel, (newUserLevel, oldUserLevel) => {
if
(
newUserLevel
!==
oldUserLevel
)
{
console
.
log
(
'newUserLevel'
,
newUserLevel
)
console
.
log
(
'Refreshing data due to userLevel change'
)
//
fetchMonthlyGiftData()
fetchMonthlyGiftData
()
}
},
{
immediate
:
false
})
...
...
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