refund.vue 4.3 KB

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