123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <template>
- <view class="container">
- <JHeader title="提现" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
- <view class="addressBack-box">
- <view class="bankTag-box bor-line-F7F7F7 flex-row-plus flex-sp-between flex-items" @click="handleBankTagClick">
- <view class="fs28 addressTag">银行卡</view>
- <view>
- <label>{{ bankCardNum }}</label>
- <tui-icon name="arrowright" :size="48" unit="upx" color="#b19970" margin="0 20upx 0 0"></tui-icon>
- </view>
- </view>
- <view style="margin-top: 20upx;font-size: 28upx;">
- 可提现金额:{{ price || 0 }}元
- </view>
- <view class="consignee-box bor-line-F7F7F7">
- <input
- v-model="withdrawalAmount" type="number" maxlength="9" class="fs28"
- placeholder-class="consignee"
- placeholder="请输入提现金额(元)" @input="applycheck"
- />
- </view>
- <view style="color: red;margin-top: 10upx;">{{ errMsg }}</view>
- <view v-if="!errMsg" style="margin-top: 10upx;text-align: right;">
- 手续费:{{ typeof withdrawCharge === 'number' ? withdrawCharge : '--' }} 元
- </view>
- <view class="apply-box">
- <view class="apply-withdraw" @click="applyWithdraw">申请提现</view>
- </view>
- </view>
- <view v-if="withdrawHistoryList && withdrawHistoryList.length" class="withdraw-history">
- <view class="history-list">
- <view class="history-head">
- <label class="history-label fs30 font-color-333">历史记录</label>
- </view>
- <view v-for="(item, index) in withdrawHistoryList" :key="index" class="history-content">
- <view class="withdraw-detail flex-items flex-sp-between">
- <view class="detail-top">
- <view class="fs24 font-color-999 mar-top-10">流水号:{{ item.orderSn || '--' }}</view>
- <view class="fs24 font-color-999">银行卡号:{{ item.bankCard }}</view>
- <view style="font-size: 24upx;color: #999999;">手续费:¥{{ item.cost }}</view>
- <view class="fs24 font-color-999 mar-top-10">{{ item.createTime }}</view>
- </view>
- <view>
- <view class="detail-bottom text-align fs28 font-color-333">
- <text v-if="item.state == 0">审核中</text>
- <text v-else-if="item.state == 1">通过</text>
- <text v-else-if="item.state == 2">拒绝</text>
- <text v-else-if="item.state == 3">打款成功</text>
- <text v-else-if="item.state == 4">打款失败</text>
- <text v-else>--</text>
- </view>
- <view class="apply-balance">提现¥{{ item.withdrawalMoney }}</view>
- <view style="font-size: 28upx;color: #201f1f;text-align: center;">到账¥{{ item.actualReceipt }}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 弹窗 -->
- <tui-select
- :list="bankcardselectList" reverse :show="bankTagShowFlag" @confirm="bankcardConfirm"
- @close="bankTagShowFlag = false"
- ></tui-select>
- </view>
- </template>
- <script>
- import { getPricePlatformAllApi, getAllBankcardListApi, updateSaveDistributorWithdrawApi, getCommissionBankApi } from '../../../api/anotherTFInterface'
- import { handleDebounce } from '../../../utils'
- export default {
- name: 'Withdraw',
- filters: {
- parseMoney(money) {
- return parseFloat(money / 100).toFixed(2)
- },
- parseStatus(status) {
- if (status == 0) {
- return '审核中'
- } else if (status == 1) {
- return '已通过'
- }
- return '已拒绝'
- }
- },
- data() {
- return {
- // 银行卡数据
- bankcardList: [],
- bankcardselectList: [ { value: '', label: '' } ],
- bankCardNum: '',
- bankName: '',
- bankTagShowFlag: false,
- // 提现数据
- price: 0,
- withdrawHistoryList: [],
- withdrawalAmount: '',
- errMsg: '',
- // 手续费
- withdrawCharge: '',
- handleDebounce: ''
- }
- },
- onLoad(options) {
- this.handleDebounce = handleDebounce(this.getCommission, 500)
- this.initBankcardList()
- this.getBalance()
- },
- watch: {
- withdrawalAmount(value) {
- if ((value + '').includes('.') && (value + '').split('.')[1].length > 2) {
- this.errMsg = '提现金额错误'
- } else if (value === '') {
- this.errMsg = '提现金额不能为空'
- } else if (value === 0) {
- this.errMsg = '提现金额不能等于零'
- } else if (value < 1) {
- this.errMsg = '提现金额不能小于1元'
- } else if (value > this.price) {
- this.errMsg = '余额不足,请重新输入申请金额'
- } else if (parseFloat(value) > 1000000) {
- this.errMsg = '提现金额不能超过1000000'
- } else {
- this.errMsg = ''
- this.handleDebounce()
- }
- }
- },
- methods: {
- getCommission() {
- getCommissionBankApi({ amount: this.withdrawalAmount })
- .then((res) => {
- this.withdrawCharge = res.data.cost
- })
- },
- getBalance() {
- getPricePlatformAllApi({}).then((res) => {
- this.price = res.data.price
- this.withdrawHistoryList = res.data.withdrawals
- })
- },
- applycheck(e) {
- // 正则表达试
- e.target.value = e.target.value.match(/^\d*(\.?\d{0,2})/g)[0] || null
- // 重新赋值给input
- this.$nextTick(() => {
- this.withdrawalAmount = e.target.value
- })
- },
- initBankcardList() {
- this.bankcardselectList = []
- getAllBankcardListApi({
- page: 1,
- pageSize: 100
- }).then((res) => {
- this.bankcardList = res.data
- for (let i = 0; i < this.bankcardList.total; i++) {
- this.bankcardselectList.push({ value: this.bankcardList.list[i].bankCard, text: this.bankcardList.list[i].bankName })
- }
- })
- },
- bankcardConfirm(e) {
- this.bankTagShowFlag = false
- this.bankCardNum = e.options.value
- this.bankName = e.options.text
- },
- handleBankTagClick() {
- if (this.bankcardList.total > 0) {
- this.bankTagShowFlag = true
- } else {
- uni.showToast({
- title: '你还没有添加银行卡~',
- duration: 2000,
- icon: 'none'
- })
- setTimeout(() => {
- this.go('/another-tf/another-serve/bankcard/addBankcard')
- }, 2000)
- }
- },
- applyWithdraw() {
- if (this.errMsg || !this.withdrawalAmount) {
- uni.showToast({
- title: '提现金额有误',
- duration: 2000,
- icon: 'none'
- })
- } else if (!this.withdrawCharge) {
- uni.showToast({
- title: '手续费错误',
- duration: 2000,
- icon: 'none'
- })
- } else if (!this.bankCardNum) {
- uni.showToast({
- title: '请选择银行卡',
- duration: 2000,
- icon: 'none'
- })
- } else {
- uni.showLoading()
- updateSaveDistributorWithdrawApi({
- bankName: this.bankName,
- bankCard: this.bankCardNum,
- withdrawalMoney: this.withdrawalAmount
- }).then((res) => {
- uni.hideLoading()
- uni.showToast({
- title: '申请成功',
- duration: 2000,
- icon: 'none'
- })
- this.withdrawalAmount = ''
- this.$nextTick(() => {
- this.errMsg = ''
- })
- this.getBalance()
- this.initBankcardList()
- })
- .catch((e) => {
- uni.hideLoading()
- })
- }
- // else {
- // let dotPos = this.withdrawalAmount.indexOf(".")
- // let length = this.withdrawalAmount.length
- // console.log(dotPos,222)
- // console.log(length,333)
- // if (length - dotPos > 3) {
- // uni.showToast({
- // title: "提现金额只能精确到小数点后两位",
- // duration: 2000,
- // icon: 'none'
- // })
- // return
- // }
- // }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .container {
- min-height: 100vh;
- padding: 20rpx;
- background-color: #F8F8F8;
- .addressBack-box {
- background-color: #FFFFFF;
- padding: 30upx 30upx;
- .consignee-box {
- padding-bottom: 36upx;
- width: 690upx;
- margin-top: 20upx;
- .consignee {
- color: #999999;
- font-size: 28upx;
- }
- }
- .apply-withdraw {
- width: 100%;
- height: 100upx;
- line-height: 100upx;
- color: #FFEBC4;
- text-align: center;
- background: #333333;
- margin: 0 auto;
- margin-top: 20rpx;
- }
- .bankTag-box {
- padding-bottom: 19px;
- .addressTag {
- color: #999999
- }
- }
- }
- .withdraw-history {
- margin-top: 14rpx;
- .history-list {
- background: white;
- padding: 30rpx;
- .history-label {
- height: 92rpx;
- line-height: 92rpx;
- }
- .history-content {
- border-top: 2rpx solid #F3F4F5;
- .withdraw-detail {
- height: 150rpx;
- .apply-balance {
- padding: 10upx 20upx;
- font-size: 24upx;
- background: #EEEEEE;
- display: block;
- text-align: center;
- color: #696868;
- }
- }
- }
- }
- }
- }
- </style>
|