applyRefund.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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"> 退款金额: </view>
  6. <view class="apply-refund-form-content">
  7. <text class="money">{{ Number(refundForm.refundAmount).toFixed(2) }}</text
  8. >元
  9. </view>
  10. </view>
  11. <view class="apply-refund-form-item">
  12. <view class="apply-refund-form-label"> 退款原因: </view>
  13. <view class="apply-refund-form-content full-width">
  14. <textarea
  15. v-model="refundForm.refundReason"
  16. maxlength="200"
  17. placeholder="请填写申请退款原因"
  18. :data-maxnum="refundForm.refundReason.length + '/200'"
  19. />
  20. <u-upload
  21. :header="{
  22. Authorization: 'Bearer ' + vuex_token
  23. }"
  24. max-count="3"
  25. ref="uUpload"
  26. :action="action"
  27. ></u-upload>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="apply-refund-form-submit">
  32. <u-button type="primary" :loading="loading" @click="submitForm">提交</u-button>
  33. </view>
  34. <view class="refund-tips" v-if="refundTipsContent">
  35. <u-parse :html="refundTipsContent"></u-parse>
  36. </view>
  37. <u-mask :show="successPop" :zoom="true" :custom-style="{ background: 'rgba(255, 255, 255, 0.8)' }">
  38. <view class="pop-warp">
  39. <view class="pop-warp-icon">
  40. <u-icon name="checkbox-mark" color="#fff" size="50"></u-icon>
  41. </view>
  42. <view class="pop-warp-tips">
  43. <text>提交成功!预计3-7个工作日内处理</text>
  44. </view>
  45. </view>
  46. </u-mask>
  47. <u-toast ref="uToast" />
  48. </view>
  49. </template>
  50. <script>
  51. import { config } from '@/common/config.js';
  52. export default {
  53. data() {
  54. return {
  55. refundForm: {
  56. orderId: '',
  57. refundAmount: '',
  58. refundReason: '',
  59. images: []
  60. },
  61. action: config.baseUrl + '/file/tencent/upload',
  62. successPop: false,
  63. // 退款温馨提示
  64. refundTipsContent: '',
  65. orderType: 'road',
  66. loading: false
  67. };
  68. },
  69. onLoad(options) {
  70. const { orderId, payAmount, tabCur } = options;
  71. this.refundForm.orderId = orderId;
  72. this.refundForm.refundAmount = Number(payAmount);
  73. this.orderType = tabCur;
  74. this.getSystems(4);
  75. },
  76. methods: {
  77. /**
  78. * @description: 提交
  79. * @return {*}
  80. */
  81. submitForm() {
  82. let files = [];
  83. // 是否有未完成上传的图片标识
  84. let isHas = false;
  85. this.$refs.uUpload.lists.forEach((item) => {
  86. if (item.progress === 100 && item.response) {
  87. const url = item?.response?.data?.url;
  88. if (url) {
  89. files.push(url);
  90. }
  91. } else {
  92. isHas = true;
  93. }
  94. });
  95. this.refundForm.images = files;
  96. if (this.refundForm.refundReason && !isHas) {
  97. const submitObj = {
  98. road: () => {
  99. this.roadRefundSubmit();
  100. },
  101. park: () => {
  102. this.parkRefundSubmit();
  103. }
  104. };
  105. submitObj[this.orderType]();
  106. } else if (this.refundForm.refundReason == '') {
  107. this.$refs.uToast.show({
  108. title: '请填写申请退款原因',
  109. type: 'warning'
  110. });
  111. } else if (isHas) {
  112. this.$refs.uToast.show({
  113. title: '还有图片未完成上传,请稍等!',
  114. type: 'warning'
  115. });
  116. }
  117. },
  118. /**
  119. * @description: 路段退款提交
  120. * @return {*}
  121. */
  122. async roadRefundSubmit() {
  123. try {
  124. this.loading = true;
  125. const { code } = await this.$u.api.updateOrderRefund({ ...this.refundForm });
  126. if (code === 200) {
  127. this.successPop = true;
  128. setTimeout(() => {
  129. this.successPop = false;
  130. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  131. orderId: this.refundForm.orderId
  132. });
  133. }, 2000);
  134. }
  135. } catch (error) {
  136. } finally {
  137. this.loading = false;
  138. }
  139. },
  140. /**
  141. * @description: 停车退款提交
  142. * @return {*}
  143. */
  144. async parkRefundSubmit() {
  145. try {
  146. this.loading = true;
  147. const { code } = await this.$u.api.updateParkingOrderRefund({ ...this.refundForm });
  148. if (code === 200) {
  149. this.successPop = true;
  150. setTimeout(() => {
  151. this.successPop = false;
  152. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  153. orderId: this.refundForm.orderId
  154. });
  155. }, 2000);
  156. }
  157. } catch (error) {
  158. } finally {
  159. this.loading = false;
  160. }
  161. },
  162. /**
  163. * @description: 获取收费标准
  164. * @param {*} termsType
  165. * @return {*}
  166. */
  167. async getSystems(termsType) {
  168. const { code, data } = await this.$u.api.getSystems({ termsType: Number(termsType) });
  169. if (code === 200) {
  170. this.refundTipsContent = data.content;
  171. }
  172. }
  173. }
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. @import './applyRefund.scss';
  178. </style>