refactor(CheckoutPage): 将微信支付组件移至弹窗中并调整支付失败处理
将微信支付组件从页面主体移至弹窗中,提升用户体验。调整支付失败处理逻辑,不再自动关闭支付弹窗,以便用户重新尝试支付。
Showing
1 changed file
with
40 additions
and
26 deletions
| ... | @@ -16,32 +16,8 @@ | ... | @@ -16,32 +16,8 @@ |
| 16 | </FrostedGlass> | 16 | </FrostedGlass> |
| 17 | </div> | 17 | </div> |
| 18 | 18 | ||
| 19 | - <WechatPayment | ||
| 20 | - v-else-if="showPayment" | ||
| 21 | - :order-id="orderId" | ||
| 22 | - @success="handlePaymentSuccess" | ||
| 23 | - @failed="handlePaymentFailed" | ||
| 24 | - @processing="handlePaymentProcessing" | ||
| 25 | - > | ||
| 26 | - <template #success-action> | ||
| 27 | - <button | ||
| 28 | - @click="handleBackToHome" | ||
| 29 | - class="w-full bg-gradient-to-r from-green-500 to-green-600 text-white py-3 rounded-xl font-medium" | ||
| 30 | - > | ||
| 31 | - 返回首页 | ||
| 32 | - </button> | ||
| 33 | - </template> | ||
| 34 | - <template #failed-action> | ||
| 35 | - <button | ||
| 36 | - @click="handleBackToHome" | ||
| 37 | - class="w-full bg-gray-100 text-gray-700 py-3 sm:py-3.5 rounded-xl font-medium text-base sm:text-lg hover:bg-gray-200 transition-colors" | ||
| 38 | - > | ||
| 39 | - 返回首页 | ||
| 40 | - </button> | ||
| 41 | - </template> | ||
| 42 | - </WechatPayment> | ||
| 43 | 19 | ||
| 44 | - <div v-else class="pb-20"> | 20 | + <div v-else-if="!orderComplete" class="pb-20"> |
| 45 | <!-- Order Summary --> | 21 | <!-- Order Summary --> |
| 46 | <div class="p-4 bg-gradient-to-r from-green-500/10 to-blue-500/10"> | 22 | <div class="p-4 bg-gradient-to-r from-green-500/10 to-blue-500/10"> |
| 47 | <FrostedGlass class="rounded-xl p-4"> | 23 | <FrostedGlass class="rounded-xl p-4"> |
| ... | @@ -270,6 +246,44 @@ | ... | @@ -270,6 +246,44 @@ |
| 270 | }" | 246 | }" |
| 271 | @cancel="itemToDelete = null" | 247 | @cancel="itemToDelete = null" |
| 272 | /> | 248 | /> |
| 249 | + | ||
| 250 | + | ||
| 251 | + <!-- 支付弹窗 --> | ||
| 252 | + <van-popup | ||
| 253 | + v-model:show="showPayment" | ||
| 254 | + position="bottom" | ||
| 255 | + round | ||
| 256 | + closeable | ||
| 257 | + close-icon-position="top-right" | ||
| 258 | + :style="{ height: '90%' }" | ||
| 259 | + > | ||
| 260 | + <div class="bg-gradient-to-r from-green-500/10 to-blue-500/10 h-full"> | ||
| 261 | + <WechatPayment | ||
| 262 | + v-if="showPayment && orderId" | ||
| 263 | + :order-id="orderId" | ||
| 264 | + @success="handlePaymentSuccess" | ||
| 265 | + @failed="handlePaymentFailed" | ||
| 266 | + @processing="handlePaymentProcessing" | ||
| 267 | + > | ||
| 268 | + <template #success-action> | ||
| 269 | + <button | ||
| 270 | + @click="handleBackToHome" | ||
| 271 | + class="w-full bg-gradient-to-r from-green-500 to-green-600 text-white py-3 rounded-xl font-medium" | ||
| 272 | + > | ||
| 273 | + 返回首页 | ||
| 274 | + </button> | ||
| 275 | + </template> | ||
| 276 | + <template #failed-action> | ||
| 277 | + <button | ||
| 278 | + @click="handleBackToHome" | ||
| 279 | + class="w-full bg-gray-100 text-gray-700 py-3 sm:py-3.5 rounded-xl font-medium text-base sm:text-lg hover:bg-gray-200 transition-colors" | ||
| 280 | + > | ||
| 281 | + 返回首页 | ||
| 282 | + </button> | ||
| 283 | + </template> | ||
| 284 | + </WechatPayment> | ||
| 285 | + </div> | ||
| 286 | + </van-popup> | ||
| 273 | </AppLayout> | 287 | </AppLayout> |
| 274 | </template> | 288 | </template> |
| 275 | 289 | ||
| ... | @@ -367,7 +381,7 @@ const handlePaymentSuccess = () => { | ... | @@ -367,7 +381,7 @@ const handlePaymentSuccess = () => { |
| 367 | // 处理支付失败 | 381 | // 处理支付失败 |
| 368 | const handlePaymentFailed = (error) => { | 382 | const handlePaymentFailed = (error) => { |
| 369 | console.error('支付失败:', error) | 383 | console.error('支付失败:', error) |
| 370 | - showPayment.value = false | 384 | + // showPayment.value = false |
| 371 | } | 385 | } |
| 372 | 386 | ||
| 373 | // 处理支付处理中 | 387 | // 处理支付处理中 | ... | ... |
-
Please register or login to post a comment