wallet-refund.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="page">
  3. <navigation-bar title="退款"></navigation-bar>
  4. <view class="block">
  5. <view class="fs-28 color-000 fw-500">退款金额</view>
  6. <view
  7. class="pt-24 pb-24 box-content flex-inline"
  8. style="border-bottom: 1rpx solid rgba(0, 0, 0, 0.1)"
  9. >
  10. <text style="font-size: 32px; line-height: 32px">¥</text>
  11. <input
  12. style="height: 46px; font-size: 46px; line-height: 46px"
  13. class="fw-600 color-000 ml-18"
  14. :value="value"
  15. :disabled="true"
  16. />
  17. </view>
  18. <view class="height-94 flex-align-center">
  19. <view class="fs-28 color-999"
  20. >可退金额 {{ user ? user.refundableAmount : 0 }} 元,优惠金额
  21. {{ user ? user.discountAmount : 0 }} 元</view
  22. >
  23. <!-- <view class="fs-28 color-primary" @click="allRefund">全部提现</view> -->
  24. </view>
  25. </view>
  26. <view class="block mt-16">
  27. <view class="fs-28 color-000 fw-500 pb-8">退款原因</view>
  28. <view class="pb-40 flex-wrap">
  29. <view
  30. :class="[
  31. 'reason',
  32. 'mt-16',
  33. 'mr-20',
  34. 'fs-26',
  35. reason === i ? 'reason-active' : '',
  36. ]"
  37. v-for="(r, i) in reasons"
  38. :key="i"
  39. @click="changeReason(i)"
  40. >{{ r }}</view
  41. >
  42. </view>
  43. </view>
  44. <view class="block mt-16 relative">
  45. <view class="fs-28 color-000 fw-500 pb-16">退款说明</view>
  46. <view class="pb-40 reason-text">
  47. <textarea
  48. class="fs-28"
  49. style="height: 100%"
  50. placeholder="请您详细填写申请说明"
  51. maxlength="200"
  52. @input="inputReasonText"
  53. ></textarea>
  54. </view>
  55. <view class="reason-text-length lh-28 fs-28 color-999"
  56. >{{ reasonText.length }}/200</view
  57. >
  58. </view>
  59. <style-bottom-view>
  60. <view class="pl-40 pr-40 pb-30 pt-30" style="background-color: #fff">
  61. <style-button type="primary" :disabled="submitting" @click="submit">提交申请</style-button>
  62. </view>
  63. </style-bottom-view>
  64. <style-result
  65. v-if="success"
  66. icon="/pages-user/static/icon-submit-success.png"
  67. title="提交成功"
  68. tip="预计需要5个工作日内审核完成请及时查收"
  69. >
  70. <view class="pt-64" style="width: 280rpx">
  71. <style-button height="80" type="primary" @click="close"
  72. >完成</style-button
  73. >
  74. </view>
  75. </style-result>
  76. </view>
  77. </template>
  78. <script setup lang="ts">
  79. import { applyRefund } from "@/api/user";
  80. import { onLoad } from "@dcloudio/uni-app";
  81. import { ref } from "vue";
  82. const user = ref();
  83. const value = ref(0);
  84. const reasonText = ref("");
  85. const reason = ref(-1);
  86. const reasons = ref([
  87. "不常住该小区",
  88. "充电故障",
  89. "下次使用再充值",
  90. "充电费用贵",
  91. "很难充上电",
  92. "其他原因",
  93. ]);
  94. const success = ref(false);
  95. const submitting = ref(false);
  96. onLoad(() => {
  97. if (getApp<any>().globalData.user) {
  98. user.value = getApp<any>().globalData.user;
  99. allRefund();
  100. }
  101. });
  102. const allRefund = () => {
  103. if (user.value) {
  104. value.value = Number(user.value.balance);
  105. }
  106. };
  107. const changeReason = (i: number) => {
  108. reason.value = i;
  109. };
  110. const inputReasonText = (e: any) => {
  111. reasonText.value = e.detail.value;
  112. };
  113. const submit = () => {
  114. if (submitting.value) {
  115. return;
  116. }
  117. submitting.value = true;
  118. uni.showLoading({
  119. title: "提交中",
  120. mask: true,
  121. });
  122. let r = "";
  123. if (reason.value >= 0) {
  124. r += `${reasons.value[reason.value]}`;
  125. if (reasonText.value) {
  126. r += "|";
  127. }
  128. }
  129. if (reasonText.value) {
  130. r += reasonText.value;
  131. }
  132. applyRefund(r)
  133. .then(() => {
  134. uni.hideLoading();
  135. success.value = true;
  136. })
  137. .catch((err) => {
  138. console.log(err);
  139. uni.hideLoading();
  140. uni.showModal({
  141. content: err.errMsg,
  142. showCancel: false
  143. })
  144. })
  145. .finally(() => {
  146. submitting.value = false;
  147. });
  148. };
  149. const close = () => {
  150. success.value = false;
  151. uni.navigateBack();
  152. };
  153. </script>
  154. <style lang="scss">
  155. .page {
  156. height: 100vh;
  157. background-color: #f6f7fa;
  158. padding: 20rpx;
  159. .block {
  160. border-radius: 24rpx;
  161. background: #fff;
  162. padding: 40rpx 40rpx 0px 40rpx;
  163. }
  164. .reason {
  165. color: #666;
  166. background-color: #f7f7f7;
  167. border-radius: 4rpx;
  168. padding: 12rpx 16rpx;
  169. border: 1px solid #f7f7f7;
  170. }
  171. .reason-active {
  172. color: var(--color-primary);
  173. border: 1px solid var(--color-primary);
  174. background: rgba(52, 125, 255, 0.1);
  175. }
  176. .reason-text {
  177. height: 224rpx;
  178. }
  179. .reason-text-length {
  180. position: absolute;
  181. top: 40rpx;
  182. right: 40rpx;
  183. }
  184. }
  185. </style>