转账功能优化
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// pages/usercenter/balance/index.js
|
||||
import { fetchAccountInfo, fetchAccountLogs, accountApplyWithdraw } from '../../../services/usercenter/fetchBalance';
|
||||
import { fetchAccountInfo, fetchAccountLogs, accountApplyWithdraw, fetchTransferAuthorization } from '../../../services/usercenter/fetchBalance';
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -24,6 +24,7 @@ Page({
|
||||
{ title: '提现次数', desc: '每个自然日最多可发起 10 次提现申请' },
|
||||
{ title: '单日限额', desc: '同一自然日累计提现金额不超过 2000 元,超出请次日再试' },
|
||||
{ title: '到账方式', desc: '转账至本人微信零钱,需填写与微信实名一致的姓名' },
|
||||
{ title: '免确认收款', desc: '提现需完成免确认收款授权,授权后审核通过将直接到账零钱' },
|
||||
{ title: '到账时间', desc: '审核通过后 1-3 个工作日内到账,节假日顺延' },
|
||||
{ title: '审核说明', desc: '工作日统一审核处理,审核期间该笔金额将暂时冻结' },
|
||||
{ title: '驳回处理', desc: '被驳回的提现金额将自动退回可提现余额,可重新发起' },
|
||||
@@ -152,6 +153,45 @@ Page({
|
||||
this.setData({ withdrawName: e.detail.value });
|
||||
},
|
||||
onConfirmWithdraw() {
|
||||
const { withdrawName, withdrawAmount } = this.data;
|
||||
//提交前提现先确保完成免确认收款授权(授权后审核通过即可免确认直接到账零钱)
|
||||
this.ensureTransferAuthorized()
|
||||
.then(() => this.submitWithdraw())
|
||||
.catch((msg) => {
|
||||
wx.showToast({ title: typeof msg === 'string' && msg ? msg : '未完成授权,已取消提现', icon: 'none' });
|
||||
});
|
||||
},
|
||||
// 确保完成免确认收款授权:已授权直接通过;未授权拉起微信授权页
|
||||
ensureTransferAuthorized() {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetchTransferAuthorization().then((res) => {
|
||||
if (res.code != 1) {
|
||||
reject(res.msg || '获取授权状态失败');
|
||||
return;
|
||||
}
|
||||
const data = res.data || {};
|
||||
if (data.authorized) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
wx.requestMerchantTransfer({
|
||||
mchId: data.mch_id,
|
||||
appId: data.app_id,
|
||||
package: data.package_info,
|
||||
success: () => {
|
||||
wx.showToast({ title: '授权成功', icon: 'success' });
|
||||
resolve();
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('requestMerchantTransfer fail', err);
|
||||
reject('需完成免确认收款授权后才能提现');
|
||||
},
|
||||
});
|
||||
}).catch(() => reject('网络异常,请稍后重试'));
|
||||
});
|
||||
},
|
||||
// 原提现提交逻辑
|
||||
submitWithdraw() {
|
||||
const { withdrawName, withdrawAmount } = this.data;
|
||||
let params = {
|
||||
'name': withdrawName,
|
||||
|
||||
Reference in New Issue
Block a user