@2kog/pkg-widget 0.1.18 → 0.1.20
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 +1 -1
- package/src/App.vue +17 -11
- package/src/components/common/payment.vue +75 -26
- package/src/locale/en-us/payment.js +4 -2
- package/src/locale/zh-cn/payment.js +3 -2
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -3,21 +3,27 @@
|
|
|
3
3
|
<h1>IRuxu Pkg Widget</h1>
|
|
4
4
|
<Logo></Logo>
|
|
5
5
|
|
|
6
|
-
<UploadImage
|
|
6
|
+
<UploadImage
|
|
7
|
+
:upload-fn="uploadImage"
|
|
8
|
+
:domain="domain"
|
|
9
|
+
:url="avatar"
|
|
10
|
+
></UploadImage>
|
|
7
11
|
|
|
8
|
-
<langSelect
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
<langSelect
|
|
13
|
+
:show-flag="false"
|
|
14
|
+
:show-name="true"
|
|
15
|
+
:optionsWithFlag="false"
|
|
16
|
+
></langSelect>
|
|
11
17
|
<pay></pay>
|
|
12
18
|
|
|
13
|
-
<payment term-link="/
|
|
19
|
+
<payment term-link="/doc/terms"></payment>
|
|
14
20
|
</div>
|
|
15
21
|
</template>
|
|
16
22
|
|
|
17
23
|
<script>
|
|
18
24
|
import Logo from "./components/common/logo.vue";
|
|
19
25
|
import UploadImage from "./components/common/upload-image.vue";
|
|
20
|
-
import {upload} from "./assets/data/upload";
|
|
26
|
+
import { upload } from "./assets/data/upload";
|
|
21
27
|
import langSelect from "./components/common/lang-select.vue";
|
|
22
28
|
import pay from "./demo/pay-dialog-demo.vue";
|
|
23
29
|
import payment from "./components/common/payment.vue";
|
|
@@ -28,7 +34,7 @@ export default {
|
|
|
28
34
|
UploadImage,
|
|
29
35
|
langSelect,
|
|
30
36
|
pay,
|
|
31
|
-
payment
|
|
37
|
+
payment,
|
|
32
38
|
},
|
|
33
39
|
data() {
|
|
34
40
|
return {
|
|
@@ -38,14 +44,14 @@ export default {
|
|
|
38
44
|
domain: "https://cdn.iruxu.com/",
|
|
39
45
|
avatar: "user/avatar/2024/11/27/81348085.jpeg",
|
|
40
46
|
|
|
41
|
-
show: true
|
|
47
|
+
show: true,
|
|
42
48
|
};
|
|
43
49
|
},
|
|
44
50
|
methods: {
|
|
45
51
|
uploadImage(file) {
|
|
46
|
-
return upload(file)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
52
|
+
return upload(file);
|
|
53
|
+
},
|
|
54
|
+
},
|
|
49
55
|
};
|
|
50
56
|
</script>
|
|
51
57
|
|
|
@@ -8,14 +8,21 @@
|
|
|
8
8
|
<div class="modal-main m-purchase-pay-main">
|
|
9
9
|
<!-- 支付方式切换 -->
|
|
10
10
|
<div class="payment-methods-grid">
|
|
11
|
-
<slot
|
|
11
|
+
<slot
|
|
12
|
+
name="payment-methods"
|
|
13
|
+
:methods="paymentMethods"
|
|
14
|
+
:active="activeMethod"
|
|
15
|
+
:switch="switchPay"
|
|
16
|
+
>
|
|
12
17
|
<button
|
|
13
18
|
v-for="method in paymentMethods"
|
|
14
19
|
:key="method.value"
|
|
15
20
|
@click="switchPay(method.value)"
|
|
16
21
|
class="pay-method-btn"
|
|
17
22
|
:class="[
|
|
18
|
-
activeMethod === method.value
|
|
23
|
+
activeMethod === method.value
|
|
24
|
+
? 'active ' + method.activeClass
|
|
25
|
+
: '',
|
|
19
26
|
method.customClass || '',
|
|
20
27
|
]"
|
|
21
28
|
>
|
|
@@ -33,7 +40,9 @@
|
|
|
33
40
|
<!-- Loading 状态 -->
|
|
34
41
|
<div v-if="loading" class="loading-overlay">
|
|
35
42
|
<slot name="loading">
|
|
36
|
-
<i
|
|
43
|
+
<i
|
|
44
|
+
class="fas fa-spinner fa-spin loading-icon"
|
|
45
|
+
></i>
|
|
37
46
|
</slot>
|
|
38
47
|
</div>
|
|
39
48
|
|
|
@@ -47,17 +56,28 @@
|
|
|
47
56
|
/>
|
|
48
57
|
|
|
49
58
|
<!-- 默认图标 -->
|
|
50
|
-
<slot
|
|
59
|
+
<slot
|
|
60
|
+
v-else
|
|
61
|
+
name="placeholder"
|
|
62
|
+
:activeMethod="activeMethod"
|
|
63
|
+
>
|
|
51
64
|
<i
|
|
52
65
|
class="placeholder-icon"
|
|
53
|
-
:class="
|
|
66
|
+
:class="
|
|
67
|
+
currentPaymentMethod?.icon ||
|
|
68
|
+
'fas fa-qrcode'
|
|
69
|
+
"
|
|
54
70
|
></i>
|
|
55
71
|
</slot>
|
|
56
72
|
</div>
|
|
57
73
|
</div>
|
|
58
74
|
<div class="secure-badge">
|
|
59
75
|
<i class="fas fa-qrcode"></i>
|
|
60
|
-
<span>{{
|
|
76
|
+
<span>{{
|
|
77
|
+
t(
|
|
78
|
+
`pay.${activeMethod === "wepay" ? "wechatScan" : "alipayScan"}`,
|
|
79
|
+
)
|
|
80
|
+
}}</span>
|
|
61
81
|
</div>
|
|
62
82
|
|
|
63
83
|
<!-- 错误提示 -->
|
|
@@ -73,7 +93,16 @@
|
|
|
73
93
|
<slot name="footer" :texts="texts">
|
|
74
94
|
<div class="m-agreement">
|
|
75
95
|
<i class="fas fa-shield-halved agreement-icon"></i>
|
|
76
|
-
<span class="agreement-text"
|
|
96
|
+
<span class="agreement-text">
|
|
97
|
+
{{ t("pay.agreement_prefix") }}
|
|
98
|
+
<a
|
|
99
|
+
class="u-link"
|
|
100
|
+
:href="termLink"
|
|
101
|
+
target="_blank"
|
|
102
|
+
>{{ t("pay.agreement_link") }}</a
|
|
103
|
+
>
|
|
104
|
+
{{ t("pay.agreement_suffix") }}
|
|
105
|
+
</span>
|
|
77
106
|
</div>
|
|
78
107
|
</slot>
|
|
79
108
|
</div>
|
|
@@ -89,13 +118,13 @@ import zhCn from "../../locale/zh-cn/payment";
|
|
|
89
118
|
|
|
90
119
|
// 创建独立的 i18n 实例
|
|
91
120
|
const getLocale = () => {
|
|
92
|
-
const storedLanguage = localStorage.getItem(
|
|
121
|
+
const storedLanguage = localStorage.getItem("lang");
|
|
93
122
|
if (!storedLanguage) {
|
|
94
123
|
return navigator.language;
|
|
95
124
|
} else {
|
|
96
125
|
return storedLanguage;
|
|
97
126
|
}
|
|
98
|
-
}
|
|
127
|
+
};
|
|
99
128
|
|
|
100
129
|
const payI18n = createI18n({
|
|
101
130
|
locale: getLocale(),
|
|
@@ -148,7 +177,7 @@ export default {
|
|
|
148
177
|
},
|
|
149
178
|
termLink: {
|
|
150
179
|
type: String,
|
|
151
|
-
default: "/
|
|
180
|
+
default: "/doc/terms",
|
|
152
181
|
},
|
|
153
182
|
},
|
|
154
183
|
data() {
|
|
@@ -218,11 +247,15 @@ export default {
|
|
|
218
247
|
},
|
|
219
248
|
computed: {
|
|
220
249
|
isMobile() {
|
|
221
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
250
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
251
|
+
navigator.userAgent,
|
|
252
|
+
);
|
|
222
253
|
},
|
|
223
254
|
|
|
224
255
|
currentPaymentMethod() {
|
|
225
|
-
return this.paymentMethods.find(
|
|
256
|
+
return this.paymentMethods.find(
|
|
257
|
+
(m) => m.value === this.activeMethod,
|
|
258
|
+
);
|
|
226
259
|
},
|
|
227
260
|
|
|
228
261
|
actualPayChannel() {
|
|
@@ -234,7 +267,9 @@ export default {
|
|
|
234
267
|
}
|
|
235
268
|
|
|
236
269
|
if (typeof method.channel === "object") {
|
|
237
|
-
return this.isMobile
|
|
270
|
+
return this.isMobile
|
|
271
|
+
? method.channel.mobile
|
|
272
|
+
: method.channel.pc;
|
|
238
273
|
}
|
|
239
274
|
|
|
240
275
|
return this.activeMethod;
|
|
@@ -320,13 +355,17 @@ export default {
|
|
|
320
355
|
try {
|
|
321
356
|
this.orderPollingRetries++;
|
|
322
357
|
|
|
323
|
-
if (
|
|
358
|
+
if (
|
|
359
|
+
this.orderPollingRetries > this.pollingConfig.maxRetries
|
|
360
|
+
) {
|
|
324
361
|
this.clearTimer("order");
|
|
325
362
|
this.handleError(this.texts.orderTimeout);
|
|
326
363
|
return;
|
|
327
364
|
}
|
|
328
365
|
|
|
329
|
-
const response = await this.api.getOrderStatus(
|
|
366
|
+
const response = await this.api.getOrderStatus(
|
|
367
|
+
this.pendingOrderId,
|
|
368
|
+
);
|
|
330
369
|
|
|
331
370
|
if (response && response.status === 2) {
|
|
332
371
|
this.clearTimer("order");
|
|
@@ -335,7 +374,9 @@ export default {
|
|
|
335
374
|
await this.getPaymentQrcode();
|
|
336
375
|
} else if (response && response.status === -1) {
|
|
337
376
|
this.clearTimer("order");
|
|
338
|
-
this.handleError(
|
|
377
|
+
this.handleError(
|
|
378
|
+
response.message || this.texts.orderFailed,
|
|
379
|
+
);
|
|
339
380
|
}
|
|
340
381
|
} catch (err) {
|
|
341
382
|
console.error("Failed to poll order status:", err);
|
|
@@ -355,7 +396,11 @@ export default {
|
|
|
355
396
|
params.qr_pay_mode = QR_PAY_MODE_ALIPAY_PC;
|
|
356
397
|
}
|
|
357
398
|
|
|
358
|
-
const response = await this.api.getPaymentQRCode(
|
|
399
|
+
const response = await this.api.getPaymentQRCode(
|
|
400
|
+
this.paymentId,
|
|
401
|
+
this.actualPayChannel,
|
|
402
|
+
params,
|
|
403
|
+
);
|
|
359
404
|
|
|
360
405
|
if (response) {
|
|
361
406
|
this.qrcode = response.qrcode || response;
|
|
@@ -381,14 +426,19 @@ export default {
|
|
|
381
426
|
try {
|
|
382
427
|
this.paymentPollingRetries++;
|
|
383
428
|
|
|
384
|
-
if (
|
|
429
|
+
if (
|
|
430
|
+
this.paymentPollingRetries >
|
|
431
|
+
this.pollingConfig.maxRetries
|
|
432
|
+
) {
|
|
385
433
|
this.clearTimer("payment");
|
|
386
434
|
this.warningVisible = true;
|
|
387
435
|
this.handleError(this.texts.paymentTimeout);
|
|
388
436
|
return;
|
|
389
437
|
}
|
|
390
438
|
|
|
391
|
-
const response = await this.api.queryPaymentStatus(
|
|
439
|
+
const response = await this.api.queryPaymentStatus(
|
|
440
|
+
this.paymentId,
|
|
441
|
+
);
|
|
392
442
|
|
|
393
443
|
if (response && response.status === 1) {
|
|
394
444
|
this.clearTimer("payment");
|
|
@@ -473,15 +523,11 @@ export default {
|
|
|
473
523
|
text-align: left;
|
|
474
524
|
|
|
475
525
|
.u-link {
|
|
476
|
-
color: #
|
|
526
|
+
color: #6777ef;
|
|
477
527
|
font-weight: 600;
|
|
478
528
|
cursor: pointer;
|
|
479
529
|
text-decoration: underline;
|
|
480
530
|
text-underline-offset: 2px;
|
|
481
|
-
|
|
482
|
-
&:hover {
|
|
483
|
-
color: #2563eb;
|
|
484
|
-
}
|
|
485
531
|
}
|
|
486
532
|
}
|
|
487
533
|
}
|
|
@@ -520,7 +566,6 @@ export default {
|
|
|
520
566
|
font-size: 0.75rem;
|
|
521
567
|
font-weight: 500;
|
|
522
568
|
}
|
|
523
|
-
|
|
524
569
|
}
|
|
525
570
|
.wepay-icon {
|
|
526
571
|
color: #10b981;
|
|
@@ -639,7 +684,11 @@ export default {
|
|
|
639
684
|
content: "";
|
|
640
685
|
position: absolute;
|
|
641
686
|
inset: 0;
|
|
642
|
-
background: linear-gradient(
|
|
687
|
+
background: linear-gradient(
|
|
688
|
+
180deg,
|
|
689
|
+
rgba(15, 23, 42, 0.85) 0%,
|
|
690
|
+
rgba(15, 23, 42, 0.95) 100%
|
|
691
|
+
);
|
|
643
692
|
z-index: 1;
|
|
644
693
|
}
|
|
645
694
|
|
|
@@ -14,7 +14,9 @@ export default {
|
|
|
14
14
|
paymentTimeout:
|
|
15
15
|
"Payment timed out, please contact customer service if you have paid",
|
|
16
16
|
paymentFailed: "Payment failed, please try again",
|
|
17
|
-
agreement
|
|
18
|
-
|
|
17
|
+
agreement_prefix: "Payment signifies agreement to the",
|
|
18
|
+
agreement_link: "Service Terms",
|
|
19
|
+
agreement_suffix:
|
|
20
|
+
", Virtual services are not eligible for 7-day unconditional refunds.",
|
|
19
21
|
},
|
|
20
22
|
};
|
|
@@ -12,7 +12,8 @@ export default {
|
|
|
12
12
|
getQrcodeFailed: "获取支付二维码失败,请重试",
|
|
13
13
|
paymentTimeout: "支付超时,如已支付请联系客服",
|
|
14
14
|
paymentFailed: "支付失败,请重试",
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
agreement_prefix: "支付即视为同意",
|
|
16
|
+
agreement_link: "服务条款",
|
|
17
|
+
agreement_suffix: ",虚拟服务不支持7天无理由退款",
|
|
17
18
|
},
|
|
18
19
|
};
|