CancelOrder.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <u-popup @close="close" :value="show" :closeable="true" mode="bottom" border-radius="16">
  3. <view class="pop-view">
  4. <view class="title">请选择取消原因</view>
  5. <view style="padding-bottom: 30rpx;">
  6. <view v-for="(item, index) in reason" :key="index" class="reason-li clearfix" @click="resonChange(item)">
  7. <text class="float_left">{{ item }}</text>
  8. <text class="float_right ibonfont primary-color" :class="[cancel_reason === item ? 'ibonxuanze1' : 'ibonweixuanze']"></text>
  9. </view>
  10. </view>
  11. <view class="other-reason" v-if="cancel_reason === '其他原因'"><u-input type="textarea" v-model="other_reason" :border="true" :height="150"></u-input></view>
  12. </view>
  13. <view class="confirm-btn primary-bg" @click="confirm">
  14. <u-loading v-if="loading" mode="circle"></u-loading>
  15. 确定
  16. </view>
  17. </u-popup>
  18. </template>
  19. <script>
  20. export default {
  21. props: {
  22. type: {
  23. type: Number,
  24. default: 1
  25. },
  26. show: {
  27. type: Boolean,
  28. default: false
  29. },
  30. orderId: {
  31. type: [Number, String],
  32. default: ''
  33. },
  34. cancelbeforeOrderStatus: {
  35. type: [Number, String],
  36. default: ''
  37. },
  38. payStatus: {
  39. type: [Number, String],
  40. default: ''
  41. }
  42. },
  43. computed: {
  44. // 系统是否开启取消订单审核状态
  45. cancelOrderAudit() {
  46. return this.$store.state.baseSet.cancelOrderAudit || 4;
  47. }
  48. },
  49. data() {
  50. return {
  51. other_reason: '',
  52. loading: false,
  53. cancel_reason: '',
  54. reason: ['不想买了', '信息填错了', '买错商品了', '卖家缺货', '其他原因']
  55. };
  56. },
  57. methods: {
  58. resonChange(item) {
  59. this.cancel_reason = item;
  60. },
  61. confirm() {
  62. if (!this.cancel_reason) {
  63. this.$api.msg('请选择取消订单的原因');
  64. return;
  65. }
  66. if (this.cancel_reason === '其他原因' && !this.other_reason) {
  67. this.$api.msg('请输入取消订单的原因');
  68. return;
  69. }
  70. if (this.loading) {
  71. return;
  72. }
  73. let obj = {
  74. orderStatus: this.payStatus === 4 ? 6 : 7,
  75. cancelReason: this.cancel_reason === '其他原因' ? this.other_reason : this.cancel_reason
  76. };
  77. if (this.cancelOrderAudit === 5) {
  78. obj.cancelbeforeOrderStatus = this.cancelbeforeOrderStatus;
  79. }
  80. this.loading = true;
  81. if(this.type == 1) {
  82. this.$u.api
  83. .updateOrderStatus(this.orderId, obj)
  84. .then(res => {
  85. this.loading = false;
  86. this.$api.msg('取消成功');
  87. this.close();
  88. this.$emit('confirm');
  89. })
  90. .catch(err => {
  91. this.loading = false;
  92. });
  93. }else {
  94. this.$u.api.itemCancel({
  95. id: this.orderId,
  96. refund_remarks: obj.cancelReason
  97. }).then(res => {
  98. // this.getOrderSelect('reload');
  99. this.loading = false;
  100. this.$api.msg('取消成功');
  101. this.close();
  102. this.$emit('confirm');
  103. })
  104. }
  105. },
  106. close() {
  107. this.$emit('close');
  108. }
  109. }
  110. };
  111. </script>
  112. <style lang="scss">
  113. .confirm-btn {
  114. color: #ffffff;
  115. line-height: 90rpx;
  116. text-align: center;
  117. width: 100%;
  118. }
  119. .pop-view {
  120. padding: 0 30rpx;
  121. .title {
  122. font-weight: bold;
  123. line-height: 70rpx;
  124. padding-top: 10rpx;
  125. }
  126. .desc {
  127. color: #6c6c6c;
  128. font-size: 24rpx;
  129. line-height: 60rpx;
  130. padding-bottom: 30rpx;
  131. }
  132. .reason-li {
  133. line-height: 90upx;
  134. padding-right: 30upx;
  135. vertical-align: middle;
  136. border-bottom: 1px solid #f5f5f5;
  137. .ibonxuanze1,
  138. .ibonweixuanze {
  139. margin-right: 0;
  140. padding-left: 0;
  141. font-size: 38upx;
  142. }
  143. }
  144. .other-reason {
  145. padding-bottom: 30rpx;
  146. }
  147. }
  148. </style>