index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="content">
  3. <view class="status-icon-wrap">
  4. <image v-if="!loading" :src="getFileUrl('img/icon/success.png')" mode="widthFix" class="status-img"></image>
  5. <view v-else class="loading-dot"></view>
  6. </view>
  7. <view class="status-title">{{ loading ? '支付中' : '支付成功' }}</view>
  8. <view class="status-desc">{{ loading ? '正在确认支付结果,请稍候...' : '感谢您的用餐' }}</view>
  9. <view v-if="!loading" class="success-btn hover-active" @click="handleBackHome">返回首页</view>
  10. </view>
  11. </template>
  12. <script setup>
  13. import { onLoad } from "@dcloudio/uni-app";
  14. import { ref } from "vue";
  15. import { go } from "@/utils/utils.js";
  16. import { getFileUrl } from "@/utils/file.js";
  17. import { GetSearchOrderByOutTradeNoPath, PostOrderComplete } from "@/api/dining.js";
  18. const orderId = ref('');
  19. const payType = ref('wechatPayMininProgram');
  20. const transactionId = ref('');
  21. const loading = ref(true);
  22. async function queryPayResult() {
  23. const tid = transactionId.value;
  24. const ptype = payType.value;
  25. const oid = orderId.value;
  26. if (!tid) {
  27. loading.value = false;
  28. return;
  29. }
  30. try {
  31. await GetSearchOrderByOutTradeNoPath({
  32. payType: ptype,
  33. transactionId: tid
  34. });
  35. if (oid) {
  36. try {
  37. await PostOrderComplete(oid);
  38. } catch (e) {
  39. console.warn('订单翻转接口调用失败', e);
  40. }
  41. }
  42. loading.value = false;
  43. } catch (e) {
  44. loading.value = false;
  45. }
  46. }
  47. onLoad((options) => {
  48. orderId.value = options?.id ?? '';
  49. payType.value = options?.payType ?? 'wechatPayMininProgram';
  50. transactionId.value = options?.transactionId ?? '';
  51. queryPayResult();
  52. });
  53. // 返回首页:清空页面栈,避免返回到支付/确认订单页
  54. const handleBackHome = () => {
  55. go('/pages/index/index', 'reLaunch');
  56. };
  57. </script>
  58. <style lang="scss" scoped>
  59. .content {
  60. background-color: #fff;
  61. width: 100%;
  62. min-height: 100vh;
  63. display: flex;
  64. flex-direction: column;
  65. align-items: center;
  66. padding-top: 120rpx;
  67. }
  68. .status-icon-wrap {
  69. width: 120rpx;
  70. height: 120rpx;
  71. display: flex;
  72. align-items: center;
  73. justify-content: center;
  74. }
  75. .status-img {
  76. width: 120rpx;
  77. height: 120rpx;
  78. }
  79. .loading-dot {
  80. width: 80rpx;
  81. height: 80rpx;
  82. border: 6rpx solid #e5e5e5;
  83. border-top-color: #07c160;
  84. border-radius: 50%;
  85. animation: spin 0.8s linear infinite;
  86. }
  87. @keyframes spin {
  88. to {
  89. transform: rotate(360deg);
  90. }
  91. }
  92. .status-title {
  93. font-weight: bold;
  94. font-size: 40rpx;
  95. color: #151515;
  96. margin-top: 40rpx;
  97. }
  98. .status-desc {
  99. font-size: 28rpx;
  100. color: #666666;
  101. margin-top: 24rpx;
  102. }
  103. .success-btn {
  104. margin-top: 80rpx;
  105. width: 400rpx;
  106. height: 88rpx;
  107. border: 2rpx solid #e5e5e5;
  108. border-radius: 44rpx;
  109. font-size: 30rpx;
  110. color: #333;
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. }
  115. </style>