@2kog/pkg-widget 0.1.14 → 0.1.16
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/index.html +1 -0
- package/package.json +5 -3
- package/postcss.config.js +5 -0
- package/src/App.vue +5 -1
- package/src/components/common/payment.vue +681 -0
- package/src/locale/en-us/payment.js +14 -0
- package/src/locale/zh-cn/payment.js +14 -0
- package/vite.config.js +4 -4
package/index.html
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<link rel="icon" href="/favicon.ico" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Iruxu Pkg Widget</title>
|
|
8
|
+
<link href="https://static.2kog.com/lib/css/font-awesome/7.1.0/css/all.min.css" rel="stylesheet" />
|
|
8
9
|
</head>
|
|
9
10
|
<body>
|
|
10
11
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2kog/pkg-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
25
|
+
"autoprefixer": "^10.4.23",
|
|
25
26
|
"less": "^4.2.0",
|
|
27
|
+
"postcss": "^8.5.6",
|
|
26
28
|
"vite": "^5.4.1",
|
|
27
|
-
"vite-
|
|
28
|
-
"vite-
|
|
29
|
+
"vite-plugin-require": "^1.2.14",
|
|
30
|
+
"vite-svg-loader": "^5.1.0"
|
|
29
31
|
},
|
|
30
32
|
"repository": {
|
|
31
33
|
"type": "git",
|
package/src/App.vue
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
:show-name="true"
|
|
10
10
|
:optionsWithFlag="false"></langSelect>
|
|
11
11
|
<pay></pay>
|
|
12
|
+
|
|
13
|
+
<payment ></payment>
|
|
12
14
|
</div>
|
|
13
15
|
</template>
|
|
14
16
|
|
|
@@ -18,13 +20,15 @@ import UploadImage from "./components/common/upload-image.vue";
|
|
|
18
20
|
import {upload} from "./assets/data/upload";
|
|
19
21
|
import langSelect from "./components/common/lang-select.vue";
|
|
20
22
|
import pay from "./demo/pay-dialog-demo.vue";
|
|
23
|
+
import payment from "./components/common/payment.vue";
|
|
21
24
|
export default {
|
|
22
25
|
name: "App",
|
|
23
26
|
components: {
|
|
24
27
|
Logo,
|
|
25
28
|
UploadImage,
|
|
26
29
|
langSelect,
|
|
27
|
-
pay
|
|
30
|
+
pay,
|
|
31
|
+
payment
|
|
28
32
|
},
|
|
29
33
|
data() {
|
|
30
34
|
return {
|
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="c-payment-component">
|
|
3
|
+
<div class="c-payment__header">
|
|
4
|
+
<slot name="header"></slot>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<!-- 右侧:支付操作区 -->
|
|
8
|
+
<div class="modal-main m-purchase-pay-main">
|
|
9
|
+
<!-- 支付方式切换 -->
|
|
10
|
+
<div class="payment-methods-grid">
|
|
11
|
+
<slot name="payment-methods" :methods="paymentMethods" :active="activeMethod" :switch="switchPay">
|
|
12
|
+
<button
|
|
13
|
+
v-for="method in paymentMethods"
|
|
14
|
+
:key="method.value"
|
|
15
|
+
@click="switchPay(method.value)"
|
|
16
|
+
class="pay-method-btn"
|
|
17
|
+
:class="[
|
|
18
|
+
activeMethod === method.value ? 'active ' + method.activeClass : '',
|
|
19
|
+
method.customClass || '',
|
|
20
|
+
]"
|
|
21
|
+
>
|
|
22
|
+
<i :class="method.icon" class="method-icon"></i>
|
|
23
|
+
<span class="method-label">{{ method.label }}</span>
|
|
24
|
+
</button>
|
|
25
|
+
</slot>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<!-- 二维码区 -->
|
|
29
|
+
<div class="qrcode-container">
|
|
30
|
+
<div class="qr-wrapper">
|
|
31
|
+
<slot name="badge"></slot>
|
|
32
|
+
<div class="qrcode-box">
|
|
33
|
+
<!-- Loading 状态 -->
|
|
34
|
+
<div v-if="loading" class="loading-overlay">
|
|
35
|
+
<slot name="loading">
|
|
36
|
+
<i class="fas fa-spinner fa-spin loading-icon"></i>
|
|
37
|
+
</slot>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- 显示二维码 -->
|
|
41
|
+
<QrcodeVue
|
|
42
|
+
v-else-if="qrcodeUrl"
|
|
43
|
+
:value="qrcodeUrl"
|
|
44
|
+
class="qrcode-image"
|
|
45
|
+
:size="160"
|
|
46
|
+
level="H"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<!-- 默认图标 -->
|
|
50
|
+
<slot v-else name="placeholder" :activeMethod="activeMethod">
|
|
51
|
+
<i
|
|
52
|
+
class="placeholder-icon"
|
|
53
|
+
:class="currentPaymentMethod?.icon || 'fas fa-qrcode text-gray-400'"
|
|
54
|
+
></i>
|
|
55
|
+
</slot>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="secure-badge">
|
|
59
|
+
<i class="fas fa-lock secure-icon"></i>
|
|
60
|
+
{{ t("pay.secureChannel") }}
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<!-- 错误提示 -->
|
|
64
|
+
<div v-if="errorMsg" class="error-message">
|
|
65
|
+
<slot name="error" :message="errorMsg">
|
|
66
|
+
{{ errorMsg }}
|
|
67
|
+
</slot>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<!-- 底部插槽 -->
|
|
72
|
+
<div class="footer-slot">
|
|
73
|
+
<slot name="footer" :texts="texts"></slot>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<script>
|
|
80
|
+
import QrcodeVue from "qrcode.vue";
|
|
81
|
+
import { createI18n } from "vue-i18n";
|
|
82
|
+
import enUs from "../../locale/en-us/payment";
|
|
83
|
+
import zhCn from "../../locale/zh-cn/payment";
|
|
84
|
+
|
|
85
|
+
// 创建独立的 i18n 实例
|
|
86
|
+
const getLocale = () => {
|
|
87
|
+
const storedLanguage = localStorage.getItem('lang');
|
|
88
|
+
if (!storedLanguage) {
|
|
89
|
+
return navigator.language;
|
|
90
|
+
} else {
|
|
91
|
+
return storedLanguage;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const payI18n = createI18n({
|
|
96
|
+
locale: getLocale(),
|
|
97
|
+
fallbackLocale: "zh-CN",
|
|
98
|
+
messages: {
|
|
99
|
+
"en-US": enUs,
|
|
100
|
+
"zh-CN": zhCn,
|
|
101
|
+
},
|
|
102
|
+
legacy: false, // 使用 Composition API 模式
|
|
103
|
+
warnHtmlInMessage: "off",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export default {
|
|
107
|
+
name: "PaymentComponent",
|
|
108
|
+
components: {
|
|
109
|
+
QrcodeVue,
|
|
110
|
+
},
|
|
111
|
+
emits: ["close", "success", "payment-type-change", "error"],
|
|
112
|
+
props: {
|
|
113
|
+
// ===== API 配置 =====
|
|
114
|
+
api: {
|
|
115
|
+
type: Object,
|
|
116
|
+
required: true,
|
|
117
|
+
validator: (value) => {
|
|
118
|
+
return (
|
|
119
|
+
typeof value.createOrder === "function" &&
|
|
120
|
+
typeof value.getOrderStatus === "function" &&
|
|
121
|
+
typeof value.getPaymentQRCode === "function" &&
|
|
122
|
+
typeof value.queryPaymentStatus === "function"
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
// ===== 订单参数 =====
|
|
128
|
+
orderParams: {
|
|
129
|
+
type: Object,
|
|
130
|
+
required: true,
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// ===== 默认支付方式 =====
|
|
134
|
+
defaultPaymentType: {
|
|
135
|
+
type: String,
|
|
136
|
+
default: "wepay",
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// ===== 自动开始 =====
|
|
140
|
+
autoStart: {
|
|
141
|
+
type: Boolean,
|
|
142
|
+
default: false,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
data() {
|
|
146
|
+
return {
|
|
147
|
+
// 支付方式配置
|
|
148
|
+
paymentMethods: [
|
|
149
|
+
{
|
|
150
|
+
value: "wepay",
|
|
151
|
+
label: payI18n.global.t("pay.wechat"),
|
|
152
|
+
icon: "fab fa-weixin text-emerald-500",
|
|
153
|
+
activeClass: "text-emerald-500",
|
|
154
|
+
customClass: "wechat",
|
|
155
|
+
channel: "wepay",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
value: "alipay",
|
|
159
|
+
label: payI18n.global.t("pay.alipay"),
|
|
160
|
+
icon: "fab fa-alipay text-blue-500",
|
|
161
|
+
activeClass: "text-blue-500",
|
|
162
|
+
customClass: "alipay",
|
|
163
|
+
channel: {
|
|
164
|
+
mobile: "alipay_wap",
|
|
165
|
+
pc: "alipay_pc",
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
|
|
170
|
+
// 文本配置
|
|
171
|
+
texts: {
|
|
172
|
+
createOrderFailed: payI18n.global.t("pay.createOrderFailed"),
|
|
173
|
+
orderTimeout: payI18n.global.t("pay.orderTimeout"),
|
|
174
|
+
orderFailed: payI18n.global.t("pay.orderFailed"),
|
|
175
|
+
getQrcodeFailed: payI18n.global.t("pay.getQrcodeFailed"),
|
|
176
|
+
paymentTimeout: payI18n.global.t("pay.paymentTimeout"),
|
|
177
|
+
paymentFailed: payI18n.global.t("pay.paymentFailed"),
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// 轮询配置
|
|
181
|
+
pollingConfig: {
|
|
182
|
+
orderInterval: 2000, // 每次轮询订单状态的间隔(毫秒),2000ms = 2 秒
|
|
183
|
+
paymentInterval: 3000, // 每次轮询支付状态的间隔(毫秒),3000ms = 3 秒
|
|
184
|
+
maxRetries: 60, // 最多轮询次数,超过后视为超时/失败
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
// 订单和支付信息
|
|
188
|
+
pendingOrderId: null,
|
|
189
|
+
paymentId: null,
|
|
190
|
+
price: null,
|
|
191
|
+
activeMethod: this.defaultPaymentType,
|
|
192
|
+
qrcode: null,
|
|
193
|
+
longUrl: null,
|
|
194
|
+
skipUrl: null,
|
|
195
|
+
paymentSuccess: false,
|
|
196
|
+
|
|
197
|
+
// UI 状态
|
|
198
|
+
loading: false,
|
|
199
|
+
errorMsg: "",
|
|
200
|
+
warningVisible: false,
|
|
201
|
+
checking: false,
|
|
202
|
+
|
|
203
|
+
// 轮询定时器
|
|
204
|
+
orderPollingTimer: null,
|
|
205
|
+
paymentPollingTimer: null,
|
|
206
|
+
orderPollingRetries: 0,
|
|
207
|
+
paymentPollingRetries: 0,
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
computed: {
|
|
211
|
+
isMobile() {
|
|
212
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
currentPaymentMethod() {
|
|
216
|
+
return this.paymentMethods.find((m) => m.value === this.activeMethod);
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
actualPayChannel() {
|
|
220
|
+
const method = this.currentPaymentMethod;
|
|
221
|
+
if (!method) return this.activeMethod;
|
|
222
|
+
|
|
223
|
+
if (typeof method.channel === "string") {
|
|
224
|
+
return method.channel;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (typeof method.channel === "object") {
|
|
228
|
+
return this.isMobile ? method.channel.mobile : method.channel.pc;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return this.activeMethod;
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
qrcodeUrl() {
|
|
235
|
+
return this.qrcode || this.longUrl || null;
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
watch: {
|
|
239
|
+
defaultPaymentType: {
|
|
240
|
+
handler(val) {
|
|
241
|
+
this.activeMethod = val;
|
|
242
|
+
},
|
|
243
|
+
immediate: true,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
mounted() {
|
|
247
|
+
if (this.autoStart) {
|
|
248
|
+
this.startPaymentProcess();
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
beforeUnmount() {
|
|
252
|
+
this.clearAllTimers();
|
|
253
|
+
},
|
|
254
|
+
methods: {
|
|
255
|
+
// ===== 公共方法 =====
|
|
256
|
+
// 翻译函数
|
|
257
|
+
t(key) {
|
|
258
|
+
return payI18n.global.t(key);
|
|
259
|
+
},
|
|
260
|
+
async startPaymentProcess() {
|
|
261
|
+
this.loading = true;
|
|
262
|
+
this.errorMsg = "";
|
|
263
|
+
await this.createOrder();
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
async switchPay(method) {
|
|
267
|
+
if (this.activeMethod === method) return;
|
|
268
|
+
|
|
269
|
+
this.activeMethod = method;
|
|
270
|
+
this.errorMsg = "";
|
|
271
|
+
this.$emit("payment-type-change", method);
|
|
272
|
+
|
|
273
|
+
if (this.paymentId) {
|
|
274
|
+
await this.getPaymentQrcode();
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
resetPaymentState() {
|
|
279
|
+
this.pendingOrderId = null;
|
|
280
|
+
this.paymentId = null;
|
|
281
|
+
this.price = null;
|
|
282
|
+
this.qrcode = null;
|
|
283
|
+
this.longUrl = null;
|
|
284
|
+
this.skipUrl = null;
|
|
285
|
+
this.paymentSuccess = false;
|
|
286
|
+
this.loading = false;
|
|
287
|
+
this.errorMsg = "";
|
|
288
|
+
this.warningVisible = false;
|
|
289
|
+
this.orderPollingRetries = 0;
|
|
290
|
+
this.paymentPollingRetries = 0;
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
// ===== 支付流程 =====
|
|
294
|
+
async createOrder() {
|
|
295
|
+
try {
|
|
296
|
+
const res = await this.api.createOrder(this.orderParams);
|
|
297
|
+
if (res && res.id) {
|
|
298
|
+
this.pendingOrderId = res.id;
|
|
299
|
+
this.startOrderPolling();
|
|
300
|
+
} else {
|
|
301
|
+
throw new Error(this.texts.createOrderFailed);
|
|
302
|
+
}
|
|
303
|
+
} catch (err) {
|
|
304
|
+
this.handleError(this.texts.createOrderFailed, err);
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
startOrderPolling() {
|
|
308
|
+
this.orderPollingRetries = 0;
|
|
309
|
+
|
|
310
|
+
this.orderPollingTimer = setInterval(async () => {
|
|
311
|
+
try {
|
|
312
|
+
this.orderPollingRetries++;
|
|
313
|
+
|
|
314
|
+
if (this.orderPollingRetries > this.pollingConfig.maxRetries) {
|
|
315
|
+
this.clearTimer("order");
|
|
316
|
+
this.handleError(this.texts.orderTimeout);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const response = await this.api.getOrderStatus(this.pendingOrderId);
|
|
321
|
+
|
|
322
|
+
if (response && response.status === 2) {
|
|
323
|
+
this.clearTimer("order");
|
|
324
|
+
this.paymentId = response.payment_id;
|
|
325
|
+
this.price = response.total_amount;
|
|
326
|
+
await this.getPaymentQrcode();
|
|
327
|
+
} else if (response && response.status === -1) {
|
|
328
|
+
this.clearTimer("order");
|
|
329
|
+
this.handleError(response.message || this.texts.orderFailed);
|
|
330
|
+
}
|
|
331
|
+
} catch (err) {
|
|
332
|
+
console.error("Failed to poll order status:", err);
|
|
333
|
+
}
|
|
334
|
+
}, this.pollingConfig.orderInterval);
|
|
335
|
+
},
|
|
336
|
+
async getPaymentQrcode() {
|
|
337
|
+
if (!this.paymentId) return;
|
|
338
|
+
|
|
339
|
+
this.loading = true;
|
|
340
|
+
this.errorMsg = "";
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
const QR_PAY_MODE_ALIPAY_PC = 4;
|
|
344
|
+
const params = {};
|
|
345
|
+
if (this.actualPayChannel === "alipay_pc") {
|
|
346
|
+
params.qr_pay_mode = QR_PAY_MODE_ALIPAY_PC;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const response = await this.api.getPaymentQRCode(this.paymentId, this.actualPayChannel, params);
|
|
350
|
+
|
|
351
|
+
if (response) {
|
|
352
|
+
this.qrcode = response.qrcode || response;
|
|
353
|
+
this.longUrl = response.long_url || response.longUrl;
|
|
354
|
+
this.skipUrl = response.skip_url || response.skipUrl;
|
|
355
|
+
this.loading = false;
|
|
356
|
+
|
|
357
|
+
if (!this.paymentPollingTimer) {
|
|
358
|
+
this.startPaymentPolling();
|
|
359
|
+
}
|
|
360
|
+
} else {
|
|
361
|
+
throw new Error(this.texts.getQrcodeFailed);
|
|
362
|
+
}
|
|
363
|
+
} catch (err) {
|
|
364
|
+
this.handleError(this.texts.getQrcodeFailed, err);
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
|
|
368
|
+
startPaymentPolling() {
|
|
369
|
+
this.paymentPollingRetries = 0;
|
|
370
|
+
|
|
371
|
+
this.paymentPollingTimer = setInterval(async () => {
|
|
372
|
+
try {
|
|
373
|
+
this.paymentPollingRetries++;
|
|
374
|
+
|
|
375
|
+
if (this.paymentPollingRetries > this.pollingConfig.maxRetries) {
|
|
376
|
+
this.clearTimer("payment");
|
|
377
|
+
this.warningVisible = true;
|
|
378
|
+
this.handleError(this.texts.paymentTimeout);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const response = await this.api.queryPaymentStatus(this.paymentId);
|
|
383
|
+
|
|
384
|
+
if (response && response.status === 1) {
|
|
385
|
+
this.clearTimer("payment");
|
|
386
|
+
this.paymentSuccess = true;
|
|
387
|
+
setTimeout(() => {
|
|
388
|
+
this.$emit("success", {
|
|
389
|
+
paymentId: this.paymentId,
|
|
390
|
+
orderId: this.pendingOrderId,
|
|
391
|
+
});
|
|
392
|
+
}, 500);
|
|
393
|
+
} else if (response && response.status === "failed") {
|
|
394
|
+
this.clearTimer("payment");
|
|
395
|
+
this.warningVisible = true;
|
|
396
|
+
this.handleError(this.texts.paymentFailed);
|
|
397
|
+
}
|
|
398
|
+
} catch (err) {
|
|
399
|
+
console.error("Failed to poll payment status:", err);
|
|
400
|
+
}
|
|
401
|
+
}, this.pollingConfig.paymentInterval);
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
// ===== 工具方法 =====
|
|
405
|
+
handleError(message, error) {
|
|
406
|
+
this.loading = false;
|
|
407
|
+
this.errorMsg = message;
|
|
408
|
+
this.$emit("error", { message, error });
|
|
409
|
+
if (error) {
|
|
410
|
+
console.error(message, error);
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
clearTimer(type) {
|
|
415
|
+
if (type === "order" && this.orderPollingTimer) {
|
|
416
|
+
clearInterval(this.orderPollingTimer);
|
|
417
|
+
this.orderPollingTimer = null;
|
|
418
|
+
} else if (type === "payment" && this.paymentPollingTimer) {
|
|
419
|
+
clearInterval(this.paymentPollingTimer);
|
|
420
|
+
this.paymentPollingTimer = null;
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
clearAllTimers() {
|
|
425
|
+
this.clearTimer("order");
|
|
426
|
+
this.clearTimer("payment");
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
</script>
|
|
431
|
+
|
|
432
|
+
<style lang="less">
|
|
433
|
+
.c-payment-component {
|
|
434
|
+
// max-width: 28rem;
|
|
435
|
+
flex: 1;
|
|
436
|
+
width: 100%;
|
|
437
|
+
background-color: #12141a;
|
|
438
|
+
color: white;
|
|
439
|
+
// border-radius: 1rem;
|
|
440
|
+
padding: 2rem;
|
|
441
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
442
|
+
border: 1px solid rgb(31 41 55);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.c-payment__header {
|
|
446
|
+
text-align: center;
|
|
447
|
+
margin-top: 2rem;
|
|
448
|
+
margin-bottom: 2rem;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.payment-methods-grid {
|
|
452
|
+
display: grid;
|
|
453
|
+
grid-template-columns: repeat(2, 1fr);
|
|
454
|
+
gap: 1rem;
|
|
455
|
+
margin-bottom: 2rem;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.pay-method-btn {
|
|
459
|
+
border-radius: 1rem;
|
|
460
|
+
padding: 1rem;
|
|
461
|
+
display: flex;
|
|
462
|
+
flex-direction: column;
|
|
463
|
+
align-items: center;
|
|
464
|
+
gap: 0.5rem;
|
|
465
|
+
cursor: pointer;
|
|
466
|
+
border: 2px solid rgba(255, 255, 255, 0.05);
|
|
467
|
+
transition: all 0.3s;
|
|
468
|
+
background: transparent;
|
|
469
|
+
|
|
470
|
+
.method-icon {
|
|
471
|
+
font-size: 1.5rem;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.method-label {
|
|
475
|
+
font-size: 0.75rem;
|
|
476
|
+
font-weight: 500;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.pay-method-btn.active.wechat {
|
|
481
|
+
border-color: #10b981;
|
|
482
|
+
background: rgba(16, 185, 129, 0.05);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.pay-method-btn.active.alipay {
|
|
486
|
+
border-color: #3b82f6;
|
|
487
|
+
background: rgba(59, 130, 246, 0.05);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
.qrcode-container {
|
|
491
|
+
display: flex;
|
|
492
|
+
flex-direction: column;
|
|
493
|
+
align-items: center;
|
|
494
|
+
justify-content: center;
|
|
495
|
+
position: relative;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.qr-wrapper {
|
|
499
|
+
background: white;
|
|
500
|
+
padding: 12px;
|
|
501
|
+
border-radius: 24px;
|
|
502
|
+
position: relative;
|
|
503
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.qrcode-box {
|
|
507
|
+
width: 11rem;
|
|
508
|
+
height: 11rem;
|
|
509
|
+
background-color: #f9fafb;
|
|
510
|
+
border-radius: 0.75rem;
|
|
511
|
+
display: flex;
|
|
512
|
+
align-items: center;
|
|
513
|
+
justify-content: center;
|
|
514
|
+
padding: 0.5rem;
|
|
515
|
+
position: relative;
|
|
516
|
+
overflow: hidden;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.loading-overlay {
|
|
520
|
+
position: absolute;
|
|
521
|
+
top: 0;
|
|
522
|
+
right: 0;
|
|
523
|
+
bottom: 0;
|
|
524
|
+
left: 0;
|
|
525
|
+
display: flex;
|
|
526
|
+
align-items: center;
|
|
527
|
+
justify-content: center;
|
|
528
|
+
background-color: white;
|
|
529
|
+
border-radius: 0.75rem;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
.loading-icon {
|
|
533
|
+
font-size: 1.875rem;
|
|
534
|
+
color: #9ca3af;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.qrcode-image {
|
|
538
|
+
width: 100%;
|
|
539
|
+
height: 100%;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.placeholder-icon {
|
|
543
|
+
font-size: 4.5rem;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.secure-badge {
|
|
547
|
+
margin-top: 1.5rem;
|
|
548
|
+
display: flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
gap: 0.5rem;
|
|
551
|
+
color: #9ca3af;
|
|
552
|
+
font-size: 0.75rem;
|
|
553
|
+
background-color: rgba(255, 255, 255, 0.05);
|
|
554
|
+
padding: 0.5rem 1rem;
|
|
555
|
+
border-radius: 9999px;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.secure-icon {
|
|
559
|
+
color: #10b981;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.error-message {
|
|
563
|
+
margin-top: 1rem;
|
|
564
|
+
color: #f87171;
|
|
565
|
+
font-size: 0.75rem;
|
|
566
|
+
text-align: center;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.footer-slot {
|
|
570
|
+
margin-top: 2rem;
|
|
571
|
+
text-align: center;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.m-purchase-pay-main {
|
|
575
|
+
/* 左侧特权侧边栏 - 增加了图片背景风格 */
|
|
576
|
+
.modal-sidebar {
|
|
577
|
+
width: 35%;
|
|
578
|
+
position: relative;
|
|
579
|
+
padding: 40px 30px;
|
|
580
|
+
border-right: 1px solid rgba(255, 255, 255, 0.05);
|
|
581
|
+
overflow: hidden;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/* 背景压暗与渐变层 */
|
|
585
|
+
.modal-sidebar::before {
|
|
586
|
+
content: "";
|
|
587
|
+
position: absolute;
|
|
588
|
+
inset: 0;
|
|
589
|
+
background: linear-gradient(180deg, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
|
|
590
|
+
z-index: 1;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.modal-sidebar > * {
|
|
594
|
+
position: relative;
|
|
595
|
+
z-index: 2;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/* 右侧支付主区 */
|
|
599
|
+
.modal-main {
|
|
600
|
+
width: 65%;
|
|
601
|
+
padding: 40px;
|
|
602
|
+
background: #0f172a;
|
|
603
|
+
position: relative;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
.badge-discount {
|
|
607
|
+
position: absolute;
|
|
608
|
+
top: -10px;
|
|
609
|
+
right: -10px;
|
|
610
|
+
background: #ef4444;
|
|
611
|
+
color: white;
|
|
612
|
+
padding: 4px 10px;
|
|
613
|
+
border-radius: 10px;
|
|
614
|
+
font-size: 10px;
|
|
615
|
+
font-weight: 800;
|
|
616
|
+
transform: rotate(10deg);
|
|
617
|
+
box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
|
|
618
|
+
animation: pulse 2s infinite;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.u-title {
|
|
622
|
+
color: #6a7282;
|
|
623
|
+
}
|
|
624
|
+
.m-purchase-feature-list {
|
|
625
|
+
.u-icon {
|
|
626
|
+
.size(32px);
|
|
627
|
+
flex-shrink: 0;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
.u-avatar {
|
|
631
|
+
.size(24px);
|
|
632
|
+
overflow: hidden;
|
|
633
|
+
.r(50%);
|
|
634
|
+
}
|
|
635
|
+
.u-mode {
|
|
636
|
+
// background: rgba(255, 255, 255, 0.1);
|
|
637
|
+
background-color: @primary;
|
|
638
|
+
color: #fff;
|
|
639
|
+
font-size: 10px;
|
|
640
|
+
font-weight: 600;
|
|
641
|
+
padding: 2px 6px;
|
|
642
|
+
border-radius: 8px;
|
|
643
|
+
margin-left: 8px;
|
|
644
|
+
vertical-align: middle;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
@keyframes pulse {
|
|
648
|
+
0%,
|
|
649
|
+
100% {
|
|
650
|
+
transform: rotate(10deg) scale(1);
|
|
651
|
+
}
|
|
652
|
+
50% {
|
|
653
|
+
transform: rotate(10deg) scale(1.1);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
@media (max-width: 640px) {
|
|
658
|
+
.modal-container {
|
|
659
|
+
flex-direction: column;
|
|
660
|
+
}
|
|
661
|
+
.modal-sidebar {
|
|
662
|
+
width: 100%;
|
|
663
|
+
padding: 20px;
|
|
664
|
+
}
|
|
665
|
+
.modal-main {
|
|
666
|
+
width: 100%;
|
|
667
|
+
padding: 20px;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/* 如果需要微调动画,可以在这里添加 */
|
|
673
|
+
.fade-enter-active,
|
|
674
|
+
.fade-leave-active {
|
|
675
|
+
transition: opacity 0.3s ease;
|
|
676
|
+
}
|
|
677
|
+
.fade-enter-from,
|
|
678
|
+
.fade-leave-to {
|
|
679
|
+
opacity: 0;
|
|
680
|
+
}
|
|
681
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
pay: {
|
|
3
|
+
wechat: "WeChat Pay",
|
|
4
|
+
alipay: "Alipay",
|
|
5
|
+
secureChannel: "Official Encrypted Payment Channel, Active Immediately",
|
|
6
|
+
|
|
7
|
+
createOrderFailed: "Failed to create order, please try again",
|
|
8
|
+
orderTimeout: "Order processing timed out, please refresh and try again",
|
|
9
|
+
orderFailed: "Order processing failed, please try again",
|
|
10
|
+
getQrcodeFailed: "Failed to get payment QR code, please try again",
|
|
11
|
+
paymentTimeout: "Payment timed out, please contact customer service if you have paid",
|
|
12
|
+
paymentFailed: "Payment failed, please try again",
|
|
13
|
+
},
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
pay: {
|
|
3
|
+
wechat: "微信支付",
|
|
4
|
+
alipay: "支付宝",
|
|
5
|
+
secureChannel: "官方加密支付通道,即开即用",
|
|
6
|
+
|
|
7
|
+
createOrderFailed: "创建订单失败,请重试",
|
|
8
|
+
orderTimeout: "订单处理超时,请刷新重试",
|
|
9
|
+
orderFailed: "订单处理失败,请重试",
|
|
10
|
+
getQrcodeFailed: "获取支付二维码失败,请重试",
|
|
11
|
+
paymentTimeout: "支付超时,如已支付请联系客服",
|
|
12
|
+
paymentFailed: "支付失败,请重试",
|
|
13
|
+
},
|
|
14
|
+
}
|
package/vite.config.js
CHANGED
|
@@ -8,13 +8,13 @@ export default defineConfig({
|
|
|
8
8
|
plugins: [vue(), svgLoader(), vitePluginRequire.default()],
|
|
9
9
|
server: {
|
|
10
10
|
proxy: {
|
|
11
|
-
|
|
12
|
-
target:
|
|
11
|
+
"/api": {
|
|
12
|
+
target: "https://pay.dpying.com",
|
|
13
13
|
changeOrigin: true,
|
|
14
14
|
secure: false,
|
|
15
15
|
// 不需要 rewrite,保持完整路径
|
|
16
|
-
}
|
|
17
|
-
}
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
18
|
},
|
|
19
19
|
css: {
|
|
20
20
|
preprocessorOptions: {
|