result.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="result-page">
  3. <EmptyState
  4. v-if="invalid"
  5. icon="📄"
  6. title="缺少支付信息"
  7. desc="无法展示该支付结果,可返回首页或重新操作"
  8. action-text="返回首页"
  9. @action="goHome"
  10. />
  11. <view v-else class="result-card">
  12. <view class="result-icon" :class="status === 'success' ? 'icon-success' : 'icon-fail'">
  13. <text>{{ status === 'success' ? '✓' : '✕' }}</text>
  14. </view>
  15. <text class="result-title">{{ status === 'success' ? '支付成功' : '支付未完成' }}</text>
  16. <text class="result-amount" v-if="amountText">支付金额:¥{{ amountText }}</text>
  17. <text class="result-order" v-if="orderNo">订单号:{{ orderNo }}</text>
  18. <button class="primary-btn" v-if="status === 'success'" @click="goList">查看我的报名</button>
  19. <button class="primary-btn" v-else @click="goPay">重新支付</button>
  20. <button class="ghost-btn" @click="goHome">返回首页</button>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import { fenToYuan } from '@/utils/format.js'
  26. import { guardPage } from '@/utils/guard.js'
  27. import EmptyState from '@/components/empty-state.vue'
  28. export default {
  29. components: { EmptyState },
  30. data() {
  31. return {
  32. status: 'success',
  33. amount: 0,
  34. amountText: '',
  35. orderNo: '',
  36. invalid: false
  37. }
  38. },
  39. onLoad(options) {
  40. if (!guardPage()) return
  41. this.status = options && options.status ? options.status : 'success'
  42. this.amount = options && options.amount ? Number(options.amount) : 0
  43. this.amountText = fenToYuan(this.amount)
  44. this.orderNo = options && options.orderNo ? options.orderNo : ''
  45. // 空态守卫:缺少订单号且金额为 0 时无法确认支付结果
  46. if (!this.orderNo && !this.amount) this.invalid = true
  47. },
  48. methods: {
  49. goList() {
  50. uni.redirectTo({ url: '/pages/enroll/list' })
  51. },
  52. goPay() {
  53. uni.navigateBack({ delta: 1 })
  54. },
  55. goHome() {
  56. uni.switchTab({ url: '/pages/index/index' })
  57. }
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. .result-page { min-height: 100vh; background: #F5FAFE; padding: 32rpx; }
  63. .result-card { background: #FFF; border-radius: 16rpx; padding: 64rpx 32rpx; display: flex; flex-direction: column; align-items: center; }
  64. .result-icon { width: 120rpx; height: 120rpx; border-radius: 50%; color: #FFF; font-size: 72rpx; display: flex; align-items: center; justify-content: center; margin-bottom: 32rpx; }
  65. .icon-success { background: #0E8A4F; }
  66. .icon-fail { background: #C0392B; }
  67. .result-title { font-size: 36rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 16rpx; }
  68. .result-amount { font-size: 28rpx; color: #3B5A78; margin-bottom: 8rpx; }
  69. .result-order { font-size: 24rpx; color: #6B7B8C; margin-bottom: 56rpx; }
  70. .primary-btn { width: 480rpx; height: 84rpx; line-height: 84rpx; background: #2E6FA8; color: #FFF; font-size: 28rpx; font-weight: 600; border-radius: 42rpx; border: none; margin-bottom: 24rpx; }
  71. .primary-btn:active { opacity: 0.85; }
  72. .ghost-btn { width: 480rpx; height: 84rpx; line-height: 84rpx; background: #FFF; color: #3B5A78; font-size: 28rpx; border-radius: 42rpx; border: 2rpx solid #E3ECF4; }
  73. .ghost-btn:active { opacity: 0.7; }
  74. </style>