applyRefund.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 { mapState } from 'vuex';
  52. import { config } from '@/common/config.js';
  53. export default {
  54. data() {
  55. return {
  56. refundForm: {
  57. orderId: '',
  58. refundAmount: '',
  59. refundReason: '',
  60. images: []
  61. },
  62. action: config.baseUrl + '/file/tencent/upload',
  63. successPop: false,
  64. // 退款温馨提示
  65. refundTipsContent: '',
  66. orderType: 'road',
  67. loading: false
  68. };
  69. },
  70. // computed: {
  71. // ...mapState(['vuex_token'])
  72. // },
  73. onLoad(options) {
  74. const { orderId, payAmount, tabCur } = options;
  75. this.refundForm.orderId = orderId;
  76. this.refundForm.refundAmount = Number(payAmount);
  77. this.orderType = tabCur;
  78. this.getSystems(4);
  79. console.log(this.vuex_token);
  80. },
  81. methods: {
  82. /**
  83. * @description: 提交
  84. * @return {*}
  85. */
  86. submitForm() {
  87. let files = [];
  88. // 是否有未完成上传的图片标识
  89. let isHas = false;
  90. this.$refs.uUpload.lists.forEach((item) => {
  91. if (item.progress === 100 && item.response) {
  92. const url = item?.response?.data?.url;
  93. if (url) {
  94. files.push(url);
  95. }
  96. } else {
  97. isHas = true;
  98. }
  99. });
  100. this.refundForm.images = files;
  101. if (this.refundForm.refundReason && !isHas) {
  102. const submitObj = {
  103. road: () => {
  104. this.roadRefundSubmit();
  105. },
  106. park: () => {
  107. this.parkRefundSubmit();
  108. }
  109. };
  110. submitObj[this.orderType]();
  111. } else if (this.refundForm.refundReason == '') {
  112. this.$refs.uToast.show({
  113. title: '请填写申请退款原因',
  114. type: 'warning'
  115. });
  116. } else if (isHas) {
  117. this.$refs.uToast.show({
  118. title: '还有图片未完成上传,请稍等!',
  119. type: 'warning'
  120. });
  121. }
  122. },
  123. /**
  124. * @description: 路段退款提交
  125. * @return {*}
  126. */
  127. async roadRefundSubmit() {
  128. try {
  129. this.loading = true;
  130. const { code } = await this.$u.api.updateOrderRefund({ ...this.refundForm });
  131. if (code === 200) {
  132. this.successPop = true;
  133. setTimeout(() => {
  134. this.successPop = false;
  135. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  136. orderId: this.refundForm.orderId
  137. });
  138. }, 2000);
  139. }
  140. } catch (error) {
  141. } finally {
  142. this.loading = false;
  143. }
  144. },
  145. /**
  146. * @description: 停车退款提交
  147. * @return {*}
  148. */
  149. async parkRefundSubmit() {
  150. try {
  151. this.loading = true;
  152. const { code } = await this.$u.api.updateParkingOrderRefund({ ...this.refundForm });
  153. if (code === 200) {
  154. this.successPop = true;
  155. setTimeout(() => {
  156. this.successPop = false;
  157. this.$u.route('pages/applyRefundDetails/applyRefundDetails', {
  158. orderId: this.refundForm.orderId
  159. });
  160. }, 2000);
  161. }
  162. } catch (error) {
  163. } finally {
  164. this.loading = false;
  165. }
  166. },
  167. /**
  168. * @description: 获取收费标准
  169. * @param {*} termsType
  170. * @return {*}
  171. */
  172. async getSystems(termsType) {
  173. const { code, data } = await this.$u.api.getSystems({ termsType: Number(termsType) });
  174. if (code === 200) {
  175. this.refundTipsContent = data.content;
  176. }
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. @import './applyRefund.scss';
  183. </style>