diff --git a/src/router/index.js b/src/router/index.js index b8e94f2..1fd9595 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -250,6 +250,12 @@ const routes = [ component: () => import('../views/Pay.vue'), meta: { title: '确认支付' } }, + { + path: '/payfailed', + name: 'PayFailed', + component: () => import('../views/PayFailed.vue'), + meta: { title: '确认支付' } + }, { path: '/:pathMatch(.*)*', name: 'NotFound', diff --git a/src/views/Pay.vue b/src/views/Pay.vue index 52de885..91d8f80 100644 --- a/src/views/Pay.vue +++ b/src/views/Pay.vue @@ -5,7 +5,7 @@ @@ -194,8 +195,17 @@ const fetchPaymentData = async () => { const cartId = route.query.cartId if (!cartId) { - ElMessage.error('缺少购物车信息') - router.go(-1) + // 允许直接访问,使用默认数据 + ElMessage.warning('未指定购物车信息,使用默认支付数据') + paymentData.value = { + totalAmount: 0, + pointsAmount: 0, + beansAmount: 0, + cartId: null + } + timeLeft.value = 900 // 默认15分钟 + startCountdown() + loading.value = false return } @@ -227,6 +237,30 @@ const fetchPaymentData = async () => { } } +const handleGoBack = async () => { + // 如果倒计时还在进行中,显示确认弹窗 + if (timeLeft.value > 0) { + try { + await ElMessageBox.confirm( + '确认要放弃付款吗?', + '提示', + { + confirmButtonText: '狠心离开', + cancelButtonText: '继续付款', + type: 'warning' + } + ) + // 用户确认放弃付款,跳转到PayFailed页面 + router.push('/payfailed') + } catch { + // 用户取消,什么都不做,留在当前页面 + } + } else { + // 倒计时已结束,直接返回 + router.go(-1) + } +} + const confirmPayment = async () => { if (timeLeft.value <= 0) { ElMessage.error('支付超时,请重新下单') @@ -308,6 +342,20 @@ onUnmounted(() => { padding: 12px 16px; background: white; border-bottom: 1px solid #eee; + position: relative; +} + +.nav-left, +.nav-right { + width: 48px; + display: flex; + justify-content: center; +} + +.nav-center { + position: absolute; + left: 50%; + transform: translateX(-50%); } .nav-title { diff --git a/src/views/PayFailed.vue b/src/views/PayFailed.vue new file mode 100644 index 0000000..74dd022 --- /dev/null +++ b/src/views/PayFailed.vue @@ -0,0 +1,509 @@ + + + + + \ No newline at end of file diff --git a/src/views/Transfers.vue b/src/views/Transfers.vue index d663793..bd8573e 100644 --- a/src/views/Transfers.vue +++ b/src/views/Transfers.vue @@ -114,7 +114,6 @@ @click="statusFilter = ''" > 全部 -
待确认 -
已确认 -
-
已拒绝 -
已收款 - +
+
+ 已取消