巴青农资商城

pay-result.vue 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="pay-result">
  3. <u-icon
  4. :name="isSuccess ? 'checkmark-circle-fill' : 'close-circle-fill'"
  5. :color="isSuccess ? '#2e7d32' : '#999'"
  6. size="80"
  7. />
  8. <text class="pay-result__title">{{ title }}</text>
  9. <text v-if="orderNo" class="pay-result__sub">订单号:{{ orderNo }}</text>
  10. <text class="pay-result__tip">{{ tip }}</text>
  11. <button v-if="isSuccess" class="pay-result__btn" @click="goHome">返回首页</button>
  12. <button v-else class="pay-result__btn" @click="goBackDetail">返回继续购买</button>
  13. </view>
  14. </template>
  15. <script setup>
  16. import { ref, computed } from 'vue'
  17. import { onLoad } from '@dcloudio/uni-app'
  18. import { getOrderDetail } from '@/api/order'
  19. import { PAGE_HOME } from '@/utils/pageRoute'
  20. const status = ref('')
  21. const orderId = ref('')
  22. const orderNo = ref('')
  23. const isSuccess = computed(() => status.value === 'success')
  24. const title = computed(() => (isSuccess.value ? '支付成功' : '订单已关闭'))
  25. const tip = computed(() =>
  26. isSuccess.value
  27. ? '商家将尽快为您发货'
  28. : '您已取消支付,可返回商品详情重新购买'
  29. )
  30. function goHome() {
  31. uni.switchTab({ url: PAGE_HOME })
  32. }
  33. function goBackDetail() {
  34. uni.navigateBack({ delta: 2 })
  35. }
  36. onLoad(async (options) => {
  37. status.value = options.status || ''
  38. orderId.value = options.orderId || ''
  39. if (orderId.value) {
  40. try {
  41. const res = await getOrderDetail(orderId.value)
  42. orderNo.value = (res.data && res.data.orderNo) || ''
  43. } catch (e) {
  44. // ignore
  45. }
  46. }
  47. })
  48. </script>
  49. <style lang="scss" scoped>
  50. .pay-result {
  51. min-height: 100vh;
  52. padding: 120rpx 48rpx;
  53. display: flex;
  54. flex-direction: column;
  55. align-items: center;
  56. background: #f5f6f8;
  57. }
  58. .pay-result__title {
  59. margin-top: 32rpx;
  60. font-size: 36rpx;
  61. font-weight: 600;
  62. color: #333;
  63. }
  64. .pay-result__sub {
  65. margin-top: 16rpx;
  66. font-size: 26rpx;
  67. color: #666;
  68. }
  69. .pay-result__tip {
  70. margin-top: 24rpx;
  71. font-size: 26rpx;
  72. color: #999;
  73. text-align: center;
  74. line-height: 1.6;
  75. }
  76. .pay-result__btn {
  77. margin-top: 64rpx;
  78. width: 320rpx;
  79. height: 80rpx;
  80. line-height: 80rpx;
  81. background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%);
  82. color: #fff;
  83. font-size: 28rpx;
  84. border-radius: 40rpx;
  85. border: none;
  86. }
  87. </style>