index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="container">
  3. <JHeader title="提现" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="addressBack-box">
  5. <view class="bankTag-box bor-line-F7F7F7 flex-row-plus flex-sp-between flex-items" @click="handleBankTagClick">
  6. <view class="fs28 addressTag">银行卡</view>
  7. <view>
  8. <label>{{ bankCardNum }}</label>
  9. <tui-icon name="arrowright" :size="48" unit="upx" color="#b19970" margin="0 20upx 0 0"></tui-icon>
  10. </view>
  11. </view>
  12. <view style="margin-top: 20upx;font-size: 28upx;">
  13. 可提现金额:{{ price || 0 }}元
  14. </view>
  15. <view class="consignee-box bor-line-F7F7F7">
  16. <input
  17. v-model="withdrawalAmount" type="number" maxlength="9" class="fs28"
  18. placeholder-class="consignee"
  19. placeholder="请输入提现金额(元)" @input="applycheck"
  20. />
  21. </view>
  22. <view style="color: red;margin-top: 10upx;">{{ errMsg }}</view>
  23. <view v-if="!errMsg" style="margin-top: 10upx;text-align: right;">
  24. 手续费:{{ typeof withdrawCharge === 'number' ? withdrawCharge : '--' }} 元
  25. </view>
  26. <view class="apply-box">
  27. <view class="apply-withdraw" @click="applyWithdraw">申请提现</view>
  28. </view>
  29. </view>
  30. <view v-if="withdrawHistoryList && withdrawHistoryList.length" class="withdraw-history">
  31. <view class="history-list">
  32. <view class="history-head">
  33. <label class="history-label fs30 font-color-333">历史记录</label>
  34. </view>
  35. <view v-for="(item, index) in withdrawHistoryList" :key="index" class="history-content">
  36. <view class="withdraw-detail flex-items flex-sp-between">
  37. <view class="detail-top">
  38. <view class="fs24 font-color-999 mar-top-10">流水号:{{ item.orderSn || '--' }}</view>
  39. <view class="fs24 font-color-999">银行卡号:{{ item.bankCard }}</view>
  40. <view style="font-size: 24upx;color: #999999;">手续费:¥{{ item.cost }}</view>
  41. <view class="fs24 font-color-999 mar-top-10">{{ item.createTime }}</view>
  42. </view>
  43. <view>
  44. <view class="detail-bottom text-align fs28 font-color-333">
  45. <text v-if="item.state == 0">审核中</text>
  46. <text v-else-if="item.state == 1">通过</text>
  47. <text v-else-if="item.state == 2">拒绝</text>
  48. <text v-else-if="item.state == 3">打款成功</text>
  49. <text v-else-if="item.state == 4">打款失败</text>
  50. <text v-else>--</text>
  51. </view>
  52. <view class="apply-balance">提现¥{{ item.withdrawalMoney }}</view>
  53. <view style="font-size: 28upx;color: #201f1f;text-align: center;">到账¥{{ item.actualReceipt }}</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 弹窗 -->
  60. <tui-select
  61. :list="bankcardselectList" reverse :show="bankTagShowFlag" @confirm="bankcardConfirm"
  62. @close="bankTagShowFlag = false"
  63. ></tui-select>
  64. </view>
  65. </template>
  66. <script>
  67. import { getPricePlatformAllApi, getAllBankcardListApi, updateSaveDistributorWithdrawApi, getCommissionBankApi } from '../../../api/anotherTFInterface'
  68. import { handleDebounce } from '../../../utils'
  69. export default {
  70. name: 'Withdraw',
  71. filters: {
  72. parseMoney(money) {
  73. return parseFloat(money / 100).toFixed(2)
  74. },
  75. parseStatus(status) {
  76. if (status == 0) {
  77. return '审核中'
  78. } else if (status == 1) {
  79. return '已通过'
  80. }
  81. return '已拒绝'
  82. }
  83. },
  84. data() {
  85. return {
  86. // 银行卡数据
  87. bankcardList: [],
  88. bankcardselectList: [ { value: '', label: '' } ],
  89. bankCardNum: '',
  90. bankName: '',
  91. bankTagShowFlag: false,
  92. // 提现数据
  93. price: 0,
  94. withdrawHistoryList: [],
  95. withdrawalAmount: '',
  96. errMsg: '',
  97. // 手续费
  98. withdrawCharge: '',
  99. handleDebounce: ''
  100. }
  101. },
  102. onLoad(options) {
  103. this.handleDebounce = handleDebounce(this.getCommission, 500)
  104. this.initBankcardList()
  105. this.getBalance()
  106. },
  107. watch: {
  108. withdrawalAmount(value) {
  109. if ((value + '').includes('.') && (value + '').split('.')[1].length > 2) {
  110. this.errMsg = '提现金额错误'
  111. } else if (value === '') {
  112. this.errMsg = '提现金额不能为空'
  113. } else if (value === 0) {
  114. this.errMsg = '提现金额不能等于零'
  115. } else if (value < 1) {
  116. this.errMsg = '提现金额不能小于1元'
  117. } else if (value > this.price) {
  118. this.errMsg = '余额不足,请重新输入申请金额'
  119. } else if (parseFloat(value) > 1000000) {
  120. this.errMsg = '提现金额不能超过1000000'
  121. } else {
  122. this.errMsg = ''
  123. this.handleDebounce()
  124. }
  125. }
  126. },
  127. methods: {
  128. getCommission() {
  129. getCommissionBankApi({ amount: this.withdrawalAmount })
  130. .then((res) => {
  131. this.withdrawCharge = res.data.cost
  132. })
  133. },
  134. getBalance() {
  135. getPricePlatformAllApi({}).then((res) => {
  136. this.price = res.data.price
  137. this.withdrawHistoryList = res.data.withdrawals
  138. })
  139. },
  140. applycheck(e) {
  141. // 正则表达试
  142. e.target.value = e.target.value.match(/^\d*(\.?\d{0,2})/g)[0] || null
  143. // 重新赋值给input
  144. this.$nextTick(() => {
  145. this.withdrawalAmount = e.target.value
  146. })
  147. },
  148. initBankcardList() {
  149. this.bankcardselectList = []
  150. getAllBankcardListApi({
  151. page: 1,
  152. pageSize: 100
  153. }).then((res) => {
  154. this.bankcardList = res.data
  155. for (let i = 0; i < this.bankcardList.total; i++) {
  156. this.bankcardselectList.push({ value: this.bankcardList.list[i].bankCard, text: this.bankcardList.list[i].bankName })
  157. }
  158. })
  159. },
  160. bankcardConfirm(e) {
  161. this.bankTagShowFlag = false
  162. this.bankCardNum = e.options.value
  163. this.bankName = e.options.text
  164. },
  165. handleBankTagClick() {
  166. if (this.bankcardList.total > 0) {
  167. this.bankTagShowFlag = true
  168. } else {
  169. uni.showToast({
  170. title: '你还没有添加银行卡~',
  171. duration: 2000,
  172. icon: 'none'
  173. })
  174. setTimeout(() => {
  175. this.go('/another-tf/another-serve/bankcard/addBankcard')
  176. }, 2000)
  177. }
  178. },
  179. applyWithdraw() {
  180. if (this.errMsg || !this.withdrawalAmount) {
  181. uni.showToast({
  182. title: '提现金额有误',
  183. duration: 2000,
  184. icon: 'none'
  185. })
  186. } else if (!this.withdrawCharge) {
  187. uni.showToast({
  188. title: '手续费错误',
  189. duration: 2000,
  190. icon: 'none'
  191. })
  192. } else if (!this.bankCardNum) {
  193. uni.showToast({
  194. title: '请选择银行卡',
  195. duration: 2000,
  196. icon: 'none'
  197. })
  198. } else {
  199. uni.showLoading()
  200. updateSaveDistributorWithdrawApi({
  201. bankName: this.bankName,
  202. bankCard: this.bankCardNum,
  203. withdrawalMoney: this.withdrawalAmount
  204. }).then((res) => {
  205. uni.hideLoading()
  206. uni.showToast({
  207. title: '申请成功',
  208. duration: 2000,
  209. icon: 'none'
  210. })
  211. this.withdrawalAmount = ''
  212. this.$nextTick(() => {
  213. this.errMsg = ''
  214. })
  215. this.getBalance()
  216. this.initBankcardList()
  217. })
  218. .catch((e) => {
  219. uni.hideLoading()
  220. })
  221. }
  222. // else {
  223. // let dotPos = this.withdrawalAmount.indexOf(".")
  224. // let length = this.withdrawalAmount.length
  225. // console.log(dotPos,222)
  226. // console.log(length,333)
  227. // if (length - dotPos > 3) {
  228. // uni.showToast({
  229. // title: "提现金额只能精确到小数点后两位",
  230. // duration: 2000,
  231. // icon: 'none'
  232. // })
  233. // return
  234. // }
  235. // }
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="less" scoped>
  241. .container {
  242. min-height: 100vh;
  243. padding: 20rpx;
  244. background-color: #F8F8F8;
  245. .addressBack-box {
  246. background-color: #FFFFFF;
  247. padding: 30upx 30upx;
  248. .consignee-box {
  249. padding-bottom: 36upx;
  250. width: 690upx;
  251. margin-top: 20upx;
  252. .consignee {
  253. color: #999999;
  254. font-size: 28upx;
  255. }
  256. }
  257. .apply-withdraw {
  258. width: 100%;
  259. height: 100upx;
  260. line-height: 100upx;
  261. color: #FFEBC4;
  262. text-align: center;
  263. background: #333333;
  264. margin: 0 auto;
  265. margin-top: 20rpx;
  266. }
  267. .bankTag-box {
  268. padding-bottom: 19px;
  269. .addressTag {
  270. color: #999999
  271. }
  272. }
  273. }
  274. .withdraw-history {
  275. margin-top: 14rpx;
  276. .history-list {
  277. background: white;
  278. padding: 30rpx;
  279. .history-label {
  280. height: 92rpx;
  281. line-height: 92rpx;
  282. }
  283. .history-content {
  284. border-top: 2rpx solid #F3F4F5;
  285. .withdraw-detail {
  286. height: 150rpx;
  287. .apply-balance {
  288. padding: 10upx 20upx;
  289. font-size: 24upx;
  290. background: #EEEEEE;
  291. display: block;
  292. text-align: center;
  293. color: #696868;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. </style>