feat(user-center): Zibll-like assets charge, transfer, and dual cards
Complete wallet/points assets surface: sidebar mini dual cards, dual asset row, balance charge packages REST + modal, transfer search/pay, points-to-balance exchange, and payment success credit for recharge orders.
This commit is contained in:
1 parent
8e0f9d989d
commit
0529ab5fb9
9 files changed
+1409
-127
No files matched your search
@@ -1,27 +1,285 @@
|
||||
/**
|
||||
* User Center — credits balance + transactions
|
||||
* User Center — assets (wallet + points) Zibll parity
|
||||
*/
|
||||
|
||||
.uc-balance-card {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/* Dual assets: wallet + points cards stack with gap */
|
||||
.uc-wallet-grid {
|
||||
/* Dual asset row */
|
||||
.uc-assets-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.uc-balance-card--wallet .uc-balance-card__bg--wallet,
|
||||
.uc-balance-card__bg--wallet {
|
||||
background: linear-gradient(135deg, #0f766e 0%, #14b8a6 45%, #2dd4bf 100%);
|
||||
.uc-assets-row--dual {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.uc-assets-row--dual {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.uc-balance-card + .uc-balance-card {
|
||||
margin-top: 12px;
|
||||
.uc-asset-card {
|
||||
background: var(--main-bg-color, var(--surface-1, #fff));
|
||||
border-radius: var(--main-radius, 8px);
|
||||
box-shadow: 0 0 10px var(--main-shadow, rgba(116, 116, 116, 0.08));
|
||||
padding: 16px 20px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.uc-asset-card__head {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.uc-asset-card__title {
|
||||
font-weight: 600;
|
||||
color: var(--main-color, #4e5358);
|
||||
}
|
||||
.uc-asset-card__amount {
|
||||
font-size: 1.75rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.uc-asset-card__mark {
|
||||
font-size: 12px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
.uc-asset-card__actions .but {
|
||||
min-width: 4.2em;
|
||||
}
|
||||
.uc-asset-card__link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-top: 8px;
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.uc-asset-card__link:hover {
|
||||
color: var(--focus-color, #f04494);
|
||||
}
|
||||
|
||||
/* Sidebar mini dual cards (Zibll) */
|
||||
.uc-asset-mini {
|
||||
gap: 8px;
|
||||
}
|
||||
.uc-asset-mini__card {
|
||||
display: block;
|
||||
background: var(--muted-bg-color, #f3f4f6);
|
||||
border-radius: 6px;
|
||||
padding: 10px 12px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.uc-asset-mini__card:hover {
|
||||
background: var(--color-line-soft, rgba(0, 0, 0, 0.06));
|
||||
}
|
||||
.uc-asset-mini__label {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.c-blue-2 {
|
||||
color: #3b82f6;
|
||||
}
|
||||
.c-yellow {
|
||||
color: #eab308;
|
||||
}
|
||||
.c-green {
|
||||
color: #16a34a;
|
||||
}
|
||||
.col-ml6 {
|
||||
margin-left: -6px;
|
||||
}
|
||||
.col-ml6 > * {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
/* Charge packages */
|
||||
.uc-charge-packages {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.uc-charge-package {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--color-line, rgba(0, 0, 0, 0.08));
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
background: var(--surface-1, #fff);
|
||||
}
|
||||
.uc-charge-package input {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.uc-charge-package.is-active,
|
||||
.uc-charge-package:has(input:checked) {
|
||||
border-color: var(--focus-color, #f04494);
|
||||
box-shadow: 0 0 0 1px var(--focus-color, #f04494);
|
||||
}
|
||||
.uc-charge-package__credit {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
.uc-charge-package__tag {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 0 8px 0 8px;
|
||||
background: #fbbf24;
|
||||
color: #333;
|
||||
}
|
||||
.uc-charge-custom__input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--color-line, #ddd);
|
||||
padding: 6px 0;
|
||||
font-size: 1.1rem;
|
||||
outline: none;
|
||||
}
|
||||
.uc-charge-methods {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.uc-charge-method {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Modal shell */
|
||||
.uc-modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1100;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
}
|
||||
.uc-modal.is-open,
|
||||
.uc-modal:not([hidden]) {
|
||||
display: flex;
|
||||
}
|
||||
.uc-modal[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
.uc-modal__overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
.uc-modal__dialog {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
max-height: 85vh;
|
||||
overflow: auto;
|
||||
background: var(--main-bg-color, #fff);
|
||||
border-radius: 12px;
|
||||
padding: 18px 18px 20px;
|
||||
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.uc-modal__close {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 12px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
color: #999;
|
||||
}
|
||||
.uc-modal__title {
|
||||
margin: 0 0 14px;
|
||||
font-size: 17px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.uc-modal__desc {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.uc-modal__tip {
|
||||
min-height: 1.4em;
|
||||
margin: 10px 0 0;
|
||||
font-size: 13px;
|
||||
color: var(--muted-color, #777);
|
||||
}
|
||||
.uc-modal__tip.is-error {
|
||||
color: #ef4444;
|
||||
}
|
||||
body.uc-modal-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
.btn-block {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
.but.jb-blue,
|
||||
.but.b-blue-2 {
|
||||
background: #3b82f6;
|
||||
color: #fff;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 0.45em 1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.but.c-blue-2.hollow,
|
||||
.but.c-green.hollow {
|
||||
background: transparent;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 4px;
|
||||
padding: 0.4em 0.9em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.but.c-blue-2 {
|
||||
color: #3b82f6;
|
||||
}
|
||||
.but.c-green {
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
/* Transfer search results */
|
||||
.uc-transfer-results {
|
||||
margin-top: 8px;
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
}
|
||||
.uc-transfer-user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
border: 0;
|
||||
background: var(--muted-bg-color, #f5f5f5);
|
||||
border-radius: 6px;
|
||||
margin-bottom: 6px;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
}
|
||||
.uc-transfer-user:hover {
|
||||
background: var(--color-primary-soft, rgba(240, 68, 148, 0.08));
|
||||
}
|
||||
.uc-transfer-user__avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.uc-transactions--wallet {
|
||||
margin-bottom: 20px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.uc-content #panel-credits .uc-transactions {
|
||||
|
||||
+269
-8
@@ -515,19 +515,280 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
initSignin();
|
||||
initInvite();
|
||||
initVipShop();
|
||||
initVipPointsExchange();
|
||||
initCardPass();
|
||||
// ===== 余额充值 / 转账 / 积分兑余额(Zibll 资产中心) =====
|
||||
function openModal(el) {
|
||||
if (!el) return;
|
||||
el.hidden = false;
|
||||
el.classList.add('is-open');
|
||||
document.body.classList.add('uc-modal-open');
|
||||
}
|
||||
function closeModal(el) {
|
||||
if (!el) return;
|
||||
el.hidden = true;
|
||||
el.classList.remove('is-open');
|
||||
if (!document.querySelector('.uc-modal.is-open')) {
|
||||
document.body.classList.remove('uc-modal-open');
|
||||
}
|
||||
}
|
||||
function pollPaidOrder(orderNumber) {
|
||||
if (!orderNumber) return;
|
||||
var tries = 0;
|
||||
var maxTries = 40;
|
||||
var timer = setInterval(function () {
|
||||
tries += 1;
|
||||
api('/pay/content/order/' + encodeURIComponent(orderNumber)).then(function (r) {
|
||||
if (r.ok && r.json && r.json.paid) {
|
||||
clearInterval(timer);
|
||||
window.location.reload();
|
||||
}
|
||||
}).catch(function () {});
|
||||
if (tries >= maxTries) clearInterval(timer);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function initBalanceCharge() {
|
||||
var modal = document.querySelector('[data-aksrt-charge-modal]');
|
||||
if (!modal) return;
|
||||
var form = modal.querySelector('[data-aksrt-charge-form]');
|
||||
var tip = modal.querySelector('[data-aksrt-charge-tip]');
|
||||
var busy = false;
|
||||
function setTip(text, isError) {
|
||||
if (!tip) return;
|
||||
tip.textContent = text || '';
|
||||
tip.classList.toggle('is-error', !!isError);
|
||||
}
|
||||
document.querySelectorAll('[data-aksrt-charge-open]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { openModal(modal); });
|
||||
});
|
||||
} else {
|
||||
modal.querySelectorAll('[data-aksrt-charge-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="balance_package"]:checked') || form.querySelector('input[name="balance_package"]');
|
||||
var pkg = pkgInput ? pkgInput.value : 'custom';
|
||||
var customEl = form.querySelector('input[name="custom_price"]');
|
||||
var custom = customEl ? parseFloat(customEl.value || '0') : 0;
|
||||
if (custom > 0) {
|
||||
pkg = 'custom';
|
||||
}
|
||||
if ((!pkg || pkg === 'custom') && !(custom > 0) && !pkgInput) {
|
||||
setTip('请选择或输入充值金额', true);
|
||||
return;
|
||||
}
|
||||
if (pkg === 'custom' && !(custom > 0)) {
|
||||
setTip('请输入有效充值金额', true);
|
||||
return;
|
||||
}
|
||||
var methodEl = form.querySelector('input[name="payment_method"]:checked');
|
||||
var method = methodEl ? methodEl.value : 'alipay';
|
||||
busy = true;
|
||||
setTip('正在创建订单…');
|
||||
api('/pay/balance/charge', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
package: pkg,
|
||||
custom_price: 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 initTransfer() {
|
||||
var modal = document.querySelector('[data-aksrt-transfer-modal]');
|
||||
if (!modal) return;
|
||||
var form = modal.querySelector('[data-aksrt-transfer-form]');
|
||||
var tip = modal.querySelector('[data-aksrt-transfer-tip]');
|
||||
var results = modal.querySelector('[data-aksrt-transfer-results]');
|
||||
var selected = modal.querySelector('[data-aksrt-transfer-selected]');
|
||||
var recipientInput = modal.querySelector('[data-aksrt-transfer-recipient]');
|
||||
var typeInput = modal.querySelector('[data-aksrt-transfer-type]');
|
||||
var title = modal.querySelector('[data-aksrt-transfer-title]');
|
||||
var searchTimer = null;
|
||||
var busy = false;
|
||||
function setTip(text, isError) {
|
||||
if (!tip) return;
|
||||
tip.textContent = text || '';
|
||||
tip.classList.toggle('is-error', !!isError);
|
||||
}
|
||||
document.querySelectorAll('[data-aksrt-transfer-open]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
var type = btn.getAttribute('data-aksrt-transfer-open') || 'balance';
|
||||
if (typeInput) typeInput.value = type;
|
||||
if (title) title.textContent = type === 'points' ? '积分转账' : '余额转账';
|
||||
if (results) results.innerHTML = '';
|
||||
if (selected) selected.textContent = '';
|
||||
if (recipientInput) recipientInput.value = '';
|
||||
setTip('');
|
||||
openModal(modal);
|
||||
});
|
||||
});
|
||||
modal.querySelectorAll('[data-aksrt-transfer-close]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { closeModal(modal); });
|
||||
});
|
||||
var searchEl = modal.querySelector('[data-aksrt-transfer-search]');
|
||||
if (searchEl) {
|
||||
searchEl.addEventListener('input', function () {
|
||||
var q = String(searchEl.value || '').trim();
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
if (q.length < 1) {
|
||||
if (results) results.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
searchTimer = setTimeout(function () {
|
||||
api('/pay/transfer/search?s=' + encodeURIComponent(q)).then(function (r) {
|
||||
if (!results) return;
|
||||
results.innerHTML = '';
|
||||
if (!r.ok) return;
|
||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||
var users = (data && data.users) || [];
|
||||
if (!users.length) {
|
||||
results.innerHTML = '<div class="muted-2-color em09">未找到相关用户</div>';
|
||||
return;
|
||||
}
|
||||
users.forEach(function (u) {
|
||||
var item = document.createElement('button');
|
||||
item.type = 'button';
|
||||
item.className = 'uc-transfer-user';
|
||||
item.innerHTML = '<img src="' + (u.avatar || '') + '" alt="" class="uc-transfer-user__avatar"><span>' + (u.display_name || u.user_login) + '</span><span class="muted-2-color em09">@' + (u.user_login || '') + '</span>';
|
||||
item.addEventListener('click', function () {
|
||||
if (recipientInput) recipientInput.value = String(u.id);
|
||||
if (selected) selected.textContent = '已选择:' + (u.display_name || u.user_login);
|
||||
results.innerHTML = '';
|
||||
});
|
||||
results.appendChild(item);
|
||||
});
|
||||
});
|
||||
}, 280);
|
||||
});
|
||||
}
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
if (busy) return;
|
||||
var type = typeInput ? typeInput.value : 'balance';
|
||||
var recipient = recipientInput ? parseInt(recipientInput.value || '0', 10) : 0;
|
||||
var amountEl = form.querySelector('[data-aksrt-transfer-amount]');
|
||||
var amount = amountEl ? amountEl.value : 0;
|
||||
if (!recipient) {
|
||||
setTip('请选择收款用户', true);
|
||||
return;
|
||||
}
|
||||
if (!(parseFloat(amount) > 0)) {
|
||||
setTip('请输入有效金额', true);
|
||||
return;
|
||||
}
|
||||
busy = true;
|
||||
setTip('正在转账…');
|
||||
api('/pay/transfer', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ type: type, recipient: recipient, amount: amount })
|
||||
}).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 initExchange() {
|
||||
var modal = document.querySelector('[data-aksrt-exchange-modal]');
|
||||
if (!modal) return;
|
||||
var form = modal.querySelector('[data-aksrt-exchange-form]');
|
||||
var tip = modal.querySelector('[data-aksrt-exchange-tip]');
|
||||
var busy = false;
|
||||
function setTip(text, isError) {
|
||||
if (!tip) return;
|
||||
tip.textContent = text || '';
|
||||
tip.classList.toggle('is-error', !!isError);
|
||||
}
|
||||
document.querySelectorAll('[data-aksrt-exchange-open]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { openModal(modal); });
|
||||
});
|
||||
modal.querySelectorAll('[data-aksrt-exchange-close]').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () { closeModal(modal); });
|
||||
});
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
if (busy) return;
|
||||
var pointsEl = form.querySelector('[data-aksrt-exchange-points]');
|
||||
var points = pointsEl ? parseInt(pointsEl.value || '0', 10) : 0;
|
||||
if (!(points > 0)) {
|
||||
setTip('请输入兑换积分数量', true);
|
||||
return;
|
||||
}
|
||||
busy = true;
|
||||
setTip('正在兑换…');
|
||||
api('/pay/balance/exchange', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ points: points })
|
||||
}).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 bootAssets() {
|
||||
initSignin();
|
||||
initInvite();
|
||||
initVipShop();
|
||||
initVipPointsExchange();
|
||||
initCardPass();
|
||||
initBalanceCharge();
|
||||
initTransfer();
|
||||
initExchange();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', bootAssets);
|
||||
} else {
|
||||
bootAssets();
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user