|
|
@@ -36,6 +36,7 @@ const openRedEnvelopeRate = ref<any>()
|
|
|
const joinRedEnvelopeRate = ref<any>()
|
|
|
const countdown = ref('00:00')
|
|
|
const timer = ref()
|
|
|
+const hasCountdownEnded = ref(false) // 标记倒计时是否已结束并查询过
|
|
|
|
|
|
// DialogBox 函数式调用配置
|
|
|
const dialogConfig = ref<any>({})
|
|
|
@@ -83,6 +84,9 @@ function startCountdown() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // 重置倒计时结束标记
|
|
|
+ hasCountdownEnded.value = false
|
|
|
+
|
|
|
// 计算过期时间(创建时间 + 20分钟)
|
|
|
const createTime = new Date(detail.value.createTime).getTime()
|
|
|
const expireTime = createTime + 20 * 60 * 1000
|
|
|
@@ -94,7 +98,11 @@ function startCountdown() {
|
|
|
if (diff <= 0) {
|
|
|
clearInterval(timer.value)
|
|
|
countdown.value = '00:00'
|
|
|
- getDetail() // 刷新订单状态
|
|
|
+ // 只在第一次倒计时结束时查询一次
|
|
|
+ if (!hasCountdownEnded.value) {
|
|
|
+ hasCountdownEnded.value = true
|
|
|
+ getDetail() // 刷新订单状态
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -104,6 +112,13 @@ function startCountdown() {
|
|
|
}, 1000)
|
|
|
}
|
|
|
|
|
|
+// 用户主动刷新时调用此函数
|
|
|
+async function handleRefresh() {
|
|
|
+ // 重置倒计时结束标记,允许重新查询
|
|
|
+ hasCountdownEnded.value = false
|
|
|
+ await getDetail()
|
|
|
+}
|
|
|
+
|
|
|
async function getDetail() {
|
|
|
try {
|
|
|
isPageLoading.value = true
|
|
|
@@ -117,12 +132,19 @@ async function getDetail() {
|
|
|
id.value = detail.value.orderId
|
|
|
}
|
|
|
if (detail.value?.status === 1) {
|
|
|
- startCountdown() // 开始倒计时
|
|
|
+ // 只有在倒计时未结束时才启动倒计时,防止倒计时结束后重复查询
|
|
|
+ if (!hasCountdownEnded.value) {
|
|
|
+ startCountdown() // 开始倒计时
|
|
|
+ }
|
|
|
// if (isPayOrder.value) {
|
|
|
// // 自动调用支付接口
|
|
|
// await goPay()
|
|
|
// }
|
|
|
}
|
|
|
+ else {
|
|
|
+ // 状态已变化,重置标记
|
|
|
+ hasCountdownEnded.value = false
|
|
|
+ }
|
|
|
await getPink()
|
|
|
paging.value.complete()
|
|
|
}
|
|
|
@@ -297,6 +319,8 @@ onLoad(async (options) => {
|
|
|
})
|
|
|
const balance = ref<number>(0)
|
|
|
onShow(async () => {
|
|
|
+ // 重置倒计时结束标记,允许重新查询
|
|
|
+ hasCountdownEnded.value = false
|
|
|
await getDetail()
|
|
|
if (isPayOrder.value && detail.value?.status === 1) {
|
|
|
const res = await getWalletAccountInfo()
|
|
|
@@ -320,7 +344,7 @@ onUnmounted(() => {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <z-paging ref="paging" refresher-only @refresh="getDetail">
|
|
|
+ <z-paging ref="paging" refresher-only @refresh="handleRefresh">
|
|
|
<!-- 页面加载时显示骨架屏 -->
|
|
|
<template v-if="isPageLoading">
|
|
|
<view class="pt-20rpx">
|