文件
yjyf/yjyf-master-app/pages/master/wallet.vue
MiAn 14533eadb7 feat: 用户端与师傅端双小程序架构解耦,新增师傅独立认证及超时自动关单机制
1. 账号体系与数据库解耦:
   - 师傅表 fa_master 解除对 fa_user.id 的外键依赖,升级为独立认证账号主表;
   - 新增师傅端独立支撑表:fa_master_security、fa_master_token、fa_master_wechat、fa_master_agreement_read;
   - 新增工单超时未接单自动关闭与原路退款配置(order_unaccepted_close_days)。

2. 服务端(Server):
   - 新增师傅端独立 API 控制器与认证库(MasterAuth, MasterBase, MasterMessage, MasterSecurity, MasterToken);
   - WxLogin 支持双小程序端(user/master)独立换取 session_key、openid 与 access_token;
   - 新增控制台调度命令 php think order:autoclose,支持订单超时自动关闭与售后退款闭环;
   - 修复 PHP 8.5 兼容性问题(Request.php 的 (bool) 强制转换);
   - 系统业务配置全面收敛至数据库 fa_config 及 site.php。

3. 小程序端:
   - yjyf-app(用户端):彻底剥离师傅端路由、组件及静态资源,增加隐私授权弹窗与评价模块;
   - yjyf-master-app(师傅端):全新独立微信小程序工程(wx140d90ceda786107),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
2026-11-23 15:10:30 +08:00

