This commit is contained in:
2025-12-25 12:40:42 +08:00
parent 46b6170c41
commit b6f1d71ee6
2 changed files with 170 additions and 3 deletions

View File

@@ -406,6 +406,8 @@ const reportPaymentDialogVisible = ref(false)
const reportPaymentStatus = ref('pending')
const currentReportOrderId = ref('')
const checkingPaymentStatus = ref(false)
const isCheckingWechatPayment = ref(false)
let wechatOrderPollTimer = null
// DOM 引用
const basicInfoRef = ref(null)
@@ -462,6 +464,9 @@ onUnmounted(() => {
window.paymentCheckIntervals = {}
}
// 清理微信支付轮询定时器
stopWechatPaymentPolling()
// 关闭所有消息框
ElMessageBox.close()
@@ -470,6 +475,29 @@ onUnmounted(() => {
loadingInstance.close()
})
// 重置支付状态检查
const resetPaymentStatusCheck = () => {
// 停止所有定时器
if (window.paymentCheckIntervals) {
Object.keys(window.paymentCheckIntervals).forEach(orderId => {
clearInterval(window.paymentCheckIntervals[orderId])
})
window.paymentCheckIntervals = {}
}
// 停止微信支付轮询
stopWechatPaymentPolling()
// 重置状态
isCheckingWechatPayment.value = false
checkingPaymentStatus.value = false
// 关闭所有加载和消息框
ElMessageBox.close()
const loadingInstance = ElLoading.service()
loadingInstance.close()
}
// 时间戳更新定时器
const timestampTimer = ref(null)
@@ -1251,6 +1279,9 @@ const showWechatPaymentQRCode = (codeUrl, orderId) => {
console.log('[showWechatPaymentQRCode] 准备显示二维码URL:', codeUrl)
// 保存当前订单号用于轮询
currentReportOrderId.value = orderId
// 使用第三方二维码生成服务将微信支付URL转换为二维码图片
const qrCodeImageUrl = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(codeUrl)}`
@@ -1323,8 +1354,8 @@ const showWechatPaymentQRCode = (codeUrl, orderId) => {
// 对话框被关闭(通过取消按钮或其他方式)
})
// 不立即开始检查支付状态,等待用户确认支付后再开始
// 这样可以避免过早开始状态检查导致用户体验不佳
// 开始轮询微信支付状态
startWechatPaymentPolling(orderId)
}
// 开始检查支付状态
@@ -1492,6 +1523,13 @@ const checkPaymentStatusManually = async () => {
// 自动下载
downloadComponentReport()
// 停止所有定时器
if (window.paymentCheckIntervals) {
Object.keys(window.paymentCheckIntervals).forEach(orderId => {
clearInterval(window.paymentCheckIntervals[orderId])
})
window.paymentCheckIntervals = {}
}
} else if (payment_status === 'failed') {
// 支付失败
ElMessage.error('支付失败,请重试')