@huyooo/ui 0.12.2 → 0.13.1

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.
@@ -0,0 +1,1194 @@
1
+ /* empty css */
2
+ /* empty css */
3
+ /* empty css */
4
+ import { U as yt } from "./index-D3Kp6R4z.js";
5
+ /* empty css */
6
+ /* empty css */
7
+ /* empty css */
8
+ /* empty css */
9
+ import { f as U, g as J } from "./apiClients-B8bOvWw_.js";
10
+ import { ref as g, computed as A, onUnmounted as Se, defineComponent as _t, openBlock as l, createElementBlock as u, Fragment as K, createVNode as r, unref as n, isRef as bt, withCtx as o, createElementVNode as a, toDisplayString as i, createBlock as ue, createTextVNode as v, createCommentVNode as W, renderList as he, normalizeClass as ke } from "vue";
11
+ import { Message as z, Modal as Pe, Button as C, Popconfirm as ce, Tabs as wt, TabPane as X, Spin as de, Empty as Ce, Progress as ht, Tag as Z } from "@arco-design/web-vue";
12
+ import { u as kt } from "./useAuthkitCreateAndUpdate-CUf8HARI.js";
13
+ import { C as pe } from "./CustomTable-BBcd4nNL.js";
14
+ import { C as Pt } from "./Clipboard-k0jtK4CJ.js";
15
+ import { _ as Ct } from "./_plugin-vue_export-helper-CHgC5LLL.js";
16
+ function Ie() {
17
+ return {
18
+ current: null,
19
+ trial: null,
20
+ entitlement: null,
21
+ features: [],
22
+ quotas: [],
23
+ pointsBalance: null,
24
+ pendingInvoice: null
25
+ };
26
+ }
27
+ function It() {
28
+ const p = g(Ie()), _ = g(!1), c = A(() => p.value.current), w = A(() => p.value.trial), k = A(() => p.value.entitlement), I = A(() => p.value.features), f = A(() => p.value.quotas), m = A(() => p.value.pointsBalance), O = A(() => p.value.pendingInvoice);
29
+ async function L() {
30
+ _.value = !0;
31
+ try {
32
+ const {
33
+ data: h,
34
+ error: P
35
+ } = await U.subscriptions.summary.post();
36
+ if (P)
37
+ throw new Error(P.message || "获取订阅摘要失败");
38
+ p.value = h || Ie();
39
+ } finally {
40
+ _.value = !1;
41
+ }
42
+ }
43
+ return {
44
+ summary: p,
45
+ current: c,
46
+ trial: w,
47
+ entitlement: k,
48
+ features: I,
49
+ quotas: f,
50
+ pointsBalance: m,
51
+ pendingInvoice: O,
52
+ loading: _,
53
+ refresh: L
54
+ };
55
+ }
56
+ function St(p) {
57
+ return /^https?:\/\//i.test(p) || p.startsWith("//");
58
+ }
59
+ function xt() {
60
+ if (J.openPricing) {
61
+ J.openPricing();
62
+ return;
63
+ }
64
+ const p = J.pricingUrl || "/Pricing";
65
+ if (St(p)) {
66
+ window.open(p, "_blank", "noopener,noreferrer");
67
+ return;
68
+ }
69
+ window.location.assign(p);
70
+ }
71
+ async function G(p, _ = {}) {
72
+ const c = localStorage.getItem("jwtToken"), w = await fetch(`${J.billingPrefixUrl}${p}`, {
73
+ method: "POST",
74
+ headers: {
75
+ "Content-Type": "application/json",
76
+ "app-id": J.appId,
77
+ ...c ? {
78
+ authorization: `Bearer ${c}`
79
+ } : {}
80
+ },
81
+ body: JSON.stringify(_)
82
+ }), k = await w.json().catch(() => null);
83
+ if (!w.ok)
84
+ throw new Error((k == null ? void 0 : k.message) || "请求失败");
85
+ return k;
86
+ }
87
+ async function Nt(p, _) {
88
+ if (p === "recharge") {
89
+ const c = await G("/pointsRecharge/verifyPayment", {
90
+ orderId: _
91
+ });
92
+ return {
93
+ success: !!(c.success || c.status === "paid"),
94
+ status: c.status || "unknown",
95
+ message: c.message,
96
+ pointsAdded: c.pointsAdded
97
+ };
98
+ }
99
+ if (p === "subscription") {
100
+ const c = await G("/invoices/verifyPayment", {
101
+ orderId: _
102
+ });
103
+ return {
104
+ success: !!(c.success || c.status === "paid"),
105
+ status: c.status || "unknown",
106
+ message: c.message
107
+ };
108
+ }
109
+ return {
110
+ success: !1,
111
+ status: "unsupported",
112
+ message: "暂不支持的支付场景"
113
+ };
114
+ }
115
+ const Wt = 3e3;
116
+ function xe() {
117
+ const p = g(!1), _ = g("");
118
+ let c = null;
119
+ function w() {
120
+ c && (clearInterval(c), c = null);
121
+ }
122
+ async function k(f, m) {
123
+ p.value = !0;
124
+ try {
125
+ return await Nt(f, m);
126
+ } finally {
127
+ p.value = !1;
128
+ }
129
+ }
130
+ function I(f) {
131
+ w();
132
+ const m = async () => {
133
+ var O, L;
134
+ try {
135
+ const h = await k(f.scene, f.orderId);
136
+ if (h.success) {
137
+ w(), f.onSuccess(h);
138
+ return;
139
+ }
140
+ _.value = h.message || "等待支付确认...", (O = f.onWaiting) == null || O.call(f, h);
141
+ } catch (h) {
142
+ w(), (L = f.onError) == null || L.call(f, h);
143
+ }
144
+ };
145
+ m(), c = setInterval(() => {
146
+ m();
147
+ }, Wt);
148
+ }
149
+ return Se(w), {
150
+ checking: p,
151
+ statusText: _,
152
+ startPolling: I,
153
+ stopPolling: w,
154
+ verifyNow: k
155
+ };
156
+ }
157
+ function Qa(p) {
158
+ const _ = g("loading"), c = g("正在确认支付结果..."), {
159
+ checking: w,
160
+ statusText: k,
161
+ startPolling: I,
162
+ stopPolling: f,
163
+ verifyNow: m
164
+ } = xe();
165
+ async function O(L, h) {
166
+ _.value = "loading", c.value = "正在确认支付结果...", I({
167
+ scene: L,
168
+ orderId: h,
169
+ onSuccess: (P) => {
170
+ _.value = "success", c.value = P.message || "支付成功", window.setTimeout(() => {
171
+ window.location.replace(p());
172
+ }, 1200);
173
+ },
174
+ onWaiting: (P) => {
175
+ c.value = P.message || k.value || "等待支付确认...";
176
+ },
177
+ onError: (P) => {
178
+ _.value = "failed", c.value = P instanceof Error ? P.message : "确认支付失败", z.error(c.value);
179
+ }
180
+ });
181
+ }
182
+ return {
183
+ phase: _,
184
+ message: c,
185
+ checking: w,
186
+ statusText: k,
187
+ confirmPayment: O,
188
+ stopPolling: f,
189
+ verifyNow: m
190
+ };
191
+ }
192
+ const zt = {
193
+ class: "content"
194
+ }, Tt = {
195
+ key: 0,
196
+ class: "current-subscription-card"
197
+ }, Et = {
198
+ class: "subscription-header"
199
+ }, At = {
200
+ class: "subscription-info"
201
+ }, Lt = {
202
+ class: "subscription-actions"
203
+ }, Ot = {
204
+ class: "subscription-details"
205
+ }, $t = {
206
+ key: 0,
207
+ class: "detail-item"
208
+ }, Rt = {
209
+ key: 1,
210
+ class: "detail-item"
211
+ }, Ut = {
212
+ key: 2,
213
+ class: "detail-item"
214
+ }, Ht = {
215
+ key: 3,
216
+ class: "detail-item"
217
+ }, Bt = {
218
+ class: "label"
219
+ }, Dt = {
220
+ key: 4,
221
+ class: "detail-item warning"
222
+ }, Yt = {
223
+ key: 5,
224
+ class: "detail-item warning"
225
+ }, Mt = {
226
+ key: 6,
227
+ class: "detail-item"
228
+ }, jt = {
229
+ key: 0,
230
+ class: "pending-invoice-alert"
231
+ }, Ft = {
232
+ key: 1,
233
+ class: "no-subscription-row"
234
+ }, Vt = {
235
+ class: "overview-grid"
236
+ }, qt = {
237
+ class: "overview-card"
238
+ }, Kt = {
239
+ class: "overview-card__value"
240
+ }, Jt = {
241
+ key: 0,
242
+ class: "overview-card__meta"
243
+ }, Gt = {
244
+ class: "overview-card"
245
+ }, Qt = {
246
+ class: "overview-card__value"
247
+ }, Xt = {
248
+ class: "overview-card"
249
+ }, Zt = {
250
+ class: "overview-card__value"
251
+ }, ea = {
252
+ key: 0,
253
+ class: "quotas-loading"
254
+ }, ta = {
255
+ key: 1,
256
+ class: "no-quotas"
257
+ }, aa = {
258
+ key: 2,
259
+ class: "quotas-grid"
260
+ }, na = {
261
+ class: "quota-header"
262
+ }, sa = {
263
+ class: "quota-name"
264
+ }, ia = {
265
+ class: "quota-period"
266
+ }, oa = {
267
+ class: "quota-progress"
268
+ }, la = {
269
+ class: "quota-detail"
270
+ }, ra = {
271
+ key: 0
272
+ }, ua = {
273
+ key: 1
274
+ }, ca = {
275
+ key: 2,
276
+ class: "reset-time"
277
+ }, da = ["title"], pa = {
278
+ key: 1
279
+ }, va = {
280
+ key: 0,
281
+ class: "invoice-actions"
282
+ }, ma = {
283
+ key: 1,
284
+ class: "invoice-actions"
285
+ }, ga = {
286
+ key: 2
287
+ }, fa = {
288
+ class: "points-panel"
289
+ }, ya = {
290
+ class: "points-balance-card"
291
+ }, _a = {
292
+ class: "points-balance-value"
293
+ }, ba = {
294
+ key: 0,
295
+ class: "points-loading"
296
+ }, wa = {
297
+ key: 1,
298
+ class: "points-empty"
299
+ }, ha = {
300
+ key: 2,
301
+ class: "points-package-grid"
302
+ }, ka = ["onClick"], Pa = {
303
+ class: "points-package-name"
304
+ }, Ca = {
305
+ class: "points-package-value"
306
+ }, Ia = {
307
+ class: "points-package-meta"
308
+ }, Sa = {
309
+ class: "points-pay-row"
310
+ }, xa = {
311
+ key: 0
312
+ }, Na = {
313
+ key: 1
314
+ }, Wa = {
315
+ class: "points-money-cell"
316
+ }, za = {
317
+ class: "payment-wait-content"
318
+ }, Ta = {
319
+ class: "payment-wait-summary"
320
+ }, Ea = {
321
+ class: "payment-wait-icon"
322
+ }, Aa = {
323
+ class: "payment-wait-tip"
324
+ }, La = {
325
+ class: "payment-wait-actions"
326
+ }, Oa = /* @__PURE__ */ _t({
327
+ __name: "PaySubscriptions",
328
+ emits: ["confirm", "cancel"],
329
+ setup(p, {
330
+ expose: _,
331
+ emit: c
332
+ }) {
333
+ const w = c, {
334
+ changeType: k,
335
+ show: I
336
+ } = kt(w), f = g("overview"), {
337
+ current: m,
338
+ entitlement: O,
339
+ quotas: L,
340
+ pointsBalance: h,
341
+ pendingInvoice: P,
342
+ loading: ve,
343
+ refresh: $
344
+ } = It(), S = A(() => O.value), me = g([]), ee = g(!1), H = g({
345
+ current: 1,
346
+ pageSize: 10,
347
+ total: 0
348
+ }), M = g([]), R = g(""), te = g(!1), ae = g(!1), j = g(!1), x = g(null), {
349
+ checking: Ne,
350
+ statusText: T,
351
+ startPolling: We,
352
+ stopPolling: ne,
353
+ verifyNow: ze
354
+ } = xe(), se = g(!1), ge = g([]), ie = g(!1), B = g({
355
+ current: 1,
356
+ pageSize: 10,
357
+ total: 0
358
+ }), fe = g([]), oe = g(!1), D = g({
359
+ current: 1,
360
+ pageSize: 10,
361
+ total: 0
362
+ }), Q = A(() => M.value.find((t) => t.id === R.value)), Te = A(() => ve.value), Ee = [{
363
+ dataIndex: "id",
364
+ slotName: "id",
365
+ title: "账单 ID",
366
+ minWidth: 320
367
+ }, {
368
+ dataIndex: "productName",
369
+ title: "价格方案",
370
+ minWidth: 180
371
+ }, {
372
+ dataIndex: "billingType",
373
+ slotName: "billingType",
374
+ title: "账单类型",
375
+ minWidth: 120
376
+ }, {
377
+ dataIndex: "total",
378
+ slotName: "total",
379
+ title: "金额",
380
+ minWidth: 110
381
+ }, {
382
+ dataIndex: "status",
383
+ slotName: "status",
384
+ title: "状态",
385
+ minWidth: 110
386
+ }, {
387
+ dataIndex: "refund",
388
+ slotName: "refund",
389
+ title: "退款",
390
+ minWidth: 120
391
+ }, {
392
+ dataIndex: "tradeNo",
393
+ title: "交易号",
394
+ minWidth: 320,
395
+ cellClassName: "mono-value"
396
+ }, {
397
+ dataIndex: "periodStart",
398
+ title: "周期开始",
399
+ minWidth: 180
400
+ }, {
401
+ dataIndex: "periodEnd",
402
+ title: "周期结束",
403
+ minWidth: 180
404
+ }, {
405
+ dataIndex: "paidAt",
406
+ title: "支付时间",
407
+ minWidth: 180
408
+ }, {
409
+ dataIndex: "expireAt",
410
+ title: "支付有效期",
411
+ minWidth: 180
412
+ }, {
413
+ dataIndex: "createAt",
414
+ title: "创建时间",
415
+ minWidth: 180
416
+ }, {
417
+ dataIndex: "actions",
418
+ slotName: "actions",
419
+ title: "操作",
420
+ width: 190,
421
+ fixed: "right",
422
+ cellClassName: "invoice-actions-cell"
423
+ }], Ae = [{
424
+ dataIndex: "packageName",
425
+ title: "套餐",
426
+ minWidth: 180
427
+ }, {
428
+ dataIndex: "price",
429
+ slotName: "price",
430
+ title: "金额",
431
+ minWidth: 110
432
+ }, {
433
+ dataIndex: "totalPoints",
434
+ slotName: "points",
435
+ title: "积分",
436
+ minWidth: 120
437
+ }, {
438
+ dataIndex: "status",
439
+ slotName: "status",
440
+ title: "状态",
441
+ minWidth: 110
442
+ }, {
443
+ dataIndex: "outTradeNo",
444
+ title: "订单号",
445
+ minWidth: 260,
446
+ cellClassName: "mono-value"
447
+ }, {
448
+ dataIndex: "expireAt",
449
+ title: "支付有效期",
450
+ minWidth: 180
451
+ }, {
452
+ dataIndex: "createAt",
453
+ title: "创建时间",
454
+ minWidth: 180
455
+ }], Le = [{
456
+ dataIndex: "type",
457
+ slotName: "type",
458
+ title: "类型",
459
+ minWidth: 110
460
+ }, {
461
+ dataIndex: "amount",
462
+ slotName: "amount",
463
+ title: "金额",
464
+ minWidth: 150
465
+ }, {
466
+ dataIndex: "balance",
467
+ slotName: "balance",
468
+ title: "余额",
469
+ minWidth: 150
470
+ }, {
471
+ dataIndex: "exchangeRate",
472
+ slotName: "exchangeRate",
473
+ title: "汇率",
474
+ minWidth: 130
475
+ }, {
476
+ dataIndex: "description",
477
+ slotName: "description",
478
+ title: "说明",
479
+ minWidth: 300
480
+ }, {
481
+ dataIndex: "priceName",
482
+ slotName: "service",
483
+ title: "服务",
484
+ minWidth: 180
485
+ }, {
486
+ dataIndex: "createAt",
487
+ title: "时间",
488
+ minWidth: 180
489
+ }];
490
+ function Oe(t) {
491
+ const e = t == null ? void 0 : t.toLowerCase();
492
+ return {
493
+ draft: "gray",
494
+ open: "orange",
495
+ paid: "green",
496
+ void: "gray",
497
+ uncollectible: "red"
498
+ }[e] || "gray";
499
+ }
500
+ function $e(t) {
501
+ const e = t == null ? void 0 : t.toLowerCase();
502
+ return {
503
+ draft: "草稿",
504
+ open: "待支付",
505
+ paid: "已支付",
506
+ void: "已作废",
507
+ uncollectible: "无法收款"
508
+ }[e] || t;
509
+ }
510
+ function Re(t) {
511
+ return t ? {
512
+ new_subscription: "新购",
513
+ upgrade: "升级",
514
+ downgrade: "降级",
515
+ renewal: "续费",
516
+ subscription: "订阅"
517
+ }[t] || t : "-";
518
+ }
519
+ function Ue(t) {
520
+ return {
521
+ pending: "orange",
522
+ approved: "blue",
523
+ processing: "blue",
524
+ success: "green",
525
+ failed: "red",
526
+ rejected: "gray"
527
+ }[t] || "gray";
528
+ }
529
+ function He(t) {
530
+ return {
531
+ pending: "审核中",
532
+ approved: "已通过",
533
+ processing: "退款中",
534
+ success: "已退款",
535
+ failed: "退款失败",
536
+ rejected: "已拒绝"
537
+ }[t] || t;
538
+ }
539
+ function Be(t) {
540
+ return {
541
+ day: "每天",
542
+ week: "每周",
543
+ month: "每月",
544
+ year: "每年",
545
+ lifetime: "不重置"
546
+ }[t] || t;
547
+ }
548
+ function ye(t, e = 1) {
549
+ const d = e > 1 ? `每 ${e} ` : "按", b = {
550
+ day: `${d}天`,
551
+ week: `${d}周`,
552
+ month: `${d}月`,
553
+ year: `${d}年`
554
+ };
555
+ return t ? b[t] || t : "-";
556
+ }
557
+ function De(t, e, d = 1) {
558
+ if (typeof t != "number") return "-";
559
+ const b = ye(e, d).replace("按", "").replace("每 ", "");
560
+ return `¥${(t / 100).toFixed(2)} / ${b}`;
561
+ }
562
+ function E(t) {
563
+ return Number(t || 0).toLocaleString();
564
+ }
565
+ function Ye(t) {
566
+ return typeof t == "number" ? E(t) : "-";
567
+ }
568
+ function _e(t, e = !1) {
569
+ return typeof t != "number" ? "-" : `${e && t > 0 ? "+" : ""}¥${(t / 100).toFixed(2)}`;
570
+ }
571
+ function Me(t) {
572
+ var b, q;
573
+ const e = (b = t.metadata) == null ? void 0 : b.billing;
574
+ if (((e == null ? void 0 : e.currency) || ((q = e == null ? void 0 : e.pricing) == null ? void 0 : q.currency)) === "USD") {
575
+ const s = (e == null ? void 0 : e.exchangeRate) || (e == null ? void 0 : e.usdToCny);
576
+ return s ? `USD→CNY ${Number(s).toFixed(2)}` : "USD→CNY";
577
+ }
578
+ return "CNY";
579
+ }
580
+ function je(t) {
581
+ return {
582
+ pending: "orange",
583
+ paying: "blue",
584
+ paid: "green",
585
+ cancelled: "gray",
586
+ expired: "red",
587
+ refunded: "purple"
588
+ }[t] || "gray";
589
+ }
590
+ function Fe(t) {
591
+ return {
592
+ pending: "待支付",
593
+ paying: "支付中",
594
+ paid: "已支付",
595
+ cancelled: "已取消",
596
+ expired: "已过期",
597
+ refunded: "已退款"
598
+ }[t] || t;
599
+ }
600
+ function Ve(t) {
601
+ return {
602
+ earn: "green",
603
+ spend: "orange",
604
+ consume: "orange",
605
+ deduct: "orange",
606
+ reversal: "blue",
607
+ clawback: "red",
608
+ adjust: "purple"
609
+ }[t] || "gray";
610
+ }
611
+ function qe(t) {
612
+ return {
613
+ earn: "收入",
614
+ spend: "消费",
615
+ consume: "消费",
616
+ deduct: "扣除",
617
+ reversal: "退还",
618
+ clawback: "扣回",
619
+ adjust: "调整"
620
+ }[t] || t;
621
+ }
622
+ function Ke(t) {
623
+ return t ? {
624
+ recharge: "积分充值",
625
+ subscription: "订阅赠送",
626
+ refund: "退款扣除",
627
+ consume: "服务消费",
628
+ service_usage: "服务消费",
629
+ continuous_service_usage: "连续服务消费",
630
+ consume_reversal: "消费退还",
631
+ earn_clawback: "收入扣回",
632
+ increase: "人工增加",
633
+ decrease: "人工扣减",
634
+ batch_increase: "批量增加",
635
+ batch_decrease: "批量扣减",
636
+ rule: "规则奖励",
637
+ referral: "邀请奖励"
638
+ }[t] || t : "";
639
+ }
640
+ function Je(t) {
641
+ return t.priceName || Ke(t.subType) || (t.orderId ? "关联订单" : "-");
642
+ }
643
+ function Ge() {
644
+ I.value = !1, w("cancel");
645
+ }
646
+ function le() {
647
+ xt();
648
+ }
649
+ async function Qe() {
650
+ f.value = "invoices", await F();
651
+ }
652
+ async function Xe() {
653
+ await $();
654
+ }
655
+ async function be(t) {
656
+ t === "points" ? await Promise.all([Ze(), Y()]) : t === "usage" ? await V() : t === "invoices" && await F();
657
+ }
658
+ async function F() {
659
+ ee.value = !0;
660
+ const {
661
+ data: t
662
+ } = await U.invoices.my.post({
663
+ current: H.value.current,
664
+ pageSize: H.value.pageSize
665
+ });
666
+ ee.value = !1, t && (me.value = t.items, H.value.total = t.count);
667
+ }
668
+ async function Ze() {
669
+ te.value = !0;
670
+ try {
671
+ const t = await G("/pointsRecharge/packages");
672
+ M.value = t.packages || [], M.value.length > 0 && !R.value && (R.value = M.value[0].id);
673
+ } catch (t) {
674
+ z.error(t instanceof Error ? t.message : "加载充值套餐失败");
675
+ } finally {
676
+ te.value = !1;
677
+ }
678
+ }
679
+ async function Y() {
680
+ ie.value = !0;
681
+ try {
682
+ const t = await G("/pointsRecharge/orders", {
683
+ page: B.value.current,
684
+ pageSize: B.value.pageSize
685
+ });
686
+ ge.value = t.items || [], B.value.total = t.count || 0;
687
+ } catch (t) {
688
+ z.error(t instanceof Error ? t.message : "加载充值记录失败");
689
+ } finally {
690
+ ie.value = !1;
691
+ }
692
+ }
693
+ async function V() {
694
+ oe.value = !0;
695
+ try {
696
+ const {
697
+ data: t
698
+ } = await U.pointsHistory.find.post({
699
+ page: D.value.current,
700
+ pageSize: D.value.pageSize
701
+ });
702
+ fe.value = (t == null ? void 0 : t.items) || [], D.value.total = (t == null ? void 0 : t.count) || 0;
703
+ } finally {
704
+ oe.value = !1;
705
+ }
706
+ }
707
+ async function et() {
708
+ var t;
709
+ if (R.value) {
710
+ ae.value = !0, x.value = null, T.value = "";
711
+ try {
712
+ const e = await G("/pointsRecharge/createOrder", {
713
+ packageId: R.value,
714
+ payType: "alipay"
715
+ });
716
+ e.alipayUrl ? (x.value = {
717
+ orderId: e.orderId,
718
+ packageName: ((t = Q.value) == null ? void 0 : t.name) || "积分充值",
719
+ priceYuan: e.priceYuan,
720
+ totalPoints: e.totalPoints
721
+ }, window.open(e.alipayUrl, "_blank", "noopener,noreferrer"), j.value = !0, tt(e.orderId), await Y()) : z.error("获取支付链接失败");
722
+ } catch (e) {
723
+ z.error(e instanceof Error ? e.message : "创建充值订单失败");
724
+ } finally {
725
+ ae.value = !1;
726
+ }
727
+ }
728
+ }
729
+ function tt(t) {
730
+ T.value = "等待支付确认...", We({
731
+ scene: "recharge",
732
+ orderId: t,
733
+ onSuccess: async (e) => {
734
+ var b;
735
+ const d = e.pointsAdded || ((b = x.value) == null ? void 0 : b.totalPoints) || 0;
736
+ j.value = !1, x.value = null, T.value = "", z.success(`充值成功,已到账 ${E(d)} 积分`), await $(), await Y(), await V();
737
+ },
738
+ onWaiting: (e) => {
739
+ T.value = e.message || "等待支付确认...";
740
+ },
741
+ onError: (e) => {
742
+ T.value = e instanceof Error ? e.message : "查询支付状态失败";
743
+ }
744
+ });
745
+ }
746
+ async function at() {
747
+ var t, e;
748
+ if ((t = x.value) != null && t.orderId)
749
+ try {
750
+ const d = await ze("recharge", x.value.orderId);
751
+ if (d.success) {
752
+ const b = d.pointsAdded || ((e = x.value) == null ? void 0 : e.totalPoints) || 0;
753
+ ne(), j.value = !1, x.value = null, T.value = "", z.success(`充值成功,已到账 ${E(b)} 积分`), await $(), await Y(), await V();
754
+ return;
755
+ }
756
+ T.value = d.message || "等待支付确认...";
757
+ } catch (d) {
758
+ T.value = d instanceof Error ? d.message : "查询支付状态失败";
759
+ }
760
+ }
761
+ function we() {
762
+ ne(), j.value = !1, x.value = null, T.value = "", Y();
763
+ }
764
+ async function nt(t) {
765
+ const {
766
+ data: e
767
+ } = await U.invoices.pay.post({
768
+ id: t.id
769
+ });
770
+ e != null && e.alipayUrl && window.open(e.alipayUrl, "_blank", "noopener,noreferrer");
771
+ }
772
+ async function st(t) {
773
+ const {
774
+ error: e
775
+ } = await U.invoices.cancel.post({
776
+ id: t.id,
777
+ reason: "用户取消待支付订阅账单"
778
+ });
779
+ if (e) {
780
+ z.error(e.message || "取消账单失败");
781
+ return;
782
+ }
783
+ z.success("账单已取消"), await $(), await F();
784
+ }
785
+ async function it(t) {
786
+ if (se.value) return;
787
+ se.value = !0;
788
+ const {
789
+ error: e
790
+ } = await U.refund.applySubscription.post({
791
+ invoiceId: t.id,
792
+ reason: "用户申请订阅退款"
793
+ });
794
+ if (se.value = !1, e) {
795
+ z.error(e.message || "申请退款失败");
796
+ return;
797
+ }
798
+ z.success("退款申请已提交,等待人工审核"), await $(), await F();
799
+ }
800
+ async function ot() {
801
+ if (!m.value) return;
802
+ const {
803
+ error: t
804
+ } = await U.subscriptions.cancel.post({
805
+ subscriptionId: m.value.id,
806
+ cancelAtPeriodEnd: !0
807
+ });
808
+ t || await $();
809
+ }
810
+ async function lt() {
811
+ if (!m.value) return;
812
+ const {
813
+ error: t
814
+ } = await U.subscriptions.resume.post({
815
+ subscriptionId: m.value.id
816
+ });
817
+ t || await $();
818
+ }
819
+ function rt(t) {
820
+ H.value.current = t, F();
821
+ }
822
+ function ut(t) {
823
+ H.value.pageSize = t, H.value.current = 1, F();
824
+ }
825
+ function ct(t) {
826
+ B.value.current = t, Y();
827
+ }
828
+ function dt(t) {
829
+ B.value.pageSize = t, B.value.current = 1, Y();
830
+ }
831
+ function pt(t) {
832
+ D.value.current = t, V();
833
+ }
834
+ function vt(t) {
835
+ D.value.pageSize = t, D.value.current = 1, V();
836
+ }
837
+ function mt(t) {
838
+ return (t == null ? void 0 : t.target) === "points" ? "points" : (t == null ? void 0 : t.target) === "usage" ? "usage" : (t == null ? void 0 : t.target) === "invoices" || (t == null ? void 0 : t.target) === "subscriptions" ? "invoices" : ((t == null ? void 0 : t.target) === "quotas", "overview");
839
+ }
840
+ function gt(t) {
841
+ be(String(t));
842
+ }
843
+ function ft(t, e) {
844
+ I.value = e, k.value = "编辑", f.value = mt(t), e && (Xe(), be(f.value));
845
+ }
846
+ return Se(() => {
847
+ ne();
848
+ }), _({
849
+ setData: ft
850
+ }), (t, e) => (l(), u(K, null, [r(n(Pe), {
851
+ visible: n(I),
852
+ "onUpdate:visible": e[1] || (e[1] = (d) => bt(I) ? I.value = d : null),
853
+ loading: !1,
854
+ "body-class": "SubscriptionsbodyClass",
855
+ "mask-closable": !1,
856
+ footer: !1,
857
+ width: n(yt),
858
+ onCancel: Ge
859
+ }, {
860
+ title: o(() => [...e[3] || (e[3] = [v(" 订阅与积分 ", -1)])]),
861
+ default: o(() => {
862
+ var d, b, q;
863
+ return [a("div", zt, [S.value ? (l(), u("div", Tt, [a("div", Et, [a("div", At, [a("h3", null, i(S.value.productName), 1)]), a("div", Lt, [S.value.type === "trial" ? (l(), ue(n(C), {
864
+ key: 0,
865
+ type: "primary",
866
+ size: "small",
867
+ onClick: le
868
+ }, {
869
+ default: o(() => [...e[4] || (e[4] = [v(" 立即订阅 ", -1)])]),
870
+ _: 1
871
+ })) : (d = n(m)) != null && d.cancelAtPeriodEnd ? (l(), ue(n(C), {
872
+ key: 1,
873
+ type: "primary",
874
+ size: "small",
875
+ onClick: lt
876
+ }, {
877
+ default: o(() => [...e[5] || (e[5] = [v(" 恢复订阅 ", -1)])]),
878
+ _: 1
879
+ })) : n(m) ? (l(), u(K, {
880
+ key: 2
881
+ }, [r(n(C), {
882
+ type: "primary",
883
+ size: "small",
884
+ onClick: le
885
+ }, {
886
+ default: o(() => [...e[6] || (e[6] = [v(" 修改订阅 ", -1)])]),
887
+ _: 1
888
+ }), r(n(ce), {
889
+ content: "取消后订阅将在当前周期结束时失效,确定取消吗?",
890
+ onOk: ot
891
+ }, {
892
+ default: o(() => [r(n(C), {
893
+ type: "outline",
894
+ size: "small",
895
+ status: "warning"
896
+ }, {
897
+ default: o(() => [...e[7] || (e[7] = [v(" 取消订阅 ", -1)])]),
898
+ _: 1
899
+ })]),
900
+ _: 1
901
+ })], 64)) : W("", !0)])]), a("div", Ot, [n(m) ? (l(), u("div", $t, [e[8] || (e[8] = a("span", {
902
+ class: "label"
903
+ }, "价格方案:", -1)), a("span", null, i(S.value.productName), 1)])) : W("", !0), n(m) ? (l(), u("div", Rt, [e[9] || (e[9] = a("span", {
904
+ class: "label"
905
+ }, "计费周期:", -1)), a("span", null, i(ye(n(m).interval, n(m).intervalCount)), 1)])) : W("", !0), n(m) ? (l(), u("div", Ut, [e[10] || (e[10] = a("span", {
906
+ class: "label"
907
+ }, "价格:", -1)), a("span", null, i(De(n(m).unitAmount, n(m).interval, n(m).intervalCount)), 1)])) : W("", !0), S.value.endAt ? (l(), u("div", Ht, [a("span", Bt, i(S.value.type === "trial" ? "试用有效期至:" : "当前周期结束:"), 1), a("span", null, i(S.value.endAt), 1)])) : W("", !0), (b = n(m)) != null && b.cancelAtPeriodEnd ? (l(), u("div", Dt, [...e[11] || (e[11] = [a("span", {
908
+ class: "label"
909
+ }, "订阅将于周期结束后停止", -1)])])) : (q = n(m)) != null && q.pendingChange ? (l(), u("div", Yt, [e[12] || (e[12] = a("span", {
910
+ class: "label"
911
+ }, "到期后变更为:", -1)), a("span", null, i(n(m).pendingChange.productName || "新方案"), 1)])) : W("", !0), n(h) ? (l(), u("div", Mt, [e[13] || (e[13] = a("span", {
912
+ class: "label"
913
+ }, "积分余额:", -1)), a("span", null, i(n(h).totalPoints), 1)])) : W("", !0)]), n(P) ? (l(), u("div", jt, [e[15] || (e[15] = a("div", null, [a("strong", null, "存在待支付订阅账单"), a("span", null, "可继续支付,也可取消后重新选择方案。")], -1)), r(n(C), {
914
+ type: "primary",
915
+ status: "warning",
916
+ size: "small",
917
+ onClick: Qe
918
+ }, {
919
+ default: o(() => [...e[14] || (e[14] = [v(" 处理 ", -1)])]),
920
+ _: 1
921
+ })])) : W("", !0)])) : (l(), u("div", Ft, [e[17] || (e[17] = a("span", {
922
+ class: "no-subscription-text"
923
+ }, "暂无方案", -1)), r(n(C), {
924
+ type: "primary",
925
+ size: "small",
926
+ onClick: le
927
+ }, {
928
+ default: o(() => [...e[16] || (e[16] = [v("查看价格方案", -1)])]),
929
+ _: 1
930
+ })])), r(n(wt), {
931
+ "active-key": f.value,
932
+ "onUpdate:activeKey": e[0] || (e[0] = (s) => f.value = s),
933
+ class: "subscription-tabs",
934
+ onChange: gt
935
+ }, {
936
+ default: o(() => [r(n(X), {
937
+ key: "overview",
938
+ title: "概览"
939
+ }, {
940
+ default: o(() => {
941
+ var s, y, re;
942
+ return [a("div", Vt, [a("div", qt, [e[18] || (e[18] = a("div", {
943
+ class: "overview-card__label"
944
+ }, "当前权益", -1)), a("div", Kt, i(((s = S.value) == null ? void 0 : s.productName) || "暂无方案"), 1), (y = S.value) != null && y.endAt ? (l(), u("div", Jt, i(S.value.type === "trial" ? "试用有效期至" : "当前周期结束") + ":" + i(S.value.endAt), 1)) : W("", !0)]), a("div", Gt, [e[19] || (e[19] = a("div", {
945
+ class: "overview-card__label"
946
+ }, "积分余额", -1)), a("div", Qt, i(E(((re = n(h)) == null ? void 0 : re.totalPoints) || 0)), 1), e[20] || (e[20] = a("div", {
947
+ class: "overview-card__meta"
948
+ }, "用于 AI 模型调用和按量服务消费", -1))]), a("div", Xt, [e[21] || (e[21] = a("div", {
949
+ class: "overview-card__label"
950
+ }, "待支付订阅账单", -1)), a("div", Zt, i(n(P) ? `¥${(n(P).total / 100).toFixed(2)}` : "无"), 1), e[22] || (e[22] = a("div", {
951
+ class: "overview-card__meta"
952
+ }, "仅包含订阅方案产生的待支付账单", -1))])]), Te.value ? (l(), u("div", ea, [r(n(de))])) : n(L).length === 0 ? (l(), u("div", ta, [r(n(Ce), {
953
+ description: "暂无配额限制"
954
+ })])) : (l(), u("div", aa, [(l(!0), u(K, null, he(n(L), (N) => (l(), u("div", {
955
+ key: N.featureKey,
956
+ class: "quota-card"
957
+ }, [a("div", na, [a("span", sa, i(N.name), 1), a("span", ia, i(Be(N.period)), 1)]), a("div", oa, [r(n(ht), {
958
+ percent: N.percentage,
959
+ status: N.percentage >= 90 ? "danger" : N.percentage >= 70 ? "warning" : "normal"
960
+ }, null, 8, ["percent", "status"])]), a("div", la, [N.unlimited ? (l(), u("span", ra, "无限制")) : (l(), u("span", ua, "已使用 " + i(N.used) + " / " + i(N.limit), 1)), N.resetsAt ? (l(), u("span", ca, i(N.resetsAt) + " 重置", 1)) : W("", !0)])]))), 128))]))];
961
+ }),
962
+ _: 1
963
+ }), r(n(X), {
964
+ key: "invoices",
965
+ title: "订阅账单"
966
+ }, {
967
+ default: o(() => [r(pe, {
968
+ columns: Ee,
969
+ data: me.value,
970
+ loading: ee.value,
971
+ pagination: H.value,
972
+ onPageChange: rt,
973
+ onPageSizeChange: ut
974
+ }, {
975
+ id: o(({
976
+ record: s
977
+ }) => [a("span", {
978
+ class: "copyable-id mono-value",
979
+ title: s.id
980
+ }, [a("span", null, i(s.id), 1), r(Pt, {
981
+ value: s.id,
982
+ message: "账单 ID 已复制"
983
+ }, null, 8, ["value"])], 8, da)]),
984
+ status: o(({
985
+ record: s
986
+ }) => [r(n(Z), {
987
+ color: Oe(s.status)
988
+ }, {
989
+ default: o(() => [v(i($e(s.status)), 1)]),
990
+ _: 2
991
+ }, 1032, ["color"])]),
992
+ billingType: o(({
993
+ record: s
994
+ }) => [v(i(Re(s.billingType)), 1)]),
995
+ refund: o(({
996
+ record: s
997
+ }) => [s.refund ? (l(), ue(n(Z), {
998
+ key: 0,
999
+ color: Ue(s.refund.status)
1000
+ }, {
1001
+ default: o(() => [v(i(He(s.refund.status)), 1)]),
1002
+ _: 2
1003
+ }, 1032, ["color"])) : (l(), u("span", pa, "-"))]),
1004
+ total: o(({
1005
+ record: s
1006
+ }) => [v(" ¥" + i((s.total / 100).toFixed(2)), 1)]),
1007
+ actions: o(({
1008
+ record: s
1009
+ }) => [s.status === "open" ? (l(), u("div", va, [r(n(C), {
1010
+ type: "primary",
1011
+ status: "warning",
1012
+ size: "small",
1013
+ onClick: (y) => nt(s)
1014
+ }, {
1015
+ default: o(() => [...e[23] || (e[23] = [v(" 去支付 ", -1)])]),
1016
+ _: 1
1017
+ }, 8, ["onClick"]), r(n(ce), {
1018
+ content: "取消后可重新发起支付,订阅方案不会变更。确定取消吗?",
1019
+ onOk: (y) => st(s)
1020
+ }, {
1021
+ default: o(() => [r(n(C), {
1022
+ type: "secondary",
1023
+ status: "warning",
1024
+ size: "small"
1025
+ }, {
1026
+ default: o(() => [...e[24] || (e[24] = [v("取消支付", -1)])]),
1027
+ _: 1
1028
+ })]),
1029
+ _: 1
1030
+ }, 8, ["onOk"])])) : s.status === "paid" && !s.refund ? (l(), u("div", ma, [r(n(ce), {
1031
+ content: "提交后将进入人工审核,审核通过后原路退款。确定申请退款吗?",
1032
+ onOk: (y) => it(s)
1033
+ }, {
1034
+ default: o(() => [r(n(C), {
1035
+ type: "secondary",
1036
+ size: "small"
1037
+ }, {
1038
+ default: o(() => [...e[25] || (e[25] = [v(" 申请退款 ", -1)])]),
1039
+ _: 1
1040
+ })]),
1041
+ _: 1
1042
+ }, 8, ["onOk"])])) : (l(), u("span", ga, "-"))]),
1043
+ _: 1
1044
+ }, 8, ["data", "loading", "pagination"])]),
1045
+ _: 1
1046
+ }), r(n(X), {
1047
+ key: "points",
1048
+ title: "积分账户"
1049
+ }, {
1050
+ default: o(() => {
1051
+ var s;
1052
+ return [a("div", fa, [a("div", ya, [a("div", null, [e[26] || (e[26] = a("div", {
1053
+ class: "points-balance-label"
1054
+ }, "当前积分余额", -1)), a("div", _a, i(E(((s = n(h)) == null ? void 0 : s.totalPoints) || 0)), 1), e[27] || (e[27] = a("div", {
1055
+ class: "points-balance-tip"
1056
+ }, "充值后实时到账,可用于模型调用和按量服务。", -1))]), r(n(C), {
1057
+ loading: n(ve),
1058
+ onClick: n($)
1059
+ }, {
1060
+ default: o(() => [...e[28] || (e[28] = [v("刷新余额", -1)])]),
1061
+ _: 1
1062
+ }, 8, ["loading", "onClick"])]), e[30] || (e[30] = a("div", {
1063
+ class: "points-section-header"
1064
+ }, [a("h4", null, "充值套餐")], -1)), te.value ? (l(), u("div", ba, [r(n(de))])) : M.value.length === 0 ? (l(), u("div", wa, [r(n(Ce), {
1065
+ description: "暂无充值套餐"
1066
+ })])) : (l(), u("div", ha, [(l(!0), u(K, null, he(M.value, (y) => (l(), u("button", {
1067
+ key: y.id,
1068
+ type: "button",
1069
+ class: ke(["points-package", {
1070
+ "points-package--selected": R.value === y.id
1071
+ }]),
1072
+ onClick: (re) => R.value = y.id
1073
+ }, [a("span", Pa, i(y.name), 1), a("span", Ca, i(E(y.totalPoints)) + " 积分", 1), a("span", Ia, [v(" ¥" + i(y.priceYuan) + " ", 1), y.bonus > 0 ? (l(), u(K, {
1074
+ key: 0
1075
+ }, [v(" · 赠送 " + i(E(y.bonus)), 1)], 64)) : W("", !0)])], 10, ka))), 128))])), a("div", Sa, [Q.value ? (l(), u("span", xa, " 应付 ¥" + i(Q.value.priceYuan) + ",获得 " + i(E(Q.value.totalPoints)) + " 积分 ", 1)) : (l(), u("span", Na, "请选择充值套餐")), r(n(C), {
1076
+ type: "primary",
1077
+ loading: ae.value,
1078
+ disabled: !R.value,
1079
+ onClick: et
1080
+ }, {
1081
+ default: o(() => [...e[29] || (e[29] = [v(" 立即充值 ", -1)])]),
1082
+ _: 1
1083
+ }, 8, ["loading", "disabled"])]), e[31] || (e[31] = a("div", {
1084
+ class: "points-section-header"
1085
+ }, [a("h4", null, "充值记录")], -1)), r(pe, {
1086
+ columns: Ae,
1087
+ data: ge.value,
1088
+ loading: ie.value,
1089
+ pagination: B.value,
1090
+ onPageChange: ct,
1091
+ onPageSizeChange: dt
1092
+ }, {
1093
+ price: o(({
1094
+ record: y
1095
+ }) => [v(" ¥" + i(y.priceYuan), 1)]),
1096
+ points: o(({
1097
+ record: y
1098
+ }) => [v(i(E(y.totalPoints)), 1)]),
1099
+ status: o(({
1100
+ record: y
1101
+ }) => [r(n(Z), {
1102
+ color: je(y.status)
1103
+ }, {
1104
+ default: o(() => [v(i(Fe(y.status)), 1)]),
1105
+ _: 2
1106
+ }, 1032, ["color"])]),
1107
+ _: 1
1108
+ }, 8, ["data", "loading", "pagination"])])];
1109
+ }),
1110
+ _: 1
1111
+ }), r(n(X), {
1112
+ key: "usage",
1113
+ title: "积分流水"
1114
+ }, {
1115
+ default: o(() => [r(pe, {
1116
+ columns: Le,
1117
+ data: fe.value,
1118
+ loading: oe.value,
1119
+ pagination: D.value,
1120
+ onPageChange: pt,
1121
+ onPageSizeChange: vt
1122
+ }, {
1123
+ type: o(({
1124
+ record: s
1125
+ }) => [r(n(Z), {
1126
+ color: Ve(s.type)
1127
+ }, {
1128
+ default: o(() => [v(i(qe(s.type)), 1)]),
1129
+ _: 2
1130
+ }, 1032, ["color"])]),
1131
+ amount: o(({
1132
+ record: s
1133
+ }) => [a("div", {
1134
+ class: ke(["points-money-cell", s.amount >= 0 ? "points-amount-plus" : "points-amount-minus"])
1135
+ }, [a("span", null, i(_e(s.amount, !0)), 1), a("small", null, i(s.amount >= 0 ? "+" : "") + i(E(s.amount)) + " 积分", 1)], 2)]),
1136
+ balance: o(({
1137
+ record: s
1138
+ }) => [a("div", Wa, [a("span", null, i(_e(s.balance)), 1), a("small", null, i(Ye(s.balance)) + " 积分", 1)])]),
1139
+ exchangeRate: o(({
1140
+ record: s
1141
+ }) => [v(i(Me(s)), 1)]),
1142
+ description: o(({
1143
+ record: s
1144
+ }) => [v(i(s.description || "-"), 1)]),
1145
+ service: o(({
1146
+ record: s
1147
+ }) => [v(i(Je(s)), 1)]),
1148
+ _: 1
1149
+ }, 8, ["data", "loading", "pagination"])]),
1150
+ _: 1
1151
+ })]),
1152
+ _: 1
1153
+ }, 8, ["active-key"])])];
1154
+ }),
1155
+ _: 1
1156
+ }, 8, ["visible", "width"]), r(n(Pe), {
1157
+ visible: j.value,
1158
+ "onUpdate:visible": e[2] || (e[2] = (d) => j.value = d),
1159
+ title: "等待支付完成",
1160
+ footer: !1,
1161
+ "mask-closable": !1,
1162
+ width: 380,
1163
+ onCancel: we
1164
+ }, {
1165
+ default: o(() => {
1166
+ var d, b;
1167
+ return [a("div", za, [a("div", Ta, [a("span", null, i(((d = x.value) == null ? void 0 : d.packageName) || "积分充值"), 1), a("strong", null, "¥" + i(((b = x.value) == null ? void 0 : b.priceYuan) || "0.00"), 1)]), a("div", Ea, [r(n(de), {
1168
+ size: 32
1169
+ })]), a("div", Aa, [e[32] || (e[32] = a("span", null, "支付宝收银台已在浏览器打开", -1)), a("small", null, i(n(T) || "请在支付宝页面完成支付,支付成功后这里会自动刷新余额"), 1)]), a("div", La, [r(n(C), {
1170
+ onClick: we
1171
+ }, {
1172
+ default: o(() => [...e[33] || (e[33] = [v("取消", -1)])]),
1173
+ _: 1
1174
+ }), r(n(C), {
1175
+ type: "primary",
1176
+ loading: n(Ne),
1177
+ onClick: at
1178
+ }, {
1179
+ default: o(() => [...e[34] || (e[34] = [v(" 我已完成支付 ", -1)])]),
1180
+ _: 1
1181
+ }, 8, ["loading"])])])];
1182
+ }),
1183
+ _: 1
1184
+ }, 8, ["visible"])], 64));
1185
+ }
1186
+ }), Xa = /* @__PURE__ */ Ct(Oa, [["__scopeId", "data-v-c97d4b66"]]);
1187
+ export {
1188
+ Xa as P,
1189
+ xe as a,
1190
+ Qa as b,
1191
+ xt as o,
1192
+ It as u,
1193
+ Nt as v
1194
+ };