feat: upgrade widgets and affiliate commission flow
This commit is contained in:
@@ -72,3 +72,24 @@
|
||||
.uc-content .uc-promotion-copy { width: 100%; }
|
||||
.uc-content .uc-promotion-record { align-items: flex-start; }
|
||||
}
|
||||
|
||||
/* New affiliate contract cards. */
|
||||
.uc-content .aksrt-affiliate-panel { display:grid; gap:18px; padding:22px; border:1px solid var(--border,rgba(0,0,0,.08)); border-radius:var(--card-radius,16px); background:var(--surface, #fff); box-shadow:0 8px 24px rgba(15,23,42,.06); }
|
||||
.uc-content .uc-panel-heading h2 { margin:0 0 4px; color:var(--text,#111827); }
|
||||
.uc-content .uc-panel-heading p,.uc-content .uc-affiliate-note { margin:0; color:var(--muted,#6b7280); line-height:1.6; }
|
||||
.uc-content .uc-affiliate-link-card { display:flex; align-items:end; gap:10px; padding:14px; border-radius:12px; background:var(--surface-muted,#f8fafc); }
|
||||
.uc-content .uc-affiliate-link-card>div { flex:1; min-width:0; display:grid; gap:6px; }
|
||||
.uc-content .uc-affiliate-link-card input { width:100%; min-width:0; height:40px; padding:0 10px; border:1px solid var(--border,#e5e7eb); border-radius:8px; background:var(--surface,#fff); color:var(--text,#111827); }
|
||||
.uc-content .uc-affiliate-link-card button { white-space:nowrap; }
|
||||
.uc-content .uc-affiliate-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
|
||||
.uc-content .uc-affiliate-stats article { display:grid; gap:5px; padding:14px; border:1px solid var(--border,#e5e7eb); border-radius:12px; }
|
||||
.uc-content .uc-affiliate-stats article:first-child strong { color:var(--danger,#dc2626); }
|
||||
.uc-content .uc-affiliate-stats article strong { color:var(--primary,#2563eb); font-size:24px; font-variant-numeric:tabular-nums; }
|
||||
.uc-content .uc-affiliate-link-card [data-affiliate-feedback] { grid-column:1/-1; margin:0; min-height:18px; color:var(--success,#16a34a); font-size:12px; }
|
||||
.uc-content .uc-affiliate-link-card [data-affiliate-feedback].is-error { color:var(--danger,#dc2626); }
|
||||
.uc-content .uc-affiliate-accounts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; padding-top:4px; }
|
||||
.uc-content .uc-affiliate-accounts label { display:grid; gap:5px; color:var(--muted,#6b7280); font-size:12px; }
|
||||
.uc-content .uc-affiliate-accounts input { height:38px; padding:0 10px; border:1px solid var(--border,#e5e7eb); border-radius:8px; background:var(--surface,#fff); color:var(--text,#111827); }
|
||||
.uc-content .uc-affiliate-accounts button { justify-self:start; }
|
||||
.uc-content .uc-affiliate-accounts p { grid-column:1/-1; margin:0; color:var(--success,#16a34a); font-size:12px; }
|
||||
@media (max-width:640px) { .uc-content .aksrt-affiliate-panel { padding:16px; } .uc-content .uc-affiliate-link-card { align-items:stretch; flex-direction:column; } .uc-content .uc-affiliate-link-card button { width:100%; } .uc-content .uc-affiliate-stats,.uc-content .uc-affiliate-accounts { grid-template-columns:1fr; } }
|
||||
|
||||
+37
-3
@@ -383,6 +383,39 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ===== Forward-only affiliate promotion center =====
|
||||
function initAffiliatePromotion() {
|
||||
var root = document.querySelector('[data-aksrt-promotion-page]');
|
||||
if (!root || root.dataset.affiliateBound) return;
|
||||
root.dataset.affiliateBound = '1';
|
||||
var input = root.querySelector('[data-affiliate-link]');
|
||||
var copy = root.querySelector('[data-affiliate-copy]');
|
||||
var feedback = root.querySelector('[data-affiliate-feedback]');
|
||||
function setFeedback(text, error) { if (feedback) { feedback.textContent = text; feedback.classList.toggle('is-error', !!error); } }
|
||||
api('/promotion/me').then(function (r) {
|
||||
if (!r.ok) { setFeedback((r.json && r.json.message) || '推广数据加载失败。', true); return; }
|
||||
var j = r.json || {}, stats = j.stats || {};
|
||||
if (input) input.value = j.url || '';
|
||||
if (copy) copy.disabled = !j.url;
|
||||
var ratio = root.querySelector('[data-affiliate-ratio]'); if (ratio) ratio.textContent = String(j.ratio || 0) + '%';
|
||||
var promoters = root.querySelector('[data-affiliate-promoters]'); if (promoters) promoters.textContent = String(stats.promoters || 0);
|
||||
var payers = root.querySelector('[data-affiliate-payers]'); if (payers) payers.textContent = String(stats.effective_payers || 0);
|
||||
}).catch(function () { setFeedback('推广数据加载失败。', true); });
|
||||
if (copy) copy.addEventListener('click', function () {
|
||||
if (!input || !input.value) return;
|
||||
var done = function () { setFeedback('推广链接已复制。'); };
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(input.value).then(done).catch(function () { input.focus(); input.select(); setFeedback('复制失败,请手动复制。', true); });
|
||||
else { input.focus(); input.select(); try { document.execCommand('copy'); done(); } catch (e) { setFeedback('复制失败,请手动复制。', true); } }
|
||||
});
|
||||
var accountForm = root.querySelector('[data-affiliate-accounts]');
|
||||
if (accountForm) accountForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
var feedback = accountForm.querySelector('[data-affiliate-account-feedback]');
|
||||
var accounts = {}; new FormData(accountForm).forEach(function (value, key) { if (String(value).trim()) accounts[key] = String(value).trim(); });
|
||||
api('/promotion/payout-accounts', { method: 'PUT', body: JSON.stringify({ accounts: accounts }) }).then(function (r) { if (feedback) feedback.textContent = r.ok ? '收款方式已保存。' : ((r.json && r.json.message) || '保存失败。'); }).catch(function () { if (feedback) feedback.textContent = '网络错误,请稍后重试。'; });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===== VIP 积分兑换 =====
|
||||
@@ -917,9 +950,9 @@
|
||||
}
|
||||
busy = true;
|
||||
setTip('正在提交…');
|
||||
api('/pay/balance/withdraw', {
|
||||
api('/earnings/withdrawals', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ amount: amount, method: method, account_info: account })
|
||||
body: JSON.stringify({ amount: amount, method: method, account: account })
|
||||
}).then(function (r) {
|
||||
busy = false;
|
||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||
@@ -996,7 +1029,8 @@
|
||||
function bootAssets() {
|
||||
initSignin();
|
||||
initSigninGoto();
|
||||
initInvite();
|
||||
initInvite();
|
||||
initAffiliatePromotion();
|
||||
initVipShop();
|
||||
initVipPointsExchange();
|
||||
initCardPass();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
|
||||
function request(payload) {
|
||||
return fetch(rest + '/pay/balance/withdraw', {
|
||||
return fetch(rest + '/earnings/withdrawals', {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
@@ -53,7 +53,7 @@
|
||||
var values = new FormData(form);
|
||||
var amount = Number(values.get('amount') || 0);
|
||||
var method = String(values.get('method') || 'alipay');
|
||||
var account = String(values.get('account_info') || '').trim();
|
||||
var account = String(values.get('account') || values.get('account_info') || '').trim();
|
||||
var minimum = Number(page.getAttribute('data-min-amount') || 50);
|
||||
if (amount < minimum) {
|
||||
setMessage('最低提现金额为 ' + minimum, true);
|
||||
@@ -69,7 +69,7 @@
|
||||
button.disabled = true;
|
||||
button.textContent = '提交中…';
|
||||
}
|
||||
request({ amount: amount, method: method, account_info: account }).then(function (result) {
|
||||
request({ amount: amount, method: method, account: account }).then(function (result) {
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.textContent = '提交提现申请';
|
||||
|
||||
Reference in New Issue
Block a user