order-return-actions.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. },
  31. methods: {
  32. handleAction(type) {
  33. if (type == 'pay') {
  34. //先校验支付参数
  35. if (this.order.orderId) {
  36. uni.$u.http.post('/token/order/refundGoPay', {
  37. refundOrderId: this.order.orderId
  38. }).then(res => {
  39. if (res.code == 200) {
  40. //如果有微信订单,则跳转去微信支付
  41. if (res.data.prepayId) {
  42. uni.requestPayment({
  43. timeStamp: res.data.timeStamp,
  44. nonceStr: res.data.nonceStr,
  45. package: `prepay_id=${res.data.prepayId}`,
  46. signType: res.data.signType,
  47. paySign: res.data.paySign,
  48. provider: 'wxpay',
  49. success: (res) => {
  50. console.log(res)
  51. //支付成功之后,跳转支付成功页面
  52. uni.navigateTo({
  53. url: `/pages-mine/pages/pay-success?orderId=${this.order.orderId}`
  54. })
  55. },
  56. fail: (err) => {
  57. console.log(err)
  58. }
  59. })
  60. } else {
  61. uni.navigateTo({
  62. url: `/pages-mine/pages/cashier-desk?id=${res.data.refundOrderId}`
  63. })
  64. }
  65. }
  66. })
  67. }
  68. } else {
  69. this.$emit('action', {
  70. type,
  71. order: this.order
  72. })
  73. }
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .order-return-actions {
  80. display: flex;
  81. justify-content: flex-end;
  82. gap: 10px;
  83. padding: 10px 0;
  84. width: 100%;
  85. .w-full {
  86. width: 100%;
  87. }
  88. .action-btn {
  89. display: flex;
  90. align-items: center;
  91. justify-content: center;
  92. min-width: 160rpx;
  93. height: 60rpx;
  94. line-height: 60rpx;
  95. border-radius: 10rpx;
  96. font-size: 28rpx;
  97. background-color: #38C148;
  98. color: #ffffff;
  99. cursor: pointer;
  100. margin: 0;
  101. border: 0;
  102. max-width: 200rpx;
  103. &::after {
  104. border: 0;
  105. }
  106. &+.action-btn {
  107. margin-left: 16rpx;
  108. }
  109. &.info-btn {
  110. background-color: #DBDBDB;
  111. color: #ffffff;
  112. }
  113. &.plain {
  114. border: 1px solid #38C148;
  115. color: #38C148;
  116. background-color: #fff;
  117. }
  118. }
  119. }
  120. .large-size {
  121. .order-return-actions {
  122. .action-btn {
  123. max-width: 200rpx;
  124. height: 80rpx;
  125. line-height: 80rpx;
  126. }
  127. }
  128. }
  129. </style>