applyRefund.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="apply-refund">
  3. <view class="apply-refund-form">
  4. <view class="apply-refund-form-item">
  5. <view class="apply-refund-form-label">
  6. 退款金额:
  7. </view>
  8. <view class="apply-refund-form-content">
  9. <text class="money">{{Number(refundForm.refundAmount).toFixed(2)}}</text>元
  10. </view>
  11. </view>
  12. <view class="apply-refund-form-item">
  13. <view class="apply-refund-form-label">
  14. 退款原因:
  15. </view>
  16. <view class="apply-refund-form-content full-width">
  17. <textarea
  18. v-model="refundForm.refundReason"
  19. maxlength="200"
  20. placeholder="请填写申请退款原因"
  21. :data-maxnum="refundForm.refundReason.length+'/200'"/>
  22. <u-upload
  23. :header="{
  24. Authorization: 'Bearer ' + vuex_token
  25. }"
  26. max-count="3"
  27. ref="uUpload"
  28. :action="action"></u-upload>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="apply-refund-form-submit">
  33. <u-button type="primary" @click="submit">提交</u-button>
  34. </view>
  35. <u-mask :show="successPop" :zoom="true" :custom-style="{background: 'rgba(255, 255, 255, 0.8)'}">
  36. <view class="pop-warp">
  37. <view class="pop-warp-icon">
  38. <u-icon name="checkbox-mark" color="#fff" size="50"></u-icon>
  39. </view>
  40. <view class="pop-warp-tips">
  41. <text>提交成功!预计3-7个工作日内处理</text>
  42. </view>
  43. </view>
  44. </u-mask>
  45. <u-toast ref="uToast" />
  46. </view>
  47. </template>
  48. <script>
  49. import {mapState, mapMutations} from 'vuex';
  50. import { config } from '@/common/config.js'
  51. export default {
  52. data() {
  53. return {
  54. refundForm: {
  55. orderId: '',
  56. refundAmount: '',
  57. refundReason: '',
  58. images: []
  59. },
  60. action: config.baseUrl + '/file/tencent/upload',
  61. successPop: false
  62. }
  63. },
  64. computed: {
  65. ...mapState(['vuex_token'])
  66. },
  67. onLoad(page) {
  68. this.refundForm.orderId = page.orderId
  69. this.refundForm.refundAmount = Number(page.payAmount)
  70. },
  71. methods: {
  72. submit() {
  73. let files = [];
  74. // 是否有未完成上传的图片标识
  75. let isHas = false
  76. this.$refs.uUpload.lists.forEach(item => {
  77. if (item.progress === 100 && item.response) {
  78. const url = item?.response?.data?.url
  79. if (url) {
  80. files.push(url)
  81. }
  82. } else {
  83. isHas = true
  84. }
  85. })
  86. this.refundForm.images = files
  87. if (this.refundForm.refundReason && !isHas) {
  88. this.$u.api.updateOrderRefund(this.refundForm)
  89. .then(res => {
  90. this.successPop = true
  91. if (res.code === 200) {
  92. setTimeout(() => {
  93. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  94. orderId: this.refundForm.orderId
  95. })
  96. }, 2000)
  97. } else {
  98. this.successPop = false
  99. this.$refs.uToast.show({
  100. title: res.msg,
  101. type: 'error'
  102. })
  103. }
  104. })
  105. .catch(err => {
  106. this.$refs.uToast.show({
  107. title: '操作失败!',
  108. type: 'error'
  109. })
  110. })
  111. } else if (this.refundForm.refundReason == '') {
  112. this.$refs.uToast.show({
  113. title: '请填写申请退款原因',
  114. type: 'warning'
  115. })
  116. // } else if (files.length === 0) {
  117. // this.$refs.uToast.show({
  118. // title: '请至少选择一张图片',
  119. // type: 'warning'
  120. // })
  121. } else if (isHas) {
  122. this.$refs.uToast.show({
  123. title: '还有图片未完成上传,请稍等!',
  124. type: 'warning'
  125. })
  126. }
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. @import './applyRefund.scss';
  133. </style>