Files
kangyuan-mobile/pages/home/pay/withdraw.vue
T

468 lines
10 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<s-pages title="提现" :pink_bg="true">
<view class="pages p-y-28 p-x-40 c0">
<!-- <view class="m-b-20 tab-header">
<text class="tab-item" :class="{ active: type === 'yougou' }" @click="changeType('yougou')">优购提现</text>
<text class="tab-item m-l-20" :class="{ active: type === 'huamao' }"
@click="changeType('huamao')">华贸提现</text>
</view> -->
<view v-if="type === 'yougou'">
<view class="bg24 radius12 m-b-32 p-y-30 p-x-28">
<view class="flex-center ju-between">
<view class="title c0">收款人</view>
<view class="c33 flex-center" @click="select"><span style="color: #333">选择</span>
<uni-icons class="m-l-10" type="right" color="#333" size="16" />
</view>
</view>
<view class="flex-center border-bottom" style="height: 100rpx" v-for="(v, i) in list" :key="i">
<view class="c0">{{ v.title }}</view>
<uni-easyinput style="text-align: right" class="flex1" v-model="dataObj[v.value]"
:type="v.type || 'text'" :placeholder="v.placeholder" :inputBorder="false"
@input="(e) => inputChange(e, v)" />
</view>
</view>
</view>
<view class="bg24 radius12 p-y-30 p-x-28 card2 pay">
<view class="weight500 c0">提现金额</view>
<view class="m-b-26 flex-row border-bottom">
<span class="size92 c0 m-r-32">¥</span>
<uni-easyinput class="flex1" v-model="dataObj.price" type="number" placeholder=""
placeholder-style="font-size: 92rpx;" @confirm="onSubmit" :inputBorder="false" :min="0"
:clearSize="50" />
<!-- @blur="blur" -->
</view>
<view class="m-b-12 c0">
当前可提现<span>{{ point }}</span>元, <span class="c3" @click="dataObj.price = point">全部提现</span>
</view>
<view></view>
</view>
<view class="size24 m-t-36 m-b-74 line46">
<view class="c0">
<view>
<span class="c_FF2D2D">*</span>
{{
`提现费率为${config.brokerageWithdrawFeePercent}%,最低提现金额为${config.brokerageWithdrawMinPrice}元`
}}
</view>
<view>
<span class="c_FF2D2D">*</span>
{{ `提现时间为${config.brokerageWithdrawTime}` }}
</view>
<!-- <view>
<span class="c_FF2D2D">*</span>
一天(24小时)内只可提现1次
</view> -->
</view>
</view>
<view class="submit-btn" @click="onSubmit">提现</view>
<view class="c2 record"><span @click="goUrl">提现记录</span></view>
<uni-popup ref="popupRef" type="center" border-radius="12rpx" background-color="#fff">
<view class="pop-bar">
<view class="close" @click="popClose()"> × </view>
<view class="img-box">
<image :src="$ygUrl + 'realname_icon.png'" />
</view>
<view class="size40 line56"> 请您补全您的实名信息 </view>
<view class="txt2 size32 line44 m-t-16">
为了保障您的账户安全,请尽快 <br />
补全您的实名身份信息
</view>
<view class="btn m-t-50" @click="goReal()"> 去认证 </view>
</view>
</uni-popup>
</view>
</s-pages>
</template>
<script setup>
import {
ref,
getCurrentInstance
} from 'vue';
import {
onLoad,
onShow
} from '@dcloudio/uni-app';
import * as api from '@/sheep/api/home/pay';
import TradeConfigApi from '@/sheep/api/trade/config';
import sheep from '@/sheep';
import popup from '@/uni_modules/uni-popup/components/uni-popup/popup';
import UserApi from '@/sheep/api/member/user';
let realStatus = ref(0); //是否已经实名认证
const popupRef = ref();
const type = ref('yougou');
const goUrl = () => {
uni.navigateTo({
url: '/pages/home/pay/withdrawRecord',
});
};
const changeType = (t) => {
type.value = t;
};
const {
proxy
} = getCurrentInstance();
let list = ref([{
title: '姓名',
value: 'userName',
placeholder: '请输入姓名',
},
{
title: '账号',
value: 'userAccount',
// type: 'number',
placeholder: '请输入银行账号',
},
{
title: '银行',
value: 'bankName',
placeholder: '请输入银行名称',
},
{
title: '支行',
value: 'bankAddress',
placeholder: '请输入支行名称',
},
]);
let dataObj = ref({
type: 1,
transferChannelCode: 'wx_lite',
price: 0,
});
let point = ref(0);
const getData = () => {
UserApi.getUserInfo().then((res) => {
realStatus.value = res.data.realStatus;
// console.log(realStatus.value);
});
api.getWallet().then((res) => {
if (res.code === 0) {
point.value = proxy.$fen2yuan(res.data.withdrawAmount);
}
});
};
const goReal = () => {
uni.redirectTo({
url: '/pages/public/realname?status=' + realStatus.value,
// query: obj,
});
popupRef.value.close();
};
const popClose = () => {
popupRef.value.close();
};
const onSubmit = () => {
if (type.value === 'yougou') {
submit();
} else {
submit2();
}
};
// 提现
const submit = () => {
//未实名不能去提现
if (realStatus.value === 0) {
popupRef.value.open('center');
return;
}
let monney = Number(dataObj.value.price);//输入框提现金额
let minMoney = config.value.brokerageWithdrawMinPrice;// 提现最小金额
// console.log(monney,minMoney);
if (monney < minMoney) {
sheep.$helper.toast(`提现金额不能小于${minMoney}元`);
return;
}
if (monney > Number(point.value)) {
sheep.$helper.toast('提现金额不能大于可提现金额');
dataObj.value.price = point.value;
return;
}
if (!dataObj.value.userName) {
sheep.$helper.toast('请输入姓名');
return;
}
if (!dataObj.value.userAccount) {
sheep.$helper.toast('请输入账号账号');
return;
}
if (!dataObj.value.bankName) {
sheep.$helper.toast('请输入银行名称');
return;
}
if (!dataObj.value.bankAddress) {
sheep.$helper.toast('请输入支行名称');
return;
}
if (!dataObj.value.price) {
sheep.$helper.toast('请输入提现金额');
return;
}
let obj = JSON.parse(JSON.stringify(dataObj.value));
obj.price = obj.price * 100;
api.createBrokerageWithdraw(obj).then((res) => {
if (res.code === 0) {
dataObj.value = {
type: 2,
transferChannelCode: 'wx_lite',
price: 0,
};
getData();
}
// console.log(res);
});
};
//huamao提现
function submit2() {
let monney = Number(dataObj.value.price);//输入框提现金额
let minMoney = config.value.brokerageWithdrawMinPrice;// Huamao提现最小金额
// console.log(monney,minMoney);
if (monney < minMoney) {
sheep.$helper.toast(`提现金额不能小于${minMoney}元`);
return;
}
if (monney > Number(point.value)) {
sheep.$helper.toast('提现金额不能大于可提现金额');
dataObj.value.price = point.value;
return;
}
api.hmPayExpenditure({
price: monney * 100,
}).then((res) => {
if (res.code === 0) {
dataObj.value = {
type: 2,
transferChannelCode: 'wx_lite',
price: 0,
};
getData();
}
// console.log(res);
});
}
const blur = () => {
// console.log(config.value.brokerageWithdrawMinPrice);
if (Number(dataObj.value.price) < 0) {
sheep.$helper.toast('提现金额不能小于0');
dataObj.value.price = 0;
return;
}
if (Number(dataObj.value.price) < proxy.$fen2yuan(config.value.brokerageWithdrawMinPrice)) {
sheep.$helper.toast(`提现金额不能小于${proxy.$fen2yuan(config.value.brokerageWithdrawMinPrice)}元`);
return;
}
if (Number(dataObj.value.price) > Number(point.value)) {
sheep.$helper.toast('提现金额不能大于可提现金额');
dataObj.value.price = point.value;
return;
}
};
const inputChange = (e, v) => {
let obj = {
bankNo: e.detail.value,
};
if (v.value == 'userAccount') {
api.getBank(obj).then((res) => {
if (res.code === 0) {
console.log(res);
dataObj.value.bankName = res.data;
}
});
}
};
let bankList = ref([]);
let bankText = ref([]);
const getBankList = () => {
api.getBankList({}).then((res) => {
if (res.code === 0) {
res.data.forEach((item) => {
// 取银行卡后四位
item.text = `${item.bankName}(${item.cardNumber.slice(-4)})`;
bankText.value.push(item.text);
});
bankList.value = res.data;
if (res?.data?.length) {
let obj = res.data[0];
dataObj.value = {
...dataObj.value,
userName: obj.trueName,
userAccount: obj.cardNumber,
bankName: obj.bankName,
bankAddress: obj.bankAddress,
};
}
}
});
};
const select = () => {
uni.showActionSheet({
itemList: bankText.value,
success: ({
tapIndex
}) => {
let obj = bankList.value[tapIndex];
dataObj.value = {
...dataObj.value,
userName: obj.trueName,
userAccount: obj.cardNumber,
bankName: obj.bankName,
};
},
fail: (error) => { },
});
};
let config = ref({
brokerageWithdrawMinPrice: 0,
brokerageWithdrawFeePercent: 0,
brokerageWithdrawTime: '',
});
onLoad(() => {
getBankList();
});
onShow(async () => {
getData();
getBankList();
let {
code,
data
} = await TradeConfigApi.getTradeConfig();
if (code === 0) {
config.value.brokerageWithdrawMinPrice = Number(proxy.$fen2yuan(data.brokerageWithdrawMinPrice));
config.value.brokerageWithdrawFeePercent = data.brokerageWithdrawFeePercent;
config.value.brokerageWithdrawTime = data.brokerageWithdrawTime;
console.log(config.value);
}
});
</script>
<style scoped lang="scss">
.pop-bar {
padding: 46rpx 28rpx;
position: relative;
.close {
width: 56rpx;
height: 56rpx;
line-height: 56rpx;
background: #dddddd;
border-radius: 50%;
color: #000;
position: absolute;
right: -24rpx;
top: -24rpx;
}
.img-box {
width: 372rpx;
height: 380rpx;
margin: 0 auto;
image {
width: 100%;
height: 100%;
}
}
.txt2 {
color: #676767;
}
.btn {
width: 608rpx;
height: 82rpx;
line-height: 82rpx;
text-align: center;
background: linear-gradient(130deg, #fa8735 0%, #fe3b48 100%);
border-radius: 12rpx;
color: #fff;
}
}
.record {
text-align: center;
padding: 36rpx 0;
font-size: 26rpx;
}
.bc_white {
background-color: #fff;
}
:deep(.uni-icons) {
font-size: 24rpx !important;
}
.pay {
:deep(.uni-easyinput__content) {
height: 108rpx;
font-size: 92rpx;
}
:deep(.uni-easyinput__content-input) {
height: 108rpx;
font-size: 92rpx;
}
:deep(.uni-easyinput__placeholder-class) {
font-size: 92rpx;
}
}
:deep(.uni-input-input) {
// color: #ffffff;
}
.infotext {
height: 62rpx;
background: #f2f2f2;
border-radius: 12rpx;
}
.c_FA7E31 {
color: #fa7e31;
}
.c_FF2D2D {
color: #ff2d2d;
}
.c_666 {
color: #666;
}
.size92 {
font-size: 92rpx;
}
:deep(.uniui-left) {
font-size: 44rpx !important;
}
:deep(.uni-icons) {
font-size: 44rpx !important;
}
.tab-header {
display: flex;
}
.tab-item {
font-size: 30rpx;
padding-bottom: 10rpx;
}
.active {
color: #ff5040;
border-bottom: 4rpx solid #ff5040;
}
</style>