feat(user-center): merge promotion rewards into revenue
This commit is contained in:
1 parent
a87fd32fa3
commit
39c92017d9
14 files changed
+1048
-159
No files matched your search
@@ -1,24 +1,520 @@
|
||||
.uc-content .uc-revenue-card { margin: 0 0 24px; padding: 20px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); border-radius: 14px; background: var(--surface-1); }
|
||||
.uc-content .uc-revenue-card__header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
|
||||
.uc-content .uc-revenue-card__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; color: #fff; background: #ce6b35; }
|
||||
.uc-content .uc-revenue-card__header p { margin: 0 0 2px; color: var(--color-ink-4); font-size: 12px; }
|
||||
.uc-content .uc-revenue-card__header h3 { margin: 0; color: var(--color-ink); font-size: 18px; }
|
||||
.uc-content .uc-revenue-card .aksrt-revenue-page__stats { margin-bottom: 18px; }
|
||||
.uc-content #panel-revenue.dashboard-panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
|
||||
.uc-content .uc-revenue-panel { padding: 4px 0; }
|
||||
.uc-content .uc-revenue-panel__header { margin-bottom: 20px; }
|
||||
.uc-content .uc-revenue-panel__header p { margin: 0 0 4px; color: var(--color-primary); font-size: 12px; font-weight: 700; }
|
||||
.uc-content .uc-revenue-panel__header h2 { margin: 0; color: var(--color-ink); font-size: 22px; }
|
||||
.uc-content .uc-revenue-panel__header > span { display: block; margin-top: 7px; color: var(--color-ink-4); font-size: 13px; }
|
||||
.uc-content .aksrt-revenue-page__layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
|
||||
.uc-content .aksrt-revenue-page__panel,
|
||||
.uc-content .aksrt-revenue-page__section { padding: 20px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); border-radius: 14px; background: var(--surface-1); }
|
||||
.uc-content .aksrt-revenue-page__panel h3,
|
||||
.uc-content .aksrt-revenue-page__section h3 { margin: 0 0 14px; font-size: 16px; }
|
||||
.uc-content .aksrt-revenue-page__withdraw-form { display: grid; gap: 12px; }
|
||||
.uc-content .aksrt-revenue-page__withdraw-form label { display: grid; gap: 6px; color: var(--color-ink-3); font-size: 13px; }
|
||||
.uc-content .aksrt-revenue-page__withdraw-form input,
|
||||
.uc-content .aksrt-revenue-page__withdraw-form select,
|
||||
.uc-content .aksrt-revenue-page__withdraw-form textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.1)); border-radius: 8px; color: var(--color-ink); background: var(--surface-2); }
|
||||
.uc-content .aksrt-revenue-page__form-msg.is-error { color: var(--color-error, #dc2626); }
|
||||
@media (max-width: 640px) { .uc-content .aksrt-revenue-page__layout { grid-template-columns: 1fr; } }
|
||||
/**
|
||||
* User Center - commission and promotion rewards.
|
||||
*/
|
||||
|
||||
.uc-content #panel-revenue.dashboard-panel {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.uc-revenue-panel {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.uc-commission-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.uc-commission-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
min-width: 0;
|
||||
min-height: 142px;
|
||||
padding: 22px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||
border-radius: 8px;
|
||||
background: var(--surface-1);
|
||||
box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
|
||||
}
|
||||
|
||||
.uc-commission-card__icon {
|
||||
display: grid;
|
||||
flex: 0 0 48px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
place-items: center;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
background: #2563a8;
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.uc-commission-card--balance .uc-commission-card__icon {
|
||||
background: #c95a31;
|
||||
}
|
||||
|
||||
.uc-commission-card__body {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.uc-commission-card__body > span,
|
||||
.uc-commission-card__body > p {
|
||||
display: block;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uc-commission-card__body > span {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.uc-commission-card__body strong {
|
||||
display: block;
|
||||
color: var(--color-ink);
|
||||
font-size: 30px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
.uc-commission-card--ratio .uc-commission-card__body strong {
|
||||
color: #2563a8;
|
||||
}
|
||||
|
||||
.uc-commission-card__body strong small {
|
||||
margin-left: 2px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.uc-commission-card__body p {
|
||||
margin: 6px 0 0;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.uc-commission-card__action {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
flex: 0 0 auto;
|
||||
margin-left: auto;
|
||||
padding: 9px 13px;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
color: #fff;
|
||||
background: var(--color-primary);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uc-commission-card__action:hover {
|
||||
color: #fff;
|
||||
filter: brightness(.95);
|
||||
}
|
||||
|
||||
.uc-reward-area {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
padding: 4px 0 0;
|
||||
}
|
||||
|
||||
.uc-reward-area__heading {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.uc-reward-area__heading h3,
|
||||
.uc-reward-list-heading h4,
|
||||
.uc-reward-block h4 {
|
||||
margin: 0;
|
||||
color: var(--color-ink);
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.uc-reward-area__heading > span,
|
||||
.uc-reward-list-heading p,
|
||||
.uc-reward-block__heading p {
|
||||
margin: 0;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uc-reward-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||
}
|
||||
|
||||
.uc-reward-tabs a {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
padding: 10px 16px;
|
||||
color: var(--color-ink-3);
|
||||
font-size: 14px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.uc-reward-tabs a::after {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
bottom: -1px;
|
||||
left: 12px;
|
||||
height: 2px;
|
||||
background: transparent;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.uc-reward-tabs a:hover,
|
||||
.uc-reward-tabs a.is-active {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.uc-reward-tabs a.is-active {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.uc-reward-tabs a.is-active::after {
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
.uc-reward-pane {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.uc-reward-pane--detail {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.uc-reward-block {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
padding: 18px;
|
||||
border: 1px solid var(--color-line-soft, rgba(15, 23, 42, .07));
|
||||
border-radius: 8px;
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.uc-reward-block__heading {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.uc-reward-block__heading p {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.uc-invite-share {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.uc-invite-code {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.uc-invite-code strong {
|
||||
color: var(--color-ink);
|
||||
font-size: 19px;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
|
||||
.uc-invite-link-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.uc-invite-link-row input {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
height: 40px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid var(--color-line-soft, rgba(15, 23, 42, .12));
|
||||
border-radius: 7px;
|
||||
color: var(--color-ink);
|
||||
background: var(--surface-1);
|
||||
}
|
||||
|
||||
.uc-reward-status,
|
||||
.uc-reward-copy-feedback {
|
||||
min-height: 17px;
|
||||
margin: 0;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uc-reward-status.is-error,
|
||||
.uc-reward-copy-feedback.is-error {
|
||||
color: var(--color-error, #dc2626);
|
||||
}
|
||||
|
||||
.uc-ratio-list {
|
||||
display: grid;
|
||||
gap: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.uc-ratio-list > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .07));
|
||||
}
|
||||
|
||||
.uc-ratio-list > div:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.uc-ratio-list dt {
|
||||
color: var(--color-ink-3);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.uc-ratio-list dd {
|
||||
margin: 0;
|
||||
color: var(--color-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.uc-total-commission {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.uc-total-commission strong {
|
||||
color: var(--color-ink);
|
||||
font-size: 28px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.uc-total-commission span {
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uc-reward-richtext {
|
||||
color: var(--color-ink-3);
|
||||
font-size: 13px;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.uc-reward-richtext p {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
|
||||
.uc-reward-richtext p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.uc-reward-list-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.uc-reward-list-heading > div {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.uc-reward-list-heading > strong {
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.uc-commission-list,
|
||||
.uc-invite-list {
|
||||
display: grid;
|
||||
gap: 0;
|
||||
border-top: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||
}
|
||||
|
||||
.uc-commission-row,
|
||||
.uc-invite-record {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
padding: 13px 0;
|
||||
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||
}
|
||||
|
||||
.uc-commission-row__icon {
|
||||
display: grid;
|
||||
flex: 0 0 34px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
place-items: center;
|
||||
border-radius: 8px;
|
||||
color: #c95a31;
|
||||
background: rgba(201, 90, 49, .12);
|
||||
}
|
||||
|
||||
.uc-commission-row__main,
|
||||
.uc-invite-record__main {
|
||||
display: grid;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.uc-commission-row__main strong,
|
||||
.uc-invite-record__main strong {
|
||||
overflow: hidden;
|
||||
color: var(--color-ink);
|
||||
font-size: 13px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uc-commission-row__main span,
|
||||
.uc-commission-row__main time,
|
||||
.uc-invite-record__main span {
|
||||
overflow: hidden;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uc-commission-row__value {
|
||||
display: grid;
|
||||
justify-items: end;
|
||||
gap: 4px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.uc-commission-row__value strong {
|
||||
color: #16816c;
|
||||
font-size: 14px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.uc-commission-row__value span {
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
color: var(--color-ink-4);
|
||||
background: var(--surface-1);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.uc-commission-row__value span.is-settled {
|
||||
color: #16816c;
|
||||
background: rgba(22, 129, 108, .1);
|
||||
}
|
||||
|
||||
.uc-commission-row__value span.is-pending {
|
||||
color: #a86d28;
|
||||
background: rgba(168, 109, 40, .12);
|
||||
}
|
||||
|
||||
.uc-invite-record__avatar {
|
||||
display: grid;
|
||||
flex: 0 0 36px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
color: var(--color-primary);
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.uc-invite-record__avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.uc-invite-record__status {
|
||||
flex: 0 0 auto;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.uc-reward-pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.uc-reward-pagination a {
|
||||
display: grid;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
place-items: center;
|
||||
border-radius: 6px;
|
||||
color: var(--color-ink-3);
|
||||
background: var(--surface-2);
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.uc-reward-pagination a.is-active,
|
||||
.uc-reward-pagination a:hover {
|
||||
color: #fff;
|
||||
background: var(--color-primary);
|
||||
}
|
||||
|
||||
.uc-reward-empty {
|
||||
margin: 0;
|
||||
padding: 30px 12px;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.uc-commission-summary,
|
||||
.uc-reward-pane--detail {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.uc-commission-card {
|
||||
min-height: 120px;
|
||||
padding: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.uc-reward-area {
|
||||
padding: 4px 0 0;
|
||||
}
|
||||
|
||||
.uc-commission-card {
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.uc-commission-card__action {
|
||||
margin-left: 63px;
|
||||
}
|
||||
|
||||
.uc-invite-link-row {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.uc-invite-link-row .btn-primary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.uc-invite-record,
|
||||
.uc-commission-row {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.uc-commission-row__value {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* Commission center referral link and invited-user records.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var root = document.querySelector('[data-aksrt-revenue-page]');
|
||||
if (!root) return;
|
||||
|
||||
var data = window.aksrtData || {};
|
||||
var rest = data.restUrl || data.apiUrl || ((data.siteUrl || '').replace(/\/$/, '') + '/wp-json/aksrt/v1');
|
||||
if (!rest) return;
|
||||
rest = rest.replace(/\/?$/, '');
|
||||
|
||||
function api(path) {
|
||||
return fetch(rest + path, {
|
||||
credentials: 'same-origin',
|
||||
headers: { 'X-WP-Nonce': data.restNonce || data.nonce || '' }
|
||||
}).then(function (response) {
|
||||
return response.json().catch(function () { return {}; }).then(function (json) {
|
||||
return { ok: response.ok, json: json };
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value == null ? '' : value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value || value === '0000-00-00 00:00:00') return '';
|
||||
var date = new Date(String(value).replace(' ', 'T') + 'Z');
|
||||
return isNaN(date.getTime()) ? String(value).slice(0, 16) : date.toLocaleString();
|
||||
}
|
||||
|
||||
var linkInput = root.querySelector('[data-invite-link]');
|
||||
var codeEl = root.querySelector('[data-invite-code]');
|
||||
var copyBtn = root.querySelector('[data-invite-copy]');
|
||||
var statusEl = root.querySelector('[data-invite-status]');
|
||||
var feedbackEl = root.querySelector('[data-invite-copy-feedback]');
|
||||
var listEl = root.querySelector('[data-invite-list]');
|
||||
var totalEl = root.querySelector('[data-invite-total]');
|
||||
|
||||
function setStatus(text, error) {
|
||||
if (!statusEl) return;
|
||||
statusEl.textContent = text || '';
|
||||
statusEl.classList.toggle('is-error', !!error);
|
||||
}
|
||||
|
||||
api('/invite/me').then(function (result) {
|
||||
if (!result.ok) {
|
||||
setStatus((result.json && result.json.message) || '推广数据加载失败', true);
|
||||
return;
|
||||
}
|
||||
var payload = result.json || {};
|
||||
if (linkInput) linkInput.value = payload.invite_url || '';
|
||||
if (codeEl) codeEl.textContent = payload.code || '--';
|
||||
if (copyBtn) copyBtn.disabled = !payload.invite_url;
|
||||
setStatus('推广数据已更新', false);
|
||||
}).catch(function () {
|
||||
setStatus('推广数据加载失败,请稍后重试', true);
|
||||
});
|
||||
|
||||
function renderPagination(total, current) {
|
||||
if (!listEl || total <= 10) return;
|
||||
var nav = root.querySelector('[data-invite-pagination]');
|
||||
if (!nav) {
|
||||
nav = document.createElement('nav');
|
||||
nav.className = 'uc-reward-pagination';
|
||||
nav.setAttribute('data-invite-pagination', 'true');
|
||||
nav.setAttribute('aria-label', '邀请记录分页');
|
||||
listEl.parentNode.appendChild(nav);
|
||||
}
|
||||
nav.innerHTML = '';
|
||||
var pages = Math.ceil(total / 10);
|
||||
for (var page = 1; page <= pages; page++) {
|
||||
var url = new URL(window.location.href);
|
||||
url.searchParams.set('reward_tab', 'users');
|
||||
if (page > 1) url.searchParams.set('invite_page', String(page));
|
||||
else url.searchParams.delete('invite_page');
|
||||
var link = document.createElement('a');
|
||||
link.href = url.toString();
|
||||
link.textContent = String(page);
|
||||
link.className = page === current ? 'is-active' : '';
|
||||
nav.appendChild(link);
|
||||
}
|
||||
}
|
||||
|
||||
function renderList(payload, page) {
|
||||
if (!listEl) return;
|
||||
var items = Array.isArray(payload.items) ? payload.items : [];
|
||||
var total = Number(payload.total || 0);
|
||||
listEl.classList.remove('is-loading');
|
||||
if (totalEl) totalEl.textContent = total ? total + ' 条' : '暂无记录';
|
||||
if (!items.length) {
|
||||
listEl.innerHTML = '<p class="uc-reward-empty">分享链接后,邀请记录会显示在这里。</p>';
|
||||
return;
|
||||
}
|
||||
listEl.innerHTML = items.map(function (item) {
|
||||
var name = item.invitee_name || (item.invitee_id ? '用户 #' + item.invitee_id : '受邀用户');
|
||||
var avatar = item.invitee_avatar ? '<img src="' + escapeHtml(item.invitee_avatar) + '" alt="">' : '<span>' + escapeHtml(name.charAt(0)) + '</span>';
|
||||
var status = item.status === 'rewarded' ? '已奖励' : (item.status === 'verified' ? '已验证' : '已注册');
|
||||
return '<article class="uc-invite-record"><span class="uc-invite-record__avatar">' + avatar + '</span><span class="uc-invite-record__main"><strong>' + escapeHtml(name) + '</strong><span>' + escapeHtml(formatDate(item.created_at)) + '</span></span><span class="uc-invite-record__status">' + status + '</span></article>';
|
||||
}).join('');
|
||||
var currentPage = Number(payload.page || page);
|
||||
renderPagination(total, isNaN(currentPage) ? 1 : currentPage);
|
||||
}
|
||||
|
||||
if (listEl) {
|
||||
var invitePage = 1;
|
||||
try {
|
||||
var requestedPage = parseInt(new URLSearchParams(window.location.search).get('invite_page') || '1', 10);
|
||||
invitePage = isNaN(requestedPage) ? 1 : Math.max(1, requestedPage);
|
||||
} catch (_) {}
|
||||
api('/invite/list?per_page=10&page=' + invitePage).then(function (result) {
|
||||
if (!result.ok) {
|
||||
listEl.classList.remove('is-loading');
|
||||
listEl.innerHTML = '<p class="uc-reward-empty">邀请记录加载失败,请稍后重试。</p>';
|
||||
return;
|
||||
}
|
||||
renderList(result.json || {}, invitePage);
|
||||
}).catch(function () {
|
||||
listEl.classList.remove('is-loading');
|
||||
listEl.innerHTML = '<p class="uc-reward-empty">邀请记录加载失败,请稍后重试。</p>';
|
||||
});
|
||||
}
|
||||
|
||||
if (copyBtn && linkInput) {
|
||||
copyBtn.addEventListener('click', function () {
|
||||
if (!linkInput.value) return;
|
||||
var done = function () {
|
||||
if (feedbackEl) feedbackEl.textContent = '推广链接已复制';
|
||||
copyBtn.disabled = false;
|
||||
};
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(linkInput.value).then(done).catch(function () { linkInput.select(); document.execCommand('copy'); done(); });
|
||||
} else {
|
||||
linkInput.select();
|
||||
document.execCommand('copy');
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
var withdrawModal = document.querySelector('[data-aksrt-commission-withdraw-modal]');
|
||||
var withdrawForm = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-form]');
|
||||
var withdrawTip = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-tip]');
|
||||
var withdrawSubmit = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-submit]');
|
||||
var lastWithdrawTrigger = null;
|
||||
var withdrawBusy = false;
|
||||
function setWithdrawTip(text, error) {
|
||||
if (!withdrawTip) return;
|
||||
withdrawTip.textContent = text || '';
|
||||
withdrawTip.classList.toggle('is-error', !!error);
|
||||
}
|
||||
function setWithdrawBusy(isBusy) {
|
||||
withdrawBusy = isBusy;
|
||||
if (withdrawSubmit) withdrawSubmit.disabled = isBusy;
|
||||
}
|
||||
function getWithdrawFocusable() {
|
||||
return Array.prototype.slice.call(withdrawModal.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));
|
||||
}
|
||||
function closeWithdrawModal() {
|
||||
if (!withdrawModal || withdrawModal.hidden) return;
|
||||
withdrawModal.hidden = true;
|
||||
document.body.classList.remove('uc-modal-open');
|
||||
if (lastWithdrawTrigger && typeof lastWithdrawTrigger.focus === 'function') {
|
||||
lastWithdrawTrigger.focus();
|
||||
}
|
||||
}
|
||||
if (withdrawModal && withdrawForm) {
|
||||
document.querySelectorAll('[data-aksrt-commission-withdraw-open]').forEach(function (button) {
|
||||
button.addEventListener('click', function () {
|
||||
lastWithdrawTrigger = button;
|
||||
withdrawModal.hidden = false;
|
||||
document.body.classList.add('uc-modal-open');
|
||||
window.requestAnimationFrame(function () {
|
||||
var amountInput = withdrawForm.querySelector('[data-aksrt-commission-withdraw-amount]');
|
||||
if (amountInput) amountInput.focus();
|
||||
});
|
||||
});
|
||||
});
|
||||
withdrawModal.querySelectorAll('[data-aksrt-commission-withdraw-close]').forEach(function (button) {
|
||||
button.addEventListener('click', closeWithdrawModal);
|
||||
});
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (withdrawModal.hidden) return;
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
closeWithdrawModal();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Tab') return;
|
||||
var focusable = getWithdrawFocusable();
|
||||
if (!focusable.length) return;
|
||||
var first = focusable[0];
|
||||
var last = focusable[focusable.length - 1];
|
||||
if (event.shiftKey && document.activeElement === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
} else if (!event.shiftKey && document.activeElement === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
});
|
||||
withdrawForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
if (withdrawBusy) return;
|
||||
var values = new FormData(withdrawForm);
|
||||
var amount = Number(values.get('amount') || 0);
|
||||
var minimum = Number(root.getAttribute('data-min-amount') || 50);
|
||||
var account = String(values.get('account_info') || '').trim();
|
||||
if (amount < minimum) { setWithdrawTip('提现金额未达到最低额度', true); return; }
|
||||
if (!account) { setWithdrawTip('请填写收款账户信息', true); return; }
|
||||
setWithdrawTip('正在提交...', false);
|
||||
setWithdrawBusy(true);
|
||||
fetch(rest + '/pay/balance/withdraw', { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': data.restNonce || data.nonce || '' }, body: JSON.stringify({ amount: amount, method: values.get('method') || 'alipay', account_info: account }) }).then(function (response) {
|
||||
return response.json().catch(function () { return {}; }).then(function (json) { return { ok: response.ok, json: json }; });
|
||||
}).then(function (result) {
|
||||
if (!result.ok || !result.json || !result.json.success) { setWithdrawBusy(false); setWithdrawTip((result.json && result.json.message) || '提现申请失败', true); return; }
|
||||
setWithdrawTip('提现申请已提交', false);
|
||||
window.setTimeout(function () { window.location.reload(); }, 700);
|
||||
}).catch(function () { setWithdrawBusy(false); setWithdrawTip('网络错误,请稍后重试', true); });
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user