index.vue 7.2 KB

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