新增一键收款功能,允许用户快速处理待确认的收款。更新相关页面以显示待收款笔数和合计金额,并优化样式以提升用户体验。调整数据处理逻辑,确保在收款过程中获取最新的确认信息。
This commit is contained in:
@@ -43,6 +43,8 @@ Page({
|
||||
pendingConfirmList: [],
|
||||
withdrawMchId: '',
|
||||
withdrawAppId: '',
|
||||
pendingConfirmAmount: '0.00',
|
||||
receivingAll: false,
|
||||
|
||||
// 未登录假资料(展示用)
|
||||
guestNickname: '游客',
|
||||
@@ -165,16 +167,18 @@ Page({
|
||||
package: item.package,
|
||||
createdAt: (item.createdAt ?? item.created_at) ? this.formatDateMy(item.createdAt ?? item.created_at) : '--'
|
||||
}))
|
||||
const total = list.reduce((sum, it) => sum + (parseFloat(it.amount) || 0), 0)
|
||||
this.setData({
|
||||
pendingConfirmList: list,
|
||||
withdrawMchId: res.data.mchId ?? res.data.mch_id ?? '',
|
||||
withdrawAppId: res.data.appId ?? res.data.app_id ?? ''
|
||||
withdrawAppId: res.data.appId ?? res.data.app_id ?? '',
|
||||
pendingConfirmAmount: total.toFixed(2)
|
||||
})
|
||||
} else {
|
||||
this.setData({ pendingConfirmList: [], withdrawMchId: '', withdrawAppId: '' })
|
||||
this.setData({ pendingConfirmList: [], withdrawMchId: '', withdrawAppId: '', pendingConfirmAmount: '0.00' })
|
||||
}
|
||||
} catch (e) {
|
||||
this.setData({ pendingConfirmList: [] })
|
||||
this.setData({ pendingConfirmList: [], pendingConfirmAmount: '0.00' })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -250,6 +254,94 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 一键收款:逐条调起微信收款页(有上一页则返回,无则回首页)
|
||||
async handleOneClickReceive() {
|
||||
if (!this.data.isLoggedIn) { this.showLogin(); return }
|
||||
if (this.data.receivingAll) return
|
||||
|
||||
const list = this.data.pendingConfirmList || []
|
||||
if (list.length === 0) {
|
||||
wx.showToast({ title: '暂无待收款', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!wx.canIUse('requestMerchantTransfer')) {
|
||||
wx.showToast({ title: '当前微信版本过低,请更新后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const mchIdDefault = this.data.withdrawMchId || ''
|
||||
const appIdDefault = this.data.withdrawAppId || ''
|
||||
|
||||
this.setData({ receivingAll: true })
|
||||
|
||||
try {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i]
|
||||
wx.showLoading({ title: `收款中 ${i + 1}/${list.length}`, mask: true })
|
||||
|
||||
// 兜底:每次收款前取最新 confirm-info,避免 package 不完整或过期
|
||||
let mchId = mchIdDefault
|
||||
let appId = appIdDefault
|
||||
let pkg = item.package
|
||||
try {
|
||||
const infoRes = await app.request({
|
||||
url: '/api/miniprogram/withdraw/confirm-info?id=' + encodeURIComponent(item.id),
|
||||
silent: true
|
||||
})
|
||||
if (infoRes && infoRes.success && infoRes.data) {
|
||||
mchId = infoRes.data.mchId || mchId
|
||||
appId = infoRes.data.appId || appId
|
||||
pkg = infoRes.data.package || pkg
|
||||
}
|
||||
} catch (e) { /* confirm-info 失败不阻断,使用列表字段兜底 */ }
|
||||
|
||||
if (!pkg) {
|
||||
wx.hideLoading()
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '当前订单无法调起收款页,请稍后在「提现记录」中点击“领取零钱”。',
|
||||
confirmText: '去查看',
|
||||
cancelText: '知道了',
|
||||
success: (r) => {
|
||||
if (r.confirm) wx.navigateTo({ url: '/pages/withdraw-records/withdraw-records' })
|
||||
}
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
// requestMerchantTransfer:失败/取消会走 fail
|
||||
await new Promise((resolve, reject) => {
|
||||
wx.requestMerchantTransfer({
|
||||
mchId,
|
||||
appId: appId || wx.getAccountInfoSync().miniProgram.appId,
|
||||
package: pkg,
|
||||
success: resolve,
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
|
||||
// 收款页调起成功后记录确认(后端负责状态流转)
|
||||
const userInfo = app.globalData.userInfo
|
||||
if (userInfo && userInfo.id) {
|
||||
try {
|
||||
await app.request({
|
||||
url: '/api/miniprogram/withdraw/confirm-received',
|
||||
method: 'POST',
|
||||
data: { withdrawalId: item.id, userId: userInfo.id }
|
||||
})
|
||||
} catch (e) { /* 仅记录,不影响前端 */ }
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
const msg = (err && err.errMsg && String(err.errMsg).includes('cancel')) ? '已取消收款' : '收款失败,请重试'
|
||||
wx.showToast({ title: msg, icon: 'none' })
|
||||
} finally {
|
||||
wx.hideLoading()
|
||||
this.setData({ receivingAll: false })
|
||||
this.loadPendingConfirm()
|
||||
}
|
||||
},
|
||||
|
||||
// 专用接口:拉取「我的收益」卡片数据(累计、可提现、推荐人数)
|
||||
async loadMyEarnings() {
|
||||
const userInfo = app.globalData.userInfo
|
||||
|
||||
@@ -63,6 +63,28 @@
|
||||
|
||||
<!-- 已登录:内容区 -->
|
||||
<view class="main-content" wx:if="{{isLoggedIn}}">
|
||||
<!-- 一键收款(仅在有待确认收款时显示) -->
|
||||
<view class="card receive-card" wx:if="{{pendingConfirmList.length > 0}}">
|
||||
<view class="receive-top">
|
||||
<view class="receive-left">
|
||||
<view class="receive-title-row">
|
||||
<image class="card-icon-img" src="/assets/icons/wallet.svg" mode="aspectFit"/>
|
||||
<text class="card-title">一键收款</text>
|
||||
</view>
|
||||
<text class="receive-sub">
|
||||
待收款 {{pendingConfirmList.length}} 笔 · 合计 ¥{{pendingConfirmAmount}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="receive-btn {{receivingAll ? 'receive-btn-disabled' : ''}}" bindtap="handleOneClickReceive">
|
||||
<text class="receive-btn-text">{{receivingAll ? '收款中...' : '立即收款'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="receive-bottom">
|
||||
<text class="receive-tip">将依次调起微信收款页完成领取</text>
|
||||
<text class="receive-link" bindtap="handleMenuTap" data-id="withdrawRecords">查看提现记录 ›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 阅读统计 -->
|
||||
<view class="card stats-card">
|
||||
<view class="card-header">
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
.profile-stat-label { display: block; font-size: 22rpx; color: #6B7280; margin-top: 8rpx; }
|
||||
|
||||
/* ===== 主内容区 ===== */
|
||||
.main-content { }
|
||||
.main-content { padding: 0 0 0 0; }
|
||||
|
||||
/* 卡片通用 */
|
||||
.card {
|
||||
@@ -97,6 +97,24 @@
|
||||
.card-icon-img { width: 40rpx; height: 40rpx; flex-shrink: 0; }
|
||||
.card-title { font-size: 32rpx; font-weight: bold; color: #fff; }
|
||||
|
||||
/* ===== 一键收款卡片 ===== */
|
||||
.receive-card { padding: 28rpx 32rpx; }
|
||||
.receive-top { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
|
||||
.receive-left { flex: 1; min-width: 0; }
|
||||
.receive-title-row { display: flex; align-items: center; gap: 16rpx; margin-bottom: 12rpx; }
|
||||
.receive-sub { display: block; font-size: 24rpx; color: rgba(255,255,255,0.65); }
|
||||
.receive-btn {
|
||||
flex-shrink: 0;
|
||||
padding: 16rpx 28rpx;
|
||||
border-radius: 999rpx;
|
||||
background: linear-gradient(135deg, #4FD1C5 0%, #20B2AA 100%);
|
||||
}
|
||||
.receive-btn-text { font-size: 26rpx; font-weight: 700; color: #000; }
|
||||
.receive-btn-disabled { opacity: 0.55; }
|
||||
.receive-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; margin-top: 18rpx; }
|
||||
.receive-tip { font-size: 22rpx; color: rgba(255,255,255,0.45); }
|
||||
.receive-link { font-size: 24rpx; color: #4FD1C5; }
|
||||
|
||||
/* 分享收益 */
|
||||
.earnings-grid {
|
||||
display: grid; grid-template-columns: 1fr 1fr 1fr;
|
||||
|
||||
470
soul-admin/dist/assets/index-CAf6YeOV.js
vendored
470
soul-admin/dist/assets/index-CAf6YeOV.js
vendored
File diff suppressed because one or more lines are too long
470
soul-admin/dist/assets/index-iq3PeMuM.js
vendored
Normal file
470
soul-admin/dist/assets/index-iq3PeMuM.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
soul-admin/dist/index.html
vendored
2
soul-admin/dist/index.html
vendored
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>管理后台 - Soul创业派对</title>
|
||||
<script type="module" crossorigin src="/assets/index-CAf6YeOV.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-iq3PeMuM.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DP984f3K.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user