@etspress/netflix 0.1.21 → 0.1.23
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 +23 -0
- package/public/console.js +42 -1
- package/public/home.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etspress/netflix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
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.23",
|
|
22
22
|
"runtime": {
|
|
23
23
|
"type": "npm-static",
|
|
24
24
|
"publicRoot": "public"
|
package/plugin.json
CHANGED
package/public/console.css
CHANGED
|
@@ -155,6 +155,28 @@
|
|
|
155
155
|
#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}
|
|
156
156
|
#netflix-theme-home.nfc-console .nfc-profile-form input[readonly]{color:#999;background:#f8f8f8}
|
|
157
157
|
#netflix-theme-home.nfc-console .nfc-profile-form .nfc-primary{justify-self:start}
|
|
158
|
+
#netflix-theme-home.nfc-console .nfc-payment-grid{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(280px,.85fr);gap:14px}
|
|
159
|
+
#netflix-theme-home.nfc-console .nfc-payment-grid .nfc-panel{padding:20px;border-radius:12px}
|
|
160
|
+
#netflix-theme-home.nfc-console .nfc-payment-order h2,#netflix-theme-home.nfc-console .nfc-payment-methods h2{margin:0 0 14px;color:#222;font-size:17px;font-weight:600}
|
|
161
|
+
#netflix-theme-home.nfc-console .nfc-payment-order>div{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid #eee;font-size:13px}
|
|
162
|
+
#netflix-theme-home.nfc-console .nfc-payment-order>div span{color:#888}
|
|
163
|
+
#netflix-theme-home.nfc-console .nfc-payment-order>div strong{min-width:0;text-align:right;overflow-wrap:anywhere}
|
|
164
|
+
#netflix-theme-home.nfc-console .nfc-payment-order .nfc-payment-amount{color:#ed4f51;font-size:20px}
|
|
165
|
+
#netflix-theme-home.nfc-console .nfc-payment-channels{display:grid;gap:8px;margin-bottom:14px}
|
|
166
|
+
#netflix-theme-home.nfc-console .nfc-payment-channel{display:flex;min-height:48px;flex-direction:column;align-items:flex-start;justify-content:center;gap:2px;padding:8px 12px;border:1px solid #e5e5e5;border-radius:8px;background:#fff;color:#333;text-align:left;cursor:pointer}
|
|
167
|
+
#netflix-theme-home.nfc-console .nfc-payment-channel.is-selected{border-color:#ef5350;background:#fff7f7;box-shadow:0 0 0 1px #ef535022}
|
|
168
|
+
#netflix-theme-home.nfc-console .nfc-payment-channel small{color:#888;font-size:11px}
|
|
169
|
+
#netflix-theme-home.nfc-console .nfc-payment-result,.nfc-console .nfc-payment-success{display:grid;justify-items:center;gap:12px;padding:22px;text-align:center}
|
|
170
|
+
#netflix-theme-home.nfc-console .nfc-payment-result h2{margin:0;font-size:18px}
|
|
171
|
+
#netflix-theme-home.nfc-console .nfc-payment-result>p{margin:0;color:#777;font-size:13px}
|
|
172
|
+
#netflix-theme-home.nfc-console .nfc-payment-result>p strong{color:#ed4f51;font-size:18px}
|
|
173
|
+
#netflix-theme-home.nfc-console .nfc-payment-pending{color:#999;font-size:12px}
|
|
174
|
+
#netflix-theme-home.nfc-console .nfc-payment-qr{width:190px;height:190px;padding:8px;border:1px solid #eee;border-radius:8px;background:#fff;object-fit:contain}
|
|
175
|
+
#netflix-theme-home.nfc-console .nfc-payment-success{min-height:260px}
|
|
176
|
+
#netflix-theme-home.nfc-console .nfc-payment-success h1{margin:0;font-size:24px}
|
|
177
|
+
#netflix-theme-home.nfc-console .nfc-payment-success-icon{display:grid;width:60px;height:60px;place-items:center;border-radius:50%;background:#e9f8ef;color:#31a667;font-size:34px}
|
|
178
|
+
#netflix-theme-home.nfc-console .nfc-payment-success strong{color:#ed4f51;font-size:22px}
|
|
179
|
+
#netflix-theme-home.nfc-console .nfc-payment-loading,#netflix-theme-home.nfc-console .nfc-payment-empty,#netflix-theme-home.nfc-console .nfc-payment-error{padding:24px;border-radius:12px;background:#fff;text-align:center;color:#777}
|
|
158
180
|
#netflix-theme-home.nfc-console .nfc-form-message{min-height:18px;color:#d74747;font-size:12px}
|
|
159
181
|
#netflix-theme-home.nfc-auth{min-height:100vh;background:#f7f7f8}
|
|
160
182
|
#netflix-theme-home.nfc-auth .nfh-header{position:relative}
|
|
@@ -181,6 +203,7 @@
|
|
|
181
203
|
#netflix-theme-home.nfc-console .nfc-account-hero{padding:14px;gap:10px}
|
|
182
204
|
#netflix-theme-home.nfc-console .nfc-account-hero>a{font-size:12px;white-space:nowrap}
|
|
183
205
|
#netflix-theme-home.nfc-console .nfc-account-grid{grid-template-columns:1fr}
|
|
206
|
+
#netflix-theme-home.nfc-console .nfc-payment-grid{grid-template-columns:1fr}
|
|
184
207
|
#netflix-theme-home.nfc-console .nfc-wallet-balance{align-items:flex-start;flex-wrap:wrap;gap:16px}
|
|
185
208
|
#netflix-theme-home.nfc-console .nfc-wallet-balance>div{min-width:calc(50% - 10px)}
|
|
186
209
|
#netflix-theme-home.nfc-auth .nfc-auth-main{min-height:calc(100vh - 126px);padding:22px 12px}
|
package/public/console.js
CHANGED
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
var walletTransactions = [];
|
|
29
29
|
var walletPage = 1;
|
|
30
30
|
var walletPageSize = 10;
|
|
31
|
+
var paymentPollTimer = null;
|
|
32
|
+
var paymentOrderNo = '';
|
|
33
|
+
var paymentChannelId = '';
|
|
34
|
+
var paymentSubmitting = false;
|
|
35
|
+
var paymentResult = null;
|
|
31
36
|
var authConfig = {};
|
|
32
37
|
var captchaData = {};
|
|
33
38
|
var captchaImage = '';
|
|
@@ -36,7 +41,8 @@
|
|
|
36
41
|
|
|
37
42
|
function isThemeRoute(path) {
|
|
38
43
|
path = path || location.pathname;
|
|
39
|
-
|
|
44
|
+
var params = new URLSearchParams(location.search);
|
|
45
|
+
return ['/me/orders', '/me/affiliate', '/me/wallet', '/me', '/me/profile', '/auth/login', '/auth/register', '/pay'].indexOf(path) >= 0 && !(['/me/affiliate', '/auth/login', '/auth/register', '/pay'].indexOf(path) >= 0 && (params.get('native') === '1' || (path === '/pay' && params.get('guest') === '1')));
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
function animateThemePage(element) {
|
|
@@ -126,6 +132,8 @@
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
function clearPage() {
|
|
135
|
+
if (paymentPollTimer) window.clearInterval(paymentPollTimer);
|
|
136
|
+
paymentPollTimer = null;
|
|
129
137
|
// The homepage owns the shared loading gate until its theme is ready.
|
|
130
138
|
if (typeof window.__DUJIAO_RELEASE_CONSOLE_GATE__ === 'function' && location.pathname !== '/' && !isThemeRoute()) window.__DUJIAO_RELEASE_CONSOLE_GATE__();
|
|
131
139
|
if (root) root.remove();
|
|
@@ -581,6 +589,38 @@
|
|
|
581
589
|
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(); });
|
|
582
590
|
}
|
|
583
591
|
|
|
592
|
+
function loadPayment() {
|
|
593
|
+
paymentOrderNo = new URLSearchParams(location.search).get('order_no') || '';
|
|
594
|
+
paymentChannelId = '';
|
|
595
|
+
paymentResult = null;
|
|
596
|
+
if (!paymentOrderNo) { pageReady('payment', '<section class="nfc-panel nfc-payment-empty">订单编号缺失,请从订单列表重新进入支付。</section>'); return; }
|
|
597
|
+
pageReady('payment', '<section class="nfc-panel nfc-payment-loading">正在读取订单与支付信息…</section>');
|
|
598
|
+
requestJson('/api/v1/orders/' + encodeURIComponent(paymentOrderNo)).then(function(body) {
|
|
599
|
+
var order = responseData(body) || {};
|
|
600
|
+
var paid = ['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(order.status) >= 0;
|
|
601
|
+
if (paid) { renderPaymentSuccess(order); return; }
|
|
602
|
+
var amount = order.pay_amount || order.total_amount || order.amount || '0';
|
|
603
|
+
return Promise.allSettled([
|
|
604
|
+
fetch('/api/v1/order/payment-channels',{method:'POST',credentials:'include',headers:Object.assign({'Content-Type':'application/json'},apiHeaders()),body:JSON.stringify({order_no:paymentOrderNo,amount:amount})}).then(function(r){return r.json().catch(function(){return {}})}),
|
|
605
|
+
requestJson('/api/v1/payments/latest?order_no='+encodeURIComponent(paymentOrderNo))
|
|
606
|
+
]).then(function(results){var channelsBody=results[0].status==='fulfilled'?results[0].value:{};paymentResult=results[1].status==='fulfilled'?responseData(results[1].value):null;if(paymentResult&&paymentResult.payment_id)paymentChannelId=String(paymentResult.channel_id||'');renderPaymentPage(order,responseData(channelsBody)||[]);if(paymentResult){if(paymentPollTimer)clearInterval(paymentPollTimer);paymentPollTimer=window.setInterval(function(){requestJson('/api/v1/orders/'+encodeURIComponent(paymentOrderNo)).then(function(res){var latest=responseData(res)||{};if(['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(latest.status)>=0){clearPage();renderPaymentSuccess(latest)}}).catch(function(){})},5000)}});
|
|
607
|
+
}).catch(function(error){pageReady('payment','<section class="nfc-panel nfc-payment-error">'+escapeHtml(error.message||'订单信息读取失败')+'</section>')});
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
function renderPaymentPage(order, channels) {
|
|
611
|
+
channels=Array.isArray(channels)?channels:[];
|
|
612
|
+
var channelMarkup=channels.map(function(channel,index){var id=String(channel.id||channel.channel_id||'');return '<button type="button" class="nfc-payment-channel'+(id===paymentChannelId?' is-selected':'')+'" data-payment-channel="'+escapeHtml(id)+'"><strong>'+escapeHtml(channel.name||channel.title||channel.channel_name||'支付方式 '+(index+1))+'</strong><small>'+escapeHtml(channel.description||'在线支付')+'</small></button>'}).join('');
|
|
613
|
+
var resultMarkup=paymentResult?'<section class="nfc-panel nfc-payment-result"><h2>请完成支付</h2><p>支付金额 <strong>'+escapeHtml(formatMoney(paymentResult.pay_amount||paymentResult.amount||order.pay_amount||order.total_amount))+'</strong></p>'+(paymentResult.qr_code?'<img class="nfc-payment-qr" data-payment-qr alt="支付二维码">':'')+(paymentResult.pay_url?'<a class="nfc-primary" href="'+escapeHtml(safeLink(paymentResult.pay_url))+'" target="_blank" rel="noopener">打开支付页面</a>':'')+'<p class="nfc-payment-pending">等待原生系统确认支付…</p></section>':'';
|
|
614
|
+
var content='<div class="nfc-section-title"><h1>订单支付</h1><a class="nfc-refresh" href="/me/orders">返回车票</a></div><div class="nfc-payment-grid"><section class="nfc-panel nfc-payment-order"><h2>订单信息</h2><div><span>订单编号</span><strong>'+escapeHtml(order.order_no||paymentOrderNo)+'</strong></div><div><span>商品</span><strong>'+escapeHtml(orderItemLabel(order))+'</strong></div><div><span>订单金额</span><strong class="nfc-payment-amount">'+escapeHtml(formatMoney(order.pay_amount||order.total_amount||order.amount))+'</strong></div></section><section class="nfc-panel nfc-payment-methods"><h2>选择支付方式</h2><div class="nfc-payment-channels">'+(channelMarkup||'<p>未获取到在线支付方式,请刷新订单或联系站点客服。</p>')+'</div><button type="button" class="nfc-primary" data-submit-payment'+(paymentSubmitting?' disabled':'')+'>'+(paymentSubmitting?'正在创建支付…':'确认支付')+'</button><p class="nfc-payment-error" aria-live="polite"></p></section></div>'+resultMarkup;
|
|
615
|
+
pageReady('payment',content);
|
|
616
|
+
root.querySelectorAll('[data-payment-channel]').forEach(function(button){button.onclick=function(){paymentChannelId=button.dataset.paymentChannel;renderPaymentPage(order,channels)}});
|
|
617
|
+
var qr=root.querySelector('[data-payment-qr]'); if(qr&&paymentResult.qr_code){if(/^https?:\/\//i.test(paymentResult.qr_code)||/^data:image\//i.test(paymentResult.qr_code))qr.src=paymentResult.qr_code;else if(window.qrcode){var code=window.qrcode(0,'M');code.addData(paymentResult.qr_code);code.make();qr.src=code.createDataURL(5,2)}}
|
|
618
|
+
var submit=root.querySelector('[data-submit-payment]'); if(submit)submit.onclick=function(){paymentSubmitting=true;renderPaymentPage(order,channels);fetch('/api/v1/payments',{method:'POST',credentials:'include',headers:Object.assign({'Content-Type':'application/json'},apiHeaders()),body:JSON.stringify({order_no:paymentOrderNo,channel_id:paymentChannelId||undefined,use_balance:false})}).then(function(r){return r.json()}).then(function(result){if(result.status_code&&result.status_code!==0)throw Error(result.msg||'支付创建失败');paymentSubmitting=false;paymentResult=responseData(result)||{};renderPaymentPage(order,channels);if(paymentPollTimer)clearInterval(paymentPollTimer);paymentPollTimer=window.setInterval(function(){requestJson('/api/v1/orders/'+encodeURIComponent(paymentOrderNo)).then(function(res){var latest=responseData(res)||{};if(['paid','fulfilling','partially_delivered','delivered','completed'].indexOf(latest.status)>=0){clearPage();renderPaymentSuccess(latest)}}).catch(function(){})},5000)}).catch(function(err){paymentSubmitting=false;renderPaymentPage(order,channels);var errorNode=root&&root.querySelector('.nfc-payment-error');if(errorNode)errorNode.textContent=err.message||'支付创建失败'})};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function safeLink(value){try{var url=new URL(value,location.origin);return url.protocol==='https:'||url.protocol==='http:'?url.href:'#'}catch(_error){return '#'}}
|
|
622
|
+
function renderPaymentSuccess(order){pageReady('payment-success','<section class="nfc-panel nfc-payment-success"><div class="nfc-payment-success-icon">✓</div><h1>支付成功</h1><p>订单 '+escapeHtml(order.order_no||paymentOrderNo)+' 已支付</p><strong>'+escapeHtml(formatMoney(order.pay_amount||order.total_amount||order.amount))+'</strong><a class="nfc-primary" href="/me/orders">查看我的车票</a></section>')}
|
|
623
|
+
|
|
584
624
|
function loadWallet() {
|
|
585
625
|
if (!requireAccount()) return;
|
|
586
626
|
var token = ++sequence;
|
|
@@ -775,6 +815,7 @@
|
|
|
775
815
|
else if (requestedPath === '/me/wallet') loadWallet();
|
|
776
816
|
else if (requestedPath === '/me') loadAccount();
|
|
777
817
|
else if (requestedPath === '/me/profile') loadProfile();
|
|
818
|
+
else if (requestedPath === '/pay') loadPayment();
|
|
778
819
|
else if (requestedPath === '/auth/login' || requestedPath === '/auth/register') loadAuthConfig(requestedPath === '/auth/login' ? 'login' : 'register').then(function () {
|
|
779
820
|
if (location.pathname === requestedPath) renderAuth(requestedPath === '/auth/login' ? 'login' : 'register');
|
|
780
821
|
});
|
package/public/home.css
CHANGED
|
@@ -194,7 +194,7 @@ body.nfh-theme-active { background-color: #ef5350 !important; }
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
@media (max-width: 639px) {
|
|
197
|
-
#netflix-theme-home { padding-top: 0; background-color:
|
|
197
|
+
#netflix-theme-home { padding-top: 0; background-color: #fff; }
|
|
198
198
|
#netflix-theme-home .nfh-header { position: fixed; z-index: 100; top: 0; left: 0; right: 0; height: 54px; background: var(--nfh-red); }
|
|
199
199
|
.nfh-header-inner { height: 54px; padding: 0 12px; }
|
|
200
200
|
#netflix-theme-home .nfh-hero { margin-top: 0; }
|