index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 storeId = ref('');
  22. const loading = ref(true);
  23. async function queryPayResult() {
  24. const tid = transactionId.value;
  25. const ptype = payType.value;
  26. const sid = storeId.value || uni.getStorageSync('currentStoreId') || '';
  27. const oid = orderId.value;
  28. if (!tid) {
  29. loading.value = false;
  30. return;
  31. }
  32. try {
  33. await GetSearchOrderByOutTradeNoPath({
  34. payType: ptype,
  35. transactionId: tid,
  36. storeId: sid || undefined
  37. });
  38. if (oid) {
  39. try {
  40. await PostOrderComplete(oid);
  41. } catch (e) {
  42. console.warn('订单翻转接口调用失败', e);
  43. }
  44. }
  45. loading.value = false;
  46. } catch (e) {
  47. loading.value = false;
  48. }
  49. }
  50. onLoad((options) => {
  51. orderId.value = options?.id ?? '';
  52. payType.value = options?.payType ?? 'wechatPayMininProgram';
  53. transactionId.value = options?.transactionId ?? '';
  54. storeId.value = options?.storeId ?? '';
  55. queryPayResult();
  56. });
  57. // 返回首页:清空页面栈,避免返回到支付/确认订单页
  58. const handleBackHome = () => {
  59. go('/pages/index/index', 'reLaunch');
  60. };
  61. </script>
  62. <style lang="scss" scoped>
  63. .content {
  64. background-color: #fff;
  65. width: 100%;
  66. min-height: 100vh;
  67. display: flex;
  68. flex-direction: column;
  69. align-items: center;
  70. padding-top: 120rpx;
  71. }
  72. .status-icon-wrap {
  73. width: 120rpx;
  74. height: 120rpx;
  75. display: flex;
  76. align-items: center;
  77. justify-content: center;
  78. }
  79. .status-img {
  80. width: 120rpx;
  81. height: 120rpx;
  82. }
  83. .loading-dot {
  84. width: 80rpx;
  85. height: 80rpx;
  86. border: 6rpx solid #e5e5e5;
  87. border-top-color: #07c160;
  88. border-radius: 50%;
  89. animation: spin 0.8s linear infinite;
  90. }
  91. @keyframes spin {
  92. to {
  93. transform: rotate(360deg);
  94. }
  95. }
  96. .status-title {
  97. font-weight: bold;
  98. font-size: 40rpx;
  99. color: #151515;
  100. margin-top: 40rpx;
  101. }
  102. .status-desc {
  103. font-size: 28rpx;
  104. color: #666666;
  105. margin-top: 24rpx;
  106. }
  107. .success-btn {
  108. margin-top: 80rpx;
  109. width: 400rpx;
  110. height: 88rpx;
  111. border: 2rpx solid #e5e5e5;
  112. border-radius: 44rpx;
  113. font-size: 30rpx;
  114. color: #333;
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. }
  119. </style>