(fix):update credits toast
This commit is contained in:
1 parent
ed6d523d05
commit
5e2c143449
8 files changed
+121
-103
No files matched your search
@@ -234,15 +234,6 @@
|
|||||||
.uc-modal__desc {
|
.uc-modal__desc {
|
||||||
margin-bottom: 12px;
|
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 {
|
body.uc-modal-open {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -509,12 +500,6 @@ body.uc-modal-open {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uc-balance-card__tip {
|
|
||||||
font-size: 12px;
|
|
||||||
opacity: 0.7;
|
|
||||||
margin: 8px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 积分流水 */
|
/* 积分流水 */
|
||||||
.uc-transactions {
|
.uc-transactions {
|
||||||
background: var(--surface-1);
|
background: var(--surface-1);
|
||||||
|
|||||||
+77
-82
@@ -37,42 +37,41 @@
|
|||||||
// ===== 签到 =====
|
// ===== 签到 =====
|
||||||
function initSignin() {
|
function initSignin() {
|
||||||
var root = document.querySelector('[data-aksrt-signin]');
|
var root = document.querySelector('[data-aksrt-signin]');
|
||||||
if (!root) return;
|
if (!root || root.dataset.aksrtSigninInitialized === '1') return;
|
||||||
|
root.dataset.aksrtSigninInitialized = '1';
|
||||||
var status = root.querySelector('[data-signin-status]');
|
var status = root.querySelector('[data-signin-status]');
|
||||||
var btn = root.querySelector('[data-signin-btn]');
|
var btn = root.querySelector('[data-signin-btn]');
|
||||||
var tip = root.querySelector('[data-signin-tip]');
|
|
||||||
if (!btn) return;
|
if (!btn) return;
|
||||||
|
|
||||||
function setStatus(text) { if (status) status.textContent = text; }
|
function setStatus(text) { if (status) status.textContent = text; }
|
||||||
function setStatusHtml(html) { if (status) status.innerHTML = html; }
|
function setStatusHtml(html) { if (status) status.innerHTML = html; }
|
||||||
function setTip(text) { if (tip) tip.textContent = text; }
|
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
api('/signin/today').then(function (r) {
|
api('/signin/today').then(function (r) {
|
||||||
if (!r.ok) {
|
if (!r.ok) {
|
||||||
setStatus((r.json && r.json.message) || '加载失败 (HTTP ' + r.status + ')');
|
var message = (r.json && r.json.message) || '签到状态加载失败 (HTTP ' + r.status + ')';
|
||||||
|
setStatus(message);
|
||||||
|
notyf(message, 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var j = r.json;
|
var j = r.json;
|
||||||
if (!j.enabled) {
|
if (!j.enabled) {
|
||||||
setStatus('签到功能未启用');
|
setStatus('签到功能未启用');
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
setTip('');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (j.signed) {
|
if (j.signed) {
|
||||||
setStatusHtml('已签到 <strong>' + j.streak + '</strong> 天 +' + j.reward_today);
|
setStatusHtml('已签到 <strong>' + j.streak + '</strong> 天 +' + j.reward_today);
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.innerHTML = '已签到';
|
btn.innerHTML = '已签到';
|
||||||
setTip('');
|
|
||||||
} else {
|
} else {
|
||||||
setStatusHtml('连续 <strong>' + j.streak + '</strong> 天,+' + j.reward_if_signin);
|
setStatusHtml('连续 <strong>' + j.streak + '</strong> 天,+' + j.reward_if_signin);
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
setTip('');
|
|
||||||
}
|
}
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
if (window.console) console.error('[AKSRT Credits] /signin/today 请求失败:', err);
|
if (window.console) console.error('[AKSRT Credits] /signin/today 请求失败:', err);
|
||||||
setStatus('加载失败,请刷新重试');
|
setStatus('加载失败,请刷新重试');
|
||||||
|
notyf('签到状态加载失败,请刷新重试', 'danger');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,36 +127,36 @@
|
|||||||
btn.addEventListener('click', function () {
|
btn.addEventListener('click', function () {
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.innerHTML = '…';
|
btn.innerHTML = '…';
|
||||||
setTip('');
|
|
||||||
|
|
||||||
triggerCaptcha(function () {
|
triggerCaptcha(function () {
|
||||||
doSignin();
|
doSignin();
|
||||||
}, function (msg) {
|
}, function (msg) {
|
||||||
resetCaptcha();
|
resetCaptcha();
|
||||||
if (msg) setTip(msg);
|
if (msg) notyf(msg, 'danger');
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '签到';
|
btn.innerHTML = '签到';
|
||||||
});
|
});
|
||||||
|
|
||||||
function doSignin() {
|
function doSignin() {
|
||||||
|
notyf('正在签到…', 'load', '', 'aksrt-balance-signin-toast');
|
||||||
api('/signin', {
|
api('/signin', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ captcha: collectCaptcha() })
|
body: JSON.stringify({ captcha: collectCaptcha() })
|
||||||
}).then(function (r) {
|
}).then(function (r) {
|
||||||
if (!r.ok) {
|
if (!r.ok) {
|
||||||
resetCaptcha();
|
resetCaptcha();
|
||||||
setTip((r.json && r.json.message) || '签到失败');
|
notyf((r.json && r.json.message) || '签到失败', 'danger', 5, 'aksrt-balance-signin-toast');
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '签到';
|
btn.innerHTML = '签到';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTip('签到成功,获得 ' + r.json.reward + ' 积分(连续 ' + r.json.streak + ' 天)');
|
notyf('签到成功,获得 ' + r.json.reward + ' 积分(连续 ' + r.json.streak + ' 天)', 'success', 5, 'aksrt-balance-signin-toast');
|
||||||
var balanceEls = document.querySelectorAll('[data-credits-value]');
|
var balanceEls = document.querySelectorAll('[data-credits-value]');
|
||||||
balanceEls.forEach(function (el) { el.textContent = r.json.balance.toLocaleString(); });
|
balanceEls.forEach(function (el) { el.textContent = r.json.balance.toLocaleString(); });
|
||||||
refresh();
|
refresh();
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
resetCaptcha();
|
resetCaptcha();
|
||||||
setTip('网络错误,请重试');
|
notyf('网络错误,请重试', 'danger', 5, 'aksrt-balance-signin-toast');
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '签到';
|
btn.innerHTML = '签到';
|
||||||
});
|
});
|
||||||
@@ -170,6 +169,8 @@
|
|||||||
// Task-list "去签到" → scroll + click the real asset-card sign-in button.
|
// Task-list "去签到" → scroll + click the real asset-card sign-in button.
|
||||||
function initSigninGoto() {
|
function initSigninGoto() {
|
||||||
document.querySelectorAll('[data-aksrt-signin-goto]').forEach(function (el) {
|
document.querySelectorAll('[data-aksrt-signin-goto]').forEach(function (el) {
|
||||||
|
if (el.dataset.aksrtSigninGotoInitialized === '1') return;
|
||||||
|
el.dataset.aksrtSigninGotoInitialized = '1';
|
||||||
el.addEventListener('click', function (e) {
|
el.addEventListener('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var root = document.querySelector('[data-aksrt-signin]');
|
var root = document.querySelector('[data-aksrt-signin]');
|
||||||
@@ -418,7 +419,10 @@
|
|||||||
}
|
}
|
||||||
function closeModal(el) {
|
function closeModal(el) {
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
if (activePoll && typeof activePoll.abort === 'function') activePoll.abort();
|
if (activePoll && typeof activePoll.abort === 'function') {
|
||||||
|
activePoll.abort();
|
||||||
|
notyf('已停止查询支付状态', 'warning', 3, 'aksrt-balance-charge-payment-toast');
|
||||||
|
}
|
||||||
activePoll = null;
|
activePoll = null;
|
||||||
el.hidden = true;
|
el.hidden = true;
|
||||||
el.classList.remove('is-open');
|
el.classList.remove('is-open');
|
||||||
@@ -426,17 +430,25 @@
|
|||||||
document.body.classList.remove('uc-modal-open');
|
document.body.classList.remove('uc-modal-open');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function pollPaidOrder(orderNumber, setTip, tags) {
|
function pollPaidOrder(orderNumber, tags) {
|
||||||
var coordinator = window.AksrtVipPurchaseCoordinator;
|
var coordinator = window.AksrtVipPurchaseCoordinator;
|
||||||
if (!orderNumber) return;
|
if (!orderNumber) return;
|
||||||
|
notyf('等待支付结果…', 'load', '', 'aksrt-balance-charge-payment-toast');
|
||||||
var handle = coordinator.poll(orderNumber, {
|
var handle = coordinator.poll(orderNumber, {
|
||||||
tags: tags || ['credits', 'orders'],
|
tags: tags || ['credits', 'orders'],
|
||||||
onTerminal: function (result) {
|
onTerminal: function (result) {
|
||||||
activePoll = null;
|
activePoll = null;
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
if (typeof setTip === 'function') setTip('支付成功,正在刷新…');
|
notyf('支付成功,正在刷新…', 'success', 5, 'aksrt-balance-charge-payment-toast');
|
||||||
window.location.reload();
|
window.setTimeout(function () { window.location.reload(); }, 800);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
var message = result.data && result.data.message ? result.data.message : '支付未完成,请重试';
|
||||||
|
notyf(message, 'danger', 5, 'aksrt-balance-charge-payment-toast');
|
||||||
|
},
|
||||||
|
onTimeout: function () {
|
||||||
|
activePoll = null;
|
||||||
|
notyf('支付状态暂未确认,请稍后在订单中心查看', 'danger', 5, 'aksrt-balance-charge-payment-toast');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return handle;
|
return handle;
|
||||||
@@ -447,20 +459,12 @@
|
|||||||
if (!modal || modal.dataset.aksrtChargeInitialized === '1') return;
|
if (!modal || modal.dataset.aksrtChargeInitialized === '1') return;
|
||||||
modal.dataset.aksrtChargeInitialized = '1';
|
modal.dataset.aksrtChargeInitialized = '1';
|
||||||
var form = modal.querySelector('[data-aksrt-charge-form]');
|
var form = modal.querySelector('[data-aksrt-charge-form]');
|
||||||
var tip = modal.querySelector('[data-aksrt-charge-tip]');
|
|
||||||
var busy = false;
|
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) {
|
document.querySelectorAll('[data-aksrt-charge-open]').forEach(function (btn) {
|
||||||
btn.addEventListener('click', function () { openModal(modal); });
|
btn.addEventListener('click', function () { openModal(modal); });
|
||||||
});
|
});
|
||||||
modal.querySelectorAll('[data-aksrt-charge-close]').forEach(function (btn) {
|
modal.querySelectorAll('[data-aksrt-charge-close]').forEach(function (btn) {
|
||||||
btn.addEventListener('click', function () {
|
btn.addEventListener('click', function () {
|
||||||
if (activePoll && typeof activePoll.abort === 'function') activePoll.abort();
|
|
||||||
activePoll = null;
|
|
||||||
closeModal(modal);
|
closeModal(modal);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -483,17 +487,17 @@
|
|||||||
pkg = 'custom';
|
pkg = 'custom';
|
||||||
}
|
}
|
||||||
if ((!pkg || pkg === 'custom') && !(custom > 0) && !pkgInput) {
|
if ((!pkg || pkg === 'custom') && !(custom > 0) && !pkgInput) {
|
||||||
setTip('请选择或输入充值金额', true);
|
notyf('请选择或输入充值金额', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pkg === 'custom' && !(custom > 0)) {
|
if (pkg === 'custom' && !(custom > 0)) {
|
||||||
setTip('请输入有效充值金额', true);
|
notyf('请输入有效充值金额', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var methodEl = form.querySelector('input[name="payment_method"]:checked');
|
var methodEl = form.querySelector('input[name="payment_method"]:checked');
|
||||||
var method = methodEl ? methodEl.value : 'alipay';
|
var method = methodEl ? methodEl.value : 'alipay';
|
||||||
busy = true;
|
busy = true;
|
||||||
setTip('正在创建订单…');
|
notyf('正在创建充值订单…', 'load', '', 'aksrt-balance-charge-toast');
|
||||||
api('/pay/balance/charge', {
|
api('/pay/balance/charge', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -504,21 +508,21 @@
|
|||||||
}).then(function (r) {
|
}).then(function (r) {
|
||||||
busy = false;
|
busy = false;
|
||||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||||
setTip((r.json && r.json.message) || '充值失败', true);
|
notyf((r.json && r.json.message) || '充值失败', 'danger', 5, 'aksrt-balance-charge-toast');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||||
if (data && data.redirect && (data.payment_url || data.qr_content)) {
|
if (data && data.redirect && (data.payment_url || data.qr_content)) {
|
||||||
if (data.payment_url) window.open(data.payment_url, '_blank');
|
if (data.payment_url) window.open(data.payment_url, '_blank');
|
||||||
setTip(data.message || '请完成支付,支付成功后将自动刷新。');
|
notyf(data.message || '请完成支付,支付成功后将自动刷新。', 'info', 5, 'aksrt-balance-charge-toast');
|
||||||
if (data.order_number) activePoll = pollPaidOrder(data.order_number, setTip, ['credits', 'orders']);
|
if (data.order_number) activePoll = pollPaidOrder(data.order_number, ['credits', 'orders']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTip((data && data.message) || '充值成功,正在刷新…');
|
notyf((data && data.message) || '充值成功,正在刷新…', 'success', 5, 'aksrt-balance-charge-toast');
|
||||||
window.location.reload();
|
window.setTimeout(function () { window.location.reload(); }, 800);
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
busy = false;
|
busy = false;
|
||||||
setTip('网络错误,请重试', true);
|
notyf('网络错误,请重试', 'danger', 5, 'aksrt-balance-charge-toast');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -528,7 +532,6 @@
|
|||||||
if (!modal || modal.dataset.aksrtTransferInitialized === '1') return;
|
if (!modal || modal.dataset.aksrtTransferInitialized === '1') return;
|
||||||
modal.dataset.aksrtTransferInitialized = '1';
|
modal.dataset.aksrtTransferInitialized = '1';
|
||||||
var form = modal.querySelector('[data-aksrt-transfer-form]');
|
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 results = modal.querySelector('[data-aksrt-transfer-results]');
|
||||||
var selected = modal.querySelector('[data-aksrt-transfer-selected]');
|
var selected = modal.querySelector('[data-aksrt-transfer-selected]');
|
||||||
var recipientInput = modal.querySelector('[data-aksrt-transfer-recipient]');
|
var recipientInput = modal.querySelector('[data-aksrt-transfer-recipient]');
|
||||||
@@ -540,11 +543,6 @@
|
|||||||
var pointsTransferMin = 1;
|
var pointsTransferMin = 1;
|
||||||
var searchTimer = null;
|
var searchTimer = null;
|
||||||
var busy = false;
|
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) {
|
document.querySelectorAll('[data-aksrt-transfer-open]').forEach(function (btn) {
|
||||||
btn.addEventListener('click', function () {
|
btn.addEventListener('click', function () {
|
||||||
var type = btn.getAttribute('data-aksrt-transfer-open') || 'balance';
|
var type = btn.getAttribute('data-aksrt-transfer-open') || 'balance';
|
||||||
@@ -566,7 +564,6 @@
|
|||||||
if (results) results.innerHTML = '';
|
if (results) results.innerHTML = '';
|
||||||
if (selected) selected.textContent = '';
|
if (selected) selected.textContent = '';
|
||||||
if (recipientInput) recipientInput.value = '';
|
if (recipientInput) recipientInput.value = '';
|
||||||
setTip('');
|
|
||||||
openModal(modal);
|
openModal(modal);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -586,7 +583,10 @@
|
|||||||
api('/pay/transfer/search?s=' + encodeURIComponent(q)).then(function (r) {
|
api('/pay/transfer/search?s=' + encodeURIComponent(q)).then(function (r) {
|
||||||
if (!results) return;
|
if (!results) return;
|
||||||
results.innerHTML = '';
|
results.innerHTML = '';
|
||||||
if (!r.ok) return;
|
if (!r.ok) {
|
||||||
|
notyf((r.json && r.json.message) || '用户搜索失败', 'danger');
|
||||||
|
return;
|
||||||
|
}
|
||||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||||
var users = (data && data.users) || [];
|
var users = (data && data.users) || [];
|
||||||
if (!users.length) {
|
if (!users.length) {
|
||||||
@@ -618,47 +618,42 @@
|
|||||||
var amountEl = form.querySelector('[data-aksrt-transfer-amount]');
|
var amountEl = form.querySelector('[data-aksrt-transfer-amount]');
|
||||||
var amount = amountEl ? amountEl.value : 0;
|
var amount = amountEl ? amountEl.value : 0;
|
||||||
if (!recipient) {
|
if (!recipient) {
|
||||||
setTip('请选择收款用户', true);
|
notyf('请选择收款用户', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(parseFloat(amount) > 0) || (type === 'points' && (!Number.isInteger(Number(amount)) || Number(amount) < pointsTransferMin))) {
|
if (!(parseFloat(amount) > 0) || (type === 'points' && (!Number.isInteger(Number(amount)) || Number(amount) < pointsTransferMin))) {
|
||||||
setTip('请输入有效金额', true);
|
notyf('请输入有效金额', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
busy = true;
|
busy = true;
|
||||||
setTip('正在转账…');
|
notyf('正在转账…', 'load', '', 'aksrt-balance-transfer-toast');
|
||||||
api('/pay/transfer', {
|
api('/pay/transfer', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ type: type, recipient: recipient, amount: amount })
|
body: JSON.stringify({ type: type, recipient: recipient, amount: amount })
|
||||||
}).then(function (r) {
|
}).then(function (r) {
|
||||||
busy = false;
|
busy = false;
|
||||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||||
setTip((r.json && r.json.message) || '转账失败', true);
|
notyf((r.json && r.json.message) || '转账失败', 'danger', 5, 'aksrt-balance-transfer-toast');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||||
setTip((data && data.message) || '转账成功,正在刷新…');
|
notyf((data && data.message) || '转账成功,正在刷新…', 'success', 5, 'aksrt-balance-transfer-toast');
|
||||||
window.location.reload();
|
window.setTimeout(function () { window.location.reload(); }, 800);
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
busy = false;
|
busy = false;
|
||||||
setTip('网络错误,请重试', true);
|
notyf('网络错误,请重试', 'danger', 5, 'aksrt-balance-transfer-toast');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPointsExchange() {
|
function initPointsExchange() {
|
||||||
var modal = document.querySelector('[data-aksrt-points-exchange-modal]');
|
var modal = document.querySelector('[data-aksrt-points-exchange-modal]');
|
||||||
if (!modal) return;
|
if (!modal || modal.dataset.aksrtPointsExchangeInitialized === '1') return;
|
||||||
|
modal.dataset.aksrtPointsExchangeInitialized = '1';
|
||||||
var form = modal.querySelector('[data-aksrt-points-exchange-form]');
|
var form = modal.querySelector('[data-aksrt-points-exchange-form]');
|
||||||
var tip = modal.querySelector('[data-aksrt-points-exchange-tip]');
|
|
||||||
var amountEl = form ? form.querySelector('[data-aksrt-points-exchange-amount]') : null;
|
var amountEl = form ? form.querySelector('[data-aksrt-points-exchange-amount]') : null;
|
||||||
var preview = form ? form.querySelector('[data-aksrt-points-exchange-preview]') : null;
|
var preview = form ? form.querySelector('[data-aksrt-points-exchange-preview]') : null;
|
||||||
var busy = false;
|
var busy = false;
|
||||||
function setTip(text, isError) {
|
|
||||||
if (!tip) return;
|
|
||||||
tip.textContent = text || '';
|
|
||||||
tip.classList.toggle('is-error', !!isError);
|
|
||||||
}
|
|
||||||
document.querySelectorAll('[data-aksrt-points-exchange-open]').forEach(function (btn) {
|
document.querySelectorAll('[data-aksrt-points-exchange-open]').forEach(function (btn) {
|
||||||
btn.addEventListener('click', function () { openModal(modal); });
|
btn.addEventListener('click', function () { openModal(modal); });
|
||||||
});
|
});
|
||||||
@@ -681,42 +676,36 @@
|
|||||||
if (busy) return;
|
if (busy) return;
|
||||||
var amount = amountEl ? Number(amountEl.value || '0') : 0;
|
var amount = amountEl ? Number(amountEl.value || '0') : 0;
|
||||||
if (!Number.isInteger(amount) || !(amount > 0)) {
|
if (!Number.isInteger(amount) || !(amount > 0)) {
|
||||||
setTip('请输入正整数余额', true);
|
notyf('请输入正整数余额', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
busy = true;
|
busy = true;
|
||||||
setTip('正在兑换…');
|
notyf('正在购买积分…', 'load', '', 'aksrt-balance-points-toast');
|
||||||
api('/pay/balance/points-exchange', {
|
api('/pay/balance/points-exchange', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ amount: amount })
|
body: JSON.stringify({ amount: amount })
|
||||||
}).then(function (r) {
|
}).then(function (r) {
|
||||||
busy = false;
|
busy = false;
|
||||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||||
setTip((r.json && r.json.message) || '购买失败', true);
|
notyf((r.json && r.json.message) || '购买失败', 'danger', 5, 'aksrt-balance-points-toast');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||||
setTip((data && data.message) || '购买成功,正在刷新…');
|
notyf((data && data.message) || '购买成功,正在刷新…', 'success', 5, 'aksrt-balance-points-toast');
|
||||||
window.location.reload();
|
window.setTimeout(function () { window.location.reload(); }, 800);
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
busy = false;
|
busy = false;
|
||||||
setTip('网络错误,请重试', true);
|
notyf('网络错误,请重试', 'danger', 5, 'aksrt-balance-points-toast');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initWithdraw() {
|
function initWithdraw() {
|
||||||
var modal = document.querySelector('[data-aksrt-withdraw-modal]');
|
var modal = document.querySelector('[data-aksrt-withdraw-modal]');
|
||||||
if (!modal || modal.dataset.aksrtWithdrawInitialized === '1') return;
|
if (!modal || modal.dataset.aksrtWithdrawInitialized === '1') return;
|
||||||
modal.dataset.aksrtWithdrawInitialized = '1';
|
modal.dataset.aksrtWithdrawInitialized = '1';
|
||||||
var form = modal.querySelector('[data-aksrt-withdraw-form]');
|
var form = modal.querySelector('[data-aksrt-withdraw-form]');
|
||||||
var tip = modal.querySelector('[data-aksrt-withdraw-tip]');
|
|
||||||
var busy = false;
|
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) {
|
document.querySelectorAll('[data-aksrt-withdraw-open]').forEach(function (btn) {
|
||||||
btn.addEventListener('click', function () { openModal(modal); });
|
btn.addEventListener('click', function () { openModal(modal); });
|
||||||
});
|
});
|
||||||
@@ -738,38 +727,38 @@
|
|||||||
var method = methodEl ? methodEl.value : 'alipay';
|
var method = methodEl ? methodEl.value : 'alipay';
|
||||||
var account = accountEl ? String(accountEl.value || '').trim() : '';
|
var account = accountEl ? String(accountEl.value || '').trim() : '';
|
||||||
if (!Number.isInteger(amount) || !(amount > 0)) {
|
if (!Number.isInteger(amount) || !(amount > 0)) {
|
||||||
setTip('提现金额必须为正整数', true);
|
notyf('提现金额必须为正整数', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (amount < minAmount) {
|
if (amount < minAmount) {
|
||||||
setTip('提现金额低于最低提现门槛', true);
|
notyf('提现金额低于最低提现门槛', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (remainingCount <= 0) {
|
if (remainingCount <= 0) {
|
||||||
setTip('当日提现次数已用尽', true);
|
notyf('当日提现次数已用尽', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (amount > remainingAmount) {
|
if (amount > remainingAmount) {
|
||||||
setTip('本次提现后将超出单日提现总额上限', true);
|
notyf('本次提现后将超出单日提现总额上限', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!account) {
|
if (!account) {
|
||||||
setTip('请填写收款账号信息', true);
|
notyf('请填写收款账号信息', 'danger');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
busy = true;
|
busy = true;
|
||||||
setTip('正在提交…');
|
notyf('正在提交提现申请…', 'load', '', 'aksrt-balance-withdraw-toast');
|
||||||
api('/earnings/withdrawals', {
|
api('/earnings/withdrawals', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ amount: amount, method: method, account: account })
|
body: JSON.stringify({ amount: amount, method: method, account: account })
|
||||||
}).then(function (r) {
|
}).then(function (r) {
|
||||||
busy = false;
|
busy = false;
|
||||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||||
setTip((r.json && r.json.message) || '提现失败', true);
|
notyf((r.json && r.json.message) || '提现失败', 'danger', 5, 'aksrt-balance-withdraw-toast');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||||
setTip((data && data.message) || '申请已提交');
|
notyf((data && data.message) || '申请已提交', 'success', 5, 'aksrt-balance-withdraw-toast');
|
||||||
closeModal(modal);
|
closeModal(modal);
|
||||||
var panel = modal.closest ? modal.closest('.dashboard-panel') : null;
|
var panel = modal.closest ? modal.closest('.dashboard-panel') : null;
|
||||||
panel = panel || document.getElementById('panel-credits');
|
panel = panel || document.getElementById('panel-credits');
|
||||||
@@ -785,7 +774,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
busy = false;
|
busy = false;
|
||||||
setTip('网络错误,请重试', true);
|
notyf('网络错误,请重试', 'danger', 5, 'aksrt-balance-withdraw-toast');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -822,7 +811,8 @@
|
|||||||
|
|
||||||
function initWithdrawHistory() {
|
function initWithdrawHistory() {
|
||||||
var modal = document.querySelector('[data-aksrt-withdraw-history-modal]');
|
var modal = document.querySelector('[data-aksrt-withdraw-history-modal]');
|
||||||
if (!modal) return;
|
if (!modal || modal.dataset.aksrtWithdrawHistoryInitialized === '1') return;
|
||||||
|
modal.dataset.aksrtWithdrawHistoryInitialized = '1';
|
||||||
function open() { modal.hidden = false; document.body.classList.add('uc-modal-open'); }
|
function open() { modal.hidden = false; document.body.classList.add('uc-modal-open'); }
|
||||||
function close() { modal.hidden = true; document.body.classList.remove('uc-modal-open'); }
|
function close() { modal.hidden = true; document.body.classList.remove('uc-modal-open'); }
|
||||||
document.querySelectorAll('[data-aksrt-withdraw-history-open]').forEach(function (btn) {
|
document.querySelectorAll('[data-aksrt-withdraw-history-open]').forEach(function (btn) {
|
||||||
@@ -838,7 +828,7 @@
|
|||||||
function bootAssets() {
|
function bootAssets() {
|
||||||
initSignin();
|
initSignin();
|
||||||
initSigninGoto();
|
initSigninGoto();
|
||||||
initAffiliateRevenue();
|
initAffiliateRevenue();
|
||||||
initVipShop();
|
initVipShop();
|
||||||
initVipPointsExchange();
|
initVipPointsExchange();
|
||||||
initCardPass();
|
initCardPass();
|
||||||
@@ -858,8 +848,13 @@
|
|||||||
|
|
||||||
if (window.AksrtFrontend && typeof window.AksrtFrontend.register === 'function') {
|
if (window.AksrtFrontend && typeof window.AksrtFrontend.register === 'function') {
|
||||||
window.AksrtFrontend.register('credits', function () {
|
window.AksrtFrontend.register('credits', function () {
|
||||||
|
initSignin();
|
||||||
|
initSigninGoto();
|
||||||
initBalanceCharge();
|
initBalanceCharge();
|
||||||
initTransfer();
|
initTransfer();
|
||||||
|
initPointsExchange();
|
||||||
|
initWithdraw();
|
||||||
|
initWithdrawHistory();
|
||||||
initAssetTabs();
|
initAssetTabs();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="uc-balance-card__tip muted-2-color em09" data-signin-tip></p>
|
|
||||||
<button type="button" class="uc-asset-card__link muted-2-color em09" data-aksrt-asset-tab="points_free"><?php esc_html_e('做任务赚积分', 'aksrt'); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i></button>
|
<button type="button" class="uc-asset-card__link muted-2-color em09" data-aksrt-asset-tab="points_free"><?php esc_html_e('做任务赚积分', 'aksrt'); ?><i class="fa fa-angle-right em12 ml3" aria-hidden="true"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -76,7 +75,6 @@ $currency = (string) ($currency_name ?? __('积分', 'aksrt'));
|
|||||||
<input type="number" class="uc-card-pass__input" name="amount" min="1" step="1" inputmode="numeric" data-aksrt-points-exchange-amount data-aksrt-points-exchange-rate="<?php echo esc_attr((string) $pb_rate); ?>">
|
<input type="number" class="uc-card-pass__input" name="amount" min="1" step="1" inputmode="numeric" data-aksrt-points-exchange-amount data-aksrt-points-exchange-rate="<?php echo esc_attr((string) $pb_rate); ?>">
|
||||||
<p class="muted-2-color em09 mt6"><?php printf(esc_html__('1 余额 = %d 积分;单笔至少 %d 积分,每日最多 %d 积分。', 'aksrt'), $pb_rate, $pb_min_points, $pb_daily_max_points); ?></p>
|
<p class="muted-2-color em09 mt6"><?php printf(esc_html__('1 余额 = %d 积分;单笔至少 %d 积分,每日最多 %d 积分。', 'aksrt'), $pb_rate, $pb_min_points, $pb_daily_max_points); ?></p>
|
||||||
<p class="muted-2-color em09 mt6" data-aksrt-points-exchange-preview></p>
|
<p class="muted-2-color em09 mt6" data-aksrt-points-exchange-preview></p>
|
||||||
<p class="uc-modal__tip" data-aksrt-points-exchange-tip></p>
|
|
||||||
<button type="submit" class="but jb-blue btn-block mt10"><?php esc_html_e('立即购买', 'aksrt'); ?></button>
|
<button type="submit" class="but jb-blue btn-block mt10"><?php esc_html_e('立即购买', 'aksrt'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ $mark = (string) ($charge_view['currency_mark'] ?? '元');
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p class="uc-modal__tip" data-aksrt-charge-tip></p>
|
|
||||||
<button type="submit" class="but jb-blue btn-block mt10" data-aksrt-charge-submit><?php esc_html_e('立即充值', 'aksrt'); ?></button>
|
<button type="submit" class="but jb-blue btn-block mt10" data-aksrt-charge-submit><?php esc_html_e('立即充值', 'aksrt'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ $points_transfer_fee = max(0, min(50, (int) ($transfer_all_settings['points_serv
|
|||||||
<?php printf(esc_html__(' 将扣除 %d%% 手续费。', 'aksrt'), $points_transfer_fee); ?>
|
<?php printf(esc_html__(' 将扣除 %d%% 手续费。', 'aksrt'), $points_transfer_fee); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<p class="uc-modal__tip" data-aksrt-transfer-tip></p>
|
|
||||||
<button type="submit" class="but jb-blue btn-block" data-aksrt-transfer-submit><?php esc_html_e('确认转账', 'aksrt'); ?></button>
|
<button type="submit" class="but jb-blue btn-block" data-aksrt-transfer-submit><?php esc_html_e('确认转账', 'aksrt'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ if (!$withdraw_channels) {
|
|||||||
</select>
|
</select>
|
||||||
<label class="muted-color em09 mt10"><?php esc_html_e('收款账户信息', 'aksrt'); ?></label>
|
<label class="muted-color em09 mt10"><?php esc_html_e('收款账户信息', 'aksrt'); ?></label>
|
||||||
<textarea class="uc-card-pass__input" name="account" rows="3" data-aksrt-withdraw-account placeholder="<?php esc_attr_e('姓名 + 账户 / 卡号', 'aksrt'); ?>"></textarea>
|
<textarea class="uc-card-pass__input" name="account" rows="3" data-aksrt-withdraw-account placeholder="<?php esc_attr_e('姓名 + 账户 / 卡号', 'aksrt'); ?>"></textarea>
|
||||||
<p class="uc-modal__tip" data-aksrt-withdraw-tip></p>
|
|
||||||
<button type="submit" class="but jb-blue btn-block" data-aksrt-withdraw-submit><?php esc_html_e('提交申请', 'aksrt'); ?></button>
|
<button type="submit" class="but jb-blue btn-block" data-aksrt-withdraw-submit><?php esc_html_e('提交申请', 'aksrt'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -858,7 +858,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
|||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'aksrt-credits',
|
'aksrt-credits',
|
||||||
$base_uri . '/assets/js/credits.js',
|
$base_uri . '/assets/js/credits.js',
|
||||||
['aksrt-script', 'aksrt-core-modal-runtime', 'aksrt-vip-coordinator'],
|
['aksrt-script', 'aksrt-core-modal-runtime', 'aksrt-vip-coordinator', 'aksrt-notyf'],
|
||||||
file_exists($credits_js_path) ? (string) filemtime($credits_js_path) : $version,
|
file_exists($credits_js_path) ? (string) filemtime($credits_js_path) : $version,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -193,6 +193,49 @@ test('notyf CSS and WordPress enqueue match the reference contract', () => {
|
|||||||
assert.match(scripts, /'\/assets\/css\/frontend\/notyf\.css',[\s\S]*?'aksrt-font-awesome-5-v4-shims'/);
|
assert.match(scripts, /'\/assets\/css\/frontend\/notyf\.css',[\s\S]*?'aksrt-font-awesome-5-v4-shims'/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('balance center actions use direct fixed-id notyf flows', () => {
|
||||||
|
const credits = read('assets/js/credits.js');
|
||||||
|
const scripts = read('src/Core/ScriptsPart1b.php');
|
||||||
|
const css = read('assets/css/routes/user-center/credits.css');
|
||||||
|
const renderers = [
|
||||||
|
'inc/helpers/user-center-renderers/credits-balance.php',
|
||||||
|
'inc/helpers/user-center-renderers/credits-wallet.php',
|
||||||
|
'inc/helpers/user-center-renderers/transfer-modal.php',
|
||||||
|
'inc/helpers/user-center-renderers/withdraw-modal.php',
|
||||||
|
].map(read).join('\n');
|
||||||
|
|
||||||
|
function section(start, end) {
|
||||||
|
const from = credits.indexOf('function ' + start + '(');
|
||||||
|
const to = credits.indexOf('function ' + end + '(', from + 1);
|
||||||
|
assert.notEqual(from, -1, start + ' should exist');
|
||||||
|
assert.notEqual(to, -1, end + ' should exist');
|
||||||
|
return credits.slice(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
|
const flows = [
|
||||||
|
[section('initSignin', 'initSigninGoto'), 'aksrt-balance-signin-toast'],
|
||||||
|
[section('initBalanceCharge', 'initTransfer'), 'aksrt-balance-charge-toast'],
|
||||||
|
[section('initTransfer', 'initPointsExchange'), 'aksrt-balance-transfer-toast'],
|
||||||
|
[section('initPointsExchange', 'initWithdraw'), 'aksrt-balance-points-toast'],
|
||||||
|
[section('initWithdraw', 'initAssetTabs'), 'aksrt-balance-withdraw-toast'],
|
||||||
|
];
|
||||||
|
|
||||||
|
flows.forEach(([source, id]) => {
|
||||||
|
assert.match(source, new RegExp("notyf\\([^;]+?'load'[^;]+?'" + id + "'\\);"));
|
||||||
|
assert.match(source, new RegExp("notyf\\([^;]+?'danger'[^;]+?'" + id + "'\\);"));
|
||||||
|
assert.match(source, new RegExp("notyf\\([^;]+?'success'[^;]+?'" + id + "'\\);"));
|
||||||
|
assert.doesNotMatch(source, /setTip|data-(?:signin|aksrt-(?:charge|transfer|points-exchange|withdraw))-tip/);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.match(credits, /notyf\('等待支付结果…', 'load', '', 'aksrt-balance-charge-payment-toast'\)/);
|
||||||
|
assert.match(credits, /onTimeout:[\s\S]*?notyf\([^;]+?'danger'[^;]+?'aksrt-balance-charge-payment-toast'\)/);
|
||||||
|
assert.match(credits, /register\('credits',[\s\S]*?initSignin\(\);[\s\S]*?initBalanceCharge\(\);[\s\S]*?initTransfer\(\);[\s\S]*?initPointsExchange\(\);[\s\S]*?initWithdraw\(\);/);
|
||||||
|
assert.match(credits, /aksrtSigninInitialized[\s\S]*?aksrtPointsExchangeInitialized[\s\S]*?aksrtWithdrawInitialized/);
|
||||||
|
assert.match(scripts, /'aksrt-credits',[\s\S]*?\/assets\/js\/credits\.js',[\s\S]*?\[[^\]]*'aksrt-notyf'[^\]]*\]/);
|
||||||
|
assert.doesNotMatch(renderers, /data-(?:signin|aksrt-(?:charge|transfer|points-exchange|withdraw))-tip/);
|
||||||
|
assert.doesNotMatch(css, /\.uc-(?:modal|balance-card)__tip/);
|
||||||
|
});
|
||||||
|
|
||||||
test('legacy frontend toast APIs and selectors are fully removed', () => {
|
test('legacy frontend toast APIs and selectors are fully removed', () => {
|
||||||
const files = [
|
const files = [
|
||||||
'assets/js',
|
'assets/js',
|
||||||
|
|||||||
Reference in new issue
Block a user