order-return-actions.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="order-container" style="width: 100%;" :class="{ 'large-size': size === 'large' }">
  3. <view class="order-return-actions">
  4. <button v-if="status == 0" class="action-btn" @click.stop="handleAction('pay')">去付款</button>
  5. <!-- 待初审 -->
  6. <template v-if="status == 2 || status == 1">
  7. <button class="action-btn" @click.stop="handleAction('cancel')">取消退回</button>
  8. </template>
  9. <!-- 待取件 -->
  10. <button v-if="status === 2" class="action-btn" @click.stop="handleAction('confirm')">确认收货</button>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'OrderActions',
  17. props: {
  18. status: {
  19. type: Number,
  20. required: true
  21. },
  22. order: {
  23. type: Object,
  24. default: () => ({})
  25. },
  26. size: {
  27. type: String,
  28. default: 'normal'
  29. },
  30. isDetail: {
  31. type: Boolean,
  32. default: false
  33. }
  34. },
  35. methods: {
  36. handleAction(type) {
  37. if (type == 'pay') {
  38. //先校验支付参数
  39. if (this.order.orderId) {
  40. uni.$u.http.post('/token/order/refundGoPay', {
  41. refundOrderId: this.isDetail ? this.order.refundOrderId : this.order.orderId
  42. }).then(res => {
  43. if (res.code == 200) {
  44. //如果有微信订单,则跳转去微信支付
  45. if (res.data.prepayId) {
  46. uni.requestPayment({
  47. timeStamp: res.data.timeStamp,
  48. nonceStr: res.data.nonceStr,
  49. package: `prepay_id=${res.data.prepayId}`,
  50. signType: res.data.signType,
  51. paySign: res.data.paySign,
  52. provider: 'wxpay',
  53. success: (res) => {
  54. console.log(res)
  55. //支付成功之后,跳转支付成功页面
  56. uni.navigateTo({
  57. url: `/pages-mine/pages/pay-success?orderId=${this.order.orderId}`
  58. })
  59. },
  60. fail: (err) => {
  61. console.log(err)
  62. }
  63. })
  64. } else {
  65. uni.navigateTo({
  66. url: `/pages-mine/pages/cashier-desk?id=${res.data.refundOrderId}`
  67. })
  68. }
  69. }
  70. })
  71. }
  72. } else {
  73. this.$emit('action', {
  74. type,
  75. order: this.order
  76. })
  77. }
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .order-return-actions {
  84. display: flex;
  85. justify-content: flex-end;
  86. gap: 10px;
  87. padding: 10px 0;
  88. width: 100%;
  89. .w-full {
  90. width: 100%;
  91. }
  92. .action-btn {
  93. display: flex;
  94. align-items: center;
  95. justify-content: center;
  96. min-width: 160rpx;
  97. height: 60rpx;
  98. line-height: 60rpx;
  99. border-radius: 10rpx;
  100. font-size: 28rpx;
  101. background-color: #38C148;
  102. color: #ffffff;
  103. cursor: pointer;
  104. margin: 0;
  105. border: 0;
  106. max-width: 200rpx;
  107. &::after {
  108. border: 0;
  109. }
  110. &+.action-btn {
  111. margin-left: 16rpx;
  112. }
  113. &.info-btn {
  114. background-color: #DBDBDB;
  115. color: #ffffff;
  116. }
  117. &.plain {
  118. border: 1px solid #38C148;
  119. color: #38C148;
  120. background-color: #fff;
  121. }
  122. }
  123. }
  124. .large-size {
  125. .order-return-actions {
  126. .action-btn {
  127. max-width: 200rpx;
  128. height: 80rpx;
  129. line-height: 80rpx;
  130. }
  131. }
  132. }
  133. </style>