feat(user-center): points buy, balance withdraw, and asset record tabs
Add cash purchase of points (points_pay_s), wallet withdraw requests via AKSRT_Withdrawal, Zibll-style dual-card layout with tabbed balance/points ledgers, and admin switches for buy-points packages and balance withdraw.
This commit is contained in:
1 parent
0529ab5fb9
commit
d57fc6f934
10 files changed
+780
-16
No files matched your search
@@ -23,6 +23,8 @@ export const rechargeSchema = {
|
||||
pay_balance_exchange_s: false,
|
||||
pay_balance_exchange_rate: 100,
|
||||
pay_balance_exchange_desc: '',
|
||||
pay_balance_withdraw_s: false,
|
||||
pay_balance_withdraw_lowest_money: 50,
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
@@ -86,5 +88,14 @@ export const rechargeSchema = {
|
||||
{ key: 'pay_balance_exchange_desc', label: '兑换说明', type: 'textarea', default: '', dependsOn: { key: 'pay_balance_exchange_s', value: true } },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'withdraw',
|
||||
title: '余额提现',
|
||||
icon: 'fas fa-hand-holding-usd',
|
||||
fields: [
|
||||
{ key: 'pay_balance_withdraw_s', label: '启用余额提现', type: 'switch', default: false, dependsOn: { key: 'pay_balance_s', value: true } },
|
||||
{ key: 'pay_balance_withdraw_lowest_money', label: '最低提现金额', type: 'number', default: 50, min: 1, max: 99999, dependsOn: { key: 'pay_balance_withdraw_s', value: true } },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -38,8 +38,12 @@ export const creditsSchema = {
|
||||
icon: 'fas fa-coins',
|
||||
fields: [
|
||||
{ key: 'points_s', label: '启用积分系统', type: 'switch', default: true },
|
||||
{ key: 'points_pay_s', label: '积分支付', type: 'switch', default: false },
|
||||
{ key: 'points_rate', label: '积分兑换比例', type: 'number', default: 100, min: 1, max: 10000 },
|
||||
{ key: 'points_pay_s', label: '启用购买积分', type: 'switch', default: false, help: '对齐 zibll points_pay_s:允许用户用现金/余额购买积分。' },
|
||||
{ key: 'points_rate', label: '积分汇率(1元=N积分)', type: 'number', default: 100, min: 1, max: 10000, dependsOn: { key: 'points_pay_s', value: true } },
|
||||
{ key: 'pay_points_desc', label: '购买积分说明', type: 'textarea', default: '', dependsOn: { key: 'points_pay_s', value: true } },
|
||||
{ key: 'pay_points_product', label: '积分套餐', type: 'textarea', default: '', help: '每行:支付金额|积分数量|标题。留空则仅自定义数量。', dependsOn: { key: 'points_pay_s', value: true } },
|
||||
{ key: 'pay_points_product_custom_s', label: '允许自定义积分数量', type: 'switch', default: true, dependsOn: { key: 'points_pay_s', value: true } },
|
||||
{ key: 'pay_points_product_custom_limit', label: '自定义积分上限', type: 'number', default: 99999, min: 1, max: 999999, dependsOn: { key: 'points_pay_s', value: true } },
|
||||
{ key: 'points_name', label: '积分名称', type: 'input', default: '积分' },
|
||||
{ key: 'points_decimal', label: '积分小数位数', type: 'number', default: 2, min: 0, max: 4 },
|
||||
],
|
||||
|
||||
@@ -282,6 +282,39 @@ body.uc-modal-open {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
/* Asset record tabs (Zibll tab-nav-theme) */
|
||||
.uc-asset-tabs {
|
||||
margin-top: 8px;
|
||||
padding: 12px 16px 16px;
|
||||
}
|
||||
.uc-asset-tabs__nav {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
list-style: none;
|
||||
margin: 0 0 12px;
|
||||
padding: 0 0 10px;
|
||||
border-bottom: 1px solid var(--color-line-soft, rgba(0,0,0,.06));
|
||||
}
|
||||
.uc-asset-tabs__nav li a {
|
||||
display: inline-block;
|
||||
padding: 4px 0;
|
||||
color: var(--muted-color, #777);
|
||||
text-decoration: none;
|
||||
font-weight: 700;
|
||||
border-bottom: 2px solid transparent;
|
||||
}
|
||||
.uc-asset-tabs__nav li.active a,
|
||||
.uc-asset-tabs__nav li a:hover {
|
||||
color: var(--focus-color, #f04494);
|
||||
border-bottom-color: var(--focus-color, #f04494);
|
||||
}
|
||||
.uc-asset-tabs__content .tab-pane[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
.uc-asset-tabs__content .tab-pane.is-active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.uc-content #panel-credits .uc-transactions {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
|
||||
@@ -775,6 +775,152 @@
|
||||
});
|
||||
}
|
||||
|
||||
function initPointsBuy() {
|
||||
var modal = document.querySelector('[data-aksrt-points-buy-modal]');
|
||||
if (!modal) return;
|
||||
var form = modal.querySelector('[data-aksrt-points-buy-form]');
|
||||
var tip = modal.querySelector('[data-aksrt-points-buy-tip]');
|
||||
var busy = false;
|
||||
function setTip(text, isError) {
|
||||
if (!tip) return;
|
||||
tip.textContent = text || '';
|
||||
tip.classList.toggle('is-error', !!isError);
|
||||
}
|
||||
document.querySelectorAll('[data-aksrt-points-buy-open]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { openModal(modal); });
|
||||
});
|
||||
modal.querySelectorAll('[data-aksrt-points-buy-close]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { closeModal(modal); });
|
||||
});
|
||||
modal.querySelectorAll('.uc-charge-package input').forEach(function (inp) {
|
||||
inp.addEventListener('change', function () {
|
||||
modal.querySelectorAll('.uc-charge-package').forEach(function (el) {
|
||||
el.classList.toggle('is-active', el.contains(inp) && inp.checked);
|
||||
});
|
||||
});
|
||||
});
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
if (busy) return;
|
||||
var pkgInput = form.querySelector('input[name="points_package"]:checked') || form.querySelector('input[name="points_package"]');
|
||||
var pkg = pkgInput ? pkgInput.value : 'custom';
|
||||
var customEl = form.querySelector('[data-aksrt-points-buy-custom]');
|
||||
var custom = customEl ? parseInt(customEl.value || '0', 10) : 0;
|
||||
if (custom > 0) pkg = 'custom';
|
||||
if (pkg === 'custom' && !(custom > 0)) {
|
||||
setTip('请输入购买积分数量', true);
|
||||
return;
|
||||
}
|
||||
var methodEl = form.querySelector('input[name="points_pay_method"]:checked');
|
||||
var method = methodEl ? methodEl.value : 'alipay';
|
||||
busy = true;
|
||||
setTip('正在创建订单…');
|
||||
api('/pay/points/buy', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
package: pkg,
|
||||
custom_points: custom,
|
||||
payment_method: method
|
||||
})
|
||||
}).then(function (r) {
|
||||
busy = false;
|
||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||
setTip((r.json && r.json.message) || '购买失败', true);
|
||||
return;
|
||||
}
|
||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||
if (data && data.redirect && (data.payment_url || data.qr_content)) {
|
||||
if (data.payment_url) window.open(data.payment_url, '_blank');
|
||||
setTip(data.message || '请完成支付,支付成功后将自动刷新。');
|
||||
if (data.order_number) pollPaidOrder(data.order_number);
|
||||
return;
|
||||
}
|
||||
setTip((data && data.message) || '购买成功,正在刷新…');
|
||||
window.location.reload();
|
||||
}).catch(function () {
|
||||
busy = false;
|
||||
setTip('网络错误,请重试', true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initWithdraw() {
|
||||
var modal = document.querySelector('[data-aksrt-withdraw-modal]');
|
||||
if (!modal) return;
|
||||
var form = modal.querySelector('[data-aksrt-withdraw-form]');
|
||||
var tip = modal.querySelector('[data-aksrt-withdraw-tip]');
|
||||
var busy = false;
|
||||
function setTip(text, isError) {
|
||||
if (!tip) return;
|
||||
tip.textContent = text || '';
|
||||
tip.classList.toggle('is-error', !!isError);
|
||||
}
|
||||
document.querySelectorAll('[data-aksrt-withdraw-open]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { openModal(modal); });
|
||||
});
|
||||
modal.querySelectorAll('[data-aksrt-withdraw-close]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { closeModal(modal); });
|
||||
});
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
if (busy) return;
|
||||
var amountEl = form.querySelector('[data-aksrt-withdraw-amount]');
|
||||
var methodEl = form.querySelector('[data-aksrt-withdraw-method]');
|
||||
var accountEl = form.querySelector('[data-aksrt-withdraw-account]');
|
||||
var amount = amountEl ? parseFloat(amountEl.value || '0') : 0;
|
||||
var method = methodEl ? methodEl.value : 'alipay';
|
||||
var account = accountEl ? String(accountEl.value || '').trim() : '';
|
||||
if (!(amount > 0)) {
|
||||
setTip('请输入提现金额', true);
|
||||
return;
|
||||
}
|
||||
if (!account) {
|
||||
setTip('请填写收款账号信息', true);
|
||||
return;
|
||||
}
|
||||
busy = true;
|
||||
setTip('正在提交…');
|
||||
api('/pay/balance/withdraw', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ amount: amount, method: method, account_info: account })
|
||||
}).then(function (r) {
|
||||
busy = false;
|
||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||
setTip((r.json && r.json.message) || '提现失败', true);
|
||||
return;
|
||||
}
|
||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||
setTip((data && data.message) || '申请已提交,正在刷新…');
|
||||
window.location.reload();
|
||||
}).catch(function () {
|
||||
busy = false;
|
||||
setTip('网络错误,请重试', true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initAssetTabs() {
|
||||
var nav = document.querySelectorAll('[data-aksrt-asset-tab]');
|
||||
if (!nav.length) return;
|
||||
nav.forEach(function (link) {
|
||||
link.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var key = link.getAttribute('data-aksrt-asset-tab');
|
||||
document.querySelectorAll('[data-aksrt-asset-tab]').forEach(function (a) {
|
||||
var li = a.closest('li');
|
||||
if (li) li.classList.toggle('active', a === link);
|
||||
});
|
||||
document.querySelectorAll('[data-aksrt-asset-pane]').forEach(function (pane) {
|
||||
var on = pane.getAttribute('data-aksrt-asset-pane') === key;
|
||||
pane.classList.toggle('is-active', on);
|
||||
pane.hidden = !on;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bootAssets() {
|
||||
initSignin();
|
||||
initInvite();
|
||||
@@ -784,6 +930,9 @@
|
||||
initBalanceCharge();
|
||||
initTransfer();
|
||||
initExchange();
|
||||
initPointsBuy();
|
||||
initWithdraw();
|
||||
initAssetTabs();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
|
||||
Reference in new issue
Block a user