Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jz_Travel
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengke
jz_Travel
Commits
81ef6974
Commit
81ef6974
authored
May 12, 2025
by
youjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付倒计时
parent
b6a59fea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
4 deletions
+103
-4
AggregateOrdersList.vue
pages/AggregateOrders/AggregateOrdersList.vue
+3
-0
orders.vue
pages/AggregateOrders/components/orders.vue
+100
-4
No files found.
pages/AggregateOrders/AggregateOrdersList.vue
View file @
81ef6974
...
...
@@ -186,6 +186,9 @@
// #endif
x
.
orderStatusInfo
=
EnumHelper
.
ParseToEnum
(
OrderStatusEnum
,
x
.
orderStatus
,
'value'
)
x
.
orderTime
=
null
x
.
remainingSeconds
=
null
x
.
isExpired
=
false
})
this
.
g
=
this
.
g
.
concat
(
res
.
data
.
pageData
);
...
...
pages/AggregateOrders/components/orders.vue
View file @
81ef6974
...
...
@@ -47,6 +47,9 @@
<!-- #endif -->
<view
class=
"row"
>
<!-- #ifdef MP-DI -->
<view
v-if=
"item.remainingSeconds"
style=
"line-height: 60rpx;color: #B99846;"
>
剩余:{{ formatTime(item.remainingSeconds) }}
</view>
<
template
v-if=
"item.goodsType==9"
>
<view
v-if=
"item.orderStatus==1||item.orderStatus==2"
class=
"jz_Zailai"
style=
"width: 110rpx;margin-left: 10rpx;"
@
click
.
stop=
"cancelHotelOrder(item)"
>
取消
...
...
@@ -58,18 +61,24 @@
</
template
>
<view
v-if=
"item.orderStatus==1"
class=
"jz_Zailai jz_ZailaiZF"
style=
"width: 150rpx;margin-left: 10rpx;"
@
click
.
stop=
"submitGetCodeByOrderNo(item)"
>
立即支付
</view>
立即支付
</view>
<view
v-if=
"item.orderStatus!=1"
style=
"margin-left: 10rpx;"
class=
"jz_Zailai"
@
click
.
stop=
"AnotherOrder(item)"
>
再来一单
</view>
<!-- #endif -->
<!-- #ifdef MP-AG -->
<view
v-if=
"item.remainingSeconds"
style=
"line-height: 60rpx;color: #B99846;"
>
剩余:{{ formatTime(item.remainingSeconds) }}
</view>
<view
v-if=
"item.goodsType==7&&(item.orderStatus==1||item.orderStatus==2)"
class=
"jz_Zailai"
style=
"width: 110rpx;margin-left: 10rpx;"
@
click
.
stop=
"cancelHotelOrder(item)"
>
取消
</view>
<view
v-if=
"item.goodsType!=7&&item.income == 0&&item.orderStatus==1"
class=
"jz_Zailai"
style=
"width: 110rpx;margin-left: 10rpx;"
@
click
.
stop=
"goCancel(item)"
>
取消
</view>
<view
v-if=
"item.goodsType==7&&item.orderStatus==1"
class=
"jz_Zailai jz_ZailaiZF"
style=
"width: 150rpx;margin-left: 10rpx;"
@
click
.
stop=
"submitGetCodeByOrderNo(item)"
>
立即支付
</view>
立即支付
</view>
<view
v-else
class=
"jz_Zailai"
style=
"margin-left: 10rpx;"
@
click
.
stop=
"AnotherOrder(item)"
>
再来一单
</view>
<!-- #endif -->
...
...
@@ -103,21 +112,108 @@
currentData
:
null
,
b2b_user
:
null
,
CancelPolicy
:
null
,
timers
:
{},
// 存储定时器对象
checkInterval
:
null
// 全局检查间隔
}
},
watch
:
{
orders
:
{
handler
(
newVal
,
oldVal
)
{
this
.
g
=
newVal
this
.
g
=
JSON
.
parse
(
JSON
.
stringify
(
newVal
))
this
.
g
.
forEach
(
x
=>
{
let
goodsTypeHotel
=
0
// #ifdef MP-DI
goodsTypeHotel
=
x
.
goodsType
==
9
?
1
:
0
// #endif
// #ifdef MP-AG
goodsTypeHotel
=
x
.
goodsType
==
7
?
1
:
0
// #endif
if
(
x
.
orderStatus
==
1
&&
goodsTypeHotel
>
0
)
{
const
now
=
Date
.
now
();
// const customStr = '2025-05-12 14:43:00'
const
customStr
=
x
.
createTimeStr
const
[
date
,
time
]
=
customStr
.
split
(
' '
)
const
[
year
,
month
,
day
]
=
date
.
split
(
'-'
)
const
[
hours
,
minutes
,
seconds
]
=
time
.
split
(
':'
)
const
parsedDate
=
new
Date
(
year
,
month
-
1
,
day
,
hours
,
minutes
,
seconds
)
x
.
orderTime
=
parsedDate
.
getTime
()
const
diff
=
x
.
orderTime
+
5
*
60
*
1000
-
now
;
// 5分钟倒计时
let
remainingSeconds
=
Math
.
max
(
diff
,
0
);
// 确保不出现负数
x
.
remainingSeconds
=
Math
.
floor
(
remainingSeconds
/
1000
)
console
.
log
(
"=========3333"
,
x
.
remainingSeconds
)
if
(
x
.
remainingSeconds
)
this
.
initCountdown
(
x
)
}
});
},
deep
:
true
,
}
},
beforeDestroy
()
{
// 清除所有定时器
Object
.
values
(
this
.
timers
).
forEach
(
timer
=>
clearInterval
(
timer
))
clearInterval
(
this
.
checkInterval
)
},
mounted
()
{
// clearInterval(null)
this
.
b2b_user
=
uni
.
getStorageSync
(
"b2b_user"
)
console
.
log
(
this
.
b2b_user
,
'=======b2b_user'
)
// 全局定时检查(防止极端情况下定时器失效)
this
.
checkInterval
=
setInterval
(()
=>
{
this
.
checkExpiredOrders
()
},
60000
)
// 每分钟检查一次
},
methods
:
{
// 时间格式化
formatTime
(
seconds
)
{
const
mins
=
Math
.
floor
(
seconds
/
60
)
const
secs
=
seconds
%
60
return
`
${
mins
.
toString
().
padStart
(
2
,
'0'
)}
:
${
secs
.
toString
().
padStart
(
2
,
'0'
)}
`
},
initCountdown
(
order
)
{
// return
const
timer
=
setInterval
(()
=>
{
if
(
order
.
remainingSeconds
>
0
){
order
.
remainingSeconds
--
}
else
{
this
.
submitCancel
=
true
let
cancelMsg
=
{
OrderNo
:
order
.
OrderNo
,
ErpOrderId
:
order
.
erpOrderId
,
OrderTypeStr
:
"Hotel"
,
//订单类型为酒店
ConfirmID
:
""
,
Amount
:
0
,
};
this
.
cancelOrder
(
cancelMsg
)
clearInterval
(
null
)
this
.
timers
[
order
.
erpOrderId
]
=
null
}
},
1000
)
this
.
timers
[
order
.
erpOrderId
]
=
timer
},
// 检查过期订单
checkExpiredOrders
()
{
const
now
=
Date
.
now
()
this
.
g
.
forEach
(
order
=>
{
let
goodsTypeHotel
=
0
// #ifdef MP-DI
goodsTypeHotel
=
order
.
goodsType
==
9
?
1
:
0
// #endif
// #ifdef MP-AG
goodsTypeHotel
=
order
.
goodsType
==
7
?
1
:
0
// #endif
if
(
order
.
orderStatus
===
1
&&
goodsTypeHotel
>
0
&&
now
-
order
.
orderTime
>
300000
)
{
// 5分钟超时
this
.
submitCancel
=
true
let
cancelMsg
=
{
OrderNo
:
order
.
OrderNo
,
ErpOrderId
:
order
.
erpOrderId
,
OrderTypeStr
:
"Hotel"
,
//订单类型为酒店
ConfirmID
:
""
,
Amount
:
0
,
};
this
.
cancelOrder
(
cancelMsg
)
}
})
},
cancelSuccess
()
{
this
.
$emit
(
'research'
,
5
)
},
...
...
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