@huyooo/ui 2.1.13 → 2.1.14
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/dist/{PricingPlans-rArK_Fv1.js → PricingPlans-CpkbxJQW.js} +47 -44
- package/dist/composables/Billing/useBillingPlans.d.ts +2 -0
- package/dist/composables.js +1 -1
- package/dist/main.js +2 -2
- package/dist/pay.js +2 -2
- package/dist/style.css +1 -1
- package/dist/{useSubscriptionCheckout-Dmg0kt4F.js → useSubscriptionCheckout-CZZLk_1d.js} +137 -137
- package/package.json +1 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as v, computed as S } from "vue";
|
|
2
2
|
import { d as V } from "./useBillingStatusOptions-C6edto7H.js";
|
|
3
3
|
import { g as $ } from "./apiClients-CWSwNzGk.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { Message as
|
|
5
|
+
import { Message as b } from "@arco-design/web-vue";
|
|
6
6
|
import { u as _ } from "./useEnsureAuthenticated-RZ1DflLz.js";
|
|
7
7
|
function D(e) {
|
|
8
8
|
var u;
|
|
9
|
-
const
|
|
10
|
-
return typeof
|
|
9
|
+
const i = (u = e == null ? void 0 : e.metadata) == null ? void 0 : u.originalPrice;
|
|
10
|
+
return typeof i == "number" ? i : void 0;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
return !e ||
|
|
12
|
+
function x(e) {
|
|
13
|
+
const i = D(e);
|
|
14
|
+
return !e || i === void 0 || i <= e.unitAmount ? 0 : i - e.unitAmount;
|
|
15
15
|
}
|
|
16
16
|
function H(e) {
|
|
17
|
-
var
|
|
18
|
-
const
|
|
17
|
+
var a;
|
|
18
|
+
const i = [], u = (a = e == null ? void 0 : e.metadata) == null ? void 0 : a.includedPointsLabel;
|
|
19
19
|
if (typeof u == "string" && u.trim())
|
|
20
|
-
|
|
20
|
+
i.push(u.trim());
|
|
21
21
|
else {
|
|
22
22
|
const s = typeof (e == null ? void 0 : e.bonusPoints) == "number" ? e.bonusPoints : 0;
|
|
23
|
-
s > 0 &&
|
|
23
|
+
s > 0 && i.push(`含 ${s.toLocaleString("zh-CN")} 积分`);
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
return
|
|
25
|
+
const c = x(e);
|
|
26
|
+
return c > 0 && i.push(`优惠 ¥${P(c)}`), i.join(" · ");
|
|
27
27
|
}
|
|
28
28
|
function P(e) {
|
|
29
29
|
return e === void 0 ? 0 : Math.floor(e / 100);
|
|
30
30
|
}
|
|
31
|
-
function J(e,
|
|
32
|
-
const u =
|
|
31
|
+
function J(e, i = 1) {
|
|
32
|
+
const u = i > 1 ? `每 ${i} ` : "按";
|
|
33
33
|
switch (e) {
|
|
34
34
|
case "month":
|
|
35
35
|
return `${u}月订阅`;
|
|
@@ -44,31 +44,31 @@ function J(e, r = 1) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function W(e) {
|
|
47
|
-
const
|
|
47
|
+
const i = e != null && e.intervalCount && e.intervalCount > 1 ? `${e.intervalCount} ` : "";
|
|
48
48
|
switch (e == null ? void 0 : e.interval) {
|
|
49
49
|
case "month":
|
|
50
|
-
return `/ ${
|
|
50
|
+
return `/ ${i}月`;
|
|
51
51
|
case "year":
|
|
52
|
-
return `/ ${
|
|
52
|
+
return `/ ${i}年`;
|
|
53
53
|
case "day":
|
|
54
|
-
return `/ ${
|
|
54
|
+
return `/ ${i}天`;
|
|
55
55
|
case "week":
|
|
56
|
-
return `/ ${
|
|
56
|
+
return `/ ${i}周`;
|
|
57
57
|
default:
|
|
58
58
|
return "";
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
function X(e) {
|
|
62
|
-
const
|
|
62
|
+
const i = (e == null ? void 0 : e.intervalCount) ?? 1;
|
|
63
63
|
switch (e == null ? void 0 : e.interval) {
|
|
64
64
|
case "month":
|
|
65
|
-
return `${
|
|
65
|
+
return `${i} 个月`;
|
|
66
66
|
case "year":
|
|
67
|
-
return `${
|
|
67
|
+
return `${i} 年`;
|
|
68
68
|
case "day":
|
|
69
|
-
return `${
|
|
69
|
+
return `${i} 天`;
|
|
70
70
|
case "week":
|
|
71
|
-
return `${
|
|
71
|
+
return `${i} 周`;
|
|
72
72
|
default:
|
|
73
73
|
return "";
|
|
74
74
|
}
|
|
@@ -91,12 +91,12 @@ function A(e) {
|
|
|
91
91
|
}
|
|
92
92
|
function q(e) {
|
|
93
93
|
if (e.type === "quota" && e.value !== void 0) {
|
|
94
|
-
const
|
|
94
|
+
const i = A(e.quotaPeriod), u = i ? ` / ${i}` : "";
|
|
95
95
|
return `${e.name}: ${e.value === -1 ? "无限" : e.value}${u}`;
|
|
96
96
|
}
|
|
97
97
|
if (e.type === "unlimited") {
|
|
98
|
-
const
|
|
99
|
-
return
|
|
98
|
+
const i = A(e.quotaPeriod);
|
|
99
|
+
return i ? `${e.name}: 不限 / ${i}` : `${e.name}不限`;
|
|
100
100
|
}
|
|
101
101
|
return e.type === "boolean" && e.value === !1 ? `${e.name}(不支持)` : e.name;
|
|
102
102
|
}
|
|
@@ -107,21 +107,21 @@ function I(e) {
|
|
|
107
107
|
intervalCount: e.intervalCount ?? 1
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
function Y(e,
|
|
110
|
+
function Y(e, i) {
|
|
111
111
|
const u = {
|
|
112
112
|
day: 1,
|
|
113
113
|
week: 2,
|
|
114
114
|
month: 3,
|
|
115
115
|
year: 4
|
|
116
116
|
};
|
|
117
|
-
return u[e.interval] - u[
|
|
117
|
+
return u[e.interval] - u[i.interval] || e.intervalCount - i.intervalCount;
|
|
118
118
|
}
|
|
119
|
-
function Z(e,
|
|
119
|
+
function Z(e, i) {
|
|
120
120
|
let u = 0;
|
|
121
|
-
for (const
|
|
122
|
-
for (const
|
|
123
|
-
const s = I(
|
|
124
|
-
(s == null ? void 0 : s.key) ===
|
|
121
|
+
for (const c of e)
|
|
122
|
+
for (const a of c.prices) {
|
|
123
|
+
const s = I(a);
|
|
124
|
+
(s == null ? void 0 : s.key) === i && (u = Math.max(u, x(a)));
|
|
125
125
|
}
|
|
126
126
|
return u > 0 ? `最高优惠 ¥${P(u)}` : void 0;
|
|
127
127
|
}
|
|
@@ -132,45 +132,45 @@ function B() {
|
|
|
132
132
|
return !!localStorage.getItem("jwtToken");
|
|
133
133
|
}
|
|
134
134
|
function ae(e = "month") {
|
|
135
|
-
const
|
|
135
|
+
const i = v([]), u = v(null), c = v(null), a = v(!1), s = v(!1), d = v(ee(e)), f = S(() => {
|
|
136
136
|
const n = /* @__PURE__ */ new Map();
|
|
137
|
-
for (const t of
|
|
138
|
-
for (const
|
|
139
|
-
const
|
|
140
|
-
|
|
137
|
+
for (const t of i.value)
|
|
138
|
+
for (const r of t.prices) {
|
|
139
|
+
const o = I(r);
|
|
140
|
+
o && n.set(o.key, o);
|
|
141
141
|
}
|
|
142
142
|
return [...n.values()].sort(Y).map((t) => ({
|
|
143
143
|
value: t.key,
|
|
144
144
|
label: J(t.interval, t.intervalCount),
|
|
145
|
-
badge: Z(
|
|
145
|
+
badge: Z(i.value, t.key)
|
|
146
146
|
}));
|
|
147
147
|
}), p = S(() => {
|
|
148
148
|
const n = [];
|
|
149
|
-
for (const t of
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
return (
|
|
153
|
-
}),
|
|
154
|
-
|
|
149
|
+
for (const t of i.value) {
|
|
150
|
+
const r = t.prices.find((g) => {
|
|
151
|
+
const h = I(g);
|
|
152
|
+
return (h == null ? void 0 : h.key) === d.value;
|
|
153
|
+
}), o = t.prices.find((g) => g.type === "free"), l = r ?? (o && t.prices.every((g) => g.type === "free") ? o : void 0);
|
|
154
|
+
l && n.push({
|
|
155
155
|
...t,
|
|
156
|
-
features:
|
|
157
|
-
selectedPrice:
|
|
156
|
+
features: l.features ?? [],
|
|
157
|
+
selectedPrice: l
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
return n;
|
|
161
161
|
});
|
|
162
|
-
function
|
|
163
|
-
|
|
162
|
+
function F(n) {
|
|
163
|
+
d.value = n;
|
|
164
164
|
}
|
|
165
165
|
function y(n) {
|
|
166
|
-
const t = u.value,
|
|
167
|
-
return t != null && t.priceId && n.selectedPrice ? t.priceId === n.selectedPrice.id : t ? t.productId === n.id :
|
|
166
|
+
const t = u.value, r = c.value;
|
|
167
|
+
return t != null && t.priceId && n.selectedPrice ? t.priceId === n.selectedPrice.id : t ? t.productId === n.id : r != null && r.priceId && n.selectedPrice ? r.priceId === n.selectedPrice.id : r ? r.productId === n.id : !1;
|
|
168
168
|
}
|
|
169
169
|
function C(n) {
|
|
170
170
|
var t;
|
|
171
171
|
return ((t = u.value) == null ? void 0 : t.productId) === n.id;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function m(n) {
|
|
174
174
|
var t;
|
|
175
175
|
return ((t = n.selectedPrice) == null ? void 0 : t.type) === "free";
|
|
176
176
|
}
|
|
@@ -178,7 +178,7 @@ function ae(e = "month") {
|
|
|
178
178
|
return !!u.value;
|
|
179
179
|
}
|
|
180
180
|
function E(n) {
|
|
181
|
-
return !!(!n.selectedPrice || y(n) ||
|
|
181
|
+
return !!(!n.selectedPrice || y(n) || m(n) && U());
|
|
182
182
|
}
|
|
183
183
|
function w(n) {
|
|
184
184
|
var t;
|
|
@@ -193,10 +193,10 @@ function ae(e = "month") {
|
|
|
193
193
|
return t === void 0 ? void 0 : P(t);
|
|
194
194
|
}
|
|
195
195
|
function G(n) {
|
|
196
|
-
return
|
|
196
|
+
return m(n) ? "" : W(n.selectedPrice);
|
|
197
197
|
}
|
|
198
198
|
function O(n) {
|
|
199
|
-
if (
|
|
199
|
+
if (m(n)) {
|
|
200
200
|
const t = X(n.selectedPrice);
|
|
201
201
|
return t ? `${t}免费体验` : "免费体验";
|
|
202
202
|
}
|
|
@@ -207,7 +207,7 @@ function ae(e = "month") {
|
|
|
207
207
|
return y(n) ? t.push({
|
|
208
208
|
label: "当前方案",
|
|
209
209
|
type: "current"
|
|
210
|
-
}) :
|
|
210
|
+
}) : m(n) ? t.push({
|
|
211
211
|
label: "免费体验",
|
|
212
212
|
type: "trial"
|
|
213
213
|
}) : w(n) && t.push({
|
|
@@ -217,55 +217,55 @@ function ae(e = "month") {
|
|
|
217
217
|
}
|
|
218
218
|
function N(n) {
|
|
219
219
|
const t = u.value;
|
|
220
|
-
return y(n) ? "当前方案" :
|
|
220
|
+
return y(n) ? "当前方案" : m(n) ? t ? "已订阅付费方案" : B() ? "免费开通" : "免费注册" : t ? C(n) ? "切换周期" : typeof t.unitAmount == "number" && n.selectedPrice.unitAmount > t.unitAmount ? "升级方案" : "切换方案" : "立即订阅";
|
|
221
221
|
}
|
|
222
222
|
function R(n, t) {
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (c) {
|
|
228
|
-
const a = A(c.quotaPeriod), o = c.value === -1 ? "不限量" : c.value;
|
|
229
|
-
return `${c.name} ${a ? `${o} / ${a}` : o},覆盖核心使用场景。`;
|
|
223
|
+
const r = n.features.find((o) => o.type === "quota" && o.value !== void 0);
|
|
224
|
+
if (r) {
|
|
225
|
+
const o = A(r.quotaPeriod), l = r.value === -1 ? "不限量" : r.value;
|
|
226
|
+
return `${r.name} ${o ? `${l} / ${o}` : l},覆盖核心使用场景。`;
|
|
230
227
|
}
|
|
231
|
-
return
|
|
228
|
+
return m(n) ? "注册后自动开通免费权益,适合先体验核心能力。" : t === 1 ? "为正式团队准备的高配能力组合。" : "包含入门所需的核心能力。";
|
|
232
229
|
}
|
|
233
230
|
function z(n) {
|
|
234
|
-
return n.filter((t) => t.
|
|
231
|
+
return n.filter((t) => t.type !== "boolean" || t.value !== !1).map((t) => ({
|
|
235
232
|
title: q(t),
|
|
236
|
-
description: t.description || ""
|
|
233
|
+
description: t.description || "",
|
|
234
|
+
highlight: t.highlight === !0
|
|
237
235
|
}));
|
|
238
236
|
}
|
|
239
237
|
function K(n) {
|
|
240
|
-
const t = n.filter((
|
|
241
|
-
title: q(
|
|
242
|
-
description:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
238
|
+
const t = n.filter((l) => l.type === "quota" || l.type === "unlimited").map((l) => ({
|
|
239
|
+
title: q(l),
|
|
240
|
+
description: l.description || "",
|
|
241
|
+
highlight: l.highlight === !0
|
|
242
|
+
})), r = n.filter((l) => l.type === "boolean" && l.value !== !1).map((l) => ({
|
|
243
|
+
title: l.name,
|
|
244
|
+
description: l.description || "",
|
|
245
|
+
highlight: l.highlight === !0
|
|
246
|
+
})), o = [];
|
|
247
|
+
return r.length && o.push({
|
|
248
248
|
title: "功能特性",
|
|
249
|
-
items:
|
|
250
|
-
}),
|
|
249
|
+
items: r
|
|
250
|
+
}), t.length && o.push({
|
|
251
251
|
title: "用量配额",
|
|
252
|
-
items:
|
|
253
|
-
}),
|
|
252
|
+
items: t
|
|
253
|
+
}), o;
|
|
254
254
|
}
|
|
255
255
|
async function k() {
|
|
256
|
-
|
|
256
|
+
a.value = !0;
|
|
257
257
|
const {
|
|
258
258
|
data: n,
|
|
259
259
|
error: t
|
|
260
260
|
} = await V.productOptions();
|
|
261
|
-
if (
|
|
261
|
+
if (a.value = !1, t)
|
|
262
262
|
return;
|
|
263
|
-
|
|
263
|
+
i.value = Array.isArray(n) ? n : [], !f.value.some((o) => o.value === d.value) && f.value[0] && (d.value = f.value[0].value);
|
|
264
264
|
}
|
|
265
265
|
async function L() {
|
|
266
|
-
var
|
|
266
|
+
var o;
|
|
267
267
|
if (!B()) {
|
|
268
|
-
u.value = null,
|
|
268
|
+
u.value = null, c.value = null;
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
s.value = !0;
|
|
@@ -275,57 +275,57 @@ function ae(e = "month") {
|
|
|
275
275
|
} = await $().billing.subscriptions.summary.post();
|
|
276
276
|
if (s.value = !1, t)
|
|
277
277
|
return;
|
|
278
|
-
const
|
|
279
|
-
if (!(
|
|
280
|
-
u.value = null,
|
|
278
|
+
const r = n;
|
|
279
|
+
if (!(r != null && r.entitlement) || !r.product) {
|
|
280
|
+
u.value = null, c.value = null;
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
|
-
if (
|
|
283
|
+
if (r.entitlement.acquiredBy === "subscribe" && r.price) {
|
|
284
284
|
u.value = {
|
|
285
|
-
id:
|
|
286
|
-
productId:
|
|
287
|
-
productName:
|
|
288
|
-
priceId:
|
|
289
|
-
interval:
|
|
290
|
-
intervalCount:
|
|
291
|
-
unitAmount:
|
|
292
|
-
currency:
|
|
293
|
-
status:
|
|
294
|
-
currentPeriodStart:
|
|
295
|
-
currentPeriodEnd:
|
|
296
|
-
cancelAtPeriodEnd: !!
|
|
297
|
-
pendingChange:
|
|
285
|
+
id: r.entitlement.sourceId,
|
|
286
|
+
productId: r.product.id,
|
|
287
|
+
productName: r.product.name,
|
|
288
|
+
priceId: r.price.id,
|
|
289
|
+
interval: r.price.interval || void 0,
|
|
290
|
+
intervalCount: r.price.intervalCount || void 0,
|
|
291
|
+
unitAmount: r.price.unitAmount || void 0,
|
|
292
|
+
currency: r.price.currency || void 0,
|
|
293
|
+
status: r.entitlement.status,
|
|
294
|
+
currentPeriodStart: r.entitlement.startAt || void 0,
|
|
295
|
+
currentPeriodEnd: r.entitlement.endAt,
|
|
296
|
+
cancelAtPeriodEnd: !!r.entitlement.cancelAtPeriodEnd,
|
|
297
|
+
pendingChange: r.entitlement.pendingChange || null,
|
|
298
298
|
trialEnd: null
|
|
299
|
-
},
|
|
299
|
+
}, c.value = null;
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
|
-
u.value = null,
|
|
303
|
-
id:
|
|
304
|
-
productId:
|
|
305
|
-
productName:
|
|
306
|
-
priceId: (
|
|
307
|
-
status:
|
|
308
|
-
startAt:
|
|
309
|
-
endAt:
|
|
302
|
+
u.value = null, c.value = {
|
|
303
|
+
id: r.entitlement.sourceId,
|
|
304
|
+
productId: r.product.id,
|
|
305
|
+
productName: r.product.name,
|
|
306
|
+
priceId: (o = r.price) == null ? void 0 : o.id,
|
|
307
|
+
status: r.entitlement.status,
|
|
308
|
+
startAt: r.entitlement.startAt,
|
|
309
|
+
endAt: r.entitlement.endAt
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
312
|
async function Q() {
|
|
313
313
|
await Promise.all([k(), L()]);
|
|
314
314
|
}
|
|
315
315
|
return {
|
|
316
|
-
products:
|
|
316
|
+
products: i,
|
|
317
317
|
plans: p,
|
|
318
318
|
currentSubscription: u,
|
|
319
|
-
currentTrial:
|
|
320
|
-
listLoading:
|
|
319
|
+
currentTrial: c,
|
|
320
|
+
listLoading: a,
|
|
321
321
|
currentLoading: s,
|
|
322
|
-
billingInterval:
|
|
323
|
-
billingIntervalTabs:
|
|
324
|
-
setBillingInterval:
|
|
322
|
+
billingInterval: d,
|
|
323
|
+
billingIntervalTabs: f,
|
|
324
|
+
setBillingInterval: F,
|
|
325
325
|
isCurrentPlan: y,
|
|
326
326
|
isSameProduct: C,
|
|
327
327
|
isRecommendedPlan: w,
|
|
328
|
-
isFreePlan:
|
|
328
|
+
isFreePlan: m,
|
|
329
329
|
isPlanActionDisabled: E,
|
|
330
330
|
getDisplayPrice: M,
|
|
331
331
|
getDisplayOriginalPrice: j,
|
|
@@ -351,46 +351,46 @@ function re(e) {
|
|
|
351
351
|
return e && typeof e == "object" && "alipayUrl" in e && typeof e.alipayUrl == "string" ? e.alipayUrl : "";
|
|
352
352
|
}
|
|
353
353
|
function de(e) {
|
|
354
|
-
const
|
|
354
|
+
const i = v(null), {
|
|
355
355
|
ensureAuthenticated: u
|
|
356
356
|
} = _();
|
|
357
|
-
async function
|
|
357
|
+
async function c(s) {
|
|
358
358
|
if (!s.selectedPrice) {
|
|
359
|
-
|
|
359
|
+
b.warning("当前方案暂无可购买价格");
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
362
|
-
if (!u(() =>
|
|
363
|
-
const
|
|
364
|
-
if ((
|
|
365
|
-
|
|
362
|
+
if (!u(() => c(s))) return;
|
|
363
|
+
const d = e.currentSubscription.value;
|
|
364
|
+
if ((d == null ? void 0 : d.priceId) === s.selectedPrice.id) {
|
|
365
|
+
b.info("当前已经是该方案");
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
368
|
if (s.selectedPrice.type === "free")
|
|
369
369
|
return;
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
subscriptionId:
|
|
370
|
+
i.value = s.id;
|
|
371
|
+
const f = d ? await $().billing.subscriptions.change.post({
|
|
372
|
+
subscriptionId: d.id,
|
|
373
373
|
newPriceId: s.selectedPrice.id,
|
|
374
374
|
proration: !0
|
|
375
375
|
}) : await $().billing.subscriptions.create.post({
|
|
376
376
|
priceId: s.selectedPrice.id
|
|
377
377
|
});
|
|
378
|
-
if (
|
|
378
|
+
if (i.value = null, f.error)
|
|
379
379
|
return;
|
|
380
|
-
const p = re(
|
|
380
|
+
const p = re(f.data);
|
|
381
381
|
if (p) {
|
|
382
382
|
te(p);
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
|
-
|
|
385
|
+
b.success(ne(f.data) || "订阅已更新"), await e.refreshCurrentSubscription();
|
|
386
386
|
}
|
|
387
|
-
function
|
|
388
|
-
return
|
|
387
|
+
function a(s) {
|
|
388
|
+
return i.value === s.id;
|
|
389
389
|
}
|
|
390
390
|
return {
|
|
391
|
-
checkoutPlanId:
|
|
392
|
-
checkout:
|
|
393
|
-
isCheckingOut:
|
|
391
|
+
checkoutPlanId: i,
|
|
392
|
+
checkout: c,
|
|
393
|
+
isCheckingOut: a
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
396
|
export {
|