@bee-hole/server 1.81.4 → 1.82.0
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/i18n/ar-EG.toml +6 -0
- package/i18n/bn-BD.toml +6 -0
- package/i18n/de-DE.toml +6 -0
- package/i18n/en-US.toml +6 -0
- package/i18n/es-ES.toml +6 -0
- package/i18n/fr-FR.toml +6 -0
- package/i18n/hi-IN.toml +6 -0
- package/i18n/id-ID.toml +6 -0
- package/i18n/it-IT.toml +6 -0
- package/i18n/ja-JP.toml +6 -0
- package/i18n/ko-KR.toml +6 -0
- package/i18n/ms-MY.toml +6 -0
- package/i18n/pt-PT.toml +6 -0
- package/i18n/ru-RU.toml +6 -0
- package/i18n/th-TH.toml +6 -0
- package/i18n/vi-VN.toml +6 -0
- package/i18n/zh-CN.toml +9 -1
- package/i18n/zh-TW.toml +6 -0
- package/main.exe +0 -0
- package/mainD +0 -0
- package/package.json +2 -2
- package/resource/public/cp/css/{app~f075b844.619fa039.css → app~f075b844.d6319cb5.css} +1 -1
- package/resource/public/cp/css/{app~f075b844.619fa039.css.gz → app~f075b844.d6319cb5.css.gz} +0 -0
- package/resource/public/cp/css/chunk-0ac1d88a.c8e3ae30.css +1 -0
- package/resource/public/cp/css/chunk-0ac1d88a.c8e3ae30.css.gz +0 -0
- package/resource/public/cp/css/chunk-4b9bd2bc.9b5ba64a.css +1 -0
- package/resource/public/cp/css/chunk-4b9bd2bc.9b5ba64a.css.gz +0 -0
- package/resource/public/cp/css/{lang-package~4e34e71e.28dd904a.css → lang-package~4e34e71e.1c9202cf.css} +1 -1
- package/resource/public/cp/css/{lang-package~4e34e71e.28dd904a.css.gz → lang-package~4e34e71e.1c9202cf.css.gz} +0 -0
- package/resource/public/cp/css/lang-zh-TW-service~f63b1681.205d1dbd.css +1 -0
- package/resource/public/cp/index.html +1 -1
- package/resource/public/cp/js/app~f075b844.85026d24.js +1 -0
- package/resource/public/cp/js/app~f075b844.85026d24.js.gz +0 -0
- package/resource/public/cp/js/chunk-0ac1d88a.e1fc95be.js +1 -0
- package/resource/public/cp/js/chunk-0ac1d88a.e1fc95be.js.gz +0 -0
- package/resource/public/cp/js/{chunk-46b7b83a.01dee211.js → chunk-46b7b83a.91104b10.js} +1 -1
- package/resource/public/cp/js/{chunk-46b7b83a.01dee211.js.gz → chunk-46b7b83a.91104b10.js.gz} +0 -0
- package/resource/public/cp/js/chunk-4b9bd2bc.85b00e67.js +1 -0
- package/resource/public/cp/js/chunk-4b9bd2bc.85b00e67.js.gz +0 -0
- package/resource/public/cp/js/{chunk-e4a3fce0.5a01bfd2.js → chunk-e4a3fce0.4077f2f6.js} +1 -1
- package/resource/public/cp/js/{chunk-e4a3fce0.5a01bfd2.js.gz → chunk-e4a3fce0.4077f2f6.js.gz} +0 -0
- package/resource/public/cp/js/lang-ar-EG~31ecd969.f37a4984.js +3 -0
- package/resource/public/cp/js/lang-ar-EG~31ecd969.f37a4984.js.gz +0 -0
- package/resource/public/cp/js/lang-bn-BD~ede72586.d27a82dc.js +1 -0
- package/resource/public/cp/js/lang-bn-BD~ede72586.d27a82dc.js.gz +0 -0
- package/resource/public/cp/js/{lang-en-US~31ecd969.08e6d06e.js → lang-en-US~31ecd969.4c01df91.js} +2 -2
- package/resource/public/cp/js/lang-en-US~31ecd969.4c01df91.js.gz +0 -0
- package/resource/public/cp/js/lang-ko-KR~31ecd969.82b5fbe4.js +1 -0
- package/resource/public/cp/js/lang-ko-KR~31ecd969.82b5fbe4.js.gz +0 -0
- package/resource/public/cp/js/lang-ms-MY~d756050e.f3dac9f0.js +1 -0
- package/resource/public/cp/js/lang-ms-MY~d756050e.f3dac9f0.js.gz +0 -0
- package/resource/public/cp/js/lang-package~4e34e71e.bf94b4c9.js +11 -0
- package/resource/public/cp/js/lang-package~4e34e71e.bf94b4c9.js.gz +0 -0
- package/resource/public/cp/js/lang-zh-TW-service~f63b1681.f6b02251.js +1 -0
- package/resource/public/cp/js/lang-zh-TW-service~f63b1681.f6b02251.js.gz +0 -0
- package/resource/public/cp/js/lang-zh-TW~31ecd969.d1410482.js +1 -0
- package/resource/public/cp/js/lang-zh-TW~31ecd969.d1410482.js.gz +0 -0
- package/resource/public/html/h5pay.html +611 -0
- package/storage/init/init.sql +189 -2
- package/storage/patch/patch.sql +109 -7
- package/version +1 -1
- package/resource/public/cp/css/chunk-0de585d4.12da7719.css +0 -1
- package/resource/public/cp/css/chunk-0de585d4.12da7719.css.gz +0 -0
- package/resource/public/cp/css/chunk-b83de892.c82d5c51.css +0 -1
- package/resource/public/cp/css/chunk-b83de892.c82d5c51.css.gz +0 -0
- package/resource/public/cp/css/lang-zh-TW-service~f63b1681.cce99047.css +0 -1
- package/resource/public/cp/js/app~f075b844.73d01863.js +0 -1
- package/resource/public/cp/js/app~f075b844.73d01863.js.gz +0 -0
- package/resource/public/cp/js/chunk-0de585d4.4623ee8b.js +0 -1
- package/resource/public/cp/js/chunk-0de585d4.4623ee8b.js.gz +0 -0
- package/resource/public/cp/js/chunk-b83de892.9598f003.js +0 -1
- package/resource/public/cp/js/chunk-b83de892.9598f003.js.gz +0 -0
- package/resource/public/cp/js/lang-ar-EG~31ecd969.d1d37891.js +0 -3
- package/resource/public/cp/js/lang-ar-EG~31ecd969.d1d37891.js.gz +0 -0
- package/resource/public/cp/js/lang-bn-BD~ede72586.83556afd.js +0 -1
- package/resource/public/cp/js/lang-bn-BD~ede72586.83556afd.js.gz +0 -0
- package/resource/public/cp/js/lang-en-US~31ecd969.08e6d06e.js.gz +0 -0
- package/resource/public/cp/js/lang-ko-KR~31ecd969.ebf16b44.js +0 -1
- package/resource/public/cp/js/lang-ko-KR~31ecd969.ebf16b44.js.gz +0 -0
- package/resource/public/cp/js/lang-ms-MY~d756050e.9dd1cdba.js +0 -1
- package/resource/public/cp/js/lang-ms-MY~d756050e.9dd1cdba.js.gz +0 -0
- package/resource/public/cp/js/lang-package~4e34e71e.c8984558.js +0 -11
- package/resource/public/cp/js/lang-package~4e34e71e.c8984558.js.gz +0 -0
- package/resource/public/cp/js/lang-zh-TW-service~f63b1681.8ea8e074.js +0 -1
- package/resource/public/cp/js/lang-zh-TW-service~f63b1681.8ea8e074.js.gz +0 -0
- package/resource/public/cp/js/lang-zh-TW~31ecd969.4669d290.js +0 -1
- package/resource/public/cp/js/lang-zh-TW~31ecd969.4669d290.js.gz +0 -0
- /package/resource/public/cp/css/{chunk-vendors~5ea6e0dc.cda87f4c.css → chunk-vendors~5ea6e0dc.d7251aeb.css} +0 -0
- /package/resource/public/cp/css/{chunk-vendors~5ea6e0dc.cda87f4c.css.gz → chunk-vendors~5ea6e0dc.d7251aeb.css.gz} +0 -0
- /package/resource/public/cp/css/{chunk-vendors~db456615.9413bf95.css → chunk-vendors~db456615.5a096447.css} +0 -0
- /package/resource/public/cp/css/{chunk-vendors~db456615.9413bf95.css.gz → chunk-vendors~db456615.5a096447.css.gz} +0 -0
- /package/resource/public/cp/js/{chunk-44a8e73b.b75bac45.js → chunk-44a8e73b.256b9f27.js} +0 -0
- /package/resource/public/cp/js/{chunk-44a8e73b.b75bac45.js.gz → chunk-44a8e73b.256b9f27.js.gz} +0 -0
- /package/resource/public/cp/js/{chunk-a751530a.9e13bf51.js → chunk-a751530a.1920c5e2.js} +0 -0
- /package/resource/public/cp/js/{chunk-a751530a.9e13bf51.js.gz → chunk-a751530a.1920c5e2.js.gz} +0 -0
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>支付页面</title>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: Arial, sans-serif;
|
|
11
|
+
line-height: 1.6;
|
|
12
|
+
color: #333;
|
|
13
|
+
max-width: 800px;
|
|
14
|
+
margin: 0 auto;
|
|
15
|
+
padding: 20px;
|
|
16
|
+
background-color: #f4f4f4;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.payment-card {
|
|
20
|
+
background-color: #fff;
|
|
21
|
+
border-radius: 8px;
|
|
22
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
23
|
+
padding: 20px;
|
|
24
|
+
margin-bottom: 20px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.payment-header {
|
|
28
|
+
border-bottom: 1px solid #eee;
|
|
29
|
+
padding-bottom: 10px;
|
|
30
|
+
margin-bottom: 20px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.payment-title {
|
|
34
|
+
font-size: 24px;
|
|
35
|
+
font-weight: bold;
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.payment-details {
|
|
40
|
+
margin-bottom: 20px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.payment-details p {
|
|
44
|
+
margin: 5px 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.payment-amount {
|
|
48
|
+
font-size: 18px;
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
color: #e53e3e;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.payment-methods {
|
|
54
|
+
display: grid;
|
|
55
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
56
|
+
gap: 15px;
|
|
57
|
+
margin-bottom: 20px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.payment-method {
|
|
61
|
+
border: 2px solid #ddd;
|
|
62
|
+
border-radius: 8px;
|
|
63
|
+
padding: 15px;
|
|
64
|
+
text-align: center;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
transition: all 0.3s ease;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.payment-method:hover {
|
|
70
|
+
border-color: #3182ce;
|
|
71
|
+
background-color: #ebf8ff;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.payment-method img {
|
|
75
|
+
height: 22px;
|
|
76
|
+
margin-bottom: 10px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.currency-select {
|
|
80
|
+
display: block;
|
|
81
|
+
width: 100%;
|
|
82
|
+
padding: 8px;
|
|
83
|
+
margin-top: 10px;
|
|
84
|
+
border: 1px solid #ddd;
|
|
85
|
+
border-radius: 4px;
|
|
86
|
+
font-size: 14px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.pay-button {
|
|
90
|
+
display: block;
|
|
91
|
+
width: 100%;
|
|
92
|
+
padding: 12px;
|
|
93
|
+
background-color: #3182ce;
|
|
94
|
+
color: white;
|
|
95
|
+
border: none;
|
|
96
|
+
border-radius: 4px;
|
|
97
|
+
font-size: 16px;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
transition: background-color 0.3s ease;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.pay-button:hover {
|
|
103
|
+
background-color: #2c5282;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#loading {
|
|
107
|
+
text-align: center;
|
|
108
|
+
font-size: 18px;
|
|
109
|
+
margin: 20px 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.language-selector {
|
|
113
|
+
text-align: right;
|
|
114
|
+
margin-bottom: 10px;
|
|
115
|
+
}
|
|
116
|
+
.notification {
|
|
117
|
+
position: fixed;
|
|
118
|
+
top: -100px;
|
|
119
|
+
left: 0;
|
|
120
|
+
right: 0;
|
|
121
|
+
background-color: #4CAF50;
|
|
122
|
+
color: white;
|
|
123
|
+
text-align: center;
|
|
124
|
+
padding: 16px;
|
|
125
|
+
transition: top 0.5s ease;
|
|
126
|
+
z-index: 1000;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.notification.show {
|
|
130
|
+
top: 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.notification.error {
|
|
134
|
+
background-color: #f44336;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.notification.warning {
|
|
138
|
+
background-color: #ff9800;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.close-btn {
|
|
142
|
+
margin-left: 15px;
|
|
143
|
+
color: white;
|
|
144
|
+
font-weight: bold;
|
|
145
|
+
float: right;
|
|
146
|
+
font-size: 22px;
|
|
147
|
+
line-height: 20px;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
transition: 0.3s;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.close-btn:hover {
|
|
153
|
+
color: black;
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
156
|
+
</head>
|
|
157
|
+
|
|
158
|
+
<body>
|
|
159
|
+
<div id="notification" class="notification">
|
|
160
|
+
<span id="notificationMessage"></span>
|
|
161
|
+
<span class="close-btn" onclick="closeNotification()">×</span>
|
|
162
|
+
</div>
|
|
163
|
+
<div class="language-selector">
|
|
164
|
+
<select id="language-select">
|
|
165
|
+
<option value="zh-CN">中文</option>
|
|
166
|
+
<option value="en-US">English</option>
|
|
167
|
+
</select>
|
|
168
|
+
</div>
|
|
169
|
+
<div class="payment-card">
|
|
170
|
+
<div class="payment-header">
|
|
171
|
+
<h1 class="payment-title" data-i18n="paymentDetails">支付详情</h1>
|
|
172
|
+
</div>
|
|
173
|
+
<div class="payment-details">
|
|
174
|
+
<p><span data-i18n="invoiceNumber">支付单据号</span>:<strong id="orderId"></strong></p>
|
|
175
|
+
<p><span data-i18n="amountDue">应付金额</span>:<span class="payment-amount"></span></p>
|
|
176
|
+
</div>
|
|
177
|
+
<div id="payCode"></div>
|
|
178
|
+
<div id="loading" data-i18n="loading">加载支付方式中...</div>
|
|
179
|
+
<div id="payment-methods" class="payment-methods"></div>
|
|
180
|
+
<button id="pay-button" class="pay-button" disabled data-i18n="payNow">去支付</button>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<script>
|
|
184
|
+
var debug = false;
|
|
185
|
+
const httpurl = 'http://192.168.3.52:8299';
|
|
186
|
+
const translations = {
|
|
187
|
+
'zh-CN': {
|
|
188
|
+
paymentDetails: '支付详情',
|
|
189
|
+
invoiceNumber: '支付单据号',
|
|
190
|
+
amountDue: '应付金额',
|
|
191
|
+
loading: '加载支付方式中...',
|
|
192
|
+
payNow: '去支付',
|
|
193
|
+
selectCurrency: '选择货币',
|
|
194
|
+
paymentProcessing: '正在使用 {method} 进行 {currency} 支付',
|
|
195
|
+
loadingFailed: '加载支付方式失败,请刷新页面重试。',
|
|
196
|
+
creditCard: '信用卡',
|
|
197
|
+
debitCard: '借记卡',
|
|
198
|
+
bankTransfer: '银行转账',
|
|
199
|
+
digitalWallet: '电子钱包',
|
|
200
|
+
translatePrice: '换算金额'
|
|
201
|
+
},
|
|
202
|
+
'en-US': {
|
|
203
|
+
paymentDetails: 'Payment Details',
|
|
204
|
+
invoiceNumber: 'Invoice Number',
|
|
205
|
+
amountDue: 'Amount Due',
|
|
206
|
+
loading: 'Loading payment methods...',
|
|
207
|
+
payNow: 'Pay Now',
|
|
208
|
+
selectCurrency: 'Select Currency',
|
|
209
|
+
paymentProcessing: 'Processing payment with {method} in {currency}',
|
|
210
|
+
loadingFailed: 'Failed to load payment methods. Please refresh the page and try again.',
|
|
211
|
+
creditCard: 'Credit Card',
|
|
212
|
+
debitCard: 'Debit Card',
|
|
213
|
+
bankTransfer: 'Bank Transfer',
|
|
214
|
+
digitalWallet: 'Digital Wallet',
|
|
215
|
+
translatePrice: 'Translate Price'
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
let currentLanguage = 'zh-CN';
|
|
220
|
+
let payRes = null;
|
|
221
|
+
function translate(key, params = {}) {
|
|
222
|
+
let text = translations[currentLanguage][key] || key;
|
|
223
|
+
for (const [param, value] of Object.entries(params)) {
|
|
224
|
+
text = text.replace(`{${param}}`, value);
|
|
225
|
+
}
|
|
226
|
+
return text;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function showNotification(message, type = 'success') {
|
|
230
|
+
const notification = document.getElementById('notification');
|
|
231
|
+
const notificationMessage = document.getElementById('notificationMessage');
|
|
232
|
+
|
|
233
|
+
notification.className = 'notification';
|
|
234
|
+
if (type === 'error') {
|
|
235
|
+
notification.classList.add('error');
|
|
236
|
+
} else if (type === 'warning') {
|
|
237
|
+
notification.classList.add('warning');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
notificationMessage.textContent = message;
|
|
241
|
+
notification.classList.add('show');
|
|
242
|
+
|
|
243
|
+
// Auto hide after 5 seconds
|
|
244
|
+
setTimeout(() => {
|
|
245
|
+
closeNotification();
|
|
246
|
+
}, 5000);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function closeNotification() {
|
|
250
|
+
const notification = document.getElementById('notification');
|
|
251
|
+
notification.classList.remove('show');
|
|
252
|
+
}
|
|
253
|
+
function showErrText(text) {
|
|
254
|
+
document.getElementById('loading').style.display = 'block';
|
|
255
|
+
document.getElementById('loading').textContent = text;
|
|
256
|
+
}
|
|
257
|
+
function hiddenErrText() {
|
|
258
|
+
document.getElementById('loading').style.display = 'none';
|
|
259
|
+
}
|
|
260
|
+
function hiidenPayCode() {
|
|
261
|
+
document.getElementById('payCode').style.display = 'none';
|
|
262
|
+
}
|
|
263
|
+
function updatePageLanguage() {
|
|
264
|
+
document.querySelectorAll('[data-i18n]').forEach(element => {
|
|
265
|
+
const key = element.getAttribute('data-i18n');
|
|
266
|
+
element.textContent = translate(key);
|
|
267
|
+
});
|
|
268
|
+
document.title = translate('paymentDetails');
|
|
269
|
+
}
|
|
270
|
+
function getRouterParams(){
|
|
271
|
+
let url = decodeURI(window.location.href);
|
|
272
|
+
// 获取地址栏参数
|
|
273
|
+
let params = url.split('?')[1];
|
|
274
|
+
// 获取参数数组
|
|
275
|
+
let paramArr = params.split('&');
|
|
276
|
+
// 定义参数对象
|
|
277
|
+
let paramObj = {};
|
|
278
|
+
// 遍历参数数组
|
|
279
|
+
paramArr.forEach((item) => {
|
|
280
|
+
// 获取参数键值对
|
|
281
|
+
let key = item.split('=')[0];
|
|
282
|
+
let value = decodeURIComponent(item.split('=')[1]);
|
|
283
|
+
// // 添加到参数对象
|
|
284
|
+
// if (key == 'path') {
|
|
285
|
+
// value = decodeBase64(value);
|
|
286
|
+
// }
|
|
287
|
+
paramObj[key] = value;
|
|
288
|
+
})
|
|
289
|
+
return paramObj;
|
|
290
|
+
}
|
|
291
|
+
function fetchPaymentMethods(credential_id) {
|
|
292
|
+
|
|
293
|
+
return new Promise((resolve) => {
|
|
294
|
+
var api = '/admin/payment/methods'
|
|
295
|
+
if (debug) {
|
|
296
|
+
api = httpurl + api;
|
|
297
|
+
}
|
|
298
|
+
fetch(api, {
|
|
299
|
+
method: 'POST',
|
|
300
|
+
headers: {
|
|
301
|
+
'Content-Type': 'application/json' // 如果需要 token 认证
|
|
302
|
+
},
|
|
303
|
+
body: JSON.stringify({
|
|
304
|
+
// 参数
|
|
305
|
+
credential_id: credential_id
|
|
306
|
+
})
|
|
307
|
+
}).then(response => response.json())
|
|
308
|
+
.then(result => {
|
|
309
|
+
if (result && result.data && result.data.list) {
|
|
310
|
+
// this.paymentList = result.data.list
|
|
311
|
+
// this.initPaymenthods();
|
|
312
|
+
resolve(result.data.list);
|
|
313
|
+
} else {
|
|
314
|
+
if (result && result.message) {
|
|
315
|
+
// this.ErrMsg = result.message;
|
|
316
|
+
// showErrText(result.message);
|
|
317
|
+
showNotification(result.message, 'error');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
.catch(error => {
|
|
322
|
+
console.error('Error:', error);
|
|
323
|
+
// showErrText(error);
|
|
324
|
+
showNotification(error, 'error');
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function renderPaymentMethods(methods) {
|
|
330
|
+
const container = document.getElementById('payment-methods');
|
|
331
|
+
container.innerHTML = methods.map(method => `
|
|
332
|
+
<div class="payment-method" data-id="${method.pay_way_id}">
|
|
333
|
+
<img src="${method.logo}" alt="${translate(method.description)}">
|
|
334
|
+
<h3 data-i18n="${method.description}">${translate(method.description)}</h3>
|
|
335
|
+
<select class="currency-select" data-id="${method.pay_way_id}">
|
|
336
|
+
<option value="" data-i18n="selectCurrency">${translate('selectCurrency')}</option>
|
|
337
|
+
${method.currencies.map(currency => `<option value="${currency}">${currency}</option>`).join('')}
|
|
338
|
+
</select>
|
|
339
|
+
</div>
|
|
340
|
+
`).join('');
|
|
341
|
+
|
|
342
|
+
container.querySelectorAll('.payment-method').forEach(method => {
|
|
343
|
+
method.addEventListener('click', selectPaymentMethod);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
container.querySelectorAll('.currency-select').forEach(select => {
|
|
347
|
+
select.addEventListener('change', (event)=>{
|
|
348
|
+
selectPaymentMethodAndCurrency(event);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
setTimeout(() => {
|
|
352
|
+
initPay();
|
|
353
|
+
}, 200);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function selectPaymentMethod(event) {
|
|
357
|
+
hiddenErrText();
|
|
358
|
+
document.querySelectorAll('.payment-method').forEach(method => {
|
|
359
|
+
method.style.borderColor = '#ddd';
|
|
360
|
+
method.style.backgroundColor = '#fff';
|
|
361
|
+
});
|
|
362
|
+
const selectedMethod = event.currentTarget;
|
|
363
|
+
selectedMethod.style.borderColor = '#3182ce';
|
|
364
|
+
selectedMethod.style.backgroundColor = '#ebf8ff';
|
|
365
|
+
updatePayButton();
|
|
366
|
+
}
|
|
367
|
+
async function selectPaymentMethodAndCurrency(event) {
|
|
368
|
+
if(event){
|
|
369
|
+
event.stopPropagation(); // 阻止事件冒泡
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const select = event.target;
|
|
373
|
+
const paymentMethod = select.closest('.payment-method');
|
|
374
|
+
|
|
375
|
+
// 重置所有支付方式的样式
|
|
376
|
+
document.querySelectorAll('.payment-method').forEach(method => {
|
|
377
|
+
method.style.borderColor = '#ddd';
|
|
378
|
+
method.style.backgroundColor = '#fff';
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// 设置当前选中的支付方式样式
|
|
382
|
+
paymentMethod.style.borderColor = '#3182ce';
|
|
383
|
+
paymentMethod.style.backgroundColor = '#ebf8ff';
|
|
384
|
+
|
|
385
|
+
hiddenErrText();
|
|
386
|
+
await updatePayButton();
|
|
387
|
+
}
|
|
388
|
+
async function updatePayButton() {
|
|
389
|
+
const selectedMethod = document.querySelector('.payment-method[style*="border-color: rgb(49, 130, 206)"]');
|
|
390
|
+
const selectedCurrency = selectedMethod ? selectedMethod.querySelector('.currency-select').value : '';
|
|
391
|
+
const payButton = document.getElementById('pay-button');
|
|
392
|
+
payButton.disabled = !selectedMethod || !selectedCurrency;
|
|
393
|
+
if (!payButton.disabled){
|
|
394
|
+
const methodName = selectedMethod.querySelector('[data-i18n]').getAttribute('data-i18n');
|
|
395
|
+
// alert(translate('paymentProcessing', { method: translate(methodName), currency: selectedCurrency }));
|
|
396
|
+
payRes = await Pay(selectedCurrency, selectedMethod.querySelector('.currency-select').getAttribute('data-id'), methodName);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function setPayAmount(amount, payAmount) {
|
|
401
|
+
const payAmountText = ', ' + translate('translatePrice') + ': ' + payAmount;
|
|
402
|
+
document.querySelector('.payment-amount').textContent = amount + payAmountText;
|
|
403
|
+
}
|
|
404
|
+
function backUrl () {
|
|
405
|
+
return window.location.href;
|
|
406
|
+
};
|
|
407
|
+
function Pay(currency, payWayId, name) {
|
|
408
|
+
return new Promise((resolve) => {
|
|
409
|
+
const params = getRouterParams();
|
|
410
|
+
var query = {
|
|
411
|
+
credential_id: params.credential_id,
|
|
412
|
+
currency: currency,
|
|
413
|
+
scene_type: name === 'Alipay' ? 'H5' : 'NATIVE',
|
|
414
|
+
cancel_return_url: backUrl(),
|
|
415
|
+
paid_return_url: params.backUrl,
|
|
416
|
+
pay_way_id: payWayId
|
|
417
|
+
}
|
|
418
|
+
var api = '/admin/payment'
|
|
419
|
+
if(debug){
|
|
420
|
+
api = httpurl+api;
|
|
421
|
+
}
|
|
422
|
+
fetch(api, {
|
|
423
|
+
method: 'POST',
|
|
424
|
+
headers: {
|
|
425
|
+
'Content-Type': 'application/json' // 如果需要 token 认证
|
|
426
|
+
},
|
|
427
|
+
body: JSON.stringify(query)
|
|
428
|
+
}).then(response => response.json())
|
|
429
|
+
.then(result => {
|
|
430
|
+
const res = result.data;
|
|
431
|
+
// console.log('res', res, result)
|
|
432
|
+
if (res) {
|
|
433
|
+
// that.prepayAmountCurrency = (res.currency)
|
|
434
|
+
// that.prepayAmount = res.amount;
|
|
435
|
+
setPayAmount((res.price_currency)+''+ res.price_amount, res.trade_currency + '' + res.trade_amount);
|
|
436
|
+
const url64 = res?.jsapi?.auth_link;
|
|
437
|
+
const h5Url = res?.h5?.h5_url;
|
|
438
|
+
const authLink = res?.jsapi?.auth_link;
|
|
439
|
+
const qrCode = res?.native?.qr_code_summary;
|
|
440
|
+
// that.payLoding = true;
|
|
441
|
+
if (url64) {
|
|
442
|
+
// 对url进行base64解码
|
|
443
|
+
const url = Buffer.from(url64, 'base64').toString('binary');
|
|
444
|
+
// that.payUrl = url;
|
|
445
|
+
resolve({url, type: 'url'});
|
|
446
|
+
}
|
|
447
|
+
if (h5Url) {
|
|
448
|
+
// that.payUrl = h5Url;
|
|
449
|
+
resolve({ url: h5Url, type: 'url' });
|
|
450
|
+
}
|
|
451
|
+
if (authLink) {
|
|
452
|
+
// that.payUrl = authLink;
|
|
453
|
+
resolve({ url: authLink, type: 'url' });
|
|
454
|
+
}
|
|
455
|
+
if (qrCode) {
|
|
456
|
+
// that.payQrCode = 'data:image/jpeg;base64, ' + qrCode
|
|
457
|
+
resolve({ url: qrCode, type: 'qrCode' });
|
|
458
|
+
// this.lunxunOrder();
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
if (result && result.message) {
|
|
462
|
+
// that.ErrMsg = result.message;
|
|
463
|
+
console.log('result.message', result.message);
|
|
464
|
+
// showErrText(result.message);
|
|
465
|
+
showNotification(result.message, 'error');
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
})
|
|
469
|
+
.catch(error => {
|
|
470
|
+
console.error('Error:', error);
|
|
471
|
+
// that.ErrMsg = error.message;
|
|
472
|
+
// showErrText(error);
|
|
473
|
+
showNotification(error, 'error');
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
let payTime =null;
|
|
479
|
+
function getOrderStatus() {
|
|
480
|
+
return new Promise((resolve) => {
|
|
481
|
+
var api = '/admin/payment/query'
|
|
482
|
+
if (debug) {
|
|
483
|
+
api = httpurl + api;
|
|
484
|
+
}
|
|
485
|
+
const params = getRouterParams();
|
|
486
|
+
var query = {
|
|
487
|
+
credential_id: params?.credential_id
|
|
488
|
+
}
|
|
489
|
+
fetch(api, {
|
|
490
|
+
method: 'POST',
|
|
491
|
+
headers: {
|
|
492
|
+
'Content-Type': 'application/json' // 如果需要 token 认证
|
|
493
|
+
},
|
|
494
|
+
body: JSON.stringify(query)
|
|
495
|
+
}).then(response => response.json())
|
|
496
|
+
.then(result => {
|
|
497
|
+
const res = result.data;
|
|
498
|
+
if (res.status === 'PENDING') {
|
|
499
|
+
payTime = setTimeout(() => {
|
|
500
|
+
getOrderStatus();
|
|
501
|
+
}, 1000);
|
|
502
|
+
} else if (res.status === 'PAID') {
|
|
503
|
+
window.close();
|
|
504
|
+
}else{
|
|
505
|
+
if(res.message){
|
|
506
|
+
// showErrText(res.message);
|
|
507
|
+
showNotification(result.message, 'error');
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
})
|
|
511
|
+
.catch(error => {
|
|
512
|
+
console.error('Error:', error);
|
|
513
|
+
// showErrText(error);
|
|
514
|
+
showNotification(error, 'error');
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function initPay (){
|
|
520
|
+
// // 默认选中第一个支付方式
|
|
521
|
+
// const payMentd = document.querySelector('.payment-method')
|
|
522
|
+
// payMentd.click();
|
|
523
|
+
// // 触发选中第一个支付方式的第一个货币
|
|
524
|
+
// // document.querySelector('.currency-select').dispatchEvent(new Event('change'));
|
|
525
|
+
// // 默认选中第二个货币
|
|
526
|
+
// // document.querySelector('.currency-select').value = document.querySelector('.currency-select option').value;
|
|
527
|
+
// const currencySelect = payMentd.querySelector('.currency-select');
|
|
528
|
+
|
|
529
|
+
// // 选中第二个 option
|
|
530
|
+
// currencySelect.selectedIndex = 1;
|
|
531
|
+
// console.log('currencySelect', currencySelect)
|
|
532
|
+
// payMentd.querySelector('.currency-select').dispatchEvent(new Event('change'));
|
|
533
|
+
// document.querySelector('.currency-select').value = document.querySelector('.currency-select option').value;
|
|
534
|
+
// 默认点击支付按钮
|
|
535
|
+
// 默认选中第一个支付方式的第一个有效货币
|
|
536
|
+
const firstPaymentMethod = document.querySelector('.payment-method');
|
|
537
|
+
const currencySelect = firstPaymentMethod.querySelector('.currency-select');
|
|
538
|
+
|
|
539
|
+
// 选中第一个有效的货币选项(跳过空选项)
|
|
540
|
+
for (let i = 1; i < currencySelect.options.length; i++) {
|
|
541
|
+
if (currencySelect.options[i].value) {
|
|
542
|
+
currencySelect.selectedIndex = i;
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// 手动触发选择事件
|
|
548
|
+
const mockEvent = {
|
|
549
|
+
target: currencySelect,
|
|
550
|
+
stopPropagation: () => { } // 添加一个空的 stopPropagation 方法
|
|
551
|
+
};
|
|
552
|
+
selectPaymentMethodAndCurrency(mockEvent);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
async function initPage() {
|
|
556
|
+
try {
|
|
557
|
+
const params = getRouterParams();
|
|
558
|
+
if(params.debug === 'true'){
|
|
559
|
+
debug = true;
|
|
560
|
+
if(params.httpurl){
|
|
561
|
+
httpurl = params.httpurl;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
document.getElementById('orderId').textContent = params.credential_id;
|
|
565
|
+
const paymentMethods = await fetchPaymentMethods(params.credential_id);
|
|
566
|
+
document.getElementById('loading').style.display = 'none';
|
|
567
|
+
renderPaymentMethods(paymentMethods);
|
|
568
|
+
|
|
569
|
+
updatePageLanguage();
|
|
570
|
+
// getOrderStatus();
|
|
571
|
+
} catch (error) {
|
|
572
|
+
// document.getElementById('loading').textContent = translate('loadingFailed');
|
|
573
|
+
// showErrText(translate('loadingFailed'));
|
|
574
|
+
showNotification(translate('loadingFailed'), 'error');
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
window.addEventListener('load', initPage);
|
|
579
|
+
|
|
580
|
+
document.getElementById('pay-button').addEventListener('click',async () => {
|
|
581
|
+
const selectedMethod = document.querySelector('.payment-method[style*="border-color: rgb(49, 130, 206)"]');
|
|
582
|
+
const selectedCurrency = selectedMethod ? selectedMethod.querySelector('.currency-select').value : '';
|
|
583
|
+
// 我想通过selectedCurrency获取他标签上的data-id
|
|
584
|
+
console.log('selectedCurrency', selectedMethod.querySelector('.currency-select').getAttribute('data-id'));
|
|
585
|
+
if (selectedMethod && selectedCurrency) {
|
|
586
|
+
// const methodName = selectedMethod.querySelector('[data-i18n]').getAttribute('data-i18n');
|
|
587
|
+
// console.log('selectedCurrency', selectedCurrency, methodName);
|
|
588
|
+
// // alert(translate('paymentProcessing', { method: translate(methodName), currency: selectedCurrency }));
|
|
589
|
+
// payRes = await Pay(selectedCurrency, selectedMethod.querySelector('.currency-select').getAttribute('data-id'), methodName);
|
|
590
|
+
// console.log('payRes-------------', payRes)
|
|
591
|
+
if (payRes) {
|
|
592
|
+
if (payRes.type === 'url') {
|
|
593
|
+
window.location.href = payRes.url;
|
|
594
|
+
} else {
|
|
595
|
+
document.getElementById('payCode').innerHTML = `<img src="data:image/jpeg;base64, ${payRes.url}" alt="支付二维码">`;
|
|
596
|
+
}
|
|
597
|
+
}else{
|
|
598
|
+
// showErrText('支付失败');
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
document.getElementById('language-select').addEventListener('change', (event) => {
|
|
605
|
+
currentLanguage = event.target.value;
|
|
606
|
+
updatePageLanguage();
|
|
607
|
+
});
|
|
608
|
+
</script>
|
|
609
|
+
</body>
|
|
610
|
+
|
|
611
|
+
</html>
|