index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="withdrawal">
  3. <view class="withdrawal-box">
  4. <view class="box-text">
  5. <text>可提现金额</text>
  6. <text>{{ balance }}</text>
  7. </view>
  8. <view class="goWithd" @click="goWithdClick">去提现</view>
  9. </view>
  10. <view class="prompt"
  11. >注:可提现金额已扣除赠送会员代金券金额中的50%费用</view
  12. >
  13. <view class="withdrawal-container">
  14. <view class="withdrawal-title">
  15. <text>提现记录</text>
  16. </view>
  17. <view class="withdrawal-list">
  18. <view
  19. class="list-item"
  20. v-for="(item, index) in withdrawalList"
  21. :key="index"
  22. >
  23. <view class="item-text">
  24. <text v-if="item.state == 1">已处理</text>
  25. <text v-else-if="item.state == 2">通过</text>
  26. <text v-else-if="item.state == 3">拒绝</text>
  27. <text v-else-if="item.state == 4">待确认</text>
  28. <!-- 0-待处理 1-已处理 2-通过 3-拒绝 4-待确认 -->
  29. <text>{{ item.applyTime }}</text>
  30. </view>
  31. <view class="item-price">{{ item.withdrawalMoney }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. <tui-bottom-popup
  36. :zIndex="1000"
  37. backgroundColor="#FFFFFF"
  38. :show="showPopup"
  39. @close="clonePopup"
  40. >
  41. <view class="popup-container">
  42. <view class="popup-title">提现</view>
  43. <view class="popup-type">
  44. <view class="type-title">提现类型</view>
  45. <view class="type-btn">
  46. <view
  47. class="btn-box"
  48. :class="popupIdx == 1 ? 'active' : ''"
  49. @click="changeIdx(1)"
  50. >正常支付订单</view
  51. >
  52. <view
  53. class="btn-box"
  54. :class="popupIdx == 2 ? 'active' : ''"
  55. @click="changeIdx(2)"
  56. >交易金</view
  57. >
  58. </view>
  59. </view>
  60. <view class="popup-amount">
  61. <text>提现金额</text>
  62. <text>{{ popupText }}</text>
  63. </view>
  64. <view class="popup-ipt">
  65. <tui-input
  66. type="number"
  67. :focus="true"
  68. :size="64"
  69. padding="16rpx 0rpx"
  70. :disabled="true"
  71. v-model="applyInfo.withdrawalMoney"
  72. >
  73. <template #left>
  74. <view class="ipt-left">¥</view>
  75. </template>
  76. <template #right>
  77. <view class="ipt-right" @click="allRawal">全部提现</view>
  78. </template>
  79. </tui-input>
  80. </view>
  81. <view class="popup-to">
  82. <text>提现至</text>
  83. <text>{{
  84. `${bankInfo.bankName}(${
  85. bankInfo.bankCard ? bankInfo.bankCard.slice(-4) : ""
  86. })`
  87. }}</text>
  88. </view>
  89. <view class="popup-btn" @click="confirmBtn">确认申请提现</view>
  90. </view>
  91. </tui-bottom-popup>
  92. </view>
  93. </template>
  94. <script>
  95. import { getWithdrawal, financeBank, applyWithdrawal } from "@/config/index";
  96. export default {
  97. onLoad(props) {
  98. // 余额
  99. this.balance = props.balance;
  100. // 交易金
  101. this.trading = props.trading;
  102. },
  103. onShow() {
  104. this.getAll();
  105. },
  106. computed: {
  107. popupText() {
  108. // 可提现{{ popupIdx == 1 ? "金额" : "交易金余额" }}:8483元
  109. if (this.popupIdx == 1) {
  110. return `可提现金额余额${this.balance}元`;
  111. } else {
  112. return `可提交易金余额${this.trading}元`;
  113. }
  114. },
  115. },
  116. data() {
  117. return {
  118. balance: "",
  119. trading: "",
  120. queryData: {
  121. page: 1,
  122. pageSize: 10,
  123. },
  124. // 提现记录列表
  125. withdrawalList: [],
  126. // 底部弹框控制
  127. showPopup: false,
  128. popupIdx: 1,
  129. // 弹窗的信息
  130. bankInfo: {},
  131. // 提现请求信息
  132. applyInfo: {
  133. bankCard: "",
  134. bankName: "",
  135. shopCode: "",
  136. shopName: "",
  137. withdrawalMoney: "",
  138. withdrawalType: "",
  139. },
  140. };
  141. },
  142. methods: {
  143. async getAll() {
  144. let { data } = await getWithdrawal(this.queryData);
  145. this.withdrawalList = [...this.withdrawalList, ...data];
  146. console.log(data);
  147. },
  148. // 去提现点击事件
  149. async goWithdClick() {
  150. this.showPopup = true;
  151. // 获取 bankInfo
  152. let { data } = await financeBank({});
  153. this.applyInfo.withdrawalMoney = this.balance;
  154. this.bankInfo = data;
  155. },
  156. // 确认申请提现
  157. async confirmBtn() {
  158. // 对数据进行判断
  159. if (
  160. this.applyInfo.withdrawalMoney >
  161. (this.popupIdx === 1 ? this.balance : this.trading)
  162. ) {
  163. this.$showToast("提现金额不能大于余额");
  164. return;
  165. }
  166. let { bankCard, bankName, shopCode, shopName } = this.bankInfo;
  167. // 对提交的信息进行处理
  168. this.applyInfo = {
  169. bankCard,
  170. bankName,
  171. shopCode,
  172. shopName,
  173. withdrawalMoney: this.applyInfo.withdrawalMoney,
  174. withdrawalType: this.popupIdx == 1 ? "1" : "2",
  175. };
  176. this.$loading.show("申请提现中");
  177. try {
  178. let res = await applyWithdrawal(this.applyInfo);
  179. if (res.code == "") {
  180. uni.redirectTo({
  181. url: "/pages_module/walSuccess/index",
  182. });
  183. }
  184. } finally {
  185. this.$loading.hide();
  186. }
  187. },
  188. // 提现类型点击
  189. changeIdx(val) {
  190. this.popupIdx = val;
  191. if (val == 1) {
  192. this.applyInfo.withdrawalMoney = this.balance;
  193. } else if (val == 2) {
  194. this.applyInfo.withdrawalMoney = this.trading;
  195. }
  196. },
  197. // 全部提现点击
  198. allRawal() {
  199. this.applyInfo.withdrawalMoney =
  200. this.popupIdx == 1 ? this.balance : this.trading;
  201. },
  202. // 关闭弹框事件
  203. clonePopup() {
  204. this.showPopup = false;
  205. },
  206. },
  207. // 触底加载
  208. onReachBottom() {
  209. if (this.withdrawalList.length < 10) return;
  210. this.queryData.page++;
  211. this.getAll();
  212. },
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. @import "./index.scss";
  217. </style>