@2kog/pkg-widget 0.1.18 → 0.1.19
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 +72 -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,13 @@
|
|
|
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 class="u-link" :href="termLink">{{
|
|
99
|
+
t("pay.agreement_link")
|
|
100
|
+
}}</a>
|
|
101
|
+
{{ t("pay.agreement_suffix") }}
|
|
102
|
+
</span>
|
|
77
103
|
</div>
|
|
78
104
|
</slot>
|
|
79
105
|
</div>
|
|
@@ -89,13 +115,13 @@ import zhCn from "../../locale/zh-cn/payment";
|
|
|
89
115
|
|
|
90
116
|
// 创建独立的 i18n 实例
|
|
91
117
|
const getLocale = () => {
|
|
92
|
-
const storedLanguage = localStorage.getItem(
|
|
118
|
+
const storedLanguage = localStorage.getItem("lang");
|
|
93
119
|
if (!storedLanguage) {
|
|
94
120
|
return navigator.language;
|
|
95
121
|
} else {
|
|
96
122
|
return storedLanguage;
|
|
97
123
|
}
|
|
98
|
-
}
|
|
124
|
+
};
|
|
99
125
|
|
|
100
126
|
const payI18n = createI18n({
|
|
101
127
|
locale: getLocale(),
|
|
@@ -148,7 +174,7 @@ export default {
|
|
|
148
174
|
},
|
|
149
175
|
termLink: {
|
|
150
176
|
type: String,
|
|
151
|
-
default: "/
|
|
177
|
+
default: "/doc/terms",
|
|
152
178
|
},
|
|
153
179
|
},
|
|
154
180
|
data() {
|
|
@@ -218,11 +244,15 @@ export default {
|
|
|
218
244
|
},
|
|
219
245
|
computed: {
|
|
220
246
|
isMobile() {
|
|
221
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
247
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
248
|
+
navigator.userAgent,
|
|
249
|
+
);
|
|
222
250
|
},
|
|
223
251
|
|
|
224
252
|
currentPaymentMethod() {
|
|
225
|
-
return this.paymentMethods.find(
|
|
253
|
+
return this.paymentMethods.find(
|
|
254
|
+
(m) => m.value === this.activeMethod,
|
|
255
|
+
);
|
|
226
256
|
},
|
|
227
257
|
|
|
228
258
|
actualPayChannel() {
|
|
@@ -234,7 +264,9 @@ export default {
|
|
|
234
264
|
}
|
|
235
265
|
|
|
236
266
|
if (typeof method.channel === "object") {
|
|
237
|
-
return this.isMobile
|
|
267
|
+
return this.isMobile
|
|
268
|
+
? method.channel.mobile
|
|
269
|
+
: method.channel.pc;
|
|
238
270
|
}
|
|
239
271
|
|
|
240
272
|
return this.activeMethod;
|
|
@@ -320,13 +352,17 @@ export default {
|
|
|
320
352
|
try {
|
|
321
353
|
this.orderPollingRetries++;
|
|
322
354
|
|
|
323
|
-
if (
|
|
355
|
+
if (
|
|
356
|
+
this.orderPollingRetries > this.pollingConfig.maxRetries
|
|
357
|
+
) {
|
|
324
358
|
this.clearTimer("order");
|
|
325
359
|
this.handleError(this.texts.orderTimeout);
|
|
326
360
|
return;
|
|
327
361
|
}
|
|
328
362
|
|
|
329
|
-
const response = await this.api.getOrderStatus(
|
|
363
|
+
const response = await this.api.getOrderStatus(
|
|
364
|
+
this.pendingOrderId,
|
|
365
|
+
);
|
|
330
366
|
|
|
331
367
|
if (response && response.status === 2) {
|
|
332
368
|
this.clearTimer("order");
|
|
@@ -335,7 +371,9 @@ export default {
|
|
|
335
371
|
await this.getPaymentQrcode();
|
|
336
372
|
} else if (response && response.status === -1) {
|
|
337
373
|
this.clearTimer("order");
|
|
338
|
-
this.handleError(
|
|
374
|
+
this.handleError(
|
|
375
|
+
response.message || this.texts.orderFailed,
|
|
376
|
+
);
|
|
339
377
|
}
|
|
340
378
|
} catch (err) {
|
|
341
379
|
console.error("Failed to poll order status:", err);
|
|
@@ -355,7 +393,11 @@ export default {
|
|
|
355
393
|
params.qr_pay_mode = QR_PAY_MODE_ALIPAY_PC;
|
|
356
394
|
}
|
|
357
395
|
|
|
358
|
-
const response = await this.api.getPaymentQRCode(
|
|
396
|
+
const response = await this.api.getPaymentQRCode(
|
|
397
|
+
this.paymentId,
|
|
398
|
+
this.actualPayChannel,
|
|
399
|
+
params,
|
|
400
|
+
);
|
|
359
401
|
|
|
360
402
|
if (response) {
|
|
361
403
|
this.qrcode = response.qrcode || response;
|
|
@@ -381,14 +423,19 @@ export default {
|
|
|
381
423
|
try {
|
|
382
424
|
this.paymentPollingRetries++;
|
|
383
425
|
|
|
384
|
-
if (
|
|
426
|
+
if (
|
|
427
|
+
this.paymentPollingRetries >
|
|
428
|
+
this.pollingConfig.maxRetries
|
|
429
|
+
) {
|
|
385
430
|
this.clearTimer("payment");
|
|
386
431
|
this.warningVisible = true;
|
|
387
432
|
this.handleError(this.texts.paymentTimeout);
|
|
388
433
|
return;
|
|
389
434
|
}
|
|
390
435
|
|
|
391
|
-
const response = await this.api.queryPaymentStatus(
|
|
436
|
+
const response = await this.api.queryPaymentStatus(
|
|
437
|
+
this.paymentId,
|
|
438
|
+
);
|
|
392
439
|
|
|
393
440
|
if (response && response.status === 1) {
|
|
394
441
|
this.clearTimer("payment");
|
|
@@ -473,15 +520,11 @@ export default {
|
|
|
473
520
|
text-align: left;
|
|
474
521
|
|
|
475
522
|
.u-link {
|
|
476
|
-
color: #
|
|
523
|
+
color: #6777ef;
|
|
477
524
|
font-weight: 600;
|
|
478
525
|
cursor: pointer;
|
|
479
526
|
text-decoration: underline;
|
|
480
527
|
text-underline-offset: 2px;
|
|
481
|
-
|
|
482
|
-
&:hover {
|
|
483
|
-
color: #2563eb;
|
|
484
|
-
}
|
|
485
528
|
}
|
|
486
529
|
}
|
|
487
530
|
}
|
|
@@ -520,7 +563,6 @@ export default {
|
|
|
520
563
|
font-size: 0.75rem;
|
|
521
564
|
font-weight: 500;
|
|
522
565
|
}
|
|
523
|
-
|
|
524
566
|
}
|
|
525
567
|
.wepay-icon {
|
|
526
568
|
color: #10b981;
|
|
@@ -639,7 +681,11 @@ export default {
|
|
|
639
681
|
content: "";
|
|
640
682
|
position: absolute;
|
|
641
683
|
inset: 0;
|
|
642
|
-
background: linear-gradient(
|
|
684
|
+
background: linear-gradient(
|
|
685
|
+
180deg,
|
|
686
|
+
rgba(15, 23, 42, 0.85) 0%,
|
|
687
|
+
rgba(15, 23, 42, 0.95) 100%
|
|
688
|
+
);
|
|
643
689
|
z-index: 1;
|
|
644
690
|
}
|
|
645
691
|
|
|
@@ -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
|
};
|