优化提现流程,新增用户确认模式以支持待用户确认的转账,更新相关API和数据库结构以确保数据一致性。同时,调整小程序界面以展示待确认收款信息,提升用户体验。
This commit is contained in:
@@ -40,9 +40,15 @@ Page({
|
||||
menuList: [
|
||||
{ id: 'orders', title: '我的订单', icon: '📦', count: 0 },
|
||||
{ id: 'referral', title: '推广中心', icon: '🎁', iconBg: 'gold', badge: '90%佣金' },
|
||||
{ id: 'withdrawRecords', title: '提现记录', icon: '📋', iconBg: 'gray' },
|
||||
{ id: 'about', title: '关于作者', icon: 'ℹ️', iconBg: 'brand' },
|
||||
{ id: 'settings', title: '设置', icon: '⚙️', iconBg: 'gray' }
|
||||
],
|
||||
|
||||
// 待确认收款(用户确认模式)
|
||||
pendingConfirmList: [],
|
||||
withdrawMchId: '',
|
||||
withdrawAppId: '',
|
||||
|
||||
// 登录弹窗
|
||||
showLoginModal: false,
|
||||
@@ -125,6 +131,7 @@ Page({
|
||||
totalReadTime: Math.floor(Math.random() * 200) + 50
|
||||
})
|
||||
this.loadReferralEarnings()
|
||||
this.loadPendingConfirm()
|
||||
} else {
|
||||
this.setData({
|
||||
isLoggedIn: false,
|
||||
@@ -139,6 +146,82 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 拉取待确认收款列表(用于「确认收款」按钮)
|
||||
async loadPendingConfirm() {
|
||||
const userInfo = app.globalData.userInfo
|
||||
if (!app.globalData.isLoggedIn || !userInfo || !userInfo.id) return
|
||||
try {
|
||||
const res = await app.request('/api/withdraw/pending-confirm?userId=' + userInfo.id)
|
||||
if (res && res.success && res.data) {
|
||||
const list = (res.data.list || []).map(item => ({
|
||||
id: item.id,
|
||||
amount: (item.amount || 0).toFixed(2),
|
||||
package: item.package,
|
||||
created_at: item.created_at ? this.formatDateMy(item.created_at) : '--'
|
||||
}))
|
||||
this.setData({
|
||||
pendingConfirmList: list,
|
||||
withdrawMchId: res.data.mch_id || '',
|
||||
withdrawAppId: res.data.app_id || ''
|
||||
})
|
||||
} else {
|
||||
this.setData({ pendingConfirmList: [], withdrawMchId: '', withdrawAppId: '' })
|
||||
}
|
||||
} catch (e) {
|
||||
this.setData({ pendingConfirmList: [] })
|
||||
}
|
||||
},
|
||||
|
||||
formatDateMy(dateStr) {
|
||||
if (!dateStr) return '--'
|
||||
const d = new Date(dateStr)
|
||||
const m = (d.getMonth() + 1).toString().padStart(2, '0')
|
||||
const day = d.getDate().toString().padStart(2, '0')
|
||||
return `${m}-${day}`
|
||||
},
|
||||
|
||||
// 确认收款(调起微信收款页)
|
||||
confirmReceive(e) {
|
||||
const index = e.currentTarget.dataset.index
|
||||
const id = e.currentTarget.dataset.id
|
||||
const list = this.data.pendingConfirmList || []
|
||||
let item = (typeof index === 'number' || (index !== undefined && index !== '')) ? list[index] : null
|
||||
if (!item && id) item = list.find(x => x.id === id) || null
|
||||
if (!item || !item.package) {
|
||||
wx.showToast({ title: '请稍后刷新再试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const mchId = this.data.withdrawMchId
|
||||
const appId = this.data.withdrawAppId
|
||||
if (!mchId || !appId) {
|
||||
wx.showToast({ title: '参数缺失,请刷新重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!wx.canIUse('requestMerchantTransfer')) {
|
||||
wx.showToast({ title: '当前微信版本不支持,请升级后重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.showLoading({ title: '调起收款...', mask: true })
|
||||
wx.requestMerchantTransfer({
|
||||
mchId,
|
||||
appId,
|
||||
package: item.package,
|
||||
success: () => {
|
||||
wx.hideLoading()
|
||||
wx.showToast({ title: '收款成功', icon: 'success' })
|
||||
const newList = list.filter(x => x.id !== item.id)
|
||||
this.setData({ pendingConfirmList: newList })
|
||||
this.loadPendingConfirm()
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading()
|
||||
const msg = (err.errMsg || '').includes('cancel') ? '已取消' : (err.errMsg || '收款失败')
|
||||
wx.showToast({ title: msg, icon: 'none' })
|
||||
},
|
||||
complete: () => { wx.hideLoading() }
|
||||
})
|
||||
},
|
||||
|
||||
// 从与推广中心相同的接口拉取收益数据并更新展示(累计收益 = totalCommission,可提现 = 累计-已提现-待审核)
|
||||
async loadReferralEarnings() {
|
||||
const userInfo = app.globalData.userInfo
|
||||
@@ -438,6 +521,7 @@ Page({
|
||||
const routes = {
|
||||
orders: '/pages/purchases/purchases',
|
||||
referral: '/pages/referral/referral',
|
||||
withdrawRecords: '/pages/withdraw-records/withdraw-records',
|
||||
about: '/pages/about/about',
|
||||
settings: '/pages/settings/settings'
|
||||
}
|
||||
|
||||
@@ -109,6 +109,24 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 待确认收款(用户确认模式)- 仅登录用户显示 -->
|
||||
<view class="pending-confirm-card" wx:if="{{isLoggedIn}}">
|
||||
<view class="pending-confirm-header">
|
||||
<text class="pending-confirm-title">待确认收款</text>
|
||||
<text class="pending-confirm-desc" wx:if="{{pendingConfirmList.length > 0}}">审核已通过,点击下方按钮完成收款</text>
|
||||
<text class="pending-confirm-desc" wx:else>暂无待确认的提现,审核通过后会出现在这里</text>
|
||||
</view>
|
||||
<view class="pending-confirm-list" wx:if="{{pendingConfirmList.length > 0}}">
|
||||
<view class="pending-confirm-item" wx:for="{{pendingConfirmList}}" wx:key="id">
|
||||
<view class="pending-confirm-info">
|
||||
<text class="pending-confirm-amount">¥{{item.amount}}</text>
|
||||
<text class="pending-confirm-time">{{item.created_at}}</text>
|
||||
</view>
|
||||
<view class="pending-confirm-btn" bindtap="confirmReceive" data-index="{{index}}">确认收款</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- Tab切换 - 仅登录用户显示 -->
|
||||
<view class="tab-bar-custom" wx:if="{{isLoggedIn}}">
|
||||
<view
|
||||
|
||||
@@ -1184,3 +1184,28 @@
|
||||
color: #ffffff;
|
||||
box-shadow: 0 8rpx 24rpx rgba(56, 189, 172, 0.3);
|
||||
}
|
||||
|
||||
/* 待确认收款 */
|
||||
.pending-confirm-card {
|
||||
margin: 32rpx;
|
||||
padding: 28rpx 32rpx;
|
||||
background: rgba(76, 175, 80, 0.08);
|
||||
border: 2rpx solid rgba(76, 175, 80, 0.25);
|
||||
border-radius: 24rpx;
|
||||
}
|
||||
.pending-confirm-header { margin-bottom: 20rpx; }
|
||||
.pending-confirm-title { font-size: 28rpx; font-weight: 600; color: #fff; display: block; }
|
||||
.pending-confirm-desc { font-size: 24rpx; color: rgba(255,255,255,0.6); margin-top: 8rpx; display: block; }
|
||||
.pending-confirm-list { display: flex; flex-direction: column; gap: 16rpx; }
|
||||
.pending-confirm-item {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 20rpx 24rpx; background: rgba(28,28,30,0.6); border-radius: 16rpx;
|
||||
}
|
||||
.pending-confirm-info { display: flex; flex-direction: column; gap: 4rpx; }
|
||||
.pending-confirm-amount { font-size: 32rpx; font-weight: 600; color: #4CAF50; }
|
||||
.pending-confirm-time { font-size: 22rpx; color: rgba(255,255,255,0.5); }
|
||||
.pending-confirm-btn {
|
||||
padding: 16rpx 32rpx;
|
||||
background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
|
||||
color: #fff; font-size: 26rpx; font-weight: 500; border-radius: 20rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user