success_pay.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="pay-success-container">
  3. <!-- 支付成功图标及状态 -->
  4. <view class="icon-circle">
  5. <image class="success-icon" src="/static/success_card.png"></image>
  6. </view>
  7. <text class="title">{{title}}</text>
  8. <text class="desc gray">{{msg}}</text>
  9. <!-- 查看订单按钮 -->
  10. <button class="check-order-btn bg_color_primary" @click="goBack">返回</button>
  11. </view>
  12. </template>
  13. <script setup>
  14. import { ref,computed } from 'vue';
  15. import { payResult } from "@/api/order.js";
  16. import { getUserInfo } from "@/utils/util.js";
  17. import { onLoad } from "@dcloudio/uni-app";
  18. const orderId = ref('');
  19. const isSuccess = ref(1);//1成功 0失败;
  20. const payMethod = ref('');//支付方式 0微信 1余额
  21. const title = computed(()=>{
  22. return isSuccess.value==1 ? '支付成功' : '支付失败'
  23. })
  24. const msg = computed(()=>{
  25. return isSuccess.value==1 ? '非常感谢您购买我们的服务~' : '抱歉,支付失败,请稍后再试~'
  26. })
  27. onLoad((e)=>{
  28. orderId.value = e.orderId || 0;
  29. isSuccess.value = e.isSuccess;
  30. payMethod.value = e.payMethod;
  31. console.log("pay-success-onload",e);
  32. getUserInfo();
  33. if(payMethod.value == 0)payResultFn();
  34. })
  35. // 导航到订单详情页面
  36. function goBack() {
  37. uni.navigateBack({
  38. delta: 1
  39. });
  40. }
  41. function payResultFn() {
  42. payResult({
  43. orderId: orderId.value,
  44. }).then(res => {
  45. console.log("payResult", res);
  46. });
  47. }
  48. </script>
  49. <style scoped>
  50. .pay-success-container {
  51. display: flex;
  52. flex-direction: column;
  53. align-items: center;
  54. justify-content: start;
  55. min-height: 100vh;
  56. background-color: #f5f5f5;
  57. padding: 0 20rpx;
  58. }
  59. .icon-circle {
  60. width: 160rpx;
  61. height: 160rpx;
  62. border-radius: 50%;
  63. background-color: #ffd9d1;
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. margin: 120rpx 0 40rpx;
  68. }
  69. .success-icon {
  70. width: 80rpx;
  71. height: 80rpx;
  72. }
  73. .title {
  74. font-size: 36rpx;
  75. font-weight: bold;
  76. color: #333;
  77. margin-bottom: 20rpx;
  78. }
  79. .desc {
  80. font-size: 28rpx;
  81. text-align: center;
  82. margin-bottom: 60rpx;
  83. line-height: 44rpx;
  84. }
  85. .check-order-btn {
  86. /* width: 320rpx; */
  87. width: 100%;
  88. height: 88rpx;
  89. line-height: 88rpx;
  90. color: #fff;
  91. font-size: 32rpx;
  92. border-radius: 44rpx;
  93. }
  94. </style>