feat: 新增提现详情页与撤销微信转账功能

新增分销提现单详情页面及接口,支持查看提现单据完整信息;新增后台撤销转账中提现单功能,前端添加对应操作按钮与交互逻辑;完善提现记录跳转逻辑,支持点击进入详情页,同时新增部署脚本同步线上代码。
这个提交包含在:
2026-10-28 17:46:51 +08:00
父节点 ea26329e80
当前提交 589d6aa216
共有 10 个文件被更改,包括 1144 次插入 和 4 次删除

查看文件

@@ -281,6 +281,24 @@ class Withdraw extends Backend
}
}
// 单笔精准反馈文案
if (count($withdraws) === 1) {
$row = $withdraws[0];
if ($errors) {
$this->error('同步失败:' . $errors[0]);
}
$latest = Db::name('fc_withdraw')->where('id', $row['id'])->find();
$transferStatus = (string)$latest['transfer_status'];
$stText = $transferStatus === 'WAIT_USER_CONFIRM' ? '待收款用户确认' : ($transferStatus === 'SUCCESS' ? '已转账成功' : ($transferStatus ?: '处理中'));
if ($latest['status'] === 'paid') {
$this->success('微信转账已完成,单据已更新为「已成功到账」');
} elseif ($latest['status'] === 'failed') {
$this->error('微信转账已失败/已撤销:' . ($latest['fail_reason'] ?: '未知原因'));
} else {
$this->success('已同步微信最新状态:' . $stText . '(微信已受理,需收款人在微信完成确认方可到账)');
}
}
$msg = '状态同步完成:';
if ($successCount > 0) {
$msg .= $successCount . ' 笔已确认到账;';
@@ -297,4 +315,33 @@ class Withdraw extends Backend
$this->success($msg);
}
/**
* 撤销「转账中」的微信转账提现单
*
* @return void
*/
public function cancel()
{
$id = (int)$this->request->post('id', 0);
if ($id <= 0) {
$this->error('参数错误');
}
$withdraw = Db::name('fc_withdraw')->where('id', $id)->find();
if (!$withdraw) {
$this->error('提现记录不存在');
}
if ((string)$withdraw['status'] !== 'paying') {
$this->error('只有处于「转账中」的记录方可撤销(当前:' . $withdraw['status'] . ')');
}
try {
$state = \app\common\library\WxTransfer::cancel($id);
} catch (\Throwable $e) {
$this->error('撤销失败:' . $e->getMessage());
}
$this->success('转账已成功撤销,款项额度已自动退回用户可提现余额');
}
}

查看文件

@@ -216,6 +216,9 @@
<button type="button" class="btn btn-info btn-action-sync" data-id="{$row.id}" style="padding:6px 16px;">
<i class="fa fa-refresh"></i> 查询微信转账最新状态
</button>
<button type="button" class="btn btn-danger btn-action-cancel" data-id="{$row.id}" data-no="{$row.withdraw_no}" style="padding:6px 16px;">
<i class="fa fa-times-circle"></i> 撤销微信转账
</button>
{/if}
<button type="button" class="btn btn-default" onclick="parent.Layer.close(parent.Layer.getFrameIndex(window.name));" style="padding:6px 16px;">关闭</button>

查看文件

@@ -376,6 +376,57 @@ class Distribution extends V1
$this->ok($list);
}
/**
* D8 提现单详情
* GET /api/v1/distribution/withdraw-detail 入参 {id|withdrawNo}
*
* @return void 输出提现流水单据详细信息JSON
*/
public function withdrawDetail()
{
$user = $this->auth();
$id = (int)$this->input('id', 0);
$no = trim((string)$this->input('withdrawNo', ''));
$query = Db::name('fc_withdraw')->where('user_id', $user['id']);
if ($id > 0) {
$query->where('id', $id);
} elseif ($no !== '') {
$query->where('withdraw_no', $no);
} else {
$this->fail('参数错误');
}
$row = $query->find();
if (!$row) {
$this->fail('提现记录不存在');
}
$epay = (array)get_addon_config('epay');
$wx = isset($epay['wechat']) && is_array($epay['wechat']) ? $epay['wechat'] : [];
$mchId = isset($wx['mch_id']) ? (string)$wx['mch_id'] : '1118898018';
$appId = isset($wx['miniapp_id']) ? (string)$wx['miniapp_id'] : 'wxbfcb778f3019cff8';
$this->ok([
'id' => (int)$row['id'],
'withdrawNo' => (string)$row['withdraw_no'],
'amount' => round((float)$row['amount'], 2),
'channel' => (string)$row['channel'],
'status' => (string)$row['status'],
'reason' => (string)$row['reason'],
'outBillNo' => (string)$row['out_bill_no'],
'transferStatus' => (string)$row['transfer_status'],
'transferId' => (string)$row['transfer_id'],
'packageInfo' => (string)$row['package_info'],
'failReason' => (string)$row['fail_reason'],
'createdAt' => $this->iso($row['createtime']),
'payTime' => !empty($row['paytime']) ? $this->iso($row['paytime']) : '',
'transferTime' => !empty($row['transfer_time']) ? $this->iso($row['transfer_time']) : '',
'transferMchId' => $mchId,
'transferAppId' => $appId,
]);
}
/**
* D7 手动输入邀请码补绑推荐人(老用户不支持自动补绑,仅支持通过手动填写邀请码完成补绑)
* POST /api/v1/distribution/bind 入参 {inviteCode}

查看文件

@@ -103,6 +103,7 @@ return [
'api/v1/distribution/poster' => 'api/Distribution/poster',
'api/v1/distribution/withdraw' => 'api/Distribution/withdraw',
'api/v1/distribution/withdraw-records' => 'api/Distribution/withdrawRecords',
'api/v1/distribution/withdraw-detail' => 'api/Distribution/withdrawDetail',
'api/v1/distribution/bind' => 'api/Distribution/bind',
/* =============== 六、用户端 · 消息中心(Module-MESSAGE) =============== */