1347 行
40 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="page">
<YjyfNavBar theme="orange" title="我的钱包" :fixed="true" :placeholder="true" />
<YjyfRefreshScroll
class="wallet-scroll"
theme="orange"
:nav-offset="navHeight"
:refresh-task="load"
>
<!-- 资产概览名片 -->
<view class="wallet-hero" :style="{ backgroundPosition: '0 -' + navHeight + 'px' }">
<view class="wallet-body">
<view class="hero-top">
<text class="hero-lab">可提现余额(元)</text>
<view class="channel-tag" v-if="withdrawChannels.length > 0">
<image
class="wechat-ico"
:src="withdrawChannels[0] === 'bank' ? '/static/icons/bank-card.svg' : '/static/icons/wechat.svg'"
mode="aspectFit"
/>
<text class="channel-txt">{{ heroChannelText }}</text>
</view>
</view>
<text class="hero-num">{{ formatMoney(income ? income.money : 0) }}</text>
<view class="hero-metrics">
<view class="metric-item">
<text class="metric-lab">今日收入</text>
<text class="metric-val">¥{{ formatMoney(income ? income.today_income : 0) }}</text>
</view>
<view class="metric-divider"></view>
<view class="metric-item">
<text class="metric-lab">提现处理中</text>
<text class="metric-val">¥{{ formatMoney(income ? income.frozen_money : 0) }}</text>
</view>
<view class="metric-divider"></view>
<view class="metric-item">
<text class="metric-lab">累计入账</text>
<text class="metric-val">¥{{ formatMoney(income ? income.total_income : 0) }}</text>
</view>
</view>
<view
class="withdraw-cta clickable-hover"
:class="{ disabled: !withdrawEnabled }"
@tap="openWithdraw"
>
<text class="withdraw-cta-txt">{{ withdrawEnabled ? '申请提现' : '暂停提现' }}</text>
</view>
</view>
</view>
<!-- 待师傅确认收款提醒横幅(仅存在待领取的微信商家转账单时展示) -->
<view class="receive-banner" v-if="pendingConfirmList.length > 0">
<image class="receive-ico" src="/static/icons/transfer-receive.svg" mode="aspectFit" />
<view class="receive-main">
<text class="receive-title">
{{ pendingConfirmList.length > 1
? `${pendingConfirmList.length} 笔提现审核已通过,待确认收款`
: `提现审核已通过 · 实到 ¥${formatMoney(pendingConfirmList[0].arrive_amount)}` }}
</text>
<text class="receive-sub">点击右侧按钮调起微信确认收款,即刻入账零钱</text>
</view>
<view
class="receive-btn clickable-hover"
:class="{ disabled: confirmingId > 0 }"
@tap="handleConfirmReceive(pendingConfirmList[0])"
>
{{ confirmingId === pendingConfirmList[0].id ? '调起中...' : '确认收款' }}
</view>
</view>
<!-- 结算规则提示(完全由后台配置中心动态下发) -->
<view class="tips-bar" v-if="ruleTipText">
<image class="tips-ico" src="/static/icons/info-orange.svg" mode="aspectFit" />
<text class="tips-txt">{{ ruleTipText }}</text>
</view>
<!-- 收支账单与提现明细 -->
<view class="bill-card">
<view class="card-head">
<text class="card-title">{{ filterType === 'withdraw' ? '提现申请记录' : '收支账单明细' }}</text>
<view class="filter-tabs">
<view class="ft-item" :class="{ on: filterType === 'all' }" @tap="filterType = 'all'">全部</view>
<view class="ft-item" :class="{ on: filterType === 'settle' }" @tap="filterType = 'settle'">结算</view>
<view class="ft-item" :class="{ on: filterType === 'withdraw' }" @tap="filterType = 'withdraw'">
<text>提现记录</text>
<text class="ft-badge" v-if="pendingConfirmList.length > 0">{{ pendingConfirmList.length }}</text>
</view>
</view>
</view>
<!-- 提现申请记录专属视图 -->
<template v-if="filterType === 'withdraw'">
<view class="log-list" v-if="withdrawList.length">
<view
class="log-row clickable-hover"
v-for="w in withdrawList"
:key="w.id"
@tap="openWithdrawDetail(w)"
>
<image class="wd-row-ico" src="/static/icons/withdraw-record.svg" mode="aspectFit" />
<view class="log-main">
<view class="log-title-line">
<text class="log-type">{{ w.channel === 'bank' ? '提现至银行卡' : '提现至微信零钱' }}</text>
<text class="wd-status-tag" :class="withdrawStatusClass(w)">{{ w.status_text }}</text>
</view>
<text class="log-remark">
实到 ¥{{ formatMoney(w.arrive_amount) }} · 手续费 ¥{{ formatMoney(w.fee) }}
</text>
<text class="wd-fail-txt" v-if="w.fail_reason || (w.status === 'reject' && w.audit_msg)">
原因:{{ w.fail_reason || w.audit_msg }}
</text>
<text class="log-time">{{ w.time_text || fullTimeText(w.createtime) }}</text>
</view>
<view class="log-right">
<view class="log-amt-wrap">
<text class="log-amt minus">-{{ formatMoney(w.amount) }}</text>
<view
v-if="w.can_confirm"
class="wd-confirm-pill clickable-hover"
:class="{ disabled: confirmingId > 0 }"
@tap.stop="handleConfirmReceive(w)"
>
{{ confirmingId === w.id ? '调起中...' : '确认收款' }}
</view>
<text class="log-bal" v-else>{{ w.transfer_state_text || w.status_text }}</text>
</view>
<image v-if="!w.can_confirm" class="row-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
</view>
<view class="empty-box" v-else>
<image class="empty-img" src="/static/icons/empty-orders.svg" mode="aspectFit" />
<text class="empty-txt">暂无提现申请记录</text>
</view>
</template>
<!-- 钱包收支流水视图 -->
<template v-else>
<view class="log-list" v-if="filteredLogs.length">
<view
class="log-row clickable-hover"
v-for="l in filteredLogs"
:key="l.id || l.createtime"
@tap="openLogDetail(l)"
>
<view class="log-main">
<view class="log-title-line">
<text class="log-type">{{ logTypeText(l.type) }}</text>
<text class="log-order-tag" v-if="Number(l.order_id) > 0">关联工单</text>
</view>
<text class="log-remark">{{ l.remark || '账单收支变动' }}</text>
<text class="log-time">{{ fullTimeText(l.createtime) }}</text>
</view>
<view class="log-right">
<view class="log-amt-wrap">
<text class="log-amt" :class="{ minus: Number(l.amount) < 0 }">
{{ Number(l.amount) > 0 ? '+' : '' }}{{ formatMoney(l.amount) }}
</text>
<text class="log-bal">余额 ¥{{ formatMoney(l.balance) }}</text>
</view>
<image class="row-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
</view>
<view class="empty-box" v-else>
<image class="empty-img" src="/static/icons/empty-orders.svg" mode="aspectFit" />
<text class="empty-txt">暂无对应账单明细</text>
</view>
</template>
</view>
</YjyfRefreshScroll>
<!-- 申请提现半屏抽屉 -->
<view class="drawer-mask" v-if="showWithdrawDrawer" @tap="showWithdrawDrawer = false">
<view class="drawer-panel withdraw-panel" @tap.stop>
<view class="drawer-head">
<view class="withdraw-heading"><text class="drawer-title">申请提现</text><text class="withdraw-subtitle">请核对到账方式及提现金额</text></view>
<view class="drawer-close" @tap="showWithdrawDrawer = false">
<image class="close-ico" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
<view class="channel-row" v-if="withdrawChannels.length <= 1">
<view class="channel-val">
<image
class="ch-ico"
:src="selectedChannel === 'bank' ? '/static/icons/bank-card.svg' : '/static/icons/wechat.svg'"
mode="aspectFit"
/>
<view class="channel-copy"><text class="channel-label">到账方式</text><text class="ch-name">{{ selectedChannel === 'bank' ? '银行储蓄卡(人工财务打款)' : arrivalDescText }}</text></view>
</view>
</view>
<view class="channel-switch-box" v-else>
<text class="channel-label">选择提现渠道</text>
<view class="channel-pills">
<view
v-if="withdrawChannels.includes('wechat')"
class="ch-pill"
:class="{ active: selectedChannel === 'wechat' }"
@tap="selectedChannel = 'wechat'"
>
<image class="ch-ico" src="/static/icons/wechat.svg" mode="aspectFit" />
<text>微信零钱</text>
</view>
<view
v-if="withdrawChannels.includes('bank')"
class="ch-pill"
:class="{ active: selectedChannel === 'bank' }"
@tap="selectedChannel = 'bank'"
>
<image class="ch-ico" src="/static/icons/bank-card.svg" mode="aspectFit" />
<text>银行储蓄卡</text>
</view>
</view>
</view>
<view class="bank-input-box" v-if="selectedChannel === 'bank'">
<text class="bank-label">收款银行与储蓄卡号</text>
<input
class="bank-input"
type="text"
maxlength="100"
v-model="bankAccount"
placeholder="请输入开户银行及本人储蓄卡号"
/>
</view>
<view class="amt-box">
<view class="amt-box-top">
<text class="amt-label">提现金额</text>
<text class="amt-all" @tap="fillAllBalance">全部提现</text>
</view>
<view class="amt-input-line">
<text class="amt-symbol">¥</text>
<input
class="amt-input"
type="digit"
v-model="withdrawAmount"
placeholder="请输入金额"
placeholder-class="amt-placeholder"
/>
</view>
<view class="amt-meta">
<text class="balance-line">可提现余额 <text class="balance-value">¥{{ formatMoney(availMoney) }}</text></text>
<text class="meta-item">单笔 ¥{{ formatMoney(minWithdraw) }} - ¥{{ formatMoney(singleLimit) }}{{ hasDailyAmountLimit ? ` · 今日剩余额度 ¥${formatMoney(todayRemain)}` : '' }}{{ hasDailyCountLimit ? ` · 剩余 ${remainDailyCount} 次` : '' }}</text>
<text class="meta-item warn" v-if="withdrawErrorHint">{{ withdrawErrorHint }}</text>
<text class="meta-item estimate" v-else-if="parsedWithdraw >= minWithdraw">
{{ Number(withdrawFee) > 0 ? `通道手续费 ¥${withdrawFee} · ` : '免收手续费 · ' }}预计到账 ¥{{ withdrawArrive }}
</text>
</view>
</view>
<view
class="drawer-submit clickable-hover"
:class="{ disabled: !canSubmitWithdraw }"
@tap="submitWithdraw"
>
{{ withdrawing ? '提交处理中...' : '确认提交提现' }}
</view>
</view>
</view>
<!-- 提现单详情半屏抽屉 -->
<view class="drawer-mask" v-if="activeWithdraw" @tap="activeWithdraw = null">
<view class="drawer-panel" @tap.stop>
<view class="drawer-head">
<text class="drawer-title">提现单详情</text>
<view class="drawer-close" @tap="activeWithdraw = null">
<image class="close-ico" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
<view class="detail-hero">
<text class="dh-type">{{ activeWithdraw.status_text }}</text>
<text class="dh-amt minus">-¥{{ formatMoney(activeWithdraw.amount) }}</text>
</view>
<view class="detail-cells">
<view class="d-cell">
<text class="d-lab">实际到账净额</text>
<text class="d-val highlight">¥{{ formatMoney(activeWithdraw.arrive_amount) }}</text>
</view>
<view class="d-cell">
<text class="d-lab">通道手续费</text>
<text class="d-val">¥{{ formatMoney(activeWithdraw.fee) }}</text>
</view>
<view class="d-cell">
<text class="d-lab">收款方式</text>
<text class="d-val">{{ activeWithdraw.channel === 'bank' ? '银行卡' : '微信零钱(商家转账)' }}</text>
</view>
<view class="d-cell">
<text class="d-lab">申请时间</text>
<text class="d-val">{{ activeWithdraw.time_text || fullTimeText(activeWithdraw.createtime) }}</text>
</view>
<view class="d-cell" v-if="activeWithdraw.confirm_time > 0">
<text class="d-lab">到账时间</text>
<text class="d-val">{{ fullTimeText(activeWithdraw.confirm_time) }}</text>
</view>
<view class="d-cell" v-if="activeWithdraw.out_bill_no">
<text class="d-lab">转账单号</text>
<text class="d-val">{{ activeWithdraw.out_bill_no }}</text>
</view>
<view class="d-cell" v-if="activeWithdraw.fail_reason || activeWithdraw.audit_msg">
<text class="d-lab">处理说明</text>
<text class="d-val multi">{{ activeWithdraw.fail_reason || activeWithdraw.audit_msg }}</text>
</view>
</view>
<view
v-if="activeWithdraw.can_confirm"
class="drawer-submit clickable-hover"
:class="{ disabled: confirmingId > 0 }"
@tap="handleConfirmReceive(activeWithdraw, true)"
>
{{ confirmingId === activeWithdraw.id ? '正在调起微信收款...' : '确认收款入账微信零钱' }}
</view>
</view>
</view>
<!-- 账单流水详情半屏抽屉 -->
<view class="drawer-mask" v-if="activeLog" @tap="activeLog = null">
<view class="drawer-panel" @tap.stop>
<view class="drawer-head">
<text class="drawer-title">账单流水详情</text>
<view class="drawer-close" @tap="activeLog = null">
<image class="close-ico" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
<view class="detail-hero">
<text class="dh-type">{{ logTypeText(activeLog.type) }}</text>
<text class="dh-amt" :class="{ minus: Number(activeLog.amount) < 0 }">
{{ Number(activeLog.amount) > 0 ? '+' : '' }}{{ formatMoney(activeLog.amount) }}
</text>
</view>
<view class="detail-cells">
<view class="d-cell">
<text class="d-lab">变动后余额</text>
<text class="d-val">¥{{ formatMoney(activeLog.balance) }}</text>
</view>
<view class="d-cell">
<text class="d-lab">发生时间</text>
<text class="d-val">{{ fullTimeText(activeLog.createtime) }}</text>
</view>
<view class="d-cell" v-if="activeLog.id">
<text class="d-lab">流水编号</text>
<text class="d-val">#{{ activeLog.id }}</text>
</view>
<view class="d-cell">
<text class="d-lab">明细说明</text>
<text class="d-val multi">{{ activeLog.remark || '-' }}</text>
</view>
</view>
<view
v-if="Number(activeLog.order_id) > 0"
class="drawer-submit clickable-hover"
@tap="goOrderDetail(activeLog.order_id)"
>
查看关联工单详情
</view>
</view>
</view>
<YjyfPaymentPassword ref="paymentPasswordDialog" />
</view>
</template>
<script setup>
import YjyfPaymentPassword from '@/components/YjyfPaymentPassword.vue';
import { ref, computed } from 'vue';
const paymentPasswordDialog = ref(null);
import { onShow } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { getSafeWxCode, invokeMerchantTransferConfirm } from '@/utils/pay.js';
import { getNavBarMetrics } from '@/utils/system.js';
import YjyfRefreshScroll from '@/components/YjyfRefreshScroll.vue';
const navHeight = ref(getNavBarMetrics().totalNavHeight);
const income = ref(null);
const logs = ref([]);
const withdrawList = ref([]);
const pendingConfirmList = ref([]);
const filterType = ref('all');
const showWithdrawDrawer = ref(false);
const withdrawAmount = ref('');
const selectedChannel = ref('wechat');
const bankAccount = ref('');
const withdrawing = ref(false);
const confirmingId = ref(0);
const activeLog = ref(null);
const activeWithdraw = ref(null);
const availMoney = computed(() => Number(income.value?.money || 0));
const withdrawCfg = computed(() => income.value?.withdraw_config || null);
const withdrawLimits = computed(() => income.value?.withdraw_limits || {});
const withdrawEnabled = computed(() => {
if (!withdrawCfg.value) return true;
return Boolean(withdrawCfg.value.enabled);
});
const withdrawCloseTip = computed(() => withdrawCfg.value?.close_tip || '当前暂未开放提现,请稍后再试');
const withdrawChannels = computed(() => {
const chs = withdrawCfg.value?.channels;
return Array.isArray(chs) && chs.length > 0 ? chs : ['wechat'];
});
const heroChannelText = computed(() => {
const chs = withdrawChannels.value;
if (chs.includes('wechat') && chs.includes('bank')) return '微信零钱 / 银行卡';
if (chs[0] === 'bank') return '银行储蓄卡到账';
return '微信零钱到账';
});
const arrivalDescText = computed(() => withdrawCfg.value?.arrival_desc || '微信零钱(确认收款即到账)');
const ruleTipText = computed(() => withdrawCfg.value?.rule_tip || '');
const minWithdraw = computed(() => Number(withdrawCfg.value?.min_amount ?? withdrawLimits.value.min_amount ?? 0.1));
const singleLimit = computed(() => Number(withdrawCfg.value?.max_amount ?? withdrawLimits.value.single_limit ?? 200));
const hasDailyAmountLimit = computed(() => Number(withdrawCfg.value?.daily_amount ?? withdrawLimits.value.daily_user_limit ?? 0) > 0);
const todayRemain = computed(() => {
if (!hasDailyAmountLimit.value) return singleLimit.value;
const rem = withdrawCfg.value?.remain_daily_amount ?? withdrawLimits.value.today_remain;
return rem !== undefined && rem !== null && Number(rem) >= 0 ? Number(rem) : singleLimit.value;
});
const hasDailyCountLimit = computed(() => Number(withdrawCfg.value?.daily_count || 0) > 0);
const remainDailyCount = computed(() => {
if (!hasDailyCountLimit.value) return -1;
return Math.max(0, Number(withdrawCfg.value?.remain_daily_count ?? 0));
});
const parsedWithdraw = computed(() => {
const n = Number(withdrawAmount.value);
return Number.isFinite(n) && n > 0 ? Math.round(n * 100) / 100 : 0;
});
const feeBreakdown = computed(() => {
const amt = parsedWithdraw.value;
if (amt <= 0) return { fee: 0, arrive: 0 };
const cfg = withdrawCfg.value;
let fee = 0;
if (cfg) {
if (cfg.fee_mode === 'percent') {
fee = Math.round(amt * Number(cfg.fee_rate || 0)) / 100;
const minF = Number(cfg.fee_min || 0);
const maxF = Number(cfg.fee_max || 0);
if (minF > 0 && fee < minF) fee = minF;
if (maxF > 0 && fee > maxF) fee = maxF;
} else if (cfg.fee_mode === 'fixed') {
fee = Number(cfg.fee_fixed || 0);
} else {
fee = 0;
}
} else {
fee = Math.round(amt * Number(withdrawLimits.value.fee_rate || 0) * 100) / 100;
}
fee = Math.round(Math.max(0, fee) * 100) / 100;
if (fee >= amt) {
fee = Math.max(0, Math.round((amt - 0.1) * 100) / 100);
}
const arrive = Math.max(0, Math.round((amt - fee) * 100) / 100);
return { fee, arrive };
});
const withdrawFee = computed(() => feeBreakdown.value.fee.toFixed(2));
const withdrawArrive = computed(() => feeBreakdown.value.arrive.toFixed(2));
const withdrawErrorHint = computed(() => {
const amt = parsedWithdraw.value;
if (selectedChannel.value === 'bank' && !bankAccount.value.trim()) {
return amt > 0 ? '请填写收款银行与储蓄卡号' : '';
}
if (!amt) return '';
if (amt < minWithdraw.value) {
return `单笔提现最低 ¥${formatMoney(minWithdraw.value)}`;
}
if (amt > availMoney.value) {
return '输入金额超出当前可提现余额';
}
if (amt > singleLimit.value) {
return `单笔提现上限为 ¥${formatMoney(singleLimit.value)}`;
}
if (hasDailyAmountLimit.value && amt > todayRemain.value) {
return `超出今日剩余可提额度 ¥${formatMoney(todayRemain.value)}`;
}
if (selectedChannel.value === 'wechat' && feeBreakdown.value.arrive < 0.1) {
return '扣除手续费后实际到账不能低于 ¥0.10';
}
return '';
});
const canSubmitWithdraw = computed(() => {
const amt = parsedWithdraw.value;
const bankOk = selectedChannel.value !== 'bank' || bankAccount.value.trim().length > 0;
const dailyAmtOk = !hasDailyAmountLimit.value || amt <= todayRemain.value;
const dailyCntOk = !hasDailyCountLimit.value || remainDailyCount.value > 0;
return !withdrawing.value
&& withdrawEnabled.value
&& bankOk
&& dailyCntOk
&& amt >= minWithdraw.value
&& amt <= availMoney.value
&& amt <= singleLimit.value
&& dailyAmtOk
&& (selectedChannel.value !== 'wechat' || feeBreakdown.value.arrive >= 0.1);
});
const filteredLogs = computed(() => {
if (filterType.value === 'all') return logs.value;
return logs.value.filter(l => l.type === filterType.value);
});
function formatMoney(v) {
const num = Number(v || 0);
return Number.isFinite(num) ? num.toFixed(2) : '0.00';
}
function logTypeText(t) {
return { settle: '工单结算入账', withdraw: '提现变动', income: '奖励补贴入账', refund: '退款扣减' }[t] || '收支变动';
}
function withdrawStatusClass(w) {
if (!w) return 'st-wait';
if (w.can_confirm) return 'st-confirm';
if (w.status === 'done') return 'st-done';
if (w.status === 'reject') return 'st-reject';
return 'st-wait';
}
function fullTimeText(ts) {
if (!ts) return '';
const d = new Date(Number(ts) * 1000);
const p = (n) => (n < 10 ? '0' + n : n);
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
}
async function load() {
try {
const res = await api.masterIncome();
income.value = res;
logs.value = res.logs || [];
withdrawList.value = res.withdraw_list || [];
pendingConfirmList.value = res.pending_confirm_withdraws || [];
if (activeWithdraw.value) {
const refreshed = withdrawList.value.find(item => item.id === activeWithdraw.value.id);
activeWithdraw.value = refreshed || null;
}
} catch (e) {}
}
function openWithdraw() {
if (!withdrawEnabled.value) {
uni.showToast({ title: withdrawCloseTip.value, icon: 'none' });
return;
}
if (hasDailyCountLimit.value && remainDailyCount.value <= 0) {
uni.showToast({ title: '今日提现申请次数已达上限,请明日再试', icon: 'none' });
return;
}
if (availMoney.value < minWithdraw.value) {
uni.showToast({ title: `可提现余额满 ¥${formatMoney(minWithdraw.value)} 方可发起提现`, icon: 'none' });
return;
}
if (hasDailyAmountLimit.value && todayRemain.value < minWithdraw.value) {
uni.showToast({ title: `今日剩余提现额度为 ¥${formatMoney(todayRemain.value)},请明日再试`, icon: 'none' });
return;
}
const chs = withdrawChannels.value;
if (!chs.includes(selectedChannel.value)) {
selectedChannel.value = chs[0] || 'wechat';
}
withdrawAmount.value = '';
showWithdrawDrawer.value = true;
}
function fillAllBalance() {
if (availMoney.value <= 0) return;
const caps = [availMoney.value, singleLimit.value];
if (hasDailyAmountLimit.value) {
caps.push(todayRemain.value);
}
const maxAllowed = Math.min(...caps);
if (maxAllowed < minWithdraw.value) {
uni.showToast({ title: `当前可提上限不足 ¥${formatMoney(minWithdraw.value)}`, icon: 'none' });
return;
}
const rounded = Math.floor(maxAllowed * 100) / 100;
withdrawAmount.value = rounded.toFixed(2);
if (availMoney.value > rounded) {
uni.showToast({ title: `受单笔/单日额度限制,本次最多可提 ¥${rounded.toFixed(2)}`, icon: 'none' });
}
}
async function submitWithdraw() {
if (withdrawing.value || !canSubmitWithdraw.value) return;
const amt = parsedWithdraw.value;
withdrawing.value = true;
try {
const paymentPassword = await paymentPasswordDialog.value.open();
if (!paymentPassword) return;
const wxCode = selectedChannel.value === 'wechat' ? await getSafeWxCode() : '';
const res = await api.masterWithdraw({
amount: amt,
payment_password: paymentPassword,
channel: selectedChannel.value,
account: selectedChannel.value === 'bank' ? bankAccount.value.trim() : '微信零钱',
wx_code: wxCode
});
const arriveVal = res?.arrive_amount ?? res?.arrive ?? withdrawArrive.value;
showWithdrawDrawer.value = false;
filterType.value = 'withdraw';
await load();
// 若命中后台「小额免审自动发起转账」,立即拉起微信官方确认收款半屏页;若自动发起失败,必须明确告知真实中文原因
if (res && res.can_confirm && res.withdraw_id) {
await handleConfirmReceive({ id: res.withdraw_id });
} else if (res && res.auto_fail_reason) {
uni.showModal({
title: '提现已受理但自动打款失败',
content: `本次小额免审自动发起微信转账失败:${res.auto_fail_reason}。提现单已保留,请等待或联系平台财务核查处理。`,
showCancel: false,
confirmText: '知道了'
});
} else {
const suffix = selectedChannel.value === 'bank' ? '财务审核后打款至银行卡' : '审核后请在此确认收款';
uni.showToast({ title: `已提交(预计到账 ¥${formatMoney(arriveVal)}),${suffix}`, icon: 'none' });
}
} catch (e) {
if (e && e.code === undefined && !e.handledToast && e.message) {
uni.showToast({ title: e.message, icon: 'none' });
}
} finally {
withdrawing.value = false;
}
}
async function handleConfirmReceive(item, closeDrawerOnDone = false) {
if (!item || !item.id || confirmingId.value > 0) return;
confirmingId.value = item.id;
try {
const res = await invokeMerchantTransferConfirm(item.id);
if (closeDrawerOnDone && res && res.done) {
activeWithdraw.value = null;
}
await load();
} catch (e) {
if (e && e.code === undefined && !e.handledToast && e.message) {
uni.showToast({ title: e.message, icon: 'none' });
}
await load();
} finally {
confirmingId.value = 0;
}
}
function openLogDetail(item) {
activeLog.value = item;
}
function openWithdrawDetail(item) {
activeWithdraw.value = item;
}
function goOrderDetail(orderId) {
activeLog.value = null;
uni.navigateTo({ url: `/pages/master/detail?id=${orderId}` });
}
onShow(() => {
navHeight.value = getNavBarMetrics().totalNavHeight;
load();
});
</script>
<style lang="scss" scoped>
.page {
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
background: $yjyf-bg-page;
}
.wallet-scroll {
flex: 1;
height: 0;
width: 100%;
}
/* 顶部沉浸式资产卡片 */
.wallet-hero {
padding-bottom: 36rpx;
background-color: $yjyf-primary;
background-image: $yjyf-gradient-primary;
background-size: 100% 620rpx;
background-repeat: no-repeat;
display: flex;
flex-direction: column;
}
.wallet-body {
padding: 20rpx $yjyf-space-lg 0;
}
.hero-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.hero-lab {
font-size: $yjyf-font-sub;
color: rgba(255, 255, 255, 0.92);
}
.channel-tag {
display: inline-flex;
align-items: center;
height: 44rpx;
padding: 0 18rpx;
border-radius: $yjyf-radius-pill;
background: rgba(255, 255, 255, 0.2);
}
.wechat-ico {
width: 26rpx;
height: 26rpx;
margin-right: 8rpx;
}
.channel-txt {
font-size: $yjyf-font-micro;
color: $yjyf-bg-card;
font-weight: 500;
}
.hero-num {
display: block;
margin-top: 14rpx;
font-size: 68rpx;
font-weight: 700;
color: $yjyf-bg-card;
line-height: 1.15;
font-variant-numeric: tabular-nums;
}
.hero-metrics {
margin-top: 24rpx;
padding: 20rpx 24rpx;
border-radius: $yjyf-radius-md;
background: rgba(255, 255, 255, 0.16);
display: flex;
align-items: center;
justify-content: space-between;
}
.metric-item {
flex: 1;
display: flex;
flex-direction: column;
}
.metric-divider {
width: 1rpx;
height: 44rpx;
background: rgba(255, 255, 255, 0.24);
margin: 0 20rpx;
}
.metric-lab {
font-size: $yjyf-font-micro;
color: rgba(255, 255, 255, 0.85);
}
.metric-val {
margin-top: 6rpx;
font-size: $yjyf-font-body;
font-weight: 700;
color: $yjyf-bg-card;
font-variant-numeric: tabular-nums;
}
.withdraw-cta {
margin-top: 28rpx;
height: 80rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-bg-card;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
}
.withdraw-cta.disabled {
opacity: 0.65;
}
.withdraw-cta-txt {
color: $yjyf-primary;
font-size: $yjyf-font-body;
font-weight: 700;
}
/* 待确认收款提醒横幅 */
.receive-banner {
margin: 20rpx $yjyf-space-md 0;
padding: 20rpx 22rpx;
background: $yjyf-bg-card;
border: 2rpx solid rgba($yjyf-success, 0.3);
border-radius: $yjyf-radius-md;
box-shadow: $yjyf-shadow-card;
display: flex;
align-items: center;
}
.receive-ico {
width: 56rpx;
height: 56rpx;
margin-right: 16rpx;
flex-shrink: 0;
}
.receive-main {
flex: 1;
min-width: 0;
margin-right: 16rpx;
display: flex;
flex-direction: column;
}
.receive-title {
font-size: $yjyf-font-body;
font-weight: 700;
color: $yjyf-text-main;
line-height: 1.35;
}
.receive-sub {
margin-top: 4rpx;
font-size: $yjyf-font-micro;
color: $yjyf-text-secondary;
line-height: 1.4;
}
.receive-btn {
height: 60rpx;
padding: 0 24rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-success;
color: $yjyf-bg-card;
font-size: $yjyf-font-sub;
font-weight: 600;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.receive-btn.disabled {
opacity: 0.55;
}
/* 规则提示条 */
.tips-bar {
margin: 20rpx $yjyf-space-md 0;
padding: 18rpx 22rpx;
background: $yjyf-primary-bg;
border-radius: $yjyf-radius-sm;
display: flex;
align-items: center;
}
.tips-ico {
width: 28rpx;
height: 28rpx;
margin-right: 12rpx;
flex-shrink: 0;
}
.tips-txt {
flex: 1;
font-size: $yjyf-font-micro;
color: $yjyf-primary;
line-height: 1.45;
}
/* 账单卡片 */
.bill-card {
margin: 20rpx $yjyf-space-md 48rpx;
padding: $yjyf-space-md;
background: $yjyf-bg-card;
border-radius: $yjyf-radius-md;
box-shadow: $yjyf-shadow-card;
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 16rpx;
border-bottom: 1rpx solid $yjyf-border-color;
}
.card-title {
font-size: $yjyf-font-title;
font-weight: 700;
color: $yjyf-text-main;
}
.filter-tabs {
display: flex;
align-items: center;
gap: 8rpx;
}
.ft-item {
height: 52rpx;
padding: 0 22rpx;
border-radius: $yjyf-radius-pill;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
background: $yjyf-bg-page;
}
.ft-item.on {
background: $yjyf-primary-bg;
color: $yjyf-primary;
font-weight: 600;
}
.ft-badge {
margin-left: 6rpx;
min-width: 30rpx;
height: 30rpx;
padding: 0 8rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-success;
color: $yjyf-bg-card;
font-size: $yjyf-font-micro;
font-weight: 700;
display: inline-flex;
align-items: center;
justify-content: center;
}
.wd-row-ico {
width: 52rpx;
height: 52rpx;
margin-right: 16rpx;
flex-shrink: 0;
}
.wd-status-tag {
height: 36rpx;
padding: 0 12rpx;
border-radius: 8rpx;
font-size: $yjyf-font-micro;
font-weight: 600;
display: inline-flex;
align-items: center;
}
.wd-status-tag.st-confirm {
background: rgba($yjyf-success, 0.12);
color: $yjyf-success;
}
.wd-status-tag.st-done {
background: $yjyf-bg-page;
color: $yjyf-text-secondary;
}
.wd-status-tag.st-reject {
background: rgba($yjyf-danger, 0.1);
color: $yjyf-danger;
}
.wd-status-tag.st-wait {
background: rgba($yjyf-warning, 0.14);
color: $yjyf-warning;
}
.wd-fail-txt {
margin-top: 6rpx;
font-size: $yjyf-font-micro;
color: $yjyf-danger;
line-height: 1.4;
}
.wd-confirm-pill {
margin-top: 10rpx;
height: 48rpx;
padding: 0 20rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-success;
color: $yjyf-bg-card;
font-size: $yjyf-font-micro;
font-weight: 600;
display: inline-flex;
align-items: center;
justify-content: center;
}
.wd-confirm-pill.disabled {
opacity: 0.55;
}
.log-list {
display: flex;
flex-direction: column;
}
.log-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 0;
border-bottom: 1rpx solid $yjyf-border-color;
}
.log-row:last-child {
border-bottom: none;
}
.log-main {
flex: 1;
min-width: 0;
margin-right: 20rpx;
display: flex;
flex-direction: column;
}
.log-title-line {
display: flex;
align-items: center;
gap: 12rpx;
}
.log-type {
font-size: $yjyf-font-body;
font-weight: 600;
color: $yjyf-text-main;
}
.log-order-tag {
height: 36rpx;
padding: 0 12rpx;
border-radius: 8rpx;
background: $yjyf-primary-bg;
color: $yjyf-primary;
font-size: $yjyf-font-micro;
display: inline-flex;
align-items: center;
}
.log-remark {
margin-top: 8rpx;
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.log-time {
margin-top: 6rpx;
font-size: $yjyf-font-micro;
color: $yjyf-text-muted;
}
.log-right {
display: flex;
align-items: center;
flex-shrink: 0;
}
.log-amt-wrap {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.log-amt {
font-size: $yjyf-font-title;
font-weight: 700;
color: $yjyf-success;
font-variant-numeric: tabular-nums;
}
.log-amt.minus {
color: $yjyf-danger;
}
.log-bal {
margin-top: 6rpx;
font-size: $yjyf-font-micro;
color: $yjyf-text-muted;
}
.row-arrow {
width: 24rpx;
height: 24rpx;
margin-left: 12rpx;
opacity: 0.45;
}
.empty-box {
display: flex;
flex-direction: column;
align-items: center;
padding: 72rpx 0 48rpx;
}
.empty-img {
width: 160rpx;
height: 160rpx;
margin-bottom: 16rpx;
}
.empty-txt {
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
}
/* 半屏抽屉通用 */
.drawer-mask {
position: fixed;
inset: 0;
z-index: 900;
background: rgba(0, 0, 0, 0.48);
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.drawer-panel {
background: $yjyf-bg-card;
border-radius: 28rpx 28rpx 0 0;
padding: 28rpx $yjyf-space-lg calc(32rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
}
.drawer-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 24rpx;
}
.drawer-title {
font-size: $yjyf-font-title;
font-weight: 700;
color: $yjyf-text-main;
}
.drawer-close {
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
}
.close-ico {
width: 30rpx;
height: 30rpx;
}
.channel-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 24rpx;
border-radius: $yjyf-radius-sm;
background: $yjyf-bg-page;
}
.channel-label {
font-size: $yjyf-font-sub;
color: $yjyf-text-regular;
}
.channel-val {
display: flex;
align-items: center;
}
.ch-ico {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
.ch-name {
font-size: $yjyf-font-sub;
font-weight: 600;
color: $yjyf-text-main;
}
.channel-switch-box {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16rpx 24rpx;
border-radius: $yjyf-radius-sm;
background: $yjyf-bg-page;
}
.channel-pills {
display: flex;
align-items: center;
gap: 16rpx;
}
.ch-pill {
height: 60rpx;
padding: 0 22rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-bg-card;
border: 2rpx solid $yjyf-border-color;
display: inline-flex;
align-items: center;
font-size: $yjyf-font-sub;
color: $yjyf-text-regular;
}
.ch-pill.active {
border-color: $yjyf-primary;
background: $yjyf-primary-bg;
color: $yjyf-primary;
font-weight: 600;
}
.bank-input-box {
margin-top: 20rpx;
padding: 20rpx 24rpx;
border-radius: $yjyf-radius-md;
border: 1rpx solid $yjyf-border-color;
}
.bank-label {
display: block;
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
margin-bottom: 12rpx;
}
.bank-input {
height: 60rpx;
font-size: $yjyf-font-body;
color: $yjyf-text-main;
}
.amt-box {
margin-top: 24rpx;
padding: 24rpx;
border-radius: $yjyf-radius-md;
border: 1rpx solid $yjyf-border-color;
}
.amt-box-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.amt-label {
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
}
.amt-all {
font-size: $yjyf-font-sub;
font-weight: 600;
color: $yjyf-primary;
padding: 4rpx 8rpx;
}
.amt-input-line {
margin-top: 20rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid $yjyf-border-color;
display: flex;
align-items: baseline;
}
.amt-symbol {
font-size: $yjyf-font-hero;
font-weight: 700;
color: $yjyf-text-main;
margin-right: 12rpx;
}
.amt-input {
flex: 1;
height: 68rpx;
font-size: $yjyf-font-hero;
font-weight: 700;
color: $yjyf-text-main;
}
.amt-meta {
margin-top: 16rpx;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.meta-item {
font-size: $yjyf-font-micro;
color: $yjyf-text-secondary;
}
.meta-item.warn {
color: $yjyf-danger;
}
/* 提现申请:让金额和到账信息更易核对 */
.withdraw-panel {
max-height: 90vh;
overflow-y: auto;
border-radius: 36rpx 36rpx 0 0;
padding-top: 32rpx;
}
.withdraw-panel .drawer-head { margin-bottom: 28rpx; }
.withdraw-heading { display: flex; flex-direction: column; gap: 8rpx; }
.withdraw-panel .drawer-title { font-size: 36rpx; }
.withdraw-subtitle { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
.withdraw-panel .drawer-close { width: 88rpx; height: 88rpx; margin: -12rpx -20rpx -12rpx 0; }
.withdraw-panel .channel-row { padding: 22rpx 24rpx; border-radius: $yjyf-radius-md; }
.withdraw-panel .channel-val { min-width: 0; }
.withdraw-panel .channel-val .ch-ico { width: 48rpx; height: 48rpx; margin-right: 20rpx; flex-shrink: 0; }
.channel-copy { display: flex; flex-direction: column; gap: 6rpx; min-width: 0; }
.withdraw-panel .channel-label { color: $yjyf-text-secondary; font-size: $yjyf-font-sub; }
.withdraw-panel .ch-name { line-height: 1.45; font-size: $yjyf-font-body; }
.withdraw-panel .channel-switch-box { align-items: flex-start; flex-direction: column; gap: 16rpx; padding: 22rpx 24rpx; border-radius: $yjyf-radius-md; }
.withdraw-panel .channel-pills { flex-wrap: wrap; }
.withdraw-panel .ch-pill { min-height: 80rpx; box-sizing: border-box; }
.withdraw-panel .amt-box { margin-top: 28rpx; padding: 0; border: 0; }
.withdraw-panel .amt-label { color: $yjyf-text-main; font-size: $yjyf-font-body; font-weight: 600; }
.withdraw-panel .amt-all { display: flex; align-items: center; min-height: 80rpx; padding: 0 8rpx; }
.withdraw-panel .amt-input-line { margin-top: 0; padding: 8rpx 0 20rpx; align-items: center; }
.withdraw-panel .amt-symbol { font-size: 48rpx; margin-right: 16rpx; }
.withdraw-panel .amt-input { min-width: 0; height: 88rpx; font-size: 56rpx; font-variant-numeric: tabular-nums; }
.withdraw-panel .amt-placeholder { color: $yjyf-text-disabled; font-size: 32rpx; font-weight: 400; }
.withdraw-panel .amt-meta { margin-top: 20rpx; gap: 10rpx; }
.balance-line { font-size: $yjyf-font-sub; color: $yjyf-text-regular; }
.balance-value { color: $yjyf-text-main; font-weight: 600; font-variant-numeric: tabular-nums; }
.withdraw-panel .meta-item { line-height: 1.5; }
.withdraw-panel .estimate { color: $yjyf-text-regular; }
.withdraw-panel .drawer-submit { margin-top: 36rpx; box-shadow: $yjyf-shadow-button; }
.withdraw-panel .drawer-submit.disabled { box-shadow: none; }
.detail-hero {
padding: 24rpx 0 28rpx;
border-bottom: 1rpx solid $yjyf-border-color;
display: flex;
flex-direction: column;
align-items: center;
}
.dh-type {
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
}
.dh-amt {
margin-top: 12rpx;
font-size: 56rpx;
font-weight: 700;
color: $yjyf-success;
font-variant-numeric: tabular-nums;
}
.dh-amt.minus {
color: $yjyf-danger;
}
.detail-cells {
padding: 16rpx 0;
}
.d-cell {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 16rpx 0;
}
.d-lab {
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
flex-shrink: 0;
margin-right: 24rpx;
}
.d-val {
font-size: $yjyf-font-sub;
color: $yjyf-text-main;
font-weight: 500;
text-align: right;
}
.d-val.multi {
line-height: 1.5;
}
.d-val.highlight {
color: $yjyf-success;
font-weight: 700;
}
.drawer-submit {
margin-top: 28rpx;
height: 88rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-gradient-primary;
color: $yjyf-bg-card;
font-size: $yjyf-font-body;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
box-shadow: $yjyf-shadow-card;
}
.drawer-submit.disabled {
opacity: 0.55;
}
</style>