feat(users): merge promotion into revenue center
This commit is contained in:
@@ -4,7 +4,7 @@ export const featuresSchema = {
|
||||
icon: 'fas fa-user-cog',
|
||||
description: '配置用户中心和个人主页的功能模块。',
|
||||
defaults: {
|
||||
user_center_tabs: 'profile,level,posts,comments,favorites,vip,credits,promotion,auth',
|
||||
user_center_tabs: 'profile,level,posts,comments,favorites,vip,credits,revenue,auth',
|
||||
user_cover_upload: true,
|
||||
user_social_links: true,
|
||||
user_desc_std: '这家伙很懒…',
|
||||
@@ -24,7 +24,7 @@ export const featuresSchema = {
|
||||
title: '用户中心',
|
||||
icon: 'fas fa-user-shield',
|
||||
fields: [
|
||||
{ key: 'user_center_tabs', label: '用户中心 Tab', type: 'input', default: 'profile,level,posts,comments,favorites,vip,credits,promotion,auth', help: '逗号分隔。level=我的等级;promotion=推广中心;auth=官方认证;等级、VIP、订单、推广中心和认证会按功能开关自动注入' },
|
||||
{ key: 'user_center_tabs', label: '用户中心 Tab', type: 'input', default: 'profile,level,posts,comments,favorites,vip,credits,revenue,auth', help: '逗号分隔。level=我的等级;revenue=收益中心;auth=官方认证;等级、VIP、订单、收益中心和认证会按功能开关自动注入' },
|
||||
{ key: 'user_cover_upload', label: '封面上传', type: 'switch', default: true },
|
||||
{ key: 'user_social_links', label: '社交链接', type: 'switch', default: true },
|
||||
{ key: 'user_desc_std', label: '默认签名', type: 'input', default: '这家伙很懒…', help: '用户未设置个人简介时显示的默认文案' },
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
@import url("user-center/credits.css");
|
||||
@import url("user-center/level.css");
|
||||
@import url("user-center/settings.css");
|
||||
@import url("revenue.css");
|
||||
@import url("user-center/revenue.css");
|
||||
@import url("user-center/responsive.css");
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/* User-center revenue and invitation additions. */
|
||||
.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); }
|
||||
.uc-content .uc-promotion-panel { display: grid; gap: 16px; margin-top: 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-promotion-panel__header { display: flex; align-items: center; gap: 12px; }
|
||||
.uc-content .uc-promotion-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; color: #fff; background: var(--color-primary); }
|
||||
.uc-content .uc-promotion-panel__eyebrow { margin: 0 0 2px; color: var(--color-primary); font-size: 12px; font-weight: 700; }
|
||||
.uc-content .uc-promotion-panel__header h3 { margin: 0; font-size: 18px; }
|
||||
.uc-content .uc-promotion-panel__intro,
|
||||
.uc-content .uc-promotion-section__header p { margin: 0; color: var(--color-ink-4); font-size: 13px; line-height: 1.65; }
|
||||
.uc-content .uc-promotion-panel__status { margin: 0; padding: 10px 12px; border-radius: 8px; color: var(--color-ink-3); background: var(--surface-2); font-size: 13px; }
|
||||
.uc-content .uc-promotion-panel__status.is-error,
|
||||
.uc-content .uc-promotion-copy-feedback.is-error { color: var(--color-error, #dc2626); }
|
||||
.uc-content .uc-promotion-section { padding-top: 4px; }
|
||||
.uc-content .uc-promotion-section h4 { margin: 0 0 4px; font-size: 15px; }
|
||||
.uc-content .uc-promotion-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); border-radius: 10px; overflow: hidden; }
|
||||
.uc-content .uc-promotion-stat { display: grid; gap: 4px; padding: 14px; border-right: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); }
|
||||
.uc-content .uc-promotion-stat:last-child { border-right: 0; }
|
||||
.uc-content .uc-promotion-stat span,
|
||||
.uc-content .uc-promotion-stat small { color: var(--color-ink-4); font-size: 12px; }
|
||||
.uc-content .uc-promotion-stat strong { color: var(--color-primary); font-size: 26px; font-variant-numeric: tabular-nums; }
|
||||
.uc-content .uc-promotion-share { display: grid; gap: 10px; margin-top: 12px; }
|
||||
.uc-content .uc-promotion-code { display: flex; align-items: baseline; gap: 10px; color: var(--color-ink-4); font-size: 13px; }
|
||||
.uc-content .uc-promotion-code strong { color: var(--color-ink); font-size: 19px; letter-spacing: .08em; }
|
||||
.uc-content .uc-promotion-link-row { display: flex; gap: 10px; }
|
||||
.uc-content .uc-promotion-link { flex: 1; min-width: 0; height: 42px; padding: 0 11px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.1)); border-radius: 8px; background: var(--surface-2); }
|
||||
.uc-content .uc-promotion-copy { min-width: 108px; }
|
||||
.uc-content .uc-promotion-copy-feedback { min-height: 18px; margin: 0; color: var(--color-ink-4); font-size: 12px; }
|
||||
.uc-content .uc-promotion-records__header { display: flex; justify-content: space-between; gap: 12px; }
|
||||
.uc-content .uc-promotion-record-list { display: grid; margin-top: 12px; }
|
||||
.uc-content .uc-promotion-record { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); }
|
||||
.uc-content .uc-promotion-record__avatar { display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; overflow: hidden; border-radius: 50%; background: var(--surface-2); }
|
||||
.uc-content .uc-promotion-record__avatar img { width: 100%; height: 100%; object-fit: cover; }
|
||||
.uc-content .uc-promotion-record__main { display: grid; flex: 1; min-width: 0; gap: 3px; }
|
||||
.uc-content .uc-promotion-record__main span,
|
||||
.uc-content .uc-promotion-record__status small { color: var(--color-ink-4); font-size: 12px; }
|
||||
.uc-content .uc-promotion-record__status { display: grid; justify-items: end; gap: 4px; }
|
||||
.uc-content .uc-promotion-badge { padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
|
||||
.uc-content .uc-promotion-badge.is-registered { color: #2563eb; background: rgba(37,99,235,.1); }
|
||||
.uc-content .uc-promotion-badge.is-verified { color: #7c3aed; background: rgba(124,58,237,.1); }
|
||||
.uc-content .uc-promotion-badge.is-rewarded { color: #16a34a; background: rgba(22,163,74,.1); }
|
||||
.uc-content .uc-promotion-record-empty { padding: 22px; border-top: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); color: var(--color-ink-4); font-size: 13px; text-align: center; }
|
||||
@media (max-width: 640px) { .uc-content .aksrt-revenue-page__layout { grid-template-columns: 1fr; } .uc-content .uc-promotion-stats { grid-template-columns: 1fr; } .uc-content .uc-promotion-stat { border-right: 0; border-bottom: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); } .uc-content .uc-promotion-stat:last-child { border-bottom: 0; } .uc-content .uc-promotion-link-row { flex-direction: column; } .uc-content .uc-promotion-copy { width: 100%; } }
|
||||
@@ -546,7 +546,7 @@ body.aksrt-user-center .uc-content,
|
||||
.uc-center-card small { margin-top: 3px; color: var(--color-ink-4); font-size: 10px; }
|
||||
.uc-center-card > i { color: var(--color-ink-4); font-size: 11px; }
|
||||
.uc-center-card--creation .uc-center-card__icon { color: #6650c7; background: rgba(124, 92, 220, 0.12); }
|
||||
.uc-center-card--promotion .uc-center-card__icon { color: #ce6b35; background: rgba(234, 112, 55, 0.12); }
|
||||
.uc-center-card--revenue .uc-center-card__icon { color: #ce6b35; background: rgba(234, 112, 55, 0.12); }
|
||||
|
||||
.uc-service-grid {
|
||||
display: grid;
|
||||
|
||||
+103
-101
@@ -1,114 +1,116 @@
|
||||
/**
|
||||
* Creator revenue / withdraw form.
|
||||
* AKSRT Revenue Center Frontend
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var page = document.querySelector("[data-aksrt-revenue-page]");
|
||||
if (!page || !window.aksrtData) return;
|
||||
var page = document.querySelector('[data-aksrt-revenue-page]');
|
||||
var data = window.aksrtData || {};
|
||||
if (!page || !data) return;
|
||||
|
||||
function restBase() {
|
||||
return ((aksrtData.siteUrl || "").replace(/\/$/, "")) + "/wp-json/aksrt/v1";
|
||||
}
|
||||
var rest = data.restUrl || data.apiUrl || ((data.siteUrl || '').replace(/\/$/, '') + '/wp-json/aksrt/v1');
|
||||
if (!rest) return;
|
||||
if (window.location.protocol === 'https:' && rest.substring(0, 5) === 'http:') {
|
||||
rest = 'https:' + rest.substring(5);
|
||||
}
|
||||
rest = rest.replace(/\/?$/, '');
|
||||
|
||||
function rest(path, method, body) {
|
||||
var opts = {
|
||||
method: method || "GET",
|
||||
credentials: "same-origin",
|
||||
headers: { "X-WP-Nonce": aksrtData.restNonce || "" },
|
||||
};
|
||||
if (body !== undefined) {
|
||||
opts.headers["Content-Type"] = "application/json";
|
||||
opts.body = JSON.stringify(body);
|
||||
}
|
||||
return fetch(restBase() + path, opts).then(function (r) {
|
||||
return r.json();
|
||||
});
|
||||
}
|
||||
var form = page.querySelector('[data-aksrt-withdraw-form]');
|
||||
var message = page.querySelector('[data-aksrt-withdraw-msg]');
|
||||
var balance = page.querySelector('[data-aksrt-revenue-balance]');
|
||||
var list = page.querySelector('[data-aksrt-withdraw-list]');
|
||||
if (!form) return;
|
||||
|
||||
var form = page.querySelector("[data-aksrt-withdraw-form]");
|
||||
var msg = page.querySelector("[data-aksrt-withdraw-msg]");
|
||||
var balanceEl = page.querySelector("[data-aksrt-revenue-balance]");
|
||||
var list = page.querySelector("[data-aksrt-withdraw-list]");
|
||||
function setMessage(text, error) {
|
||||
if (!message) return;
|
||||
message.hidden = false;
|
||||
message.textContent = text;
|
||||
message.classList.toggle('is-error', !!error);
|
||||
}
|
||||
|
||||
if (!form) return;
|
||||
function request(payload) {
|
||||
return 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(payload)
|
||||
}).then(function (response) {
|
||||
return response.json().catch(function () {
|
||||
return { message: '服务器返回了非 JSON 响应' };
|
||||
}).then(function (json) {
|
||||
return { ok: response.ok, json: json };
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
form.addEventListener("submit", function (e) {
|
||||
e.preventDefault();
|
||||
var fd = new FormData(form);
|
||||
var amount = Number(fd.get("amount") || 0);
|
||||
var method = String(fd.get("method") || "alipay");
|
||||
var account = String(fd.get("account_info") || "").trim();
|
||||
var min = Number(page.getAttribute("data-min-amount") || 50);
|
||||
if (amount < min) {
|
||||
if (msg) {
|
||||
msg.hidden = false;
|
||||
msg.textContent = "最低提现金额为 " + min;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!account) {
|
||||
if (msg) {
|
||||
msg.hidden = false;
|
||||
msg.textContent = "请填写收款账户信息";
|
||||
}
|
||||
return;
|
||||
}
|
||||
form.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
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 minimum = Number(page.getAttribute('data-min-amount') || 50);
|
||||
if (amount < minimum) {
|
||||
setMessage('最低提现金额为 ' + minimum, true);
|
||||
return;
|
||||
}
|
||||
if (!account) {
|
||||
setMessage('请填写收款账户信息', true);
|
||||
return;
|
||||
}
|
||||
|
||||
var btn = form.querySelector('button[type="submit"]');
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = "提交中...";
|
||||
}
|
||||
|
||||
rest("/shop/frontend/revenue/withdraw", "POST", {
|
||||
amount: amount,
|
||||
method: method,
|
||||
account_info: account,
|
||||
})
|
||||
.then(function (result) {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = "提交提现申请";
|
||||
}
|
||||
if (!result || !result.success) {
|
||||
if (msg) {
|
||||
msg.hidden = false;
|
||||
msg.textContent = (result && result.message) || "提现失败";
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (msg) {
|
||||
msg.hidden = false;
|
||||
msg.textContent = result.message || "提现申请已提交";
|
||||
}
|
||||
if (balanceEl && result.data && typeof result.data.balance !== "undefined") {
|
||||
balanceEl.textContent = "¥" + Number(result.data.balance).toFixed(2);
|
||||
}
|
||||
if (list && result.data) {
|
||||
var item = document.createElement("div");
|
||||
item.className = "aksrt-revenue-page__item";
|
||||
item.innerHTML =
|
||||
"<div><strong>¥" +
|
||||
Number(result.data.amount || amount).toFixed(2) +
|
||||
"</strong><span>" +
|
||||
method +
|
||||
"</span></div><div><span>pending</span><time>just now</time></div>";
|
||||
list.insertBefore(item, list.firstChild);
|
||||
}
|
||||
form.reset();
|
||||
})
|
||||
.catch(function () {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.textContent = "提交提现申请";
|
||||
}
|
||||
if (msg) {
|
||||
msg.hidden = false;
|
||||
msg.textContent = "网络错误";
|
||||
}
|
||||
});
|
||||
});
|
||||
var button = form.querySelector('button[type="submit"]');
|
||||
if (button) {
|
||||
button.disabled = true;
|
||||
button.textContent = '提交中…';
|
||||
}
|
||||
request({ amount: amount, method: method, account_info: account }).then(function (result) {
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.textContent = '提交提现申请';
|
||||
}
|
||||
if (!result.ok || !result.json || !result.json.success) {
|
||||
setMessage((result.json && result.json.message) || '提现失败,请稍后重试。', true);
|
||||
return;
|
||||
}
|
||||
var response = result.json.data || {};
|
||||
setMessage(response.message || '提现申请已提交。', false);
|
||||
if (balance && typeof response.wallet_balance !== 'undefined') {
|
||||
balance.textContent = '¥' + Number(response.wallet_balance).toFixed(2);
|
||||
}
|
||||
if (list) {
|
||||
var item = document.createElement('div');
|
||||
item.className = 'aksrt-revenue-page__item';
|
||||
var main = document.createElement('div');
|
||||
var amountEl = document.createElement('strong');
|
||||
amountEl.textContent = '¥' + Number(response.amount || amount).toFixed(2);
|
||||
var methodEl = document.createElement('span');
|
||||
methodEl.textContent = method;
|
||||
main.appendChild(amountEl);
|
||||
main.appendChild(methodEl);
|
||||
var state = document.createElement('div');
|
||||
var pending = document.createElement('span');
|
||||
pending.textContent = 'pending';
|
||||
var time = document.createElement('time');
|
||||
time.textContent = 'just now';
|
||||
state.appendChild(pending);
|
||||
state.appendChild(time);
|
||||
item.appendChild(main);
|
||||
item.appendChild(state);
|
||||
list.insertBefore(item, list.firstChild);
|
||||
}
|
||||
form.reset();
|
||||
}).catch(function () {
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.textContent = '提交提现申请';
|
||||
}
|
||||
setMessage('网络错误,请稍后重试。', true);
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user