|
@@ -10,11 +10,11 @@
|
|
indeterminate
|
|
indeterminate
|
|
></v-progress-linear>
|
|
></v-progress-linear>
|
|
</template>
|
|
</template>
|
|
- <div>{{ countdown }}</div>
|
|
|
|
<div style="color: var(--v-error-base); font-weight: bold; text-align: center;">
|
|
<div style="color: var(--v-error-base); font-weight: bold; text-align: center;">
|
|
<span class="font-size-13 mr-2">¥</span>
|
|
<span class="font-size-13 mr-2">¥</span>
|
|
<span class="font-size-40"> {{ orderInfo?.price ? orderInfo?.price / 100 : 0 }}</span>
|
|
<span class="font-size-40"> {{ orderInfo?.price ? orderInfo?.price / 100 : 0 }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div style="text-align: center; color: #bbbbbb;" class="mb-2 mt-1">{{ countdownText }}</div>
|
|
<template v-if="payMethods?.length">
|
|
<template v-if="payMethods?.length">
|
|
<v-chip-group v-model="payment" selected-class="text-primary" column mandatory @update:modelValue="payTypeChange">
|
|
<v-chip-group v-model="payment" selected-class="text-primary" column mandatory @update:modelValue="payTypeChange">
|
|
<v-chip filter v-for="k in payMethods" :key="k.code" :value="k.code" class="mr-3" label>
|
|
<v-chip filter v-for="k in payMethods" :key="k.code" :value="k.code" class="mr-3" label>
|
|
@@ -132,7 +132,7 @@ const notEnoughMoney = computed(() => {
|
|
const Destroyed = ref(false)
|
|
const Destroyed = ref(false)
|
|
onBeforeUnmount(() => {
|
|
onBeforeUnmount(() => {
|
|
Destroyed.value = true // 避免执行paySubmit中关闭支付弹窗,造成setInterval一直存在
|
|
Destroyed.value = true // 避免执行paySubmit中关闭支付弹窗,造成setInterval一直存在
|
|
- clear()
|
|
|
|
|
|
+ clearIntervalList()
|
|
})
|
|
})
|
|
|
|
|
|
// 提交支付订单 (提交后倒计时显示及支付状态轮巡)
|
|
// 提交支付订单 (提交后倒计时显示及支付状态轮巡)
|
|
@@ -182,7 +182,7 @@ const checkPayStatus = () => {
|
|
const countdownInterval = ref(null)
|
|
const countdownInterval = ref(null)
|
|
const countdownIntervalInit = () => {
|
|
const countdownIntervalInit = () => {
|
|
countdownInterval.value = setInterval(() => {
|
|
countdownInterval.value = setInterval(() => {
|
|
- countdown.value
|
|
|
|
|
|
+ countdown()
|
|
}, 1000)
|
|
}, 1000)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -215,9 +215,7 @@ const setOrder = async () => {
|
|
setOrder()
|
|
setOrder()
|
|
|
|
|
|
// 清空setInterval
|
|
// 清空setInterval
|
|
-function clear() {
|
|
|
|
- remainder.value = 1
|
|
|
|
- payQrCodeTxt.value = '' // 二维码内容
|
|
|
|
|
|
+function clearIntervalList() {
|
|
if (countdownInterval.value) clearInterval(countdownInterval.value); countdownInterval.value = null
|
|
if (countdownInterval.value) clearInterval(countdownInterval.value); countdownInterval.value = null
|
|
if (timer.value) clearInterval(timer.value); timer.value = null
|
|
if (timer.value) clearInterval(timer.value); timer.value = null
|
|
if (remainderTimer.value) clearInterval(remainderTimer.value); remainderTimer.value = null
|
|
if (remainderTimer.value) clearInterval(remainderTimer.value); remainderTimer.value = null
|
|
@@ -232,7 +230,10 @@ const payTypeChange = (value) => {
|
|
isQrCodePay.value = qrCodePay.includes(payment.value)
|
|
isQrCodePay.value = qrCodePay.includes(payment.value)
|
|
isWalletPay.value = walletPay.includes(payment.value)
|
|
isWalletPay.value = walletPay.includes(payment.value)
|
|
if (isQrCodePay.value) submitOrderFun() // 二维码支付时自动创建订单获取二维码内容展示
|
|
if (isQrCodePay.value) submitOrderFun() // 二维码支付时自动创建订单获取二维码内容展示
|
|
- else { clear() }
|
|
|
|
|
|
+ else {
|
|
|
|
+ remainder.value = 1
|
|
|
|
+ payQrCodeTxt.value = '' // 二维码内容
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// 1.支付方式
|
|
// 1.支付方式
|
|
const setPayMethods = async () => {
|
|
const setPayMethods = async () => {
|
|
@@ -273,12 +274,12 @@ import Snackbar from '@/plugins/snackbar'
|
|
import { useRoute } from 'vue-router'; const route = useRoute()
|
|
import { useRoute } from 'vue-router'; const route = useRoute()
|
|
import { useRouter } from 'vue-router'; const router = useRouter()
|
|
import { useRouter } from 'vue-router'; const router = useRouter()
|
|
const getPayStatus = async () => {
|
|
const getPayStatus = async () => {
|
|
- if (Destroyed.value) return clear() // 用户关闭支付
|
|
|
|
|
|
+ if (Destroyed.value) return clearIntervalList() // 用户关闭支付
|
|
try {
|
|
try {
|
|
const data = await getOrderPayStatus({ id: orderInfo.value.id || orderInfo.value.payOrderId })
|
|
const data = await getOrderPayStatus({ id: orderInfo.value.id || orderInfo.value.payOrderId })
|
|
if ((data?.status - 0) === 10) {
|
|
if ((data?.status - 0) === 10) {
|
|
// 支付成功
|
|
// 支付成功
|
|
- clear()
|
|
|
|
|
|
+ clearIntervalList()
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
emit('paySuccess', { price: orderInfo.value.price })
|
|
emit('paySuccess', { price: orderInfo.value.price })
|
|
if (isWalletPay.value) updateAccountInfo() // 更新余额
|
|
if (isWalletPay.value) updateAccountInfo() // 更新余额
|
|
@@ -310,7 +311,7 @@ const initIntervalFun = async () => {
|
|
}
|
|
}
|
|
|
|
|
|
const remainderCalc = () => {
|
|
const remainderCalc = () => {
|
|
- if (Destroyed.value) return clear() // 用户关闭支付
|
|
|
|
|
|
+ if (Destroyed.value) return clearIntervalList() // 用户关闭支付
|
|
remainder.value -= 1000
|
|
remainder.value -= 1000
|
|
remainderZhShow.value = formatDuration(remainder.value)
|
|
remainderZhShow.value = formatDuration(remainder.value)
|
|
if (remainder.value <= 0) { // 倒计时结束
|
|
if (remainder.value <= 0) { // 倒计时结束
|
|
@@ -334,14 +335,14 @@ const formatDuration = (remainder) => {
|
|
}
|
|
}
|
|
|
|
|
|
// 支付倒计时文案提示
|
|
// 支付倒计时文案提示
|
|
-const countdown = computed(() => {
|
|
|
|
|
|
+const countdownText = ref('')
|
|
|
|
+const countdown = () => {
|
|
const now = Date.now();
|
|
const now = Date.now();
|
|
const distance = orderInfo.value.expireTime - now
|
|
const distance = orderInfo.value.expireTime - now
|
|
|
|
|
|
if (distance < 0) {
|
|
if (distance < 0) {
|
|
- clearInterval(countdownInterval.value)
|
|
|
|
- router.go(0)
|
|
|
|
- return '已过期'
|
|
|
|
|
|
+ if (countdownInterval.value) clearInterval(countdownInterval.value); countdownInterval.value = null
|
|
|
|
+ return '支付已过期'
|
|
}
|
|
}
|
|
|
|
|
|
const seconds = Math.floor((distance / 1000) % 60)
|
|
const seconds = Math.floor((distance / 1000) % 60)
|
|
@@ -349,8 +350,8 @@ const countdown = computed(() => {
|
|
const hours = Math.floor((distance / (1000 * 60 * 60)) % 24)
|
|
const hours = Math.floor((distance / (1000 * 60 * 60)) % 24)
|
|
// const days = Math.floor(distance / (1000 * 60 * 60 * 24))
|
|
// const days = Math.floor(distance / (1000 * 60 * 60 * 24))
|
|
|
|
|
|
- return '剩余支付时间: ' + hours + ':' + minutes + ':' + seconds
|
|
|
|
-});
|
|
|
|
|
|
+ countdownText.value = '剩余支付时间: ' + hours + ':' + minutes + ':' + seconds
|
|
|
|
+}
|
|
|
|
|
|
const open = () => {
|
|
const open = () => {
|
|
window.open('/personalRecharge')
|
|
window.open('/personalRecharge')
|