result.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="pay-wrap" v-loading="fullscreenLoading">
  3. <div class="pay">
  4. <div class="pay-icon"><i class=" ns-text-color"
  5. :class="payInfo.pay_status ? 'el-icon-circle-check' : 'el-icon-circle-close\n'"></i></div>
  6. <div class="pay-text">{{ payInfo.pay_status ? '支付成功' : '支付失败' }}</div>
  7. <div class="pay-money">支付金额:¥{{ payInfo.pay_money }}</div>
  8. <div class="pay-footer">
  9. <router-link to="/member">
  10. <el-button type="primary">会员中心</el-button>
  11. </router-link>
  12. <router-link to="/" class="pay-button">
  13. <el-button>回到首页</el-button>
  14. </router-link>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import {
  21. getPayInfo
  22. } from '@/api/pay';
  23. import {
  24. memberInfo
  25. } from '@/api/member/index.js'
  26. export default {
  27. name: 'pay_result',
  28. components: {},
  29. data: () => {
  30. return {
  31. payInfo: {},
  32. outTradeNo: '',
  33. fullscreenLoading: true
  34. };
  35. },
  36. created() {
  37. if (!this.$route.query.code) {
  38. this.$router.push({
  39. path: '/'
  40. });
  41. return;
  42. }
  43. this.outTradeNo = this.$route.query.code;
  44. this.getPayInfo();
  45. this.memberInfo()
  46. },
  47. methods: {
  48. getPayInfo() {
  49. getPayInfo({
  50. out_trade_no: this.outTradeNo,
  51. forceLogin: true
  52. })
  53. .then(res => {
  54. const {
  55. code,
  56. message,
  57. data
  58. } = res;
  59. if (code >= 0 && data) {
  60. this.payInfo = res.data;
  61. } else {
  62. this.$message({
  63. message: '未获取到支付信息',
  64. type: 'warning',
  65. duration: 2000,
  66. onClose: () => {
  67. this.$router.push({
  68. path: '/member/order_list'
  69. });
  70. }
  71. });
  72. }
  73. this.fullscreenLoading = false;
  74. })
  75. .catch(err => {
  76. this.fullscreenLoading = false;
  77. this.$message.error({
  78. message: err.message,
  79. duration: 2000,
  80. onClose: () => {
  81. this.$router.push({
  82. path: '/member/order_list'
  83. });
  84. }
  85. });
  86. });
  87. },
  88. memberInfo() {
  89. memberInfo()
  90. .then(res => {
  91. const {
  92. data
  93. } = res
  94. this.$store.commit("member/SET_MEMBER", data)
  95. })
  96. .catch(err => {
  97. console.log('err')
  98. })
  99. }
  100. }
  101. };
  102. </script>
  103. <style lang="scss" scoped>
  104. .pay-wrap {
  105. width: 1210px;
  106. margin: 20px auto;
  107. }
  108. .pay {
  109. padding: 40px 15px;
  110. margin: 10px 0;
  111. border-radius: 0;
  112. border: none;
  113. background: #ffffff;
  114. .pay-icon {
  115. text-align: center;
  116. i {
  117. font-size: 65px;
  118. }
  119. }
  120. .pay-text {
  121. text-align: center;
  122. font-size: 16px;
  123. margin-top: 10px;
  124. }
  125. .pay-money {
  126. text-align: center;
  127. color: $base-color;
  128. font-size: $ns-font-size-lg;
  129. }
  130. .pay-footer {
  131. text-align: center;
  132. margin-top: 30px;
  133. .pay-button {
  134. margin-left: 15px;
  135. }
  136. }
  137. }
  138. </style>