@etspress/netflix 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/plugin.json +1 -1
- package/public/console.css +55 -0
- package/public/console.js +233 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etspress/netflix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "流媒体合租主题插件",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"id": "netflix",
|
|
19
19
|
"name": "流媒体合租主题",
|
|
20
20
|
"description": "流媒体合租商店主题与页面展示配置",
|
|
21
|
-
"version": "0.1.
|
|
21
|
+
"version": "0.1.6",
|
|
22
22
|
"runtime": {
|
|
23
23
|
"type": "npm-static",
|
|
24
24
|
"publicRoot": "public"
|
package/plugin.json
CHANGED
package/public/console.css
CHANGED
|
@@ -111,6 +111,61 @@
|
|
|
111
111
|
#netflix-theme-home.nfc-console .nfc-to-top{position:fixed;right:20px;bottom:80px;display:flex;width:40px;height:40px;align-items:center;justify-content:center;color:#ef5350;background:#fff;border:1px solid #ef5350;border-radius:5px;font-size:23px;cursor:pointer}
|
|
112
112
|
#netflix-theme-home.nfc-console .nfc-language{padding:6px 10px;color:#fff;background:transparent;border:1px solid #596273;border-radius:5px;font:inherit;font-size:12px}
|
|
113
113
|
|
|
114
|
+
#netflix-theme-home.nfc-console .nfc-account-hero{display:flex;min-height:116px;padding:18px 22px;align-items:center;gap:15px}
|
|
115
|
+
#netflix-theme-home.nfc-console .nfc-account-hero .nfc-avatar{width:58px;height:58px;flex:0 0 58px}
|
|
116
|
+
#netflix-theme-home.nfc-console .nfc-account-hero>div{min-width:0;flex:1}
|
|
117
|
+
#netflix-theme-home.nfc-console .nfc-account-hero h2{margin:0;color:#222;font-size:18px;font-weight:600}
|
|
118
|
+
#netflix-theme-home.nfc-console .nfc-account-hero p{margin:4px 0 0;color:#888;font-size:13px}
|
|
119
|
+
#netflix-theme-home.nfc-console .nfc-account-hero>a{color:#ed4f51;font-size:13px}
|
|
120
|
+
#netflix-theme-home.nfc-console .nfc-account-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
|
|
121
|
+
#netflix-theme-home.nfc-console .nfc-account-tile{display:flex;min-height:90px;padding:18px;justify-content:center;flex-direction:column;gap:7px;color:#333}
|
|
122
|
+
#netflix-theme-home.nfc-console .nfc-account-tile strong{font-size:15px;font-weight:600}
|
|
123
|
+
#netflix-theme-home.nfc-console .nfc-account-tile span{color:#888;font-size:12px}
|
|
124
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance{display:flex;min-height:116px;padding:18px 22px;align-items:center;gap:30px}
|
|
125
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance>div{display:flex;min-width:110px;flex-direction:column;gap:5px}
|
|
126
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance small{color:#999;font-size:12px}
|
|
127
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance strong{color:#ed4f51;font-size:26px;font-weight:600}
|
|
128
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance b{color:#444;font-size:16px;font-weight:500}
|
|
129
|
+
#netflix-theme-home.nfc-console .nfc-primary{display:inline-flex;min-height:38px;padding:8px 23px;align-items:center;justify-content:center;color:#fff;background:#ed4f51;border:0;border-radius:22px;font:inherit;font-size:13px;text-decoration:none;cursor:pointer}
|
|
130
|
+
#netflix-theme-home.nfc-console .nfc-primary:hover{background:#e44648}
|
|
131
|
+
#netflix-theme-home.nfc-console .nfc-profile-form{display:grid;max-width:720px;padding:22px;gap:16px}
|
|
132
|
+
#netflix-theme-home.nfc-console .nfc-profile-form>label,.nfc-console .nfc-auth-field{display:grid;gap:7px;color:#444;font-size:13px;font-weight:500}
|
|
133
|
+
#netflix-theme-home.nfc-console .nfc-profile-form input,#netflix-theme-home.nfc-console .nfc-profile-form select,.nfc-console .nfc-auth-field input{width:100%;min-height:42px;padding:9px 12px;color:#333;background:#fff;border:1px solid #dedede;border-radius:6px;font:inherit;font-size:14px;outline:none}
|
|
134
|
+
#netflix-theme-home.nfc-console .nfc-profile-form input:focus,#netflix-theme-home.nfc-console .nfc-profile-form select:focus,.nfc-console .nfc-auth-field input:focus{border-color:#ed7776;box-shadow:0 0 0 3px #ed4f5117}
|
|
135
|
+
#netflix-theme-home.nfc-console .nfc-profile-form input[readonly]{color:#999;background:#f8f8f8}
|
|
136
|
+
#netflix-theme-home.nfc-console .nfc-profile-form .nfc-primary{justify-self:start}
|
|
137
|
+
#netflix-theme-home.nfc-console .nfc-form-message{min-height:18px;color:#d74747;font-size:12px}
|
|
138
|
+
#netflix-theme-home.nfc-auth{min-height:100vh;background:#f7f7f8}
|
|
139
|
+
#netflix-theme-home.nfc-auth .nfh-header{position:relative}
|
|
140
|
+
#netflix-theme-home.nfc-auth .nfc-auth-main{display:flex;min-height:calc(100vh - 138px);padding:36px 18px;align-items:flex-start;justify-content:center}
|
|
141
|
+
#netflix-theme-home.nfc-auth .nfc-auth-card{width:440px;max-width:100%;padding:24px 30px 28px;background:#fff;border-radius:10px;box-shadow:0 3px 18px rgba(25,30,40,.09)}
|
|
142
|
+
#netflix-theme-home.nfc-auth .nfc-auth-back{display:inline-block;margin-bottom:20px;color:#777;font-size:13px}
|
|
143
|
+
#netflix-theme-home.nfc-auth .nfc-auth-card h1{margin:0;color:#222;font-size:24px;font-weight:650;text-align:center}
|
|
144
|
+
#netflix-theme-home.nfc-auth .nfc-auth-subtitle{margin:7px 0 22px;color:#888;font-size:13px;text-align:center}
|
|
145
|
+
#netflix-theme-home.nfc-auth .nfc-auth-form{display:grid;gap:15px}
|
|
146
|
+
#netflix-theme-home.nfc-auth .nfc-auth-field{gap:6px}
|
|
147
|
+
#netflix-theme-home.nfc-auth .nfc-captcha-row{display:flex;gap:8px}
|
|
148
|
+
#netflix-theme-home.nfc-auth .nfc-captcha-row>input{min-width:0;flex:1}
|
|
149
|
+
#netflix-theme-home.nfc-auth .nfc-captcha-row>button{display:flex;min-width:100px;min-height:42px;padding:4px 10px;align-items:center;justify-content:center;color:#555;background:#fafafa;border:1px solid #dedede;border-radius:6px;font:inherit;font-size:12px;cursor:pointer}
|
|
150
|
+
#netflix-theme-home.nfc-auth .nfc-captcha-row>button img{display:block;max-width:100px;height:34px;object-fit:contain}
|
|
151
|
+
#netflix-theme-home.nfc-auth .nfc-auth-agreement{display:flex;align-items:flex-start;gap:7px;color:#777;font-size:12px}
|
|
152
|
+
#netflix-theme-home.nfc-auth .nfc-auth-agreement input{margin-top:3px;accent-color:#ed4f51}
|
|
153
|
+
#netflix-theme-home.nfc-auth .nfc-auth-agreement a,#netflix-theme-home.nfc-auth .nfc-auth-switch a{color:#ed4f51}
|
|
154
|
+
#netflix-theme-home.nfc-auth .nfc-auth-submit{width:100%;min-height:44px;margin-top:1px}
|
|
155
|
+
#netflix-theme-home.nfc-auth .nfc-auth-switch{margin-top:18px;color:#888;font-size:13px;text-align:center}
|
|
156
|
+
#netflix-theme-home.nfc-auth .nfc-auth-hint{margin:0;color:#a66a27;font-size:12px}
|
|
157
|
+
#netflix-theme-home.nfc-auth .nfc-auth-footer{padding:14px;color:#999;font-size:11px;text-align:center}
|
|
158
|
+
|
|
159
|
+
@media(max-width:720px){
|
|
160
|
+
#netflix-theme-home.nfc-console .nfc-account-hero{padding:14px;gap:10px}
|
|
161
|
+
#netflix-theme-home.nfc-console .nfc-account-hero>a{font-size:12px;white-space:nowrap}
|
|
162
|
+
#netflix-theme-home.nfc-console .nfc-account-grid{grid-template-columns:1fr}
|
|
163
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance{align-items:flex-start;flex-wrap:wrap;gap:16px}
|
|
164
|
+
#netflix-theme-home.nfc-console .nfc-wallet-balance>div{min-width:calc(50% - 10px)}
|
|
165
|
+
#netflix-theme-home.nfc-auth .nfc-auth-main{min-height:calc(100vh - 126px);padding:22px 12px}
|
|
166
|
+
#netflix-theme-home.nfc-auth .nfc-auth-card{padding:20px 18px 24px;border-radius:9px}
|
|
167
|
+
}
|
|
168
|
+
|
|
114
169
|
@media(max-width:1050px){
|
|
115
170
|
#netflix-theme-home.nfc-console .nfc-promo-top{grid-template-columns:1fr 1fr}
|
|
116
171
|
#netflix-theme-home.nfc-console .nfc-summary-panel{grid-column:1/-1}
|
package/public/console.js
CHANGED
|
@@ -21,6 +21,21 @@
|
|
|
21
21
|
var currentOrders = [];
|
|
22
22
|
var affiliateInfo = {};
|
|
23
23
|
var errorText = '';
|
|
24
|
+
var accountProfile = {};
|
|
25
|
+
var walletAccount = {};
|
|
26
|
+
var walletTransactions = [];
|
|
27
|
+
var walletPage = 1;
|
|
28
|
+
var walletPageSize = 10;
|
|
29
|
+
var authConfig = {};
|
|
30
|
+
var captchaData = {};
|
|
31
|
+
var captchaImage = '';
|
|
32
|
+
var authChallengeToken = '';
|
|
33
|
+
var authInviteTicket = '';
|
|
34
|
+
|
|
35
|
+
function isThemeRoute(path) {
|
|
36
|
+
path = path || location.pathname;
|
|
37
|
+
return ['/me/orders', '/me/affiliate', '/me/wallet', '/me', '/me/profile', '/auth/login', '/auth/register'].indexOf(path) >= 0 && !(['/me/affiliate', '/auth/login', '/auth/register'].indexOf(path) >= 0 && new URLSearchParams(location.search).get('native') === '1');
|
|
38
|
+
}
|
|
24
39
|
|
|
25
40
|
var statusLabels = {
|
|
26
41
|
pending_payment: '待支付', paid: '已支付', processing: '处理中', delivered: '已交付',
|
|
@@ -78,7 +93,7 @@
|
|
|
78
93
|
mobileNavItem('/', config.navHomeLabel || '首页', 'M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z', false) +
|
|
79
94
|
mobileNavItem('/me/orders', config.navProductsLabel || '车票', 'M5.35 5.64c-.9-.64-1.12-1.88-.49-2.79.63-.9 1.88-1.12 2.79-.49.9.64 1.12 1.88.49 2.79-.64.9-1.88 1.12-2.79.49M16 20c0-.55-.45-1-1-1H8.93c-1.48 0-2.74-1.08-2.96-2.54L4.16 7.78A.976.976 0 0 0 3.2 7c-.62 0-1.08.57-.96 1.18l1.75 8.58A5.01 5.01 0 0 0 8.94 21H15c.55 0 1-.45 1-1m-.46-5h-4.19l-1.03-4.1c1.28.72 2.63 1.28 4.1 1.3.58.01 1.05-.49 1.05-1.07 0-.59-.49-1.04-1.08-1.06-1.31-.04-2.63-.56-3.61-1.33L9.14 7.47c-.23-.18-.49-.3-.76-.38a2.2 2.2 0 0 0-.99-.06h-.02a2.27 2.27 0 0 0-1.84 2.61l1.35 5.92A3.01 3.01 0 0 0 9.83 18h6.85l3.09 2.42c.42.33 1.02.29 1.39-.08.45-.45.4-1.18-.1-1.57l-4.29-3.35a2 2 0 0 0-1.23-.42', page === 'ticket') +
|
|
80
95
|
mobileNavItem('/me/affiliate', config.navPromotionLabel || '推广', 'm13.576 17.271-5.11-2.787a3.5 3.5 0 1 1 0-4.968l5.11-2.787a3.5 3.5 0 1 1 .958 1.755l-5.11 2.787a3.5 3.5 0 0 1 0 1.457l5.11 2.788a3.5 3.5 0 1 1-.958 1.755', page === 'promotion') +
|
|
81
|
-
mobileNavItem('/me', '我的', 'M12 17c3.662 0 6.865 1.575 8.607 3.925l-1.842.871C17.347 20.116 14.847 19 12 19c-2.848 0-5.347 1.116-6.765 2.796l-1.841-.872C5.136 18.574 8.338 17 12 17m0-15a5 5 0 0 1 5 5v3a5 5 0 0 1-4.783 4.995L12 15a5 5 0 0 1-5-5V7a5 5 0 0 1 4.783-4.995zm0 2a3 3 0 0 0-2.995 2.824L9 7v3a3 3 0 0 0 5.995.176L15 10V7a3 3 0 0 0-3-3',
|
|
96
|
+
mobileNavItem('/me', '我的', 'M12 17c3.662 0 6.865 1.575 8.607 3.925l-1.842.871C17.347 20.116 14.847 19 12 19c-2.848 0-5.347 1.116-6.765 2.796l-1.841-.872C5.136 18.574 8.338 17 12 17m0-15a5 5 0 0 1 5 5v3a5 5 0 0 1-4.783 4.995L12 15a5 5 0 0 1-5-5V7a5 5 0 0 1 4.783-4.995zm0 2a3 3 0 0 0-2.995 2.824L9 7v3a3 3 0 0 0 5.995.176L15 10V7a3 3 0 0 0-3-3', page === 'account' || page === 'profile' || page === 'wallet') + '</nav>';
|
|
82
97
|
}
|
|
83
98
|
|
|
84
99
|
function promoIconMarkup() {
|
|
@@ -105,7 +120,7 @@
|
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
function clearPage() {
|
|
108
|
-
if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function' &&
|
|
123
|
+
if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function' && !isThemeRoute()) window.__DUJIAO_RELEASE_CONSOLE_GATE__();
|
|
109
124
|
if (root) root.remove();
|
|
110
125
|
if (host && host.isConnected) {
|
|
111
126
|
host.style.display = hostDisplay;
|
|
@@ -203,7 +218,7 @@
|
|
|
203
218
|
}).join('<span class="nfh-license-separator">|</span>');
|
|
204
219
|
var sidebarLinks = [
|
|
205
220
|
['/me/orders', '我的车票', activeTicket], ['/me/affiliate', '我的推广', activePromotion],
|
|
206
|
-
['/me/wallet', '我的钱包', ''], ['/me', '个人中心', '']
|
|
221
|
+
['/me/wallet', '我的钱包', page === 'wallet' ? ' is-active' : ''], ['/me', '个人中心', page === 'account' || page === 'profile' ? ' is-active' : '']
|
|
207
222
|
].map(function (item) {
|
|
208
223
|
var icon = item[1] === '我的车票' ? '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7h18v3a2 2 0 0 0 0 4v3H3v-3a2 2 0 0 0 0-4zM9 7v10"/></svg>'
|
|
209
224
|
: item[1] === '我的推广' ? '<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="18" cy="5" r="2.5"/><circle cx="6" cy="12" r="2.5"/><circle cx="18" cy="19" r="2.5"/><path d="m8.2 10.7 7.6-4.4M8.2 13.3l7.6 4.4"/></svg>'
|
|
@@ -410,7 +425,213 @@
|
|
|
410
425
|
clearTimeout(toast.timer); toast.timer = setTimeout(function () { toast.classList.remove('is-visible'); }, 1800);
|
|
411
426
|
}
|
|
412
427
|
|
|
413
|
-
function renderCurrent() {
|
|
428
|
+
function renderCurrent() {
|
|
429
|
+
if (location.pathname === '/me/orders') renderTickets();
|
|
430
|
+
else if (location.pathname === '/me/affiliate') renderPromotion();
|
|
431
|
+
else if (location.pathname === '/me/wallet') renderWallet();
|
|
432
|
+
else if (location.pathname === '/me/profile') renderProfile();
|
|
433
|
+
else if (location.pathname === '/me') renderAccount();
|
|
434
|
+
else if (location.pathname === '/auth/login') renderAuth('login');
|
|
435
|
+
else if (location.pathname === '/auth/register') renderAuth('register');
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function apiRequest(path, options) {
|
|
439
|
+
var settings = options || {};
|
|
440
|
+
var headers = apiHeaders();
|
|
441
|
+
if (settings.body !== undefined) headers['Content-Type'] = 'application/json';
|
|
442
|
+
return fetch('/api/v1' + path, Object.assign({ method: settings.method || 'GET', headers: headers, credentials: 'include', cache: 'no-store' }, settings, { headers: headers })).then(function (response) {
|
|
443
|
+
return response.json().catch(function () { return {}; }).then(function (body) {
|
|
444
|
+
if ((response.status === 401 || body.status_code === 401) && path.indexOf('/public/') !== 0) {
|
|
445
|
+
localStorage.removeItem('user_token'); localStorage.removeItem('user_profile');
|
|
446
|
+
location.replace('/auth/login?redirect=' + encodeURIComponent(location.pathname + location.search));
|
|
447
|
+
}
|
|
448
|
+
if (!response.ok || (body.status_code != null && body.status_code !== 0)) throw new Error(body.msg || body.message || '请求失败');
|
|
449
|
+
return body;
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function responseData(body) { return body && body.data && body.data.data != null ? body.data.data : body && body.data != null ? body.data : body || {}; }
|
|
455
|
+
|
|
456
|
+
function requireAccount() {
|
|
457
|
+
if (localStorage.getItem('user_token')) return true;
|
|
458
|
+
location.replace('/auth/login?redirect=' + encodeURIComponent(location.pathname + location.search));
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function renderAccount() {
|
|
463
|
+
var p = accountProfile || {};
|
|
464
|
+
var avatar = safeHref(p.avatar_url || p.avatar || '', '');
|
|
465
|
+
var avatarMarkup = avatar ? '<img src="' + escapeHtml(avatar) + '" alt="">' : escapeHtml(String(p.nickname || p.email || 'U').charAt(0).toUpperCase());
|
|
466
|
+
var content = '<div class="nfc-section-title"><h1>个人中心</h1><a class="nfc-refresh" href="/me/profile">编辑资料</a></div>' +
|
|
467
|
+
'<section class="nfc-panel nfc-account-hero"><span class="nfc-avatar">' + avatarMarkup + '</span><div><h2>' + escapeHtml(p.nickname || p.email || '用户') + '</h2><p>' + escapeHtml(p.email || '账号信息') + '</p></div><a href="/me/profile">账户设置 ›</a></section>' +
|
|
468
|
+
'<section class="nfc-account-grid"><a class="nfc-panel nfc-account-tile" href="/me/orders"><strong>我的车票</strong><span>查看订单与车票状态 ›</span></a><a class="nfc-panel nfc-account-tile" href="/me/affiliate"><strong>我的推广</strong><span>推广链接与返佣记录 ›</span></a><a class="nfc-panel nfc-account-tile" href="/me/wallet"><strong>我的钱包</strong><span>余额 ' + escapeHtml(formatMoney(walletAccount.balance_amount || walletAccount.balance || 0, walletAccount.currency)) + ' ›</span></a><a class="nfc-panel nfc-account-tile" href="/me/profile"><strong>个人资料</strong><span>昵称与账号安全 ›</span></a></section>';
|
|
469
|
+
pageReady('account', content);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function renderProfile() {
|
|
473
|
+
var p = accountProfile || {};
|
|
474
|
+
var content = (errorText ? '<div class="nfc-error">' + escapeHtml(errorText) + '</div>' : '') + '<div class="nfc-section-title"><h1>个人资料</h1><a class="nfc-refresh" href="/me">返回个人中心</a></div>' +
|
|
475
|
+
'<form class="nfc-panel nfc-profile-form" data-profile-form><label>邮箱<input readonly value="' + escapeHtml(p.email || '') + '"></label><label>昵称<input name="nickname" maxlength="40" value="' + escapeHtml(p.nickname || '') + '"></label><label>界面语言<select name="locale"><option value="zh-CN">简体中文</option><option value="zh-TW">繁體中文</option><option value="en-US">English</option></select></label><div class="nfc-form-message" aria-live="polite"></div><button class="nfc-primary" type="submit">保存资料</button></form>';
|
|
476
|
+
pageReady('profile', content);
|
|
477
|
+
root.querySelector('[name="locale"]').value = p.locale || localStorage.getItem('locale') || 'zh-CN';
|
|
478
|
+
root.querySelector('[data-profile-form]').onsubmit = function (event) {
|
|
479
|
+
event.preventDefault();
|
|
480
|
+
var form = event.currentTarget, button = form.querySelector('button'), message = form.querySelector('.nfc-form-message');
|
|
481
|
+
button.disabled = true; button.textContent = '保存中…'; message.textContent = '';
|
|
482
|
+
apiRequest('/me/profile', { method: 'PUT', body: JSON.stringify({ nickname: form.elements.nickname.value.trim(), locale: form.elements.locale.value }) }).then(function (body) {
|
|
483
|
+
accountProfile = responseData(body); localStorage.setItem('user_profile', JSON.stringify(accountProfile));
|
|
484
|
+
if (localStorage.getItem('locale') !== form.elements.locale.value) { localStorage.setItem('locale', form.elements.locale.value); location.reload(); return; }
|
|
485
|
+
message.style.color = '#42a878'; message.textContent = '资料已保存'; button.disabled = false; button.textContent = '保存资料';
|
|
486
|
+
}).catch(function (error) { message.textContent = error.message; button.disabled = false; button.textContent = '保存资料'; });
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function renderWallet() {
|
|
491
|
+
var account = walletAccount || {};
|
|
492
|
+
var transactions = walletTransactions || [];
|
|
493
|
+
var content = '<div class="nfc-section-title"><h1>我的钱包</h1><button class="nfc-refresh" type="button" data-wallet-refresh>刷新</button></div>' +
|
|
494
|
+
'<section class="nfc-panel nfc-wallet-balance"><div><small>钱包余额</small><strong>' + escapeHtml(formatMoney(account.balance_amount != null ? account.balance_amount : account.balance, account.currency)) + '</strong></div><div><small>累计充值</small><b>' + escapeHtml(formatMoney(account.total_recharged, account.currency)) + '</b></div><div><small>累计消费</small><b>' + escapeHtml(formatMoney(account.total_spent, account.currency)) + '</b></div></section>' +
|
|
495
|
+
'<section class="nfc-panel nfc-details"><div class="nfc-details-heading"><h2>钱包明细</h2></div>' + (transactions.length ? '<div class="nfc-table-scroll"><table><thead><tr><th>类型</th><th>金额</th><th>状态</th><th>时间</th></tr></thead><tbody>' + transactions.map(function (item) { var amount = item.amount != null ? item.amount : item.amount_amount; return '<tr><td>' + escapeHtml(item.description || item.title || item.type || '钱包交易') + '</td><td>' + escapeHtml(formatMoney(amount, item.currency || account.currency)) + '</td><td>' + escapeHtml(statusName(item.status)) + '</td><td>' + escapeHtml(formatDate(item.created_at || item.createdAt)) + '</td></tr>'; }).join('') + '</tbody></table></div>' : '<div class="nfc-table-empty">暂无钱包记录</div>') + '</section>';
|
|
496
|
+
if (errorText) content = '<div class="nfc-error">' + escapeHtml(errorText) + '</div>' + content;
|
|
497
|
+
pageReady('wallet', content);
|
|
498
|
+
root.querySelector('[data-wallet-refresh]').onclick = loadWallet;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function loadAccount() {
|
|
502
|
+
if (!requireAccount()) return;
|
|
503
|
+
var token = ++sequence;
|
|
504
|
+
Promise.allSettled([apiRequest('/me'), apiRequest('/wallet')]).then(function (results) {
|
|
505
|
+
if (token !== sequence || location.pathname !== '/me') return;
|
|
506
|
+
accountProfile = results[0].status === 'fulfilled' ? responseData(results[0].value) : {};
|
|
507
|
+
walletAccount = results[1].status === 'fulfilled' ? responseData(results[1].value) : {};
|
|
508
|
+
errorText = results[0].status === 'rejected' ? results[0].reason.message : '';
|
|
509
|
+
renderAccount();
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function loadProfile() {
|
|
514
|
+
if (!requireAccount()) return;
|
|
515
|
+
var token = ++sequence;
|
|
516
|
+
errorText = '';
|
|
517
|
+
apiRequest('/me').then(function (body) { if (token !== sequence || location.pathname !== '/me/profile') return; accountProfile = responseData(body); renderProfile(); }).catch(function (error) { if (token !== sequence || location.pathname !== '/me/profile') return; errorText = error.message; renderProfile(); });
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function loadWallet() {
|
|
521
|
+
if (!requireAccount()) return;
|
|
522
|
+
var token = ++sequence;
|
|
523
|
+
var page = walletPage;
|
|
524
|
+
Promise.allSettled([apiRequest('/wallet'), apiRequest('/wallet/transactions?page=' + page + '&page_size=' + walletPageSize)]).then(function (results) {
|
|
525
|
+
if (token !== sequence || location.pathname !== '/me/wallet') return;
|
|
526
|
+
walletAccount = results[0].status === 'fulfilled' ? responseData(results[0].value) : {};
|
|
527
|
+
var data = results[1].status === 'fulfilled' ? responseData(results[1].value) : {};
|
|
528
|
+
walletTransactions = Array.isArray(data.data) ? data.data : Array.isArray(data) ? data : [];
|
|
529
|
+
errorText = results[0].status === 'rejected' ? results[0].reason.message : results[1].status === 'rejected' ? results[1].reason.message : '';
|
|
530
|
+
renderWallet();
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function authRequest(path, body) {
|
|
535
|
+
return fetch('/api/v1' + path, { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', 'X-Lang': localStorage.getItem('locale') || 'zh-CN' }, body: JSON.stringify(body) }).then(function (response) {
|
|
536
|
+
return response.json().catch(function () { return {}; }).then(function (payload) {
|
|
537
|
+
if (!response.ok || (payload.status_code != null && payload.status_code !== 0)) throw new Error(payload.msg || payload.message || '请求失败');
|
|
538
|
+
return responseData(payload);
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function authShell(kind, content) {
|
|
544
|
+
if (root) root.remove();
|
|
545
|
+
root = document.createElement('div'); root.id = 'netflix-theme-home'; root.className = 'nfc-console nfc-auth';
|
|
546
|
+
var brand = homeConfig.brandLogoUrl ? '<img src="' + escapeHtml(homeConfig.brandLogoUrl) + '" alt="' + escapeHtml(homeConfig.brandName || '奈飞小铺') + '">' : escapeHtml(homeConfig.brandName || '奈飞小铺');
|
|
547
|
+
root.innerHTML = '<header class="nfh-header"><nav class="nfh-header-inner"><a class="nfh-logo" href="/">' + brand + '</a><div class="nfh-header-right"><div class="nfh-header-nav"><a href="/">' + escapeHtml(homeConfig.navHomeLabel || '首页') + '</a><a href="/me/orders">' + escapeHtml(homeConfig.navProductsLabel || '车票') + '</a><a href="/me/affiliate">' + escapeHtml(homeConfig.navPromotionLabel || '推广') + '</a></div></div></nav></header><main class="nfc-auth-main"><section class="nfc-auth-card"><a class="nfc-auth-back" href="/">‹ 返回首页</a>' + content + '</section></main><footer class="nfc-auth-footer">' + escapeHtml(homeConfig.copyrightText || '© 2019 - 2026 奈飞小铺') + '</footer>';
|
|
548
|
+
document.body.appendChild(root); document.documentElement.classList.add('nfc-active');
|
|
549
|
+
host = document.querySelector('#app'); if (host) {
|
|
550
|
+
if (!hostStateSaved) { hostDisplay = host.style.display; hostVisibility = host.style.visibility; hostStateSaved = true; }
|
|
551
|
+
host.style.visibility = ''; host.style.display = 'none';
|
|
552
|
+
}
|
|
553
|
+
if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function') window.__DUJIAO_RELEASE_CONSOLE_GATE__();
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function loadAuthConfig(kind) {
|
|
557
|
+
return apiRequest('/public/config').then(function (body) { authConfig = responseData(body); }).catch(function () { authConfig = {}; }).then(function () {
|
|
558
|
+
var captcha = authConfig.captcha || {}, scenes = captcha.scenes || {}, scene = kind === 'register' ? 'register_send_code' : kind;
|
|
559
|
+
if (captcha.provider === 'image' && scenes[scene]) return apiRequest('/public/captcha/image').then(function (body) { captchaData = responseData(body); captchaImage = captchaData.image || captchaData.image_base64 || captchaData.data_url || ''; });
|
|
560
|
+
}).catch(function () { captchaData = {}; captchaImage = ''; });
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function authCaptchaMarkup(kind) {
|
|
564
|
+
var captcha = authConfig.captcha || {}, scene = kind === 'register' ? 'register_send_code' : kind, enabled = !!((captcha.scenes || {})[scene] && captcha.provider !== 'none');
|
|
565
|
+
if (!enabled) return '';
|
|
566
|
+
if (captcha.provider === 'image') return '<label class="nfc-auth-field">图形验证码<div class="nfc-captcha-row"><input name="captcha_code" autocomplete="off" required><button type="button" data-refresh-captcha>' + (captchaImage ? '<img src="' + escapeHtml(captchaImage.indexOf('data:') === 0 ? captchaImage : 'data:image/png;base64,' + captchaImage) + '" alt="刷新验证码">' : '刷新验证码') + '</button></div></label>';
|
|
567
|
+
return '<p class="nfc-auth-hint">此站点启用了安全验证,请使用系统验证页面完成登录。</p>';
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function authCaptchaPayload(form, scene) {
|
|
571
|
+
var captcha = authConfig.captcha || {}, scenes = captcha.scenes || {};
|
|
572
|
+
if (!scenes[scene || (location.pathname === '/auth/login' ? 'login' : 'register_send_code')]) return undefined;
|
|
573
|
+
if (captcha.provider === 'image') return { captcha_id: captchaData.captcha_id || captchaData.id || '', captcha_code: form.elements.captcha_code ? form.elements.captcha_code.value.trim() : '' };
|
|
574
|
+
return undefined;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
function renderAuth(kind) {
|
|
578
|
+
var registering = kind === 'register';
|
|
579
|
+
var challengeMode = !registering && !!authChallengeToken;
|
|
580
|
+
var inviteMode = !registering && !!authInviteTicket;
|
|
581
|
+
var content = '<h1>' + (challengeMode ? '两步验证' : inviteMode ? '邀请码验证' : registering ? '注册账号' : '欢迎回来') + '</h1><p class="nfc-auth-subtitle">' + escapeHtml(homeConfig.brandName || '奈飞小铺') + ' · ' + (registering ? '创建账号,开启流媒体之旅' : challengeMode ? '请输入动态验证码或备用恢复码' : inviteMode ? '该账号需要邀请码才能继续登录' : '登录后继续使用您的账户') + '</p>' +
|
|
582
|
+
'<form class="nfc-auth-form" data-auth-form>' + (!challengeMode && !inviteMode ? '<label class="nfc-auth-field">邮箱<input name="email" type="email" autocomplete="email" placeholder="请输入邮箱" required></label>' : '') +
|
|
583
|
+
(registering && authConfig.invite_only_enabled ? '<label class="nfc-auth-field">邀请码<input name="invite_code" autocomplete="off" placeholder="请输入邀请码" required></label>' : '') +
|
|
584
|
+
(!challengeMode && !inviteMode ? '<label class="nfc-auth-field">密码<input name="password" type="password" autocomplete="' + (registering ? 'new-password' : 'current-password') + '" minlength="6" placeholder="' + (registering ? '至少 6 位密码' : '请输入密码') + '" required></label>' : '') +
|
|
585
|
+
(challengeMode ? '<label class="nfc-auth-field">动态验证码<input name="totp_code" inputmode="numeric" autocomplete="one-time-code" placeholder="输入 6 位验证码"></label><label class="nfc-auth-field">恢复码<input name="recovery_code" autocomplete="off" placeholder="也可输入恢复码"></label>' : '') +
|
|
586
|
+
(inviteMode ? '<label class="nfc-auth-field">邀请码<input name="invite_code" autocomplete="off" placeholder="请输入邀请码" required></label>' : '') +
|
|
587
|
+
(registering && authConfig.email_verification_enabled !== false ? '<label class="nfc-auth-field">邮箱验证码<div class="nfc-captcha-row"><input name="code" inputmode="numeric" autocomplete="one-time-code" required><button type="button" data-send-code>发送验证码</button></div></label>' : '') + (registering && authConfig.email_verification_enabled === false ? '' : authCaptchaMarkup(kind)) +
|
|
588
|
+
(registering ? '<label class="nfc-auth-agreement"><input type="checkbox" name="agreement_accepted" required>我已阅读并同意 <a href="/terms" target="_blank">用户协议</a> 和 <a href="/privacy" target="_blank">隐私政策</a></label>' : '') +
|
|
589
|
+
'<div class="nfc-form-message" aria-live="polite"></div><button class="nfc-primary nfc-auth-submit" type="submit">' + (registering ? '注册' : challengeMode ? '验证并登录' : inviteMode ? '完成验证' : '登录') + '</button></form><div class="nfc-auth-switch">' + (challengeMode || inviteMode ? '<button type="button" data-auth-back>返回登录</button>' : registering ? '已有账号? <a href="/auth/login">立即登录</a>' : (authConfig.registration_enabled === false ? '' : '还没有账号? <a href="/auth/register">立即注册</a>')) + '</div>';
|
|
590
|
+
if (registering && authConfig.registration_enabled === false) {
|
|
591
|
+
authShell(kind, '<h1>暂未开放注册</h1><p class="nfc-auth-subtitle">当前站点暂不接受新账号注册</p><a class="nfc-primary nfc-auth-submit" href="/auth/login">返回登录</a>');
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
authShell(kind, content);
|
|
595
|
+
var form = root.querySelector('[data-auth-form]');
|
|
596
|
+
var message = form.querySelector('.nfc-form-message');
|
|
597
|
+
var backButton = root.querySelector('[data-auth-back]');
|
|
598
|
+
if (backButton) backButton.onclick = function () { authChallengeToken = ''; authInviteTicket = ''; renderAuth('login'); };
|
|
599
|
+
var refresh = form.querySelector('[data-refresh-captcha]');
|
|
600
|
+
if (refresh) refresh.onclick = function () { loadAuthConfig(kind).then(function () { renderAuth(kind); }); };
|
|
601
|
+
var sendCode = form.querySelector('[data-send-code]');
|
|
602
|
+
if (sendCode) sendCode.onclick = function () {
|
|
603
|
+
var email = form.elements.email.value.trim();
|
|
604
|
+
if (!email) { message.textContent = '请先填写邮箱'; return; }
|
|
605
|
+
var payload = { email: email, purpose: 'register', invite_code: form.elements.invite_code ? form.elements.invite_code.value.trim() : undefined, captcha_payload: authCaptchaPayload(form, 'register_send_code') };
|
|
606
|
+
sendCode.disabled = true; sendCode.textContent = '发送中…'; message.textContent = '';
|
|
607
|
+
authRequest('/auth/send-verify-code', payload).then(function () { message.textContent = '验证码已发送,请查收邮件'; sendCode.textContent = '已发送'; }).catch(function (error) { message.textContent = error.message; sendCode.disabled = false; sendCode.textContent = '发送验证码'; });
|
|
608
|
+
};
|
|
609
|
+
form.onsubmit = function (event) {
|
|
610
|
+
event.preventDefault(); message.textContent = '';
|
|
611
|
+
var captchaScene = kind === 'register' ? 'register_send_code' : kind;
|
|
612
|
+
if (authConfig.captcha && authConfig.captcha.provider === 'turnstile' && authConfig.captcha.scenes && authConfig.captcha.scenes[captchaScene] && !challengeMode && !inviteMode) { location.href = '/auth/' + kind + '?native=1' + (location.search ? '&' + location.search.slice(1) : ''); return; }
|
|
613
|
+
var button = form.querySelector('.nfc-auth-submit'); button.disabled = true; button.textContent = registering ? '正在注册…' : '正在登录…';
|
|
614
|
+
var captchaPayload = registering ? undefined : authCaptchaPayload(form, 'login');
|
|
615
|
+
var body = challengeMode ? { challenge_token: authChallengeToken } : inviteMode ? { invite_ticket: authInviteTicket, invite_code: form.elements.invite_code.value.trim() } : { email: form.elements.email.value.trim(), password: form.elements.password.value };
|
|
616
|
+
var endpoint = challengeMode ? '/auth/login/verify-2fa' : inviteMode ? '/auth/invite/complete' : '';
|
|
617
|
+
if (challengeMode) { if (form.elements.totp_code.value.trim()) body.code = form.elements.totp_code.value.trim(); if (form.elements.recovery_code.value.trim()) body.recovery_code = form.elements.recovery_code.value.trim(); }
|
|
618
|
+
if (captchaPayload) body.captcha_payload = captchaPayload;
|
|
619
|
+
var request = registering ? authRequest('/auth/register', Object.assign(body, { code: form.elements.code ? form.elements.code.value.trim() : '', agreement_accepted: !!(form.elements.agreement_accepted && form.elements.agreement_accepted.checked), invite_code: form.elements.invite_code ? form.elements.invite_code.value.trim() : undefined })) : authRequest(endpoint || '/auth/login', endpoint ? body : Object.assign(body, { remember_me: true }));
|
|
620
|
+
request.then(function (data) {
|
|
621
|
+
if (registering) {
|
|
622
|
+
if (data.token) localStorage.setItem('user_token', data.token);
|
|
623
|
+
if (data.user) localStorage.setItem('user_profile', JSON.stringify(data.user));
|
|
624
|
+
location.href = '/me/orders'; return;
|
|
625
|
+
}
|
|
626
|
+
if (data.requires_totp) { authChallengeToken = data.challenge_token || ''; renderAuth('login'); return; }
|
|
627
|
+
if (data.invite_required) { authInviteTicket = data.invite_ticket || ''; renderAuth('login'); return; }
|
|
628
|
+
if (data.token) localStorage.setItem('user_token', data.token);
|
|
629
|
+
if (data.user) localStorage.setItem('user_profile', JSON.stringify(data.user));
|
|
630
|
+
var redirect = new URLSearchParams(location.search).get('redirect') || '/me/orders';
|
|
631
|
+
location.href = safeInternalHref(redirect, '/me/orders');
|
|
632
|
+
}).catch(function (error) { message.textContent = error.message; button.disabled = false; button.textContent = registering ? '注册' : '登录'; });
|
|
633
|
+
};
|
|
634
|
+
}
|
|
414
635
|
|
|
415
636
|
function loadOrders() {
|
|
416
637
|
var token = ++sequence;
|
|
@@ -460,8 +681,7 @@
|
|
|
460
681
|
routeKey = next;
|
|
461
682
|
sequence++;
|
|
462
683
|
clearPage();
|
|
463
|
-
if (
|
|
464
|
-
if (location.pathname === '/me/affiliate' && new URLSearchParams(location.search).get('native') === '1') return;
|
|
684
|
+
if (!isThemeRoute()) return;
|
|
465
685
|
var requestedPath = location.pathname;
|
|
466
686
|
Promise.allSettled([
|
|
467
687
|
fetch('/plugins/appstore/api/plugins/public-assets?context=store', { cache: 'no-store' }).then(function (response) { return response.json(); }),
|
|
@@ -485,7 +705,13 @@
|
|
|
485
705
|
host.style.visibility = 'hidden';
|
|
486
706
|
document.documentElement.classList.add('nfc-active');
|
|
487
707
|
if (requestedPath === '/me/orders') loadOrders();
|
|
488
|
-
else loadPromotion();
|
|
708
|
+
else if (requestedPath === '/me/affiliate') loadPromotion();
|
|
709
|
+
else if (requestedPath === '/me/wallet') loadWallet();
|
|
710
|
+
else if (requestedPath === '/me') loadAccount();
|
|
711
|
+
else if (requestedPath === '/me/profile') loadProfile();
|
|
712
|
+
else if (requestedPath === '/auth/login' || requestedPath === '/auth/register') loadAuthConfig(requestedPath === '/auth/login' ? 'login' : 'register').then(function () {
|
|
713
|
+
if (location.pathname === requestedPath) renderAuth(requestedPath === '/auth/login' ? 'login' : 'register');
|
|
714
|
+
});
|
|
489
715
|
});
|
|
490
716
|
}
|
|
491
717
|
|