scanPayRefund.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="app-content scan-pay-refund">
  3. <view class="card">
  4. <view class="row"><text class="label">订单金额</text><text class="val">¥{{ parseFloat(info.actPrice || 0) }}</text></view>
  5. <view class="row"><text class="label">已退金额</text><text class="val">¥{{ parseFloat(info.tkPrice || 0) }}</text></view>
  6. <view class="row"><text class="label">可退金额</text><text class="val price">¥{{ parseFloat(canRefundPrice) }}</text></view>
  7. <text class="tip online-tip" v-if="canOnlineRefund">此单线上付款,提交后钱会原路自动退回给客户</text>
  8. </view>
  9. <view class="card">
  10. <view class="form-label">退款金额</view>
  11. <view class="input-wrap">
  12. <input class="input" type="digit" v-model="refundMoney" placeholder="请输入退款金额" />
  13. <text class="unit">元</text>
  14. </view>
  15. <view class="form-label">备注</view>
  16. <textarea class="textarea" v-model="remark" placeholder="选填" maxlength="200" />
  17. </view>
  18. <view class="footer">
  19. <button class="admin-button-com bule middle" @click="confirmRefund">确认退款</button>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import { getScanPayDetail, scanPayRefund } from "@/api/order";
  25. export default {
  26. name: "scanPayRefund",
  27. data() {
  28. return {
  29. id: 0,
  30. info: {},
  31. canRefundPrice: 0,
  32. refundMoney: '',
  33. remark: ''
  34. };
  35. },
  36. computed: {
  37. canOnlineRefund() {
  38. const pw = Number(this.info.payWay);
  39. return pw === 0 || pw === 1;
  40. }
  41. },
  42. onLoad(option) {
  43. this.id = option.id || 0;
  44. this.loadDetail();
  45. },
  46. methods: {
  47. loadDetail() {
  48. if (!this.id) return;
  49. getScanPayDetail({ id: this.id }).then(res => {
  50. if (res.code != 1 || this.$util.isEmpty(res.data)) return;
  51. const data = res.data;
  52. this.info = data.info || {};
  53. this.canRefundPrice = data.canRefundPrice || 0;
  54. this.refundMoney = String(this.canRefundPrice > 0 ? this.canRefundPrice : '');
  55. });
  56. },
  57. confirmRefund() {
  58. const price = Number(this.refundMoney);
  59. if (!price || price <= 0) {
  60. return this.$msg('请填写退款金额');
  61. }
  62. if (price > Number(this.canRefundPrice)) {
  63. return this.$msg('退款金额超过可退金额');
  64. }
  65. let title = '确认退款 ¥' + price + ' ?';
  66. if (this.canOnlineRefund) {
  67. title = '提交后钱会原路退回给客户,确认退款 ¥' + price + ' ?';
  68. }
  69. uni.showModal({
  70. title: '确认退款',
  71. content: title,
  72. success: (res) => {
  73. if (res.confirm) this.submitRefund(price);
  74. }
  75. });
  76. },
  77. submitRefund(price) {
  78. scanPayRefund({ id: this.id, price, remark: this.remark }).then(res => {
  79. if (res.code == 1) {
  80. this.$msg('退款成功');
  81. setTimeout(() => {
  82. this.$util.pageTo({ url: '/admin/order/scanPayDetail', query: { id: this.id }, type: 2 });
  83. }, 500);
  84. }
  85. });
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss" scoped>
  91. .scan-pay-refund {
  92. padding-bottom: 120upx;
  93. background: #f9fbfc;
  94. min-height: 100%;
  95. }
  96. .card {
  97. margin: 20upx;
  98. padding: 30upx;
  99. background: #fff;
  100. border-radius: 12upx;
  101. }
  102. .row {
  103. display: flex;
  104. justify-content: space-between;
  105. padding: 16upx 0;
  106. font-size: 28upx;
  107. .label { color: #666; }
  108. .val { color: #333; }
  109. .price { color: #3385ff; font-weight: 600; }
  110. }
  111. .tip {
  112. display: block;
  113. margin-top: 16upx;
  114. padding: 16upx;
  115. font-size: 24upx;
  116. border-radius: 8upx;
  117. }
  118. .online-tip {
  119. background: #fff7e6;
  120. color: #ad760d;
  121. }
  122. .form-label {
  123. margin-top: 10upx;
  124. font-size: 28upx;
  125. color: #333;
  126. }
  127. .input-wrap {
  128. display: flex;
  129. align-items: center;
  130. margin-top: 16upx;
  131. padding: 0 20upx;
  132. height: 80upx;
  133. background: #f5f7fa;
  134. border-radius: 8upx;
  135. }
  136. .input { flex: 1; font-size: 32upx; }
  137. .unit { color: #999; font-size: 28upx; }
  138. .textarea {
  139. width: 100%;
  140. margin-top: 16upx;
  141. padding: 20upx;
  142. min-height: 160upx;
  143. background: #f5f7fa;
  144. border-radius: 8upx;
  145. font-size: 28upx;
  146. box-sizing: border-box;
  147. }
  148. .footer {
  149. position: fixed;
  150. left: 0;
  151. right: 0;
  152. bottom: 0;
  153. padding: 20upx 30upx 40upx;
  154. background: #fff;
  155. }
  156. </style>