553 行
17 KiB
Vue
553 行
17 KiB
Vue
<template>
|
||
<s-layout :title="state.walletType === 'madow' ? 'dmepa提现' : '申请提现'" class="withdraw-wrap" navbar="inner">
|
||
<!-- <view class="page-bg"></view> -->
|
||
<view
|
||
class="wallet-num-box ss-flex ss-col-center ss-row-between"
|
||
:style="[
|
||
{
|
||
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
|
||
paddingTop: Number(statusBarHeight + 108) + 'rpx',
|
||
},
|
||
]"
|
||
>
|
||
<view class="" v-if="state.walletType === 'madow'">
|
||
<view class="num-title">可提现dmepa(枚)</view>
|
||
<view class="wallet-num">{{ state.madowInfo.madow || '0' }}</view>
|
||
<view class="ss-m-t-10" style="font-size: 22rpx; color: rgba(255,255,255,0.85);">
|
||
预估总市值:¥{{ state.madowInfo.madow_value || '0.00' }} (1 dmepa ≈ ¥{{ state.madowInfo.madow_rate || '0' }})
|
||
</view>
|
||
</view>
|
||
<view class="" v-else>
|
||
<view class="num-title">可提现佣金(元)</view>
|
||
<view class="wallet-num">{{ userInfo.commission || '0.00' }}</view>
|
||
<view class="ss-m-t-10" style="font-size: 22rpx; color: rgba(255,255,255,0.85);">
|
||
商城可用余额:¥{{ userInfo.money || '0.00' }}
|
||
</view>
|
||
</view>
|
||
<button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/withdraw-log')"
|
||
>提现记录</button
|
||
>
|
||
</view>
|
||
<!-- 提现输入卡片-->
|
||
<view class="draw-card">
|
||
<view class="card-title ss-flex ss-row-between ss-col-center">
|
||
<text>提现金额</text>
|
||
<text
|
||
v-if="state.walletType === 'madow' && Number(state.madowInfo.madow_value) > 0"
|
||
style="font-size: 24rpx; color: #b78328; font-weight: 500;"
|
||
@tap="onWithdrawAllMadow"
|
||
>
|
||
全部提现
|
||
</text>
|
||
</view>
|
||
<view class="input-box ss-flex ss-col-center border-bottom">
|
||
<view class="unit">¥</view>
|
||
<uni-easyinput
|
||
:inputBorder="false"
|
||
class="ss-flex-1 ss-p-l-10"
|
||
v-model="state.amount"
|
||
type="number"
|
||
placeholder="请输入提现金额"
|
||
/>
|
||
</view>
|
||
<view
|
||
v-if="state.walletType === 'madow' && Number(state.amount) > 0"
|
||
style="padding: 12rpx 0 16rpx; font-size: 22rpx; color: #999;"
|
||
>
|
||
预计扣除约 {{ estimatedDeductMadow }} dmepa(实时汇率 1 dmepa ≈ ¥{{ state.madowInfo.madow_rate || '0' }})
|
||
</view>
|
||
<view class="bank-box ss-flex ss-col-center ss-row-between ss-m-b-30" :style="state.walletType === 'madow' && Number(state.amount) > 0 ? 'margin-top: 10rpx;' : ''">
|
||
<view class="name">提现至</view>
|
||
<view class="bank-list ss-flex ss-col-center" @tap="onAccountSelect(true)">
|
||
<view v-if="!state.accountInfo.type" class="empty-text">请选择提现方式</view>
|
||
<view v-if="state.accountInfo.type === 'wechat'" class="empty-text">微信零钱</view>
|
||
<view v-if="state.accountInfo.type === 'alipay'" class="empty-text">支付宝账户</view>
|
||
<view v-if="state.accountInfo.type === 'bank'" class="empty-text">银行卡转账</view>
|
||
<text class="cicon-forward" v-if="state.walletType !== 'madow'"></text>
|
||
</view>
|
||
</view>
|
||
<view class="bind-box ss-flex ss-col-center ss-row-between" v-if="state.accountInfo.type">
|
||
<view class="placeholder-text" v-if="state.accountInfo.account_name">
|
||
{{ state.accountInfo.account_header }}|{{ state.accountInfo.account_name }}
|
||
</view>
|
||
<view class="placeholder-text" v-else>暂无提现账户</view>
|
||
<button class="add-btn ss-reset-button" @tap="onAccountEdit(true)">
|
||
{{ state.accountInfo.account_name ? '修改' : '添加' }}
|
||
</button>
|
||
</view>
|
||
<button
|
||
class="ss-reset-button save-btn ui-BG-Main-Gradient ui-Shadow-Main"
|
||
:style="!state.isWithdrawOpen ? 'opacity: 0.6; filter: grayscale(1);' : ''"
|
||
@tap="onConfirm"
|
||
>
|
||
{{ state.isWithdrawOpen ? '确认提现' : '提现暂未开启' }}
|
||
</button>
|
||
</view>
|
||
|
||
<!-- 提现说明 -->
|
||
<view class="draw-notice">
|
||
<view class="title ss-m-b-20">提现说明</view>
|
||
<view class="tip-banner ss-m-b-20" v-if="state.walletType !== 'madow'" style="background: #fff8f2; color: #ff6000; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;">
|
||
💡 提示:商城收益分成已全额直接入账商城余额,可用于下单直接抵扣。历史存量佣金可转入商城余额消费。
|
||
</view>
|
||
<view class="tip-banner ss-m-b-20" v-else style="background: #fdfbf7; color: #b78328; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;">
|
||
💡 提示:dmepa 按大盘实时汇率折算为现金扣除持仓,提现渠道限定为银行卡转账。审核驳回后对应 dmepa 将全额原路退回。
|
||
</view>
|
||
<view class="draw-list" v-for="(rule, index) in state.rulesList" :key="index">
|
||
{{ index + 1 }}.{{ rule }}
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 选择提现账户 -->
|
||
<account-type-select
|
||
:show="state.accountSelect"
|
||
@close="onAccountSelect(false)"
|
||
round="10"
|
||
v-model="state.accountInfo"
|
||
:methods="state.walletType === 'madow' ? ['bank'] : state.rules.methods"
|
||
/>
|
||
<!-- 编辑账户信息 -->
|
||
<account-info-modal
|
||
v-if="state.accountInfo.type"
|
||
v-model="state.accountInfo"
|
||
:show="state.accountEdit"
|
||
@close="onAccountEdit(false)"
|
||
round="10"
|
||
/>
|
||
</s-layout>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed, reactive, onBeforeMount } from 'vue';
|
||
import { onShow, onLoad, onPageScroll } from '@dcloudio/uni-app';
|
||
import sheep from '@/sheep';
|
||
import accountTypeSelect from './components/account-type-select.vue';
|
||
import accountInfoModal from './components/account-info-modal.vue';
|
||
|
||
const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/user/withdraw_bg.png');
|
||
onPageScroll(() => {});
|
||
|
||
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
|
||
function filterRules(rules) {
|
||
let list = [];
|
||
let str1 = '';
|
||
if (rules.min_amount > 0) {
|
||
str1 += `最少 ${rules.min_amount}元; `;
|
||
}
|
||
if (rules.max_amount > 0) {
|
||
str1 += `最多 ${rules.max_amount}元;`;
|
||
}
|
||
if (str1 !== '') {
|
||
list.push('单次提现金额 ' + str1);
|
||
}
|
||
|
||
if (rules.max_num > 0) {
|
||
list.push(`每${rules.num_unit === 'day' ? '天' : '月'}最多可提现 ${rules.max_num} 次;`);
|
||
}
|
||
|
||
if (rules.charge_rate_format > 0) {
|
||
list.push(`每次收取提现手续费 ${rules.charge_rate_format}%;`);
|
||
}
|
||
list.push(
|
||
`提现申请后将${rules.auto_arrival ? '自动' : '审核后'}到账, 到账结果请查收对应渠道服务通知;`,
|
||
);
|
||
list.push('如有疑问请及时联系客服.');
|
||
|
||
return list;
|
||
}
|
||
|
||
const userStore = sheep.$store('user');
|
||
const userInfo = computed(() => userStore.userInfo);
|
||
const state = reactive({
|
||
walletType: '',
|
||
amount: '',
|
||
type: '',
|
||
accountInfo: {},
|
||
accountSelect: false,
|
||
accountEdit: false,
|
||
madowInfo: {
|
||
madow: '0',
|
||
madow_rate: '0',
|
||
madow_value: '0.00',
|
||
can_withdraw_madow: 1,
|
||
madow_withdraw_min: 1,
|
||
},
|
||
rules: {
|
||
min_amount: 0,
|
||
max_amount: 0,
|
||
max_num: 0,
|
||
num_unit: 0,
|
||
charge_rate_format: 0,
|
||
charge_rate: 0,
|
||
methods: [],
|
||
},
|
||
rulesList: [],
|
||
isWithdrawOpen: true,
|
||
});
|
||
|
||
const estimatedDeductMadow = computed(() => {
|
||
if (!state.amount || !state.madowInfo.madow_rate || Number(state.madowInfo.madow_rate) <= 0) return '0.0000';
|
||
const deduct = Number(state.amount) / Number(state.madowInfo.madow_rate);
|
||
return deduct.toFixed(4);
|
||
});
|
||
|
||
function onWithdrawAllMadow() {
|
||
if (state.madowInfo.madow_value) {
|
||
state.amount = String(state.madowInfo.madow_value);
|
||
}
|
||
}
|
||
|
||
async function fetchUserBankAccount() {
|
||
try {
|
||
let res = await sheep.$api.user.account.info({
|
||
type: 'bank',
|
||
});
|
||
if (res?.code === 1 && res.data) {
|
||
state.accountInfo = {
|
||
type: 'bank',
|
||
account_header: res.data.account_header,
|
||
account_name: res.data.account_name,
|
||
account_no: res.data.account_no,
|
||
};
|
||
}
|
||
} catch (e) {}
|
||
}
|
||
|
||
async function getMadowInfo() {
|
||
try {
|
||
const res = await sheep.$api.partner.madow();
|
||
if (res?.code === 1 && res.data) {
|
||
state.madowInfo = {
|
||
madow: res.data.madow || '0',
|
||
madow_rate: res.data.madow_rate || '0',
|
||
madow_value: res.data.madow_value || '0.00',
|
||
can_withdraw_madow: res.data.can_withdraw_madow ?? 1,
|
||
madow_withdraw_min: res.data.madow_withdraw_min ?? 1,
|
||
};
|
||
const isOpen = state.madowInfo.can_withdraw_madow !== 0 && state.madowInfo.can_withdraw_madow !== false;
|
||
state.isWithdrawOpen = Boolean(isOpen);
|
||
if (!state.isWithdrawOpen) {
|
||
sheep.$helper.toast('dmepa提现暂未开启');
|
||
}
|
||
state.rulesList = [
|
||
`dmepa按大盘实时市值换算扣除(当前 1 dmepa ≈ ¥${state.madowInfo.madow_rate});`,
|
||
`单次提现金额最低 ${state.madowInfo.madow_withdraw_min || 1} 元;`,
|
||
'提现仅支持打款至银行卡,申请提交后由财务人工审核;',
|
||
'审核驳回或打款失败后,对应dmepa将全额原路退还至账户持仓。',
|
||
];
|
||
}
|
||
} catch (e) {}
|
||
}
|
||
|
||
const onAccountEdit = (e) => {
|
||
state.accountEdit = e;
|
||
};
|
||
|
||
const onAccountSelect = (e) => {
|
||
state.accountSelect = e;
|
||
};
|
||
|
||
const onConfirm = async () => {
|
||
if (!state.isWithdrawOpen) {
|
||
sheep.$helper.toast(state.walletType === 'madow' ? 'dmepa提现暂未开启' : '系统提现功能暂未开启');
|
||
return;
|
||
}
|
||
|
||
let payload = {
|
||
money: state.amount,
|
||
...state.accountInfo,
|
||
};
|
||
|
||
if (state.walletType === 'madow') {
|
||
payload.wallet_type = 'madow';
|
||
payload.type = 'bank';
|
||
|
||
if (Number(payload.money) <= 0) {
|
||
sheep.$helper.toast('请输入正确的提现金额');
|
||
return;
|
||
}
|
||
const minMadowCny = Number(state.madowInfo.madow_withdraw_min || 1);
|
||
if (minMadowCny > 0 && Number(payload.money) < minMadowCny) {
|
||
sheep.$helper.toast(`最低提现金额为 ${minMadowCny} 元`);
|
||
return;
|
||
}
|
||
if (Number(payload.money) > Number(state.madowInfo.madow_value || 0)) {
|
||
sheep.$helper.toast('提现金额超出持有dmepa可用市值');
|
||
return;
|
||
}
|
||
} else {
|
||
if (payload.money > userInfo.commission || payload.money <= 0) {
|
||
sheep.$helper.toast('请输入正确的提现金额');
|
||
return;
|
||
}
|
||
|
||
if (!payload.type) {
|
||
sheep.$helper.toast('请选择提现方式');
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (!payload.account_name || !payload.account_header || !payload.account_no) {
|
||
sheep.$helper.toast('请完善您的账户信息');
|
||
return;
|
||
}
|
||
|
||
if (sheep.$platform.name === 'H5' && payload.type === 'wechat') {
|
||
sheep.$helper.toast('请使用微信浏览器操作');
|
||
return;
|
||
}
|
||
|
||
let { code, msg, data } = await sheep.$api.pay.withdraw.apply(payload);
|
||
if (code === -1) {
|
||
sheep.$platform.useProvider('wechat').bind();
|
||
}
|
||
if (code === 1) {
|
||
// 刷新用户佣金余额
|
||
userStore.getInfo();
|
||
if (state.walletType === 'madow') {
|
||
getMadowInfo();
|
||
sheep.$helper.toast('提现申请已提交,等待审核打款');
|
||
setTimeout(() => {
|
||
sheep.$router.go('/pages/pay/withdraw-log');
|
||
}, 1500);
|
||
}
|
||
|
||
if (payload.type === 'wechat') {
|
||
sheep.$platform.useProvider('wechat').transfer(data.transfer_data);
|
||
}
|
||
}
|
||
};
|
||
|
||
async function getWithdrawRules() {
|
||
let { code, data } = await sheep.$api.pay.withdraw.rules();
|
||
if (code === 1) {
|
||
state.rules = data;
|
||
if (state.walletType !== 'madow') {
|
||
state.rulesList = filterRules(state.rules);
|
||
const isOpen = (data.status === undefined || Number(data.status) === 1)
|
||
&& Array.isArray(data.methods)
|
||
&& data.methods.length > 0;
|
||
state.isWithdrawOpen = Boolean(isOpen);
|
||
if (!state.isWithdrawOpen) {
|
||
sheep.$helper.toast('系统提现功能暂未开启');
|
||
}
|
||
// 如果当前选中的方式已被后台关闭,清空该选择
|
||
if (state.accountInfo.type && Array.isArray(data.methods) && !data.methods.includes(state.accountInfo.type)) {
|
||
state.accountInfo = {};
|
||
}
|
||
// 若当前未选择提现方式,且后台仅开启了 1 种提现方式,默认选中该方式并自动读取对应账户
|
||
if (!state.accountInfo.type && Array.isArray(data.methods) && data.methods.length === 1) {
|
||
const onlyType = data.methods[0];
|
||
state.accountInfo.type = onlyType;
|
||
try {
|
||
let res = await sheep.$api.user.account.info({ type: onlyType });
|
||
if (res?.code === 1 && res.data) {
|
||
state.accountInfo = {
|
||
type: onlyType,
|
||
account_header: res.data.account_header,
|
||
account_name: res.data.account_name,
|
||
account_no: res.data.account_no,
|
||
};
|
||
}
|
||
} catch (e) {}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
onLoad(async (options) => {
|
||
if (options?.type === 'madow') {
|
||
state.walletType = 'madow';
|
||
state.accountInfo.type = 'bank';
|
||
await getMadowInfo();
|
||
fetchUserBankAccount();
|
||
}
|
||
});
|
||
|
||
onBeforeMount(() => {
|
||
getWithdrawRules();
|
||
});
|
||
|
||
onShow(() => {
|
||
userStore.getInfo();
|
||
if (state.walletType === 'madow') {
|
||
getMadowInfo();
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
:deep() {
|
||
.uni-input-input {
|
||
font-family: OPPOSANS !important;
|
||
}
|
||
}
|
||
|
||
.wallet-num-box {
|
||
padding: 0 40rpx 80rpx;
|
||
background: var(--ui-BG-Main) v-bind(headerBg) center/750rpx 100% no-repeat;
|
||
border-radius: 0 0 5% 5%;
|
||
|
||
.num-title {
|
||
font-size: 26rpx;
|
||
font-weight: 500;
|
||
color: $white;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
|
||
.wallet-num {
|
||
font-size: 60rpx;
|
||
font-weight: 500;
|
||
color: $white;
|
||
font-family: OPPOSANS;
|
||
}
|
||
|
||
.log-btn {
|
||
width: 170rpx;
|
||
height: 60rpx;
|
||
line-height: 60rpx;
|
||
border: 1rpx solid $white;
|
||
border-radius: 30rpx;
|
||
padding: 0;
|
||
font-size: 26rpx;
|
||
font-weight: 500;
|
||
color: $white;
|
||
}
|
||
}
|
||
|
||
// 提现输入卡片
|
||
.draw-card {
|
||
background-color: $white;
|
||
border-radius: 20rpx;
|
||
width: 690rpx;
|
||
min-height: 560rpx;
|
||
margin: -60rpx 30rpx 30rpx 30rpx;
|
||
padding: 30rpx;
|
||
position: relative;
|
||
z-index: 3;
|
||
box-sizing: border-box;
|
||
|
||
.card-title {
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
margin-bottom: 30rpx;
|
||
}
|
||
|
||
.bank-box {
|
||
.name {
|
||
font-size: 28rpx;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.bank-list {
|
||
.empty-text {
|
||
font-size: 28rpx;
|
||
font-weight: 400;
|
||
color: $dark-9;
|
||
}
|
||
|
||
.cicon-forward {
|
||
color: $dark-9;
|
||
}
|
||
}
|
||
|
||
.input-box {
|
||
width: 624rpx;
|
||
height: 100rpx;
|
||
margin-bottom: 40rpx;
|
||
|
||
.unit {
|
||
font-size: 48rpx;
|
||
color: #333;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.uni-easyinput__placeholder-class {
|
||
font-size: 30rpx;
|
||
height: 36rpx;
|
||
}
|
||
|
||
:deep(.uni-easyinput__content-input) {
|
||
font-size: 48rpx;
|
||
}
|
||
}
|
||
|
||
.save-btn {
|
||
width: 616rpx;
|
||
height: 86rpx;
|
||
line-height: 86rpx;
|
||
border-radius: 40rpx;
|
||
margin-top: 80rpx;
|
||
}
|
||
}
|
||
|
||
.bind-box {
|
||
.placeholder-text {
|
||
font-size: 26rpx;
|
||
color: $dark-9;
|
||
}
|
||
|
||
.add-btn {
|
||
width: 100rpx;
|
||
height: 50rpx;
|
||
border-radius: 25rpx;
|
||
line-height: 50rpx;
|
||
font-size: 22rpx;
|
||
color: var(--ui-BG-Main);
|
||
background-color: var(--ui-BG-Main-light);
|
||
}
|
||
}
|
||
|
||
.input-box {
|
||
width: 624rpx;
|
||
height: 100rpx;
|
||
margin-bottom: 40rpx;
|
||
|
||
.unit {
|
||
font-size: 48rpx;
|
||
color: #333;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.uni-easyinput__placeholder-class {
|
||
font-size: 30rpx;
|
||
}
|
||
|
||
:deep(.uni-easyinput__content-input) {
|
||
font-size: 48rpx;
|
||
}
|
||
}
|
||
|
||
.save-btn {
|
||
width: 616rpx;
|
||
height: 86rpx;
|
||
line-height: 86rpx;
|
||
border-radius: 40rpx;
|
||
margin-top: 80rpx;
|
||
}
|
||
}
|
||
|
||
// 提现说明
|
||
.draw-notice {
|
||
width: 684rpx;
|
||
background: #ffffff;
|
||
border: 2rpx solid #fffaee;
|
||
border-radius: 20rpx;
|
||
margin: 20rpx 32rpx 0 32rpx;
|
||
padding: 30rpx;
|
||
box-sizing: border-box;
|
||
|
||
.title {
|
||
font-weight: 500;
|
||
color: #333333;
|
||
font-size: 30rpx;
|
||
}
|
||
|
||
.draw-list {
|
||
font-size: 24rpx;
|
||
color: #999999;
|
||
line-height: 46rpx;
|
||
}
|
||
}
|
||
</style>
|