feat(withdraw): 后台支持提现总开关与方式过滤并升级钱包与提现页面体验

这个提交包含在:
chen
2026-09-19 15:41:25 +08:00
父节点 efab61498d
当前提交 3868becc63
共有 17 个文件被更改,包括 1872 次插入 和 116 次删除

查看文件

@@ -5,10 +5,10 @@
<text class="modal-title ss-m-b-20">选择提现方式</text>
</view>
<view class="modal-content ss-flex-1 ss-p-b-100">
<radio-group @change="onChange">
<radio-group @change="onChange" v-if="filteredTypeList.length > 0">
<label
class="container-list ss-p-l-34 ss-p-r-24 ss-flex ss-col-center ss-row-center"
v-for="(item, index) in typeList"
v-for="(item, index) in filteredTypeList"
:key="index"
>
<view class="container-icon ss-flex ss-m-r-20">
@@ -20,10 +20,12 @@
:value="item.value"
color="var(--ui-BG-Main)"
:checked="item.value === state.currentValue"
:disabled="!methods.includes(item.value)"
/>
</label>
</radio-group>
<view v-else class="empty-tip ss-p-40 ss-text-center" style="padding: 40rpx; text-align: center; color: #999; font-size: 26rpx;">
暂无可用的提现方式
</view>
</view>
<view class="modal-footer ss-flex ss-row-center ss-col-center">
<button class="ss-reset-button save-btn" @tap="onConfirm">确定</button>
@@ -33,7 +35,7 @@
</template>
<script setup>
import { reactive, onBeforeMount, nextTick } from 'vue';
import { reactive, onBeforeMount, computed, watch } from 'vue';
import sheep from '@/sheep';
const props = defineProps({
@@ -47,7 +49,7 @@
},
methods: {
type: Array,
default: [],
default: () => [],
},
});
const emits = defineEmits(['update:modelValue', 'change', 'close']);
@@ -71,23 +73,89 @@
value: 'bank',
},
];
// 仅展示后台已开启的提现方式(后台关闭的在此彻底隐藏)
const filteredTypeList = computed(() => {
if (!Array.isArray(props.methods) || props.methods.length === 0) {
return [];
}
return typeList.filter((item) => props.methods.includes(item.value));
});
function syncCurrentValue() {
const validMethods = Array.isArray(props.methods) ? props.methods : [];
// 1. 若当前已选中的值在后台开启的列表中,优先保留
if (props.modelValue?.type && validMethods.includes(props.modelValue.type)) {
state.currentValue = props.modelValue.type;
return;
}
// 2. 若 state.currentValue 仍属于有效开启列表,保留
if (state.currentValue && validMethods.includes(state.currentValue)) {
return;
}
// 3. 若仅有 1 种开启的提现方式,默认选中
if (validMethods.length === 1) {
state.currentValue = validMethods[0];
return;
}
// 4. 若开启了多种但未选择或选择已失效,且开启列表非空,默认选择首项
if (validMethods.length > 0 && !validMethods.includes(state.currentValue)) {
state.currentValue = validMethods[0];
return;
}
state.currentValue = '';
}
watch(
() => props.methods,
() => {
syncCurrentValue();
},
{ immediate: true, deep: true }
);
watch(
() => props.modelValue,
() => {
syncCurrentValue();
},
{ immediate: true, deep: true }
);
watch(
() => props.show,
(val) => {
if (val) {
syncCurrentValue();
}
}
);
const getWalletAccountInfo = async () => {
if (!state.currentValue) return;
return new Promise(async (resolve, reject) => {
let res = await sheep.$api.user.account.info({
type: state.currentValue,
});
if (res.code === 1) {
if (!props.methods.includes(res.data.type)) {
return;
}
state.currentValue = res.data.type;
emits('update:modelValue', {
type: res.data.type,
account_header: res.data.account_header,
account_name: res.data.account_name,
account_no: res.data.account_no,
try {
let res = await sheep.$api.user.account.info({
type: state.currentValue,
});
} else {
if (res.code === 1) {
if (!props.methods.includes(res.data.type)) {
resolve();
return;
}
state.currentValue = res.data.type;
emits('update:modelValue', {
type: res.data.type,
account_header: res.data.account_header,
account_name: res.data.account_name,
account_no: res.data.account_no,
});
} else {
emits('update:modelValue', {
type: state.currentValue,
});
}
} catch (e) {
emits('update:modelValue', {
type: state.currentValue,
});
@@ -105,6 +173,10 @@
sheep.$helper.toast('请选择提现方式');
return;
}
if (!props.methods.includes(state.currentValue)) {
sheep.$helper.toast('该提现方式暂未开启');
return;
}
await getWalletAccountInfo();
emits('close');
};
@@ -114,7 +186,10 @@
};
onBeforeMount(async () => {
await getWalletAccountInfo();
syncCurrentValue();
if (state.currentValue) {
await getWalletAccountInfo();
}
});
</script>

查看文件

@@ -1,5 +1,5 @@
<template>
<s-layout title="申请提现" class="withdraw-wrap" navbar="inner">
<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"
@@ -10,7 +10,14 @@
},
]"
>
<view class="">
<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);">
@@ -23,7 +30,16 @@
</view>
<!-- 提现输入卡片-->
<view class="draw-card">
<view class="card-title">提现金额</view>
<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
@@ -34,14 +50,20 @@
placeholder="请输入提现金额"
/>
</view>
<view class="bank-box ss-flex ss-col-center ss-row-between ss-m-b-30">
<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"></text>
<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">
@@ -53,17 +75,24 @@
{{ state.accountInfo.account_name ? '修改' : '添加' }}
</button>
</view>
<button class="ss-reset-button save-btn ui-BG-Main-Gradient ui-Shadow-Main" @tap="onConfirm">
确认提现
<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" style="background: #fff8f2; color: #ff6000; font-size: 22rpx; padding: 16rpx 20rpx; border-radius: 12rpx; line-height: 1.5;">
<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>
@@ -75,7 +104,7 @@
@close="onAccountSelect(false)"
round="10"
v-model="state.accountInfo"
:methods="state.rules.methods"
:methods="state.walletType === 'madow' ? ['bank'] : state.rules.methods"
/>
<!-- 编辑账户信息 -->
<account-info-modal
@@ -90,11 +119,10 @@
<script setup>
import { computed, reactive, onBeforeMount } from 'vue';
import { onShow } from '@dcloudio/uni-app';
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';
import { onPageScroll } from '@dcloudio/uni-app';
const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/user/withdraw_bg.png');
onPageScroll(() => {});
@@ -131,11 +159,19 @@
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,
@@ -146,8 +182,63 @@
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;
};
@@ -157,19 +248,43 @@
};
const onConfirm = async () => {
if (!state.isWithdrawOpen) {
sheep.$helper.toast(state.walletType === 'madow' ? 'dmepa提现暂未开启' : '系统提现功能暂未开启');
return;
}
let payload = {
money: state.amount,
...state.accountInfo,
};
if (payload.money > userInfo.commission || payload.money <= 0) {
sheep.$helper.toast('请输入正确的提现金额');
return;
}
if (state.walletType === 'madow') {
payload.wallet_type = 'madow';
payload.type = 'bank';
if (!payload.type) {
sheep.$helper.toast('请选择提现方式');
return;
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) {
@@ -189,6 +304,13 @@
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);
@@ -200,16 +322,57 @@
let { code, data } = await sheep.$api.pay.withdraw.rules();
if (code === 1) {
state.rules = data;
state.rulesList = filterRules(state.rules);
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>

查看文件

@@ -7,7 +7,6 @@
<view class="card-top ss-flex ss-row-between ss-col-center">
<view class="top-tag ss-flex ss-col-center">
<text class="tag-badge">现金资产</text>
<text class="top-title">账户钱包余额</text>
</view>
<view
class="eye-btn ss-flex ss-col-center"
@@ -29,23 +28,15 @@
<text class="hero-unit">元</text>
</view>
<button
v-if="state.canWithdraw"
class="ss-reset-button topup-btn ss-flex ss-row-center ss-col-center"
@tap="sheep.$router.go('/pages/pay/recharge')"
@tap="onWithdraw"
>
<text class="cicon-moneybag ss-m-r-6"></text>
<text>充值</text>
<text>提现</text>
</button>
</view>
<!-- 动态指示胶囊 -->
<view class="rate-capsule ss-flex ss-row-between ss-col-center">
<view class="capsule-left ss-flex ss-col-center">
<text class="capsule-dot"></text>
<text class="capsule-text">线上充值与收益分成全额入账 · 下单直接抵扣</text>
</view>
<text class="capsule-tag">即时可用</text>
</view>
<!-- 底部数据栏:当前周期总收入 / 总支出 -->
<view class="card-footer ss-flex ss-row-between ss-col-center">
<view class="footer-metric">
@@ -173,6 +164,7 @@
const state = reactive({
showMoney: true,
canWithdraw: false,
date: [],
currentTab: 0,
pagination,
@@ -210,6 +202,32 @@
}
});
async function checkWithdrawStatus() {
try {
const appStore = sheep.$store('app');
if (appStore?.platform && typeof appStore.platform.withdraw_status === 'boolean') {
state.canWithdraw = appStore.platform.withdraw_status;
}
const res = await sheep.$api.pay.withdraw.rules();
if (res?.code === 1 && res.data) {
const isOpen = (res.data.status === undefined || Number(res.data.status) === 1)
&& Array.isArray(res.data.methods)
&& res.data.methods.length > 0;
state.canWithdraw = Boolean(isOpen);
}
} catch (e) {
state.canWithdraw = false;
}
}
function onWithdraw() {
if (!state.canWithdraw) {
sheep.$helper.toast('暂未开启提现功能');
return;
}
sheep.$router.go('/pages/pay/withdraw');
}
async function getLogList(page = 1, list_rows = 10) {
state.loadStatus = 'loading';
try {
@@ -239,11 +257,13 @@
state.today = dayjs().format('YYYY-MM-DD');
state.date = [state.today, state.today];
sheep.$store('user').getInfo();
checkWithdrawStatus();
getLogList(1);
});
onPullDownRefresh(async () => {
await sheep.$store('user').getInfo();
await checkWithdrawStatus();
await getLogList(1);
uni.stopPullDownRefresh();
});
@@ -318,14 +338,6 @@
padding: 4rpx 14rpx;
border-radius: 8rpx;
font-weight: 600;
margin-right: 12rpx;
}
.top-title {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.85);
font-weight: 400;
letter-spacing: 1rpx;
}
}
@@ -393,39 +405,6 @@
}
}
/* 胶囊指示栏 */
.rate-capsule {
margin-top: 24rpx;
background: rgba(244, 211, 151, 0.1);
border: 1rpx solid rgba(244, 211, 151, 0.22);
border-radius: 12rpx;
padding: 14rpx 20rpx;
position: relative;
z-index: 2;
.capsule-left {
.capsule-dot {
width: 10rpx;
height: 10rpx;
border-radius: 50%;
background-color: #eabf76;
margin-right: 12rpx;
box-shadow: 0 0 8rpx #eabf76;
}
.capsule-text {
font-size: 24rpx;
color: #fce8bf;
font-weight: 500;
}
}
.capsule-tag {
font-size: 20rpx;
color: #f7d598;
opacity: 0.85;
}
}
/* 底部收支汇总栏 */
.card-footer {