提现模块对接接口处理

This commit is contained in:
2021-09-27 10:56:22 +08:00
parent e6d503fec5
commit bc87a9223c
8 changed files with 801 additions and 462 deletions

View File

@@ -4,9 +4,9 @@
<image src="/static/imgs/account-bg.png" mode="aspectFill" class="record-bg" />
<view class="propery-content">
<view class="currency">能量球钱包
<!-- <span>( {{ price || '0.00' }} CNY)</span> -->
<span>( {{ cost || '0.00' }} CNY)</span>
</view>
<view class="balance">{{ balance.balance || '0.00' }}</view>
<view class="balance">{{ balance || '0.00' }}</view>
<view class="frozen" @click="withdrawDetail">提现记录</view>
</view>
</view>
@@ -14,98 +14,59 @@
<view class="item-name">
提现至银行卡
<view class="right">
<view class="cardName" @click="addCard">添加银行卡</view>
<uni-icons type="arrowright" size="12" color="#fff" />
</view>
</view>
<view class="item-name">
选择银行卡
<view class="right">
<view class="cardName" @click="selectCard">选择银行卡</view>
<view class="cardName" v-if="bank_accounts === 0" @click="addBanks">添加银行卡</view>
<view class="cardName" v-if='bank_accounts>0' @click="bankLists">{{bankInfo.name?bankInfo.name:'选择银行卡'}}</view>
<uni-icons type="arrowright" size="12" color="#fff" />
</view>
</view>
<view class="withdrawing-content">
<view class="item">
<view style="flex: 1;">
<input class="input_num" v-model="withdraw_input" @input='inputNum' type="number"
placeholder-style="color:#999;font-weight:normal; font-size:40rpx;"
placeholder="能量球数量" />
<view v-if="total"> {{total}}</view>
placeholder-style="color:#999;font-weight:normal; font-size:34rpx;" placeholder="提现数量" />
</view>
<view class="all" @click="all">全部提现</view>
</view>
</view>
<view class="btn" @click="open">提现至银行卡</view>
<view class="des">预计5- 10个工作日到账</view>
<view class="total" v-if="total">≈ ¥{{total}} </view>
<view class="btn" @click="actions">提现至银行卡</view>
<view class="des">预计5- 10个工作日到账 手续费: {{tax}}%</view>
</view>
</template>
<script>
import {
withdraw,
withdrawLogs,
withdrawDo
} from '@/apis/interfaces/wallet.js';
import numberJpan from "@/components/numberJpan/numberJpan.vue";
withdrawsIndexCreate,
withdrawsIndex
} from '@/apis/interfaces/withdraws';
export default {
data() {
return {
balance: 0, // 钱包能量球数量
price: 0, // 当前能量球价格
tax: 0, // 当前手续费
cost:1,// 每个能量球的价格
total:0,// 约合人民币
card: '', // 银行卡号
name: '', // 姓名
password: '', //
withdraw_input: '', // 提现能量球数量
total: '', // 提现能量球转化成的钱数
page: 1,
has_more: true,
withdrawLists: [],
bank_accounts: 0,
bankInfo:{}
};
},
components: {
'number-jpan': numberJpan
},
onLoad() {
this.reset()
this.getInfo()
},
onReachBottom() {
if (this.withdrawLists.length > 0) {
if (this.has_more) {
this.withdrawLogs()
} else {
uni.showToast({
title: '没有更多~',
icon: 'none'
})
}
}
},
methods: {
// 提现基本信息
withdraw() {
withdraw().then(res => {
this.balance = Number(res.balance)
this.price = Number(res.price)
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
// 提现记录
withdrawLogs() {
withdrawLogs({
page: this.page
}).then(res => {
this.withdrawLists = this.withdrawLists.concat(res.data)
if (res.page.has_more) {
this.page = this.page + 1
this.has_more = true
} else {
this.has_more = false
}
getInfo() {
withdrawsIndexCreate().then(res => {
this.balance = res.balance
this.tax = res.tax
this.cost = res.cost
this.bank_accounts = res.bank_accounts.length
}).catch(err => {
uni.showToast({
title: err.message,
@@ -117,7 +78,7 @@
inputNum(e) {
let number = Number(e.detail.value)
if (number <= this.balance) {
this.total = Number(e.detail.value) * this.price
this.total = Number(e.detail.value) * this.cost
} else {
uni.showToast({
title: '最大值能超过' + this.balance + '',
@@ -133,7 +94,7 @@
all() {
if (this.balance > 0) {
this.withdraw_input = this.balance
this.total = this.balance * this.price
this.total = this.balance * this.cost
} else {
uni.showToast({
title: '啥也没有我也做不到~',
@@ -142,84 +103,63 @@
})
}
},
// 打开密码 出发提现功能
open() {
if (this.total > 0) {
let params = {
name: this.name,
card: this.card,
total: this.withdraw_input
}
if (params.name === '' || params.card === '' || params.total === 0) {
uni.showToast({
title: '重新确认提现信息',
icon: 'none',
duration: 2000
})
} else {
this.$refs.numberPad.open()
}
} else {
uni.showToast({
title: '啥也没有,我也做不到~',
icon: 'none',
duration: 2000
})
// 提现
actions(){
let data = {
bank_account_id:this.bankInfo.bank_account_id,
amount:Number(this.withdraw_input)
}
},
// 输入密码成功后,,,
closeChange(e) {
uni.showLoading({
title: '提现中~'
})
let params = {
name: this.name,
card: this.card,
total: this.withdraw_input,
code: e
if(data.bank_account_id === undefined || data.bank_account_id === null || data.bank_account_id === ''){
uni.showToast({
title:this.bank_accounts>0?'请选择银行卡':'请添加银行卡',
icon:'none'
})
return;
}
withdrawDo(params).then(res => {
uni.showToast({
title: '申请提现成功,耐心等待打款',
icon: 'none',
duration: 2000
})
this.reset()
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none',
duration: 2000
})
uni.showModal({
title:'温馨提示',
content:'您是否确认提现将会扣除' +this.tax+'%手续费' ,
confirmColor:'#7c52fc',
cancelColor:'#cacaca',
cancelText:'我再想想',
confirmText:'确认提现',
success: (res) => {
if(res.confirm){
withdrawsIndex(data).then(res=>{
uni.showToast({
title:res.message,
icon:'none'
})
this.withdraw_input = ''
this.total = ''
this.getInfo()
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
}
})
},
reset() {
this.name = ''
this.card = ''
this.page = 1
this.has_more = true
this.withdraw_input = ''
this.total = 0
this.withdrawLists = []
this.withdrawLogs();
this.withdraw();
},
// 添加银行卡
addCard() {
addBanks() {
uni.navigateTo({
url:'/pages/wallet/addCard'
url: '/pages/wallet/addBank'
})
},
// 选择银行卡
selectCard(){
bankLists() {
uni.navigateTo({
url:'/pages/wallet/selectCard'
url: '/pages/wallet/bankList'
})
},
// 提现记录
withdrawDetail(){
withdrawDetail() {
uni.navigateTo({
url:'/pages/wallet/withdrawList'
url: '/pages/wallet/withdrawList'
})
}
}
@@ -232,12 +172,14 @@
min-height: 100vh;
background-color: #f7f7f7;
}
.receiptCode {
color: #808080;
text-align: left;
// margin: $margin 0;
font-size: $title-size-m;
}
.WithdrawingCoin {
background-color: #f7f7f7;
width: 100%;
@@ -262,6 +204,7 @@
opacity: .5;
transform: rotate(-7deg);
}
.propery-content {
position: relative;
z-index: 1;
@@ -292,11 +235,13 @@
}
}
.all {
color: $text-price;
width: 160rpx;
text-align: center;
}
.item-name {
text-align: center;
color: #303030;
@@ -326,6 +271,7 @@
}
}
}
.withdrawing-content {
background-color: #fff;
padding: $padding $padding $padding $padding * 2;
@@ -390,6 +336,7 @@
}
}
.btn {
background-image: linear-gradient(to right, #7c52fc, #976dff);
color: #fff;
@@ -400,9 +347,17 @@
font-size: $title-size;
font-weight: bold;
}
.des{
.des {
text-align: center;
color: #cacaca;
font-size: 26rpx;
}
.total {
color: $mian-color;
margin-top: 20rpx;
margin-left: 50rpx;
font-size: 36rpx;
}
</style>