查看文件

@@ -174,6 +174,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
return true;
});
}
},
{
name: 'cancel',
text: '撤销',
title: '撤销微信转账',
classname: 'btn btn-xs btn-danger btn-click',
icon: 'fa fa-times-circle',
visible: function (row) {
return row.status === 'paying';
},
click: function (options, row) {
Layer.confirm('确认撤销提现单「' + row.withdraw_no + '」的微信转账?<br><span class="text-danger" style="font-size:12px;">撤销后微信转账单将失效,款项额度自动退回用户可提现余额。</span>', {
title: '撤销转账单确认',
icon: 3,
btn: ['确认撤销', '取消']
}, function (index) {
Layer.close(index);
var loadIdx = Layer.load(1);
Fast.api.ajax({
url: 'fc/withdraw/cancel',
data: {id: row.id}
}, function (data, ret) {
Layer.close(loadIdx);
Toastr.success(ret.msg || '转账已撤销');
$('#' + options.tableId).bootstrapTable('refresh');
return false;
}, function () {
Layer.close(loadIdx);
return true;
});
});
}
}
]
}
@@ -292,6 +324,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
return true;
});
});
// 4. 撤销微信转账单
$(document).on('click', '.btn-action-cancel', function () {
var id = $(this).data('id');
var no = $(this).data('no');
Layer.confirm('确认撤销提现单「' + no + '」的微信转账?<br><span class="text-danger" style="font-size:12px;">撤销后微信转账单失效,款项额度将自动退回用户可提现余额。</span>', {
title: '撤销转账单确认',
icon: 3,
btn: ['确认撤销', '取消']
}, function (index) {
Layer.close(index);
var loadIdx = Layer.load(1);
Fast.api.ajax({
url: 'fc/withdraw/cancel',
data: {id: id}
}, function (data, ret) {
Layer.close(loadIdx);
Toastr.success(ret.msg || '转账已撤销');
setTimeout(function () {
Fast.api.close();
parent.$("#table").bootstrapTable('refresh');
}, 1200);
return false;
}, function () {
Layer.close(loadIdx);
return true;
});
});
});
},
api: {

查看文件

@@ -0,0 +1,89 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
部署最新修改到线上服务器:
- application/admin/controller/fc/Withdraw.php
- application/admin/view/fc/withdraw/edit.html
- application/api/controller/Distribution.php
- application/route.php
- public/assets/js/backend/fc/withdraw.js
"""
import os
import sys
import io
import paramiko
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
HOST = "8.137.181.63"
PORT = 22
USER = "root"
PASSWORD = "liyanxia@6688"
REMOTE_ROOT = "/www/wwwroot/fenleixinxi.gzyakj.com.cn"
LOCAL_ROOT = r"D:\Softwares\phpstudy_pro\WWW\fenleixinxi"
SYNC_FILES = [
"application/admin/controller/fc/Withdraw.php",
"application/admin/view/fc/withdraw/edit.html",
"application/api/controller/Distribution.php",
"application/route.php",
"public/assets/js/backend/fc/withdraw.js",
]
def ssh_exec(client, cmd):
stdin, stdout, stderr = client.exec_command(cmd)
out = stdout.read().decode("utf-8", errors="replace").strip()
err = stderr.read().decode("utf-8", errors="replace").strip()
return out, err
def main():
print("=== [1/3] 连接线上服务器 ===")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(HOST, port=PORT, username=USER, password=PASSWORD, timeout=30)
print(f"✓ 成功连接 {HOST}")
sftp = client.open_sftp()
print("✓ SFTP 通道已建立")
print("\n=== [2/3] 上传最新修改文件 ===")
for rel_path in SYNC_FILES:
local_path = os.path.join(LOCAL_ROOT, rel_path.replace("/", "\\"))
remote_path = f"{REMOTE_ROOT}/{rel_path}"
if not os.path.exists(local_path):
print(f" ✗ 本地文件缺失: {local_path}")
continue
remote_dir = os.path.dirname(remote_path)
ssh_exec(client, f"mkdir -p '{remote_dir}'")
sftp.put(local_path, remote_path)
ssh_exec(client, f"chown www:www '{remote_path}'")
file_size = os.path.getsize(local_path)
print(f" ✓ 已同步: {rel_path} ({file_size} 字节)")
sftp.close()
print("\n=== [3/3] 清理缓存与服务自检 ===")
ssh_exec(client, f"rm -rf {REMOTE_ROOT}/runtime/temp/* {REMOTE_ROOT}/runtime/cache/*")
print("✓ 线上 ThinkPHP 运行时缓存清理完成")
# 服务健康自检
check_urls = [
("API 信息流接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/home/feed"),
("API 分类接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/home/categories"),
("API 提现详情接口", "https://fenleixinxi.gzyakj.com.cn/api/v1/distribution/withdraw-detail"),
("后台登录页面", "https://fenleixinxi.gzyakj.com.cn/s.php/index/login"),
]
for name, url in check_urls:
cmd = f"curl -s -o /dev/null -w '%{{http_code}}' -k '{url}'"
code, _ = ssh_exec(client, cmd)
print(f" {name}: HTTP {code}")
client.close()
print("\n✓ 最新代码已全部部署至线上服务器!")
if __name__ == "__main__":
main()

查看文件

@@ -17,6 +17,8 @@ export const distributionApi = {
withdraw: (payload) => post('/distribution/withdraw', payload, { silent: true }),
/** 提现记录 */
withdrawRecords: () => get('/distribution/withdraw-records', {}, { silent: true }),
/** 提现单详情 */
withdrawDetail: (params = {}) => get('/distribution/withdraw-detail', params, { silent: true }),
/** 绑定分销推荐人(扫码自动补绑 / 手动填写邀请码绑定) */
bind: (payload = {}) => post('/distribution/bind', payload, { silent: true }),
}

查看文件

@@ -165,6 +165,14 @@
"enablePullDownRefresh": true
}
},
{
"path": "pages/distribution/withdraw-detail",
"style": {
"navigationBarTitleText": "提现详情",
"navigationStyle": "custom",
"backgroundColor": "#f2fef7"
}
},
{
"path": "pages/admin/setting",
"style": {

查看文件

@@ -329,7 +329,7 @@
</view>
<view v-else class="dist__record-list">
<view v-for="w in visibleRecords" :key="w.id" class="dist__record">
<view v-for="w in visibleRecords" :key="w.id" class="dist__record" @click="goWithdrawDetail(w)">
<view class="dist__record-main">
<view class="dist__record-top">
<text class="dist__record-title">提现到微信零钱</text>
@@ -343,9 +343,10 @@
</view>
<view class="dist__record-right">
<text class="dist__record-amount">-¥{{ money(w.amount) }}</text>
<view v-if="w.status === 'paying'" class="dist__record-action" @click="confirmTransfer(w)">
<text>{{ w.transferStatus === 'WAIT_USER_CONFIRM' ? '去确认收款' : '转账中' }}</text>
<view v-if="w.status === 'paying'" class="dist__record-action" @click.stop="confirmTransfer(w)">
<text>{{ w.transferStatus === 'WAIT_USER_CONFIRM' ? (w.packageInfo ? '去确认收款' : '查看详情') : '转账中' }}</text>
</view>
<view v-else class="dist__record-arrow">›</view>
</view>
</view>
@@ -358,6 +359,65 @@
<view class="dist__bottom-space"></view>
<!-- ==================== 提现单据详情弹层(双重兜底保障) ==================== -->
<view v-if="showDetailModal && activeWithdrawItem" class="dist__mask" @click="showDetailModal = false" @touchmove.stop.prevent>
<view class="dist__sheet" @click.stop>
<view class="dist__sheet-handle"></view>
<view class="dist__sheet-head">
<text class="dist__sheet-title">提现单详情</text>
<view class="dist__sheet-close" @click="showDetailModal = false">
<text class="dist__sheet-close-x">✕</text>
</view>
</view>
<view class="dist__detail-content">
<view class="dist__detail-hero">
<text class="dist__detail-symbol">-¥</text>
<text class="dist__detail-amount">{{ money(activeWithdrawItem.amount) }}</text>
</view>
<view class="dist__detail-status-tag" :class="'dist__record-status--' + activeWithdrawItem.status">
{{ statusText(activeWithdrawItem.status) }}
<text v-if="activeWithdrawItem.status === 'paying'"> · {{ activeWithdrawItem.transferStatus === 'WAIT_USER_CONFIRM' ? '待确认' : '处理中' }}</text>
</view>
<view v-if="activeWithdrawItem.status === 'paying' && !activeWithdrawItem.packageInfo" class="dist__detail-warn">
<text class="dist__detail-warn-text">⚠️ 该单据未获取到直接确认凭据。请联系管理员在后台点击「撤销」,撤销后额度将恢复,您可重新发起提现。</text>
</view>
<view class="dist__detail-rows">
<view class="dist__detail-row">
<text class="dist__detail-k">提现渠道</text>
<text class="dist__detail-v">微信零钱(商家转账)</text>
</view>
<view class="dist__detail-row">
<text class="dist__detail-k">提现单号</text>
<view class="dist__detail-v-wrap" @click="copyText(activeWithdrawItem.withdrawNo, '单号已复制')">
<text class="dist__detail-v fc-ellipsis">{{ activeWithdrawItem.withdrawNo }}</text>
<text class="dist__detail-copy">复制</text>
</view>
</view>
<view class="dist__detail-row">
<text class="dist__detail-k">申请时间</text>
<text class="dist__detail-v">{{ timeText(activeWithdrawItem.createdAt) }}</text>
</view>
<view v-if="activeWithdrawItem.failReason" class="dist__detail-row">
<text class="dist__detail-k">失败说明</text>
<text class="dist__detail-v text-danger">{{ activeWithdrawItem.failReason }}</text>
</view>
</view>
<button
v-if="activeWithdrawItem.status === 'paying' && activeWithdrawItem.packageInfo"
class="dist__btn-primary"
style="margin-top:28rpx;width:100%;height:80rpx;line-height:80rpx;"
@click="confirmTransfer(activeWithdrawItem)"
>
微信确认收款并到账
</button>
</view>
</view>
</view>
<!-- ==================== 提现申请弹层 ==================== -->
<view v-if="showWithdraw" class="dist__mask" @click="closeWithdraw" @touchmove.stop.prevent>
<view class="dist__sheet" @click.stop>
@@ -611,6 +671,8 @@ export default {
commissionStatus: '',
minWithdraw: 50,
showWithdraw: false,
showDetailModal: false,
activeWithdrawItem: null,
showRuleModal: false,
showBindModal: false,
bindCodeInput: '',
@@ -1569,9 +1631,26 @@ export default {
* 拉起微信「确认收款」页(商家转账模式)
* @param {Object} w 提现记录项
*/
/**
* 跳转到提现单详情页
* @param {Object} w 提现记录项
*/
goWithdrawDetail(w) {
if (!w) return
this.activeWithdrawItem = w
uni.navigateTo({
url: `/pages/distribution/withdraw-detail?id=${w.id || 0}&no=${w.withdrawNo || ''}`,
fail: (err) => {
console.warn('[WithdrawDetail] 独立页面跳转失败,激活内置详情抽屉:', err)
this.showDetailModal = true
},
})
},
confirmTransfer(w) {
if (!w || !w.packageInfo) {
uni.showToast({ title: '转账处理中,请稍后刷新重试', icon: 'none' })
// 未获取到确认 package 时直接引导跳转详情页查看排查指引
this.goWithdrawDetail(w)
return
}
// 优先使用微信原生 API(wx.requestMerchantTransfer 为微信基础库 3.3.0+ 商家转账确认专属 API)
@@ -2343,6 +2422,96 @@ export default {
font-size: 20rpx;
font-weight: 700;
}
.dist__detail-content {
padding: 20rpx 0 30rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.dist__detail-hero {
display: flex;
align-items: baseline;
margin-top: 10rpx;
color: #1E293B;
}
.dist__detail-symbol {
font-size: 36rpx;
font-weight: 700;
margin-right: 4rpx;
}
.dist__detail-amount {
font-size: 64rpx;
font-weight: 800;
}
.dist__detail-status-tag {
margin-top: 12rpx;
padding: 6rpx 20rpx;
border-radius: 999rpx;
font-size: 24rpx;
font-weight: 600;
}
.dist__detail-warn {
margin-top: 24rpx;
padding: 16rpx 20rpx;
background: #FFF8EB;
border: 1rpx solid #FFE1A6;
border-radius: 12rpx;
width: 100%;
box-sizing: border-box;
}
.dist__detail-warn-text {
font-size: 24rpx;
color: #D97706;
line-height: 1.5;
}
.dist__detail-rows {
width: 100%;
margin-top: 30rpx;
background: #F8FAFC;
border-radius: 16rpx;
padding: 20rpx 24rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 16rpx;
}
.dist__detail-row {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 26rpx;
}
.dist__detail-k {
color: #64748B;
flex-shrink: 0;
}
.dist__detail-v {
color: #1E293B;
font-weight: 500;
max-width: 420rpx;
text-align: right;
}
.dist__detail-v-wrap {
display: flex;
align-items: center;
gap: 8rpx;
}
.dist__detail-copy {
font-size: 22rpx;
color: #00A854;
background: #E8FAF0;
padding: 2rpx 10rpx;
border-radius: 6rpx;
}
.dist__record-arrow {
font-size: 32rpx;
color: #94A3B8;
margin-top: 4rpx;
line-height: 1;
}
.dist__record:active {
opacity: 0.85;
}
/* ==================== 展开收起 ==================== */
.dist__more {

查看文件

@@ -0,0 +1,708 @@
<template>
<view class="withdraw-detail-page">
<!-- 顶部沉浸式导航栏 -->
<fc-navbar title="提现详情" theme="gradient" :show-back="true"></fc-navbar>
<!-- 加载中状态 -->
<view v-if="loading" class="detail__loading">
<text class="detail__loading-text">加载中...</text>
</view>
<!-- 详情主体内容 -->
<view v-else-if="detail" class="detail__body">
<!-- 状态金额卡片 -->
<view class="detail__card detail__card--hero">
<view class="detail__status-icon-wrap" :class="'detail__status-icon-wrap--' + statusTheme">
<!-- 已到账图标 -->
<view v-if="detail.status === 'paid'" class="icon-paid">✓</view>
<!-- 待确认图标 -->
<view v-else-if="detail.status === 'paying'" class="icon-paying">⏳</view>
<!-- 审核中图标 -->
<view v-else-if="detail.status === 'auditing'" class="icon-auditing">⏱</view>
<!-- 失败/驳回图标 -->
<view v-else class="icon-failed">✕</view>
</view>
<text class="detail__status-title">{{ statusTitle }}</text>
<text class="detail__status-desc">{{ statusDesc }}</text>
<view class="detail__amount-wrap">
<text class="detail__amount-symbol">-¥</text>
<text class="detail__amount-num">{{ formatMoney(detail.amount) }}</text>
</view>
<!-- 针对无 packageInfo 时的特殊异常提示 -->
<view v-if="detail.status === 'paying' && !detail.packageInfo" class="detail__notice-warn">
<text class="detail__notice-icon">⚠️</text>
<text class="detail__notice-text">该笔提现因此前系统更新未记录到小程序确认凭据。请在微信服务通知中查看并确认收款,或联系管理员撤销该笔重新申请。</text>
</view>
</view>
<!-- 进度时间线卡片 -->
<view class="detail__card">
<view class="detail__card-header">
<text class="detail__card-title">流转进度</text>
</view>
<view class="detail__timeline">
<!-- 步骤1: 提交申请 -->
<view class="detail__timeline-item detail__timeline-item--done">
<view class="detail__timeline-dot"></view>
<view class="detail__timeline-content">
<text class="detail__timeline-name">提现申请已提交</text>
<text class="detail__timeline-time">{{ fmtTime(detail.createdAt) }}</text>
</view>
</view>
<!-- 步骤2: 审核与转账 -->
<view class="detail__timeline-item" :class="step2Class">
<view class="detail__timeline-dot"></view>
<view class="detail__timeline-content">
<text class="detail__timeline-name">{{ step2Title }}</text>
<text class="detail__timeline-time">{{ step2Time }}</text>
</view>
</view>
<!-- 步骤3: 确认收款与入账 -->
<view class="detail__timeline-item" :class="step3Class">
<view class="detail__timeline-dot"></view>
<view class="detail__timeline-content">
<text class="detail__timeline-name">{{ step3Title }}</text>
<text class="detail__timeline-time">{{ step3Time }}</text>
</view>
</view>
</view>
</view>
<!-- 单据详情信息卡片 -->
<view class="detail__card">
<view class="detail__card-header">
<text class="detail__card-title">单据凭证信息</text>
</view>
<view class="detail__info-list">
<view class="detail__info-item">
<text class="detail__info-label">提现渠道</text>
<text class="detail__info-val">微信零钱(商家转账)</text>
</view>
<view class="detail__info-item">
<text class="detail__info-label">提现单号</text>
<view class="detail__info-val-wrap" @click="copyText(detail.withdrawNo, '提现单号已复制')">
<text class="detail__info-val fc-ellipsis">{{ detail.withdrawNo }}</text>
<text class="detail__info-copy">复制</text>
</view>
</view>
<view v-if="detail.outBillNo" class="detail__info-item">
<text class="detail__info-label">商户转账单号</text>
<view class="detail__info-val-wrap" @click="copyText(detail.outBillNo, '商户转账单号已复制')">
<text class="detail__info-val fc-ellipsis">{{ detail.outBillNo }}</text>
<text class="detail__info-copy">复制</text>
</view>
</view>
<view v-if="detail.transferId" class="detail__info-item">
<text class="detail__info-label">微信转账单号</text>
<view class="detail__info-val-wrap" @click="copyText(detail.transferId, '微信转账单号已复制')">
<text class="detail__info-val fc-ellipsis">{{ detail.transferId }}</text>
<text class="detail__info-copy">复制</text>
</view>
</view>
<view class="detail__info-item">
<text class="detail__info-label">申请时间</text>
<text class="detail__info-val">{{ fmtTime(detail.createdAt) }}</text>
</view>
<view v-if="detail.payTime" class="detail__info-item">
<text class="detail__info-label">到账时间</text>
<text class="detail__info-val">{{ fmtTime(detail.payTime) }}</text>
</view>
<view v-if="detail.reason" class="detail__info-item">
<text class="detail__info-label">驳回原因</text>
<text class="detail__info-val detail__info-val--danger">{{ detail.reason }}</text>
</view>
<view v-if="detail.failReason" class="detail__info-item">
<text class="detail__info-label">失败原因</text>
<text class="detail__info-val detail__info-val--danger">{{ detail.failReason }}</text>
</view>
</view>
</view>
</view>
<!-- 底部固定操作栏 -->
<view v-if="detail" class="detail__footer">
<!-- 有 packageInfo 且处于待确认状态:显示唤起收款按钮 -->
<button
v-if="detail.status === 'paying' && detail.packageInfo"
class="detail__btn detail__btn--primary"
@click="confirmTransfer(detail)"
>
微信确认收款并到账
</button>
<!-- 兜底刷新状态按钮 -->
<button class="detail__btn detail__btn--secondary" @click="fetchDetail(true)">
刷新状态
</button>
</view>
</view>
</template>
<script>
/**
* 页面级脚本 · 提现记录详情
* 展示单笔提现流转凭据、各节点时间线及微信原生唤起确认收款逻辑
*/
import distributionApi from '@/common/api/distribution.js'
import { formatTime } from '@/common/utils/format.js'
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
export default {
components: { FcNavbar },
data() {
return {
id: 0,
withdrawNo: '',
loading: true,
detail: null,
}
},
computed: {
/**
* 状态主题颜色标识
* @returns {string} 主题样式后缀 (success|warning|danger|info)
*/
statusTheme() {
if (!this.detail) return 'info'
if (this.detail.status === 'paid') return 'success'
if (this.detail.status === 'paying') return 'warning'
if (this.detail.status === 'auditing') return 'info'
return 'danger'
},
/**
* 状态大标题文案
* @returns {string} 状态文案
*/
statusTitle() {
if (!this.detail) return '提现详情'
if (this.detail.status === 'paid') return '转账成功 · 已到账'
if (this.detail.status === 'paying') {
return this.detail.transferStatus === 'WAIT_USER_CONFIRM' ? '等待用户确认收款' : '转账处理中'
}
if (this.detail.status === 'auditing') return '提现申请审核中'
if (this.detail.status === 'rejected') return '提现已被驳回'
if (this.detail.status === 'failed') return '转账失败'
return '提现中'
},
/**
* 状态描述引导文案
* @returns {string} 引导文案
*/
statusDesc() {
if (!this.detail) return ''
if (this.detail.status === 'paid') return '资金已转入微信零钱,请在微信钱包查看'
if (this.detail.status === 'paying') {
return this.detail.packageInfo
? '微信转账已受理,请点击下方「微信确认收款」入账'
: '微信已受理,请在微信服务通知中确认或联系客服处理'
}
if (this.detail.status === 'auditing') return '平台管理员正在审核中,审核后将自动转账'
if (this.detail.status === 'rejected') return this.detail.reason || '审核未通过'
if (this.detail.status === 'failed') return this.detail.failReason || '转账未成功'
return ''
},
/**
* 步骤2(审核/转账)的样式类
* @returns {string} 样式类名
*/
step2Class() {
if (!this.detail) return ''
if (['paying', 'paid'].includes(this.detail.status)) return 'detail__timeline-item--done'
if (this.detail.status === 'auditing') return 'detail__timeline-item--active'
return 'detail__timeline-item--error'
},
/**
* 步骤2标题
* @returns {string} 步骤标题
*/
step2Title() {
if (!this.detail) return '平台审核与打款'
if (this.detail.status === 'rejected') return '平台审核驳回'
if (['paying', 'paid'].includes(this.detail.status)) return '平台审核通过,发起微信转账'
return '平台审核中'
},
/**
* 步骤2时间
* @returns {string} 时间字符串
*/
step2Time() {
if (!this.detail) return '—'
const t = this.detail.transferTime || (this.detail.status !== 'auditing' ? this.detail.createdAt : '')
return t ? this.fmtTime(t) : '等待处理'
},
/**
* 步骤3(到账/确认)的样式类
* @returns {string} 样式类名
*/
step3Class() {
if (!this.detail) return ''
if (this.detail.status === 'paid') return 'detail__timeline-item--done'
if (this.detail.status === 'paying') return 'detail__timeline-item--active'
if (['rejected', 'failed'].includes(this.detail.status)) return 'detail__timeline-item--error'
return ''
},
/**
* 步骤3标题
* @returns {string} 步骤标题
*/
step3Title() {
if (!this.detail) return '到账微信零钱'
if (this.detail.status === 'paid') return '已完成收款,已到账微信零钱'
if (this.detail.status === 'paying') return '等待收款方确认'
if (this.detail.status === 'failed') return '转账失败'
return '等待到账'
},
/**
* 步骤3时间
* @returns {string} 时间字符串
*/
step3Time() {
if (!this.detail) return '—'
if (this.detail.status === 'paid') {
return this.fmtTime(this.detail.payTime || this.detail.transferTime) || '已入账'
}
if (this.detail.status === 'paying') return '请在24小时内确认'
return '—'
},
},
/**
* 页面加载接收入参
* @param {Object} options 页面入参 {id, no}
*/
onLoad(options) {
if (options && options.id) {
this.id = Number(options.id)
}
if (options && options.no) {
this.withdrawNo = options.no
}
this.fetchDetail()
},
/**
* 下拉刷新数据
*/
onPullDownRefresh() {
this.fetchDetail(true).then(() => {
uni.stopPullDownRefresh()
})
},
methods: {
/**
* 格式化金额数值
* @param {number|string} val 金额数值
* @returns {string} 两位小数字符串
*/
formatMoney(val) {
const n = parseFloat(val)
return isNaN(n) ? '0.00' : n.toFixed(2)
},
/**
* 格式化后端 ISO 时间串为 YYYY-MM-DD HH:mm
* @param {string} t 后端下发的时间
* @returns {string} 展示用时间文案
*/
fmtTime(t) {
return formatTime(t) || '—'
},
/**
* 获取提现详情数据
* @param {boolean} [silent=false] 是否静默加载
* @returns {Promise<void>} 异步任务
*/
async fetchDetail(silent = false) {
if (!silent) this.loading = true
try {
const params = {}
if (this.id > 0) params.id = this.id
if (this.withdrawNo) params.withdrawNo = this.withdrawNo
const res = await distributionApi.withdrawDetail(params)
if (res && res.withdrawNo) {
this.detail = res
if (silent) uni.showToast({ title: '已刷新', icon: 'none' })
} else {
uni.showToast({ title: '未获取到记录', icon: 'none' })
}
} catch (e) {
uni.showToast({ title: (e && e.message) || '加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
/**
* 复制指定文本到系统剪贴板
* @param {string} text 要复制的文本
* @param {string} toast 提示文案
*/
copyText(text, toast = '已复制') {
if (!text) return
uni.setClipboardData({
data: String(text),
success: () => {
uni.showToast({ title: toast, icon: 'none' })
},
})
},
/**
* 拉起微信「确认收款」组件
* @param {Object} w 提现单据对象
*/
confirmTransfer(w) {
if (!w || !w.packageInfo) {
uni.showToast({ title: '转账凭据未生成,请在微信服务通知中确认', icon: 'none' })
return
}
const api = (typeof wx !== 'undefined' && typeof wx.requestMerchantTransfer === 'function')
? wx.requestMerchantTransfer
: (typeof uni !== 'undefined' && typeof uni.requestMerchantTransfer === 'function' ? uni.requestMerchantTransfer : null)
if (!api) {
uni.showToast({ title: '微信版本过低,请升级后重试', icon: 'none' })
return
}
const mchId = String(w.transferMchId || '1118898018')
const appId = String(w.transferAppId || 'wxbfcb778f3019cff8')
const pkg = String(w.packageInfo)
api({
mchId: mchId,
appId: appId,
package: pkg,
success: (res) => {
console.log('[Transfer] 详情页确认收款成功:', res)
uni.showToast({ title: '收款已确认', icon: 'success' })
setTimeout(() => this.fetchDetail(true), 1500)
},
fail: (err) => {
console.warn('[Transfer] 详情页确认收款失败:', err)
const msg = (err && (err.errMsg || err.message)) || ''
if (msg.indexOf('cancel') !== -1) {
uni.showToast({ title: '您取消了确认收款', icon: 'none' })
} else {
uni.showToast({ title: msg || '调起确认失败', icon: 'none', duration: 3000 })
}
},
})
},
},
}
</script>
<style lang="scss" scoped>
.withdraw-detail-page {
min-height: 100vh;
background: #f2fef7;
padding-bottom: 160rpx;
box-sizing: border-box;
}
.detail__loading {
padding: 120rpx 0;
text-align: center;
color: #64748b;
font-size: 28rpx;
}
.detail__body {
padding: 24rpx;
display: flex;
flex-direction: column;
gap: 24rpx;
}
/* 卡片通用规范 */
.detail__card {
background: #ffffff;
border-radius: 24rpx;
padding: 32rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 168, 84, 0.04);
border: 1rpx solid rgba(0, 210, 106, 0.08);
&--hero {
display: flex;
flex-direction: column;
align-items: center;
padding: 48rpx 32rpx 40rpx;
background: linear-gradient(180deg, #ffffff 0%, #fafffc 100%);
}
}
/* 状态徽标与主金额 */
.detail__status-icon-wrap {
width: 104rpx;
height: 104rpx;
border-radius: 52rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 48rpx;
margin-bottom: 20rpx;
&--success {
background: rgba(0, 210, 106, 0.12);
color: #00a854;
}
&--warning {
background: rgba(245, 166, 35, 0.12);
color: #f5a623;
}
&--danger {
background: rgba(250, 81, 81, 0.12);
color: #fa5151;
}
&--info {
background: rgba(100, 116, 139, 0.12);
color: #64748b;
}
}
.detail__status-title {
font-size: 34rpx;
font-weight: 700;
color: #1e293b;
margin-bottom: 8rpx;
}
.detail__status-desc {
font-size: 24rpx;
color: #64748b;
text-align: center;
margin-bottom: 28rpx;
}
.detail__amount-wrap {
display: flex;
align-items: baseline;
color: #1e293b;
}
.detail__amount-symbol {
font-size: 36rpx;
font-weight: 700;
color: #1e293b;
margin-right: 4rpx;
}
.detail__amount-num {
font-size: 64rpx;
font-weight: 800;
letter-spacing: -1rpx;
}
.detail__notice-warn {
margin-top: 24rpx;
padding: 16rpx 20rpx;
background: #fff8eb;
border: 1rpx solid #ffe1a6;
border-radius: 12rpx;
display: flex;
align-items: flex-start;
gap: 12rpx;
}
.detail__notice-icon {
font-size: 26rpx;
}
.detail__notice-text {
font-size: 22rpx;
color: #d97706;
line-height: 1.5;
}
/* 时间线 */
.detail__card-header {
margin-bottom: 24rpx;
}
.detail__card-title {
font-size: 28rpx;
font-weight: 700;
color: #1e293b;
}
.detail__timeline {
display: flex;
flex-direction: column;
position: relative;
padding-left: 20rpx;
&::before {
content: '';
position: absolute;
left: 28rpx;
top: 16rpx;
bottom: 30rpx;
width: 2rpx;
background: #e2e8f0;
}
}
.detail__timeline-item {
display: flex;
align-items: flex-start;
position: relative;
padding-bottom: 36rpx;
&:last-child {
padding-bottom: 0;
}
&--done {
.detail__timeline-dot {
background: #00d26a;
box-shadow: 0 0 0 6rpx rgba(0, 210, 106, 0.16);
}
.detail__timeline-name {
color: #1e293b;
font-weight: 600;
}
}
&--active {
.detail__timeline-dot {
background: #f5a623;
box-shadow: 0 0 0 6rpx rgba(245, 166, 35, 0.2);
}
.detail__timeline-name {
color: #f5a623;
font-weight: 600;
}
}
&--error {
.detail__timeline-dot {
background: #fa5151;
box-shadow: 0 0 0 6rpx rgba(250, 81, 81, 0.2);
}
.detail__timeline-name {
color: #fa5151;
}
}
}
.detail__timeline-dot {
width: 18rpx;
height: 18rpx;
border-radius: 50%;
background: #cbd5e1;
margin-right: 24rpx;
margin-top: 10rpx;
position: relative;
z-index: 1;
flex-shrink: 0;
}
.detail__timeline-content {
display: flex;
flex-direction: column;
gap: 4rpx;
}
.detail__timeline-name {
font-size: 26rpx;
color: #64748b;
}
.detail__timeline-time {
font-size: 22rpx;
color: #94a3b8;
}
/* 详情信息条目 */
.detail__info-list {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.detail__info-item {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 26rpx;
}
.detail__info-label {
color: #64748b;
flex-shrink: 0;
}
.detail__info-val {
color: #334155;
text-align: right;
max-width: 440rpx;
&--danger {
color: #fa5151;
}
}
.detail__info-val-wrap {
display: flex;
align-items: center;
gap: 12rpx;
}
.detail__info-copy {
font-size: 22rpx;
color: #00a854;
background: #e8faf0;
padding: 4rpx 12rpx;
border-radius: 8rpx;
flex-shrink: 0;
}
/* 底部操作条 */
.detail__footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 32rpx;
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(12px);
border-top: 1rpx solid rgba(0, 0, 0, 0.05);
display: flex;
gap: 20rpx;
z-index: 99;
}
.detail__btn {
flex: 1;
height: 84rpx;
line-height: 84rpx;
text-align: center;
border-radius: 42rpx;
font-size: 28rpx;
font-weight: 600;
border: none;
&--primary {
background: linear-gradient(135deg, #00e070, #00d26a);
color: #ffffff;
box-shadow: 0 8rpx 20rpx rgba(0, 210, 106, 0.3);
}
&--secondary {
background: #f1f5f9;
color: #475569;
max-width: 220rpx;
}
}
</style>