index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="withdrawal">
  3. <view class="withdrawal-box">
  4. <view class="box-text">
  5. <text>可提现余额</text>
  6. <text>{{ financialData.withdrawableMoney }}</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 class="btn-box" v-for="item in popupList" :key="item.value" :class="popupIdx == item.value ? 'active' : ''" @click="changeIdx(item.value)">
  47. {{ item.name }}
  48. </view>
  49. <!-- <view
  50. class="btn-box"
  51. :class="popupIdx == 1 ? 'active' : ''"
  52. @click="changeIdx(1)"
  53. >正常支付订单</view
  54. >
  55. <view
  56. class="btn-box"
  57. :class="popupIdx == 2 ? 'active' : ''"
  58. @click="changeIdx(2)"
  59. >交易金</view
  60. > -->
  61. </view>
  62. </view>
  63. <view class="popup-amount">
  64. <text>提现金额</text>
  65. <text>{{ popupText }}</text>
  66. </view>
  67. <view class="popup-ipt">
  68. <tui-input
  69. type="number"
  70. :focus="true"
  71. :size="64"
  72. padding="16rpx 0rpx"
  73. :disabled="true"
  74. v-model="applyInfo.withdrawalMoney"
  75. >
  76. <template #left>
  77. <view class="ipt-left">¥</view>
  78. </template>
  79. <template #right>
  80. <view class="ipt-right" @click="allRawal">全部提现</view>
  81. </template>
  82. </tui-input>
  83. </view>
  84. <view class="popup-to">
  85. <text>提现至</text>
  86. <text>{{
  87. `${bankInfo.bankName}(${
  88. bankInfo.bankCard ? bankInfo.bankCard.slice(-4) : ""
  89. })`
  90. }}</text>
  91. </view>
  92. <view class="popup-btn" @click="confirmBtn">确认申请提现</view>
  93. </view>
  94. </tui-bottom-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import { getFinancial,getWithdrawal, financeBank, applyWithdrawal } from "@/config/index";
  99. export default {
  100. onShow() {
  101. this.getAll();
  102. this.getFinancialData()
  103. },
  104. computed: {
  105. popupText() {
  106. let item = this.popupList.find((item) => item.value == this.popupIdx);
  107. // 赋值
  108. this.applyInfo.withdrawalMoney = this.financialData[item.title];
  109. return `可提现${item.name}:${this.financialData[item.title]}元`;
  110. },
  111. },
  112. data() {
  113. return {
  114. queryData: {
  115. page: 1,
  116. pageSize: 10,
  117. withdrawalType:""
  118. },
  119. // 提现记录列表
  120. withdrawalList: [],
  121. // 底部弹框控制
  122. showPopup: false,
  123. popupIdx: 1,
  124. // 提现列表
  125. popupList:[
  126. {
  127. name:"余额",
  128. value:1,
  129. title:"withdrawableMoney"
  130. },
  131. {
  132. name:"交易金",
  133. value:2,
  134. title:"beeWithdrawal"
  135. },
  136. {
  137. name:"代金券",
  138. value:3,
  139. title:"voucherWithdrawal"
  140. },
  141. {
  142. name:"平台余额",
  143. value:4,
  144. title:"rechargeWithdrawalIn"
  145. },
  146. ],
  147. // 弹窗的信息
  148. bankInfo: {},
  149. // 提现请求信息
  150. applyInfo: {
  151. bankCard: "",
  152. bankName: "",
  153. shopCode: "",
  154. shopName: "",
  155. withdrawalMoney: "",
  156. withdrawalType: "",
  157. },
  158. // 提现数据
  159. financialData:{}
  160. };
  161. },
  162. methods: {
  163. // 获取提现总体数据
  164. async getFinancialData() {
  165. try {
  166. this.$loading.show("计算中...");
  167. const res = await getFinancial({condition: "1",time: "",paymentMode: 1,});
  168. this.financialData = res.data;
  169. } finally {
  170. this.$loading.hide();
  171. }
  172. },
  173. async getAll() {
  174. let { data } = await getWithdrawal(this.queryData);
  175. this.withdrawalList = [...this.withdrawalList, ...data];
  176. console.log(data);
  177. },
  178. // 去提现点击事件
  179. async goWithdClick() {
  180. this.showPopup = true;
  181. // 获取 bankInfo
  182. let { data } = await financeBank({});
  183. this.bankInfo = data;
  184. // 过滤出当前是什么提现模块
  185. let obj = this.popupList.find((item) => item.value == this.popupIdx);
  186. this.applyInfo.withdrawalMoney = this.financialData[obj.title];
  187. },
  188. // 确认申请提现
  189. async confirmBtn() {
  190. if(this.applyInfo.withdrawalMoney == 0){
  191. this.$showToast("您当前的提现额度为0");
  192. return;
  193. }
  194. // 对数据进行判断
  195. let { bankCard, bankName, shopCode, shopName } = this.bankInfo;
  196. // 对提交的信息进行处理
  197. this.applyInfo = {
  198. bankCard,
  199. bankName,
  200. shopCode,
  201. shopName,
  202. withdrawalMoney: this.applyInfo.withdrawalMoney,
  203. withdrawalType: this.popupIdx,
  204. };
  205. this.$loading.show("申请提现中");
  206. try {
  207. let res = await applyWithdrawal(this.applyInfo);
  208. if (res.code == "") {
  209. uni.redirectTo({
  210. url: "/pages_module/walSuccess/index",
  211. });
  212. }
  213. } finally {
  214. this.$loading.hide();
  215. }
  216. },
  217. // 提现类型点击
  218. changeIdx(val) {
  219. this.popupIdx = val;
  220. // 过滤出来当前点击的是哪一项
  221. let obj = this.popupList.find((item) => item.value == val);
  222. this.applyInfo.withdrawalType = this.financialData[obj.title];
  223. },
  224. // 全部提现点击
  225. allRawal() {
  226. return;
  227. },
  228. // 关闭弹框事件
  229. clonePopup() {
  230. this.showPopup = false;
  231. },
  232. },
  233. // 触底加载
  234. onReachBottom() {
  235. // if (this.withdrawalList.length < 10) return;
  236. // this.queryData.page++;
  237. // this.getAll();
  238. },
  239. };
  240. </script>
  241. <style lang="scss" scoped>
  242. @import "./index.scss";
  243. </style>