@seayoo-web/gamer-api 1.0.3 → 1.1.0
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/README.md +6 -14
- package/dist/index.js +359 -295
- package/package.json +8 -8
- package/types/src/token.d.ts +16 -15
- package/types/src/token.define.d.ts +0 -4
- package/types/src/utils.d.ts +8 -2
- package/types/src/weixin.d.ts +1 -3
package/dist/index.js
CHANGED
|
@@ -1,32 +1,69 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (e, t, r) =>
|
|
4
|
-
import { isComboWebView as
|
|
5
|
-
import { isPlainObject as n, useConsole as
|
|
1
|
+
var V = Object.defineProperty;
|
|
2
|
+
var Q = (e, t, r) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var u = (e, t, r) => Q(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { isComboWebView as M } from "@seayoo-web/combo-webview";
|
|
5
|
+
import { isPlainObject as n, useConsole as H, Support as m, usePromise as T, pruneURL as j, queryString as h, pruneObject as s, isArray as a, isString as z, isValuedString as J, parseJSON as K, removePara as A } from "@seayoo-web/utils";
|
|
6
6
|
import "@seayoo-web/request";
|
|
7
|
-
function
|
|
7
|
+
function N(e) {
|
|
8
8
|
return n(e, "gamer_token") && typeof e.gamer_token == "string";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function L(e) {
|
|
11
11
|
return n(e);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
const l = H("GamerApiSDK");
|
|
14
|
+
async function O() {
|
|
15
|
+
const { promise: e, resolve: t } = T();
|
|
16
|
+
return wx.login({
|
|
17
|
+
success(r) {
|
|
18
|
+
t(r);
|
|
19
|
+
},
|
|
20
|
+
fail() {
|
|
21
|
+
t("");
|
|
22
|
+
}
|
|
23
|
+
}), await e;
|
|
24
|
+
}
|
|
25
|
+
const X = {
|
|
26
|
+
get(e) {
|
|
27
|
+
return localStorage.getItem(e) || "";
|
|
28
|
+
},
|
|
29
|
+
set(e, t) {
|
|
30
|
+
localStorage.setItem(e, t);
|
|
31
|
+
},
|
|
32
|
+
remove(e) {
|
|
33
|
+
localStorage.removeItem(e);
|
|
34
|
+
}
|
|
35
|
+
}, Y = {
|
|
36
|
+
get(e) {
|
|
37
|
+
try {
|
|
38
|
+
if (m.wx) return wx.getStorageSync(e) || "";
|
|
39
|
+
} catch (t) {
|
|
40
|
+
l.error("getStorageSyncError", t);
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
},
|
|
44
|
+
set(e, t) {
|
|
45
|
+
try {
|
|
46
|
+
m.wx && wx.setStorageSync(e, t);
|
|
47
|
+
} catch (r) {
|
|
48
|
+
l.error("setStorageSyncError", r);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
remove(e) {
|
|
52
|
+
try {
|
|
53
|
+
m.wx && wx.removeStorageSync(e);
|
|
54
|
+
} catch (t) {
|
|
55
|
+
l.error("removeStorageSync", t);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, _ = "gamer_token";
|
|
59
|
+
class Xt {
|
|
60
|
+
constructor(t, r) {
|
|
23
61
|
u(this, "$idToken", "");
|
|
24
62
|
u(this, "$weixinToken", "");
|
|
25
63
|
u(this, "$gamerToken", "");
|
|
26
|
-
u(this, "inWxMiniProgram", !1);
|
|
27
64
|
u(this, "req");
|
|
28
65
|
u(this, "storage");
|
|
29
|
-
this.storage =
|
|
66
|
+
this.storage = m.wx ? Y : X, this.req = r({
|
|
30
67
|
baseURL: `https://${j(t)}/v1`,
|
|
31
68
|
timeout: 1e4,
|
|
32
69
|
responseRule: {
|
|
@@ -38,10 +75,21 @@ class Ot {
|
|
|
38
75
|
}
|
|
39
76
|
},
|
|
40
77
|
// 使用箭头函数绑定执行上下文
|
|
41
|
-
requestTransformer: (
|
|
42
|
-
this.$gamerToken && (
|
|
78
|
+
requestTransformer: (i) => {
|
|
79
|
+
this.$gamerToken && (i.headers.Authorization = `Bearer ${this.$gamerToken}`);
|
|
80
|
+
}
|
|
81
|
+
}), M() ? this.$gamerToken = h("gamer_token") : this.loadGamerTokenCache();
|
|
82
|
+
}
|
|
83
|
+
loadGamerTokenCache() {
|
|
84
|
+
const r = this.storage.get(_).match(/^(\d{12,})#(.{8,})$/);
|
|
85
|
+
if (r) {
|
|
86
|
+
const i = parseInt(r[1]), c = r[2];
|
|
87
|
+
if (i > Date.now() - 2 * 24 * 3600 * 1e3) {
|
|
88
|
+
this.$gamerToken = c;
|
|
89
|
+
return;
|
|
43
90
|
}
|
|
44
|
-
}
|
|
91
|
+
}
|
|
92
|
+
this.storage.remove(_);
|
|
45
93
|
}
|
|
46
94
|
/** 当前是否为登录状态,即是否拥有 gamerToken */
|
|
47
95
|
get isLogined() {
|
|
@@ -53,7 +101,7 @@ class Ot {
|
|
|
53
101
|
}
|
|
54
102
|
/** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
|
|
55
103
|
set idToken(t) {
|
|
56
|
-
t !== this.$idToken && (this.$
|
|
104
|
+
t !== this.$idToken && (this.$idToken = t, this.gamerToken = "");
|
|
57
105
|
}
|
|
58
106
|
/** 读取设置 wexinToken */
|
|
59
107
|
get weixinToken() {
|
|
@@ -65,15 +113,17 @@ class Ot {
|
|
|
65
113
|
* 仅仅在微信小程序模式下有效
|
|
66
114
|
*/
|
|
67
115
|
set weixinToken(t) {
|
|
68
|
-
this.$weixinToken !== t && (this.$weixinToken = t, this
|
|
116
|
+
this.$weixinToken !== t && (this.$weixinToken = t, this.gamerToken = "");
|
|
69
117
|
}
|
|
70
118
|
/** 读取自动置换的 gamerToken */
|
|
71
119
|
get gamerToken() {
|
|
72
120
|
return this.$gamerToken;
|
|
73
121
|
}
|
|
74
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* 直接写入 Gamer Token,并更新缓存
|
|
124
|
+
*/
|
|
75
125
|
set gamerToken(t) {
|
|
76
|
-
this.$gamerToken = t;
|
|
126
|
+
this.$gamerToken = t, t ? this.storage.set(_, `${Date.now()}#${t}`) : this.storage.remove(_);
|
|
77
127
|
}
|
|
78
128
|
/**
|
|
79
129
|
* 用世游通行证统一登录能力签发的 ID Token / Weixin Token,自动置换 Gamer Token,成功后会自动设置后续 Request Headers
|
|
@@ -86,20 +136,31 @@ class Ot {
|
|
|
86
136
|
*
|
|
87
137
|
* - 此方法通常不需要手动调用,在需要登录的接口调用时会自动执行
|
|
88
138
|
* - 为了提高页面执行速度,可以在设置 Token 后立即调用 autoLogin
|
|
139
|
+
*
|
|
140
|
+
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=ReeJpWraRO
|
|
89
141
|
*/
|
|
90
142
|
async autoLogin() {
|
|
91
143
|
if (this.gamerToken)
|
|
92
144
|
return !0;
|
|
93
145
|
if (!this.idToken)
|
|
94
|
-
return
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
97
|
-
const {
|
|
146
|
+
return l.error("Missing idToken when call autoLogin()"), !1;
|
|
147
|
+
if (m.wx && !this.weixinToken)
|
|
148
|
+
return l.error("Missing weixinToken when call autoLogin()"), !1;
|
|
149
|
+
const { code: t, data: r } = await this.req.post(
|
|
98
150
|
"login-with-token",
|
|
99
|
-
s({ id_token: this.idToken, weixin_token:
|
|
100
|
-
|
|
151
|
+
s({ id_token: this.idToken, weixin_token: m.wx ? this.weixinToken : null }),
|
|
152
|
+
N,
|
|
153
|
+
{ message: !1 }
|
|
101
154
|
);
|
|
102
|
-
|
|
155
|
+
switch (t) {
|
|
156
|
+
case "invalid_id_token":
|
|
157
|
+
this.idToken = "";
|
|
158
|
+
break;
|
|
159
|
+
case "invalid_weixin_token":
|
|
160
|
+
this.weixinToken = "";
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
return this.gamerToken = (r == null ? void 0 : r.gamer_token) || "", !!this.gamerToken;
|
|
103
164
|
}
|
|
104
165
|
/**
|
|
105
166
|
* 获取当前 Session 的信息
|
|
@@ -108,7 +169,9 @@ class Ot {
|
|
|
108
169
|
*/
|
|
109
170
|
async getSession() {
|
|
110
171
|
if (await this.autoLogin()) return null;
|
|
111
|
-
const { data: t } = await this.req.get("session",
|
|
172
|
+
const { data: t } = await this.req.get("session", L, {
|
|
173
|
+
message: !1
|
|
174
|
+
});
|
|
112
175
|
return t;
|
|
113
176
|
}
|
|
114
177
|
/**
|
|
@@ -118,11 +181,11 @@ class Ot {
|
|
|
118
181
|
*/
|
|
119
182
|
async authRealName(t) {
|
|
120
183
|
if (await this.autoLogin()) return null;
|
|
121
|
-
const { data: r } = await this.req.post("auth-real-name", s(t),
|
|
184
|
+
const { data: r } = await this.req.post("auth-real-name", s(t), L);
|
|
122
185
|
return r;
|
|
123
186
|
}
|
|
124
187
|
}
|
|
125
|
-
function
|
|
188
|
+
function Z(e) {
|
|
126
189
|
return n(
|
|
127
190
|
e,
|
|
128
191
|
"default_avatar_url",
|
|
@@ -140,7 +203,7 @@ function N(e) {
|
|
|
140
203
|
(t) => n(t, "exp", "level", "title")
|
|
141
204
|
);
|
|
142
205
|
}
|
|
143
|
-
function
|
|
206
|
+
function W(e) {
|
|
144
207
|
return n(
|
|
145
208
|
e,
|
|
146
209
|
"member_id",
|
|
@@ -154,10 +217,10 @@ function X(e) {
|
|
|
154
217
|
"level_expire_time"
|
|
155
218
|
) && typeof e.player_id == "string";
|
|
156
219
|
}
|
|
157
|
-
function
|
|
158
|
-
return n(e, "player") &&
|
|
220
|
+
function C(e) {
|
|
221
|
+
return n(e, "player") && W(e.player);
|
|
159
222
|
}
|
|
160
|
-
function
|
|
223
|
+
function S(e) {
|
|
161
224
|
return n(
|
|
162
225
|
e,
|
|
163
226
|
"role_id",
|
|
@@ -166,21 +229,21 @@ function U(e) {
|
|
|
166
229
|
"server_id",
|
|
167
230
|
"server_name",
|
|
168
231
|
"last_login_time"
|
|
169
|
-
) &&
|
|
232
|
+
) && z(e.server_id) && J(e.role_id);
|
|
170
233
|
}
|
|
171
|
-
function
|
|
172
|
-
return n(e, "roles") && a(e.roles,
|
|
234
|
+
function ee(e) {
|
|
235
|
+
return n(e, "roles") && a(e.roles, S);
|
|
173
236
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
237
|
+
function te(e) {
|
|
238
|
+
return S(e) && n(e, "role_fighting");
|
|
176
239
|
}
|
|
177
|
-
function
|
|
178
|
-
return n(e, "role_card") &&
|
|
240
|
+
function f(e) {
|
|
241
|
+
return n(e, "role_card") && te(e.role_card);
|
|
179
242
|
}
|
|
180
|
-
function
|
|
243
|
+
function U(e) {
|
|
181
244
|
return n(e, "name", "avatar_url", "bio", "gender", "birthday") && n(e.birthday, "year", "month", "day");
|
|
182
245
|
}
|
|
183
|
-
function
|
|
246
|
+
function v(e) {
|
|
184
247
|
return n(
|
|
185
248
|
e,
|
|
186
249
|
"address_id",
|
|
@@ -193,10 +256,10 @@ function y(e) {
|
|
|
193
256
|
"is_default"
|
|
194
257
|
);
|
|
195
258
|
}
|
|
196
|
-
function
|
|
197
|
-
return n(e, "addresses") && a(e.addresses,
|
|
259
|
+
function re(e) {
|
|
260
|
+
return n(e, "addresses") && a(e.addresses, v);
|
|
198
261
|
}
|
|
199
|
-
function
|
|
262
|
+
function ne(e) {
|
|
200
263
|
return n(
|
|
201
264
|
e,
|
|
202
265
|
"increased_credit",
|
|
@@ -205,7 +268,7 @@ function W(e) {
|
|
|
205
268
|
"balance_credit"
|
|
206
269
|
);
|
|
207
270
|
}
|
|
208
|
-
function
|
|
271
|
+
function ie(e) {
|
|
209
272
|
return n(
|
|
210
273
|
e,
|
|
211
274
|
"id",
|
|
@@ -216,10 +279,10 @@ function ee(e) {
|
|
|
216
279
|
"change_scene"
|
|
217
280
|
);
|
|
218
281
|
}
|
|
219
|
-
function
|
|
220
|
-
return n(e, "credit_logs") && a(e.credit_logs,
|
|
282
|
+
function se(e) {
|
|
283
|
+
return n(e, "credit_logs") && a(e.credit_logs, ie);
|
|
221
284
|
}
|
|
222
|
-
function
|
|
285
|
+
function oe(e) {
|
|
223
286
|
return n(
|
|
224
287
|
e,
|
|
225
288
|
"benefit_id",
|
|
@@ -232,10 +295,10 @@ function re(e) {
|
|
|
232
295
|
"tag"
|
|
233
296
|
);
|
|
234
297
|
}
|
|
235
|
-
function
|
|
236
|
-
return n(e, "benefits") && a(e.benefits,
|
|
298
|
+
function ae(e) {
|
|
299
|
+
return n(e, "benefits") && a(e.benefits, oe);
|
|
237
300
|
}
|
|
238
|
-
function
|
|
301
|
+
function ue(e) {
|
|
239
302
|
return n(
|
|
240
303
|
e,
|
|
241
304
|
"benefit_id",
|
|
@@ -245,12 +308,12 @@ function ie(e) {
|
|
|
245
308
|
"min_level",
|
|
246
309
|
"max_level",
|
|
247
310
|
"product_id"
|
|
248
|
-
) && ("product" in e ?
|
|
311
|
+
) && ("product" in e ? D(e.product) : !0);
|
|
249
312
|
}
|
|
250
|
-
function
|
|
251
|
-
return n(e, "benefit") &&
|
|
313
|
+
function ce(e) {
|
|
314
|
+
return n(e, "benefit") && ue(e.benefit);
|
|
252
315
|
}
|
|
253
|
-
function
|
|
316
|
+
function D(e) {
|
|
254
317
|
return n(
|
|
255
318
|
e,
|
|
256
319
|
"product_id",
|
|
@@ -279,10 +342,10 @@ function $(e) {
|
|
|
279
342
|
"updated_at"
|
|
280
343
|
);
|
|
281
344
|
}
|
|
282
|
-
function
|
|
283
|
-
return n(e, "products") && a(e.products,
|
|
345
|
+
function me(e) {
|
|
346
|
+
return n(e, "products") && a(e.products, D);
|
|
284
347
|
}
|
|
285
|
-
function
|
|
348
|
+
function le(e) {
|
|
286
349
|
return n(
|
|
287
350
|
e,
|
|
288
351
|
"redemption_id",
|
|
@@ -297,9 +360,9 @@ function ae(e) {
|
|
|
297
360
|
"amount",
|
|
298
361
|
"status",
|
|
299
362
|
"created_at"
|
|
300
|
-
) && ("extra_data" in e ?
|
|
363
|
+
) && ("extra_data" in e ? _e(e.extra_data) || ge(e.extra_data) : !0);
|
|
301
364
|
}
|
|
302
|
-
function
|
|
365
|
+
function _e(e) {
|
|
303
366
|
return n(
|
|
304
367
|
e,
|
|
305
368
|
"address",
|
|
@@ -312,14 +375,14 @@ function ue(e) {
|
|
|
312
375
|
"express_number"
|
|
313
376
|
);
|
|
314
377
|
}
|
|
315
|
-
function
|
|
378
|
+
function ge(e) {
|
|
316
379
|
return n(e, "server_id", "role_id", "role_name");
|
|
317
380
|
}
|
|
318
|
-
function
|
|
319
|
-
return n(e, "redemptions") && a(e.redemptions,
|
|
381
|
+
function de(e) {
|
|
382
|
+
return n(e, "redemptions") && a(e.redemptions, le);
|
|
320
383
|
}
|
|
321
|
-
var
|
|
322
|
-
class
|
|
384
|
+
var pe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Male = "male", e.Female = "female", e))(pe || {}), fe = /* @__PURE__ */ ((e) => (e.Increase = "increase", e.Decrease = "decrease", e.Expired = "expired", e))(fe || {}), ye = /* @__PURE__ */ ((e) => (e.Order = "order", e.Consumption = "consumption", e.Redeem = "redeem", e.Expire = "expire", e.Admin = "admin", e.Event = "event", e))(ye || {}), we = /* @__PURE__ */ ((e) => (e.GameReward = "game_reward", e.Physical = "physical", e.Virtual = "virtual", e))(we || {}), he = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.issued = "issued", e.failed = "failed", e))(he || {});
|
|
385
|
+
class Yt {
|
|
323
386
|
constructor(t) {
|
|
324
387
|
u(this, "token");
|
|
325
388
|
u(this, "req");
|
|
@@ -331,7 +394,7 @@ class Kt {
|
|
|
331
394
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=tuhsPt3ihp
|
|
332
395
|
*/
|
|
333
396
|
async getConfig() {
|
|
334
|
-
const { data: t } = await this.req.get("club/config",
|
|
397
|
+
const { data: t } = await this.req.get("club/config", Z);
|
|
335
398
|
return t;
|
|
336
399
|
}
|
|
337
400
|
/**
|
|
@@ -341,7 +404,7 @@ class Kt {
|
|
|
341
404
|
*/
|
|
342
405
|
async getCurrentPlayer() {
|
|
343
406
|
await this.token.autoLogin();
|
|
344
|
-
const { data: t, code: r } = await this.req.get("club/current-player",
|
|
407
|
+
const { data: t, code: r } = await this.req.get("club/current-player", C);
|
|
345
408
|
return (t == null ? void 0 : t.player) ?? { error: r };
|
|
346
409
|
}
|
|
347
410
|
/**
|
|
@@ -356,7 +419,7 @@ class Kt {
|
|
|
356
419
|
{
|
|
357
420
|
id_token: this.token.idToken
|
|
358
421
|
},
|
|
359
|
-
|
|
422
|
+
C
|
|
360
423
|
);
|
|
361
424
|
return (t == null ? void 0 : t.player) ?? {
|
|
362
425
|
error: r
|
|
@@ -369,7 +432,7 @@ class Kt {
|
|
|
369
432
|
*/
|
|
370
433
|
async getRoles(t, r) {
|
|
371
434
|
if (!await this.token.autoLogin()) return [];
|
|
372
|
-
const { data: i } = await this.req.get("club/roles",
|
|
435
|
+
const { data: i } = await this.req.get("club/roles", ee, {
|
|
373
436
|
params: s({ player_id: t, refresh: r })
|
|
374
437
|
});
|
|
375
438
|
return (i == null ? void 0 : i.roles) || [];
|
|
@@ -380,7 +443,7 @@ class Kt {
|
|
|
380
443
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=A1Wr7kUXnS
|
|
381
444
|
*/
|
|
382
445
|
async getRoleCard(t) {
|
|
383
|
-
const { data: r } = await this.req.get("club/role-card",
|
|
446
|
+
const { data: r } = await this.req.get("club/role-card", f, {
|
|
384
447
|
params: { member_id: t }
|
|
385
448
|
});
|
|
386
449
|
return (r == null ? void 0 : r.role_card) ?? null;
|
|
@@ -392,7 +455,7 @@ class Kt {
|
|
|
392
455
|
*/
|
|
393
456
|
async setRoleCard(t) {
|
|
394
457
|
if (!await this.token.autoLogin()) return null;
|
|
395
|
-
const { data: r } = await this.req.post("club/role-card", t,
|
|
458
|
+
const { data: r } = await this.req.post("club/role-card", t, f);
|
|
396
459
|
return (r == null ? void 0 : r.role_card) ?? null;
|
|
397
460
|
}
|
|
398
461
|
/**
|
|
@@ -402,7 +465,7 @@ class Kt {
|
|
|
402
465
|
*/
|
|
403
466
|
async refreshRoleCard() {
|
|
404
467
|
if (!await this.token.autoLogin()) return null;
|
|
405
|
-
const { data: t } = await this.req.post("club/refresh-role-card", {},
|
|
468
|
+
const { data: t } = await this.req.post("club/refresh-role-card", {}, f);
|
|
406
469
|
return (t == null ? void 0 : t.role_card) ?? null;
|
|
407
470
|
}
|
|
408
471
|
/**
|
|
@@ -411,7 +474,7 @@ class Kt {
|
|
|
411
474
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=TMWBCFcOr2
|
|
412
475
|
*/
|
|
413
476
|
async getUserProfile(t) {
|
|
414
|
-
const { data: r } = await this.req.get("club/user-profile",
|
|
477
|
+
const { data: r } = await this.req.get("club/user-profile", U, {
|
|
415
478
|
params: { member_id: t }
|
|
416
479
|
});
|
|
417
480
|
return r;
|
|
@@ -423,7 +486,7 @@ class Kt {
|
|
|
423
486
|
*/
|
|
424
487
|
async updateUserProfile(t) {
|
|
425
488
|
await this.token.autoLogin();
|
|
426
|
-
const { data: r, code: i } = await this.req.post("club/user-profile", t,
|
|
489
|
+
const { data: r, code: i } = await this.req.post("club/user-profile", t, U);
|
|
427
490
|
return r ?? {
|
|
428
491
|
error: i
|
|
429
492
|
};
|
|
@@ -435,7 +498,7 @@ class Kt {
|
|
|
435
498
|
*/
|
|
436
499
|
async getAddresses() {
|
|
437
500
|
if (!await this.token.autoLogin()) return [];
|
|
438
|
-
const { data: t } = await this.req.get("club/addresses",
|
|
501
|
+
const { data: t } = await this.req.get("club/addresses", re);
|
|
439
502
|
return (t == null ? void 0 : t.addresses) ?? [];
|
|
440
503
|
}
|
|
441
504
|
/**
|
|
@@ -445,7 +508,7 @@ class Kt {
|
|
|
445
508
|
*/
|
|
446
509
|
async addAddress(t) {
|
|
447
510
|
if (!await this.token.autoLogin()) return null;
|
|
448
|
-
const { data: r } = await this.req.post("/club/add-address", s(t),
|
|
511
|
+
const { data: r } = await this.req.post("/club/add-address", s(t), v);
|
|
449
512
|
return r;
|
|
450
513
|
}
|
|
451
514
|
/**
|
|
@@ -455,7 +518,7 @@ class Kt {
|
|
|
455
518
|
*/
|
|
456
519
|
async updateAddress(t) {
|
|
457
520
|
await this.token.autoLogin();
|
|
458
|
-
const { data: r, code: i } = await this.req.post("club/update-address", s(t),
|
|
521
|
+
const { data: r, code: i } = await this.req.post("club/update-address", s(t), v);
|
|
459
522
|
return r ?? { error: i };
|
|
460
523
|
}
|
|
461
524
|
/**
|
|
@@ -475,7 +538,7 @@ class Kt {
|
|
|
475
538
|
*/
|
|
476
539
|
async getUserCredit(t) {
|
|
477
540
|
await this.token.autoLogin();
|
|
478
|
-
const { data: r, code: i } = await this.req.get("club/user-credit",
|
|
541
|
+
const { data: r, code: i } = await this.req.get("club/user-credit", ne, { params: s(t) });
|
|
479
542
|
return r ?? { error: i };
|
|
480
543
|
}
|
|
481
544
|
/**
|
|
@@ -485,7 +548,7 @@ class Kt {
|
|
|
485
548
|
*/
|
|
486
549
|
async getCreditLogs(t) {
|
|
487
550
|
await this.token.autoLogin();
|
|
488
|
-
const { data: r } = await this.req.get("club/credit-logs",
|
|
551
|
+
const { data: r } = await this.req.get("club/credit-logs", se, {
|
|
489
552
|
params: s({ max_results: 20, ...t })
|
|
490
553
|
});
|
|
491
554
|
return r || { credit_logs: [] };
|
|
@@ -497,7 +560,7 @@ class Kt {
|
|
|
497
560
|
*/
|
|
498
561
|
async getBenefits() {
|
|
499
562
|
if (!await this.token.autoLogin()) return [];
|
|
500
|
-
const { data: t } = await this.req.get("club/benefits",
|
|
563
|
+
const { data: t } = await this.req.get("club/benefits", ae);
|
|
501
564
|
return (t == null ? void 0 : t.benefits) || [];
|
|
502
565
|
}
|
|
503
566
|
/**
|
|
@@ -507,7 +570,7 @@ class Kt {
|
|
|
507
570
|
*/
|
|
508
571
|
async getBenefit(t) {
|
|
509
572
|
if (!await this.token.autoLogin()) return null;
|
|
510
|
-
const { data: r } = await this.req.get("club/benefit",
|
|
573
|
+
const { data: r } = await this.req.get("club/benefit", ce, {
|
|
511
574
|
params: { benefit_id: t }
|
|
512
575
|
});
|
|
513
576
|
return (r == null ? void 0 : r.benefit) || null;
|
|
@@ -518,7 +581,7 @@ class Kt {
|
|
|
518
581
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=r3vC3PzfMQ
|
|
519
582
|
*/
|
|
520
583
|
async getProducts() {
|
|
521
|
-
const { data: t } = await this.req.get("club/products",
|
|
584
|
+
const { data: t } = await this.req.get("club/products", me);
|
|
522
585
|
return (t == null ? void 0 : t.products) || [];
|
|
523
586
|
}
|
|
524
587
|
/**
|
|
@@ -540,18 +603,18 @@ class Kt {
|
|
|
540
603
|
*/
|
|
541
604
|
async getRedemptions(t) {
|
|
542
605
|
await this.token.autoLogin();
|
|
543
|
-
const { data: r } = await this.req.get("club/redemptions",
|
|
606
|
+
const { data: r } = await this.req.get("club/redemptions", de, {
|
|
544
607
|
params: s({ max_results: 20, ...t })
|
|
545
608
|
});
|
|
546
609
|
return r || { redemptions: [] };
|
|
547
610
|
}
|
|
548
611
|
}
|
|
549
|
-
var
|
|
550
|
-
function
|
|
551
|
-
return n(e, "event_name", "rules", "since", "until", "visit_count", "features") && Array.isArray(e.features) && e.features.every(
|
|
612
|
+
var ve = /* @__PURE__ */ ((e) => (e.EventItem = "event_item", e.GameItem = "game_item", e.PhysicalItem = "physical_item", e.WeixinHongbao = "weixin_hongbao", e.GiftCode = "gift_code", e.LotteryTicket = "lottery_ticket", e.VoidItem = "void_item", e))(ve || {}), ke = /* @__PURE__ */ ((e) => (e.UserId = "user_id", e.RoleId = "role_id", e))(ke || {}), be = /* @__PURE__ */ ((e) => (e.None = "none", e.Daily = "daily", e.Weekly = "weekly", e.Monthly = "monthly", e))(be || {}), o = /* @__PURE__ */ ((e) => (e.Preregister = "preregister", e.Lottery = "lottery", e.Survey = "survey", e.Invite = "invite", e.Share = "share", e.Follow = "follow", e.Subscribe = "weixin_subscribe", e.Comment = "comment", e.Vote = "vote", e.GiftCode = "gift_code", e.Register = "register", e.InvitedRegister = "invited_register", e.ClaimRewards = "claim_rewards", e.Cashback = "cashback", e.Quest = "quest", e.Team = "team", e.LotteryDraw = "lottery_draw", e))(o || {}), qe = /* @__PURE__ */ ((e) => (e.Active = "player_active_points", e.Login = "player_login_days", e.OrderAmount = "order_total_amount", e.Posts = "community_posts", e.Comments = "community_comments", e))(qe || {}), Re = /* @__PURE__ */ ((e) => (e.System = "system", e.UserSubmission = "user_submission", e.Shortlisted = "shortlisted", e))(Re || {}), xe = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e))(xe || {}), Ae = /* @__PURE__ */ ((e) => (e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e.Delivered = "delivered", e))(Ae || {}), Le = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e))(Le || {}), Ce = /* @__PURE__ */ ((e) => (e.Output = "output", e.Engage = "engage", e))(Ce || {}), Ue = /* @__PURE__ */ ((e) => (e.Private = "private", e.Public = "public", e))(Ue || {}), Pe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Pending = "pending", e.Drawn = "drawn", e.Claimed = "claimed", e.Fail = "fail", e))(Pe || {}), $e = /* @__PURE__ */ ((e) => (e.Assemble = "assemble", e.Join = "join", e.Disband = "disband", e.ChangeVisibility = "change_visibility", e.Query = "query", e))($e || {}), Se = /* @__PURE__ */ ((e) => (e.Query = "query", e.Draw = "draw", e.Claim = "claim", e))(Se || {});
|
|
613
|
+
function De(e) {
|
|
614
|
+
return n(e, "event_name", "rules", "since", "until", "visit_count", "features") && Array.isArray(e.features) && e.features.every(Ee);
|
|
552
615
|
}
|
|
553
|
-
function
|
|
554
|
-
if (!
|
|
616
|
+
function Ee(e) {
|
|
617
|
+
if (!Fe(e))
|
|
555
618
|
return !1;
|
|
556
619
|
switch (e.feature_type) {
|
|
557
620
|
case o.Preregister:
|
|
@@ -560,36 +623,36 @@ function Ue(e) {
|
|
|
560
623
|
case o.InvitedRegister:
|
|
561
624
|
return !0;
|
|
562
625
|
case o.Lottery:
|
|
563
|
-
return
|
|
626
|
+
return Be(e.config);
|
|
564
627
|
case o.Survey:
|
|
565
|
-
return
|
|
628
|
+
return Ve(e.config);
|
|
566
629
|
case o.Invite:
|
|
567
|
-
return
|
|
630
|
+
return Qe(e.config);
|
|
568
631
|
case o.Share:
|
|
569
|
-
return Se(e.config);
|
|
570
|
-
case o.Follow:
|
|
571
632
|
return Me(e.config);
|
|
633
|
+
case o.Follow:
|
|
634
|
+
return He(e.config);
|
|
572
635
|
case o.Subscribe:
|
|
573
|
-
return
|
|
636
|
+
return Te(e.config);
|
|
574
637
|
case o.Comment:
|
|
575
|
-
return
|
|
638
|
+
return je(e.config);
|
|
576
639
|
case o.Vote:
|
|
577
|
-
return
|
|
640
|
+
return ze(e.config);
|
|
578
641
|
case o.Cashback:
|
|
579
|
-
return
|
|
642
|
+
return Ke(e.config);
|
|
580
643
|
case o.GiftCode:
|
|
581
|
-
return
|
|
644
|
+
return Ne(e.config);
|
|
582
645
|
case o.Quest:
|
|
583
|
-
return
|
|
646
|
+
return Xe(e.config);
|
|
584
647
|
case o.Team:
|
|
585
|
-
return
|
|
648
|
+
return Ye(e.config);
|
|
586
649
|
case o.LotteryDraw:
|
|
587
|
-
return
|
|
650
|
+
return Ze(e.config);
|
|
588
651
|
default:
|
|
589
652
|
return !1;
|
|
590
653
|
}
|
|
591
654
|
}
|
|
592
|
-
function
|
|
655
|
+
function k(e) {
|
|
593
656
|
return n(
|
|
594
657
|
e,
|
|
595
658
|
"reward_item_id",
|
|
@@ -599,10 +662,10 @@ function w(e) {
|
|
|
599
662
|
"reward_item_type"
|
|
600
663
|
);
|
|
601
664
|
}
|
|
602
|
-
function
|
|
603
|
-
return n(e, "feature_reward_type", "reward_details") && (e.feature_reward_type === "every" ? Array.isArray(e.reward_details) && e.reward_details.every(
|
|
665
|
+
function Ge(e) {
|
|
666
|
+
return n(e, "feature_reward_type", "reward_details") && (e.feature_reward_type === "every" ? Array.isArray(e.reward_details) && e.reward_details.every(k) : e.feature_reward_type === "regular" ? n(e.reward_details, "engage_count", "rewards") && Array.isArray(e.reward_details.rewards) && e.reward_details.rewards.every(k) : !1);
|
|
604
667
|
}
|
|
605
|
-
function
|
|
668
|
+
function Fe(e) {
|
|
606
669
|
return n(
|
|
607
670
|
e,
|
|
608
671
|
"feature_id",
|
|
@@ -615,9 +678,9 @@ function De(e) {
|
|
|
615
678
|
"until",
|
|
616
679
|
"engage_account_type",
|
|
617
680
|
"feature_rewards"
|
|
618
|
-
) && Array.isArray(e.feature_rewards) && e.feature_rewards.every(
|
|
681
|
+
) && Array.isArray(e.feature_rewards) && e.feature_rewards.every(Ge);
|
|
619
682
|
}
|
|
620
|
-
function
|
|
683
|
+
function Ie(e) {
|
|
621
684
|
return n(
|
|
622
685
|
e,
|
|
623
686
|
"reward_item_id",
|
|
@@ -628,7 +691,7 @@ function Ee(e) {
|
|
|
628
691
|
"reward_remaining_stock"
|
|
629
692
|
);
|
|
630
693
|
}
|
|
631
|
-
function
|
|
694
|
+
function Be(e) {
|
|
632
695
|
return n(
|
|
633
696
|
e,
|
|
634
697
|
"consume_item_id",
|
|
@@ -636,27 +699,27 @@ function Fe(e) {
|
|
|
636
699
|
"consume_item_icon_url",
|
|
637
700
|
"consume_item_count",
|
|
638
701
|
"rewards"
|
|
639
|
-
) && Array.isArray(e.rewards) && e.rewards.every(
|
|
702
|
+
) && Array.isArray(e.rewards) && e.rewards.every(Ie);
|
|
640
703
|
}
|
|
641
|
-
function
|
|
704
|
+
function Ve(e) {
|
|
642
705
|
return n(e, "survey_id", "survey_url");
|
|
643
706
|
}
|
|
644
|
-
function
|
|
707
|
+
function Qe(e) {
|
|
645
708
|
return n(e, "share_url");
|
|
646
709
|
}
|
|
647
|
-
function
|
|
710
|
+
function Me(e) {
|
|
648
711
|
return n(e, "share_platform");
|
|
649
712
|
}
|
|
650
|
-
function
|
|
713
|
+
function He(e) {
|
|
651
714
|
return n(e, "platform");
|
|
652
715
|
}
|
|
653
|
-
function
|
|
716
|
+
function Te(e) {
|
|
654
717
|
return n(e, "weixin_template_ids") && Array.isArray(e.weixin_template_ids) && e.weixin_template_ids.every((t) => typeof t == "string");
|
|
655
718
|
}
|
|
656
|
-
function
|
|
719
|
+
function je(e) {
|
|
657
720
|
return n(e, "comments", "send_rate") && Array.isArray(e.comments) && e.comments.every((t) => typeof t == "string");
|
|
658
721
|
}
|
|
659
|
-
function
|
|
722
|
+
function ze(e) {
|
|
660
723
|
return n(
|
|
661
724
|
e,
|
|
662
725
|
"vote_feature_ids",
|
|
@@ -665,12 +728,12 @@ function Qe(e) {
|
|
|
665
728
|
"source",
|
|
666
729
|
"options",
|
|
667
730
|
"rewards"
|
|
668
|
-
) && Array.isArray(e.vote_feature_ids) && Array.isArray(e.submission_feature_ids) && Array.isArray(e.options) && e.options.every(
|
|
731
|
+
) && Array.isArray(e.vote_feature_ids) && Array.isArray(e.submission_feature_ids) && Array.isArray(e.options) && e.options.every(Je) && Array.isArray(e.rewards) && e.rewards.every(k);
|
|
669
732
|
}
|
|
670
|
-
function
|
|
733
|
+
function Je(e) {
|
|
671
734
|
return n(e, "sn", "name", "amount", "jump_url", "last_vote_time", "finalists") && ("img_urls" in e ? Array.isArray(e.img_urls) : !0) && ("video_urls" in e ? Array.isArray(e.video_urls) : !0) && ("descriptions" in e ? Array.isArray(e.descriptions) : !0);
|
|
672
735
|
}
|
|
673
|
-
function
|
|
736
|
+
function Ke(e) {
|
|
674
737
|
return n(
|
|
675
738
|
e,
|
|
676
739
|
"order_start_time",
|
|
@@ -679,42 +742,42 @@ function He(e) {
|
|
|
679
742
|
"claim_rewards_end_time"
|
|
680
743
|
);
|
|
681
744
|
}
|
|
682
|
-
function
|
|
683
|
-
return n(e, "gift_items") && Array.isArray(e.gift_items) && e.gift_items.every(
|
|
745
|
+
function Ne(e) {
|
|
746
|
+
return n(e, "gift_items") && Array.isArray(e.gift_items) && e.gift_items.every(Oe);
|
|
684
747
|
}
|
|
685
|
-
function
|
|
748
|
+
function Oe(e) {
|
|
686
749
|
return n(e, "name", "count", "icon_url");
|
|
687
750
|
}
|
|
688
|
-
function
|
|
751
|
+
function Xe(e) {
|
|
689
752
|
return n(e, "objective", "completion_value") && ("team" in e ? n(e.team, "completion_value") : !0);
|
|
690
753
|
}
|
|
691
|
-
function
|
|
754
|
+
function Ye(e) {
|
|
692
755
|
return n(e, "min_members", "max_members");
|
|
693
756
|
}
|
|
694
|
-
function
|
|
757
|
+
function Ze(e) {
|
|
695
758
|
return n(e, "draw_not_after", "draw_not_before");
|
|
696
759
|
}
|
|
697
|
-
function
|
|
760
|
+
function We(e) {
|
|
698
761
|
return n(e, "allowed", "registered");
|
|
699
762
|
}
|
|
700
|
-
function
|
|
763
|
+
function y(e) {
|
|
701
764
|
return n(e, "count");
|
|
702
765
|
}
|
|
703
|
-
function
|
|
766
|
+
function et(e) {
|
|
704
767
|
return n(e, "engagements") && Array.isArray(e.engagements) && (e.engagements.every(
|
|
705
768
|
(t) => n(t, "user_id", "name", "avatar_url", "comment", "video_note", "created_at")
|
|
706
769
|
) || e.engagements.every((t) => n(t, "team_code", "leader_name", "total_members")));
|
|
707
770
|
}
|
|
708
|
-
function
|
|
771
|
+
function tt(e) {
|
|
709
772
|
return n(e, "first_visit") && typeof e.first_visit == "boolean";
|
|
710
773
|
}
|
|
711
|
-
function
|
|
774
|
+
function rt(e) {
|
|
712
775
|
return n(e, "status") && Array.isArray(e.status) && e.status.every((t) => n(t, "feature_id", "can_engage", "has_unclaimed_rewards"));
|
|
713
776
|
}
|
|
714
|
-
function
|
|
715
|
-
return n(e, "engagements") && a(e.engagements,
|
|
777
|
+
function nt(e) {
|
|
778
|
+
return n(e, "engagements") && a(e.engagements, E);
|
|
716
779
|
}
|
|
717
|
-
function
|
|
780
|
+
function E(e) {
|
|
718
781
|
if (!n(
|
|
719
782
|
e,
|
|
720
783
|
"engagement_id",
|
|
@@ -729,41 +792,41 @@ function D(e) {
|
|
|
729
792
|
if (!("data" in e))
|
|
730
793
|
return !0;
|
|
731
794
|
const t = e.data;
|
|
732
|
-
return
|
|
795
|
+
return it(t) || st(t) || ot(t) || at(t) || ut(t) || ct(t) || mt(t) || lt(t) || _t(t) || gt(t) || dt(t) || pt(t);
|
|
733
796
|
}
|
|
734
|
-
function
|
|
797
|
+
function it(e) {
|
|
735
798
|
return n(e, "platforms") && Array.isArray(e.platforms);
|
|
736
799
|
}
|
|
737
|
-
function
|
|
800
|
+
function st(e) {
|
|
738
801
|
return n(e, "lottery_count");
|
|
739
802
|
}
|
|
740
|
-
function
|
|
803
|
+
function ot(e) {
|
|
741
804
|
return n(e, "serial_number");
|
|
742
805
|
}
|
|
743
|
-
function
|
|
806
|
+
function at(e) {
|
|
744
807
|
return n(e, "user_id");
|
|
745
808
|
}
|
|
746
|
-
function
|
|
809
|
+
function ut(e) {
|
|
747
810
|
return n(e, "platform");
|
|
748
811
|
}
|
|
749
|
-
function
|
|
812
|
+
function ct(e) {
|
|
750
813
|
return n(e, "option_sn");
|
|
751
814
|
}
|
|
752
|
-
function
|
|
815
|
+
function mt(e) {
|
|
753
816
|
return n(e, "weixin_openid");
|
|
754
817
|
}
|
|
755
|
-
function
|
|
818
|
+
function lt(e) {
|
|
756
819
|
return n(e, "cashback_total_amount", "game_item_count", "order_total_amount");
|
|
757
820
|
}
|
|
758
|
-
function
|
|
821
|
+
function _t(e) {
|
|
759
822
|
return n(e, "gift_code");
|
|
760
823
|
}
|
|
761
|
-
function
|
|
824
|
+
function gt(e) {
|
|
762
825
|
return n(e, "team_code", "visibility", "members") && Array.isArray(e.members) && e.members.every(
|
|
763
826
|
(t) => n(t, "is_leader", "role_name", "server_name")
|
|
764
827
|
);
|
|
765
828
|
}
|
|
766
|
-
function
|
|
829
|
+
function dt(e) {
|
|
767
830
|
return n(e, "objective", "progress") ? "team" in e ? n(e.team, "progress", "players") && Array.isArray(e.team.players) && e.team.players.every(
|
|
768
831
|
(t) => n(
|
|
769
832
|
t,
|
|
@@ -773,7 +836,7 @@ function mt(e) {
|
|
|
773
836
|
)
|
|
774
837
|
) : !0 : !1;
|
|
775
838
|
}
|
|
776
|
-
function
|
|
839
|
+
function G(e) {
|
|
777
840
|
return n(
|
|
778
841
|
e,
|
|
779
842
|
"reward_id",
|
|
@@ -792,10 +855,10 @@ function E(e) {
|
|
|
792
855
|
"receive_time"
|
|
793
856
|
) && ("extra_data" in e ? n(e.extra_data) : !0);
|
|
794
857
|
}
|
|
795
|
-
function
|
|
796
|
-
return !n(e, "tickets") || !("status" in e) ? !1 : e.status === "unknown" || e.status === "pending" ? !0 : "reward" in e ?
|
|
858
|
+
function pt(e) {
|
|
859
|
+
return !n(e, "tickets") || !("status" in e) ? !1 : e.status === "unknown" || e.status === "pending" ? !0 : "reward" in e ? G(e.reward) : !1;
|
|
797
860
|
}
|
|
798
|
-
function
|
|
861
|
+
function ft(e) {
|
|
799
862
|
return n(
|
|
800
863
|
e,
|
|
801
864
|
"reward_id",
|
|
@@ -808,31 +871,31 @@ function _t(e) {
|
|
|
808
871
|
"reward_source"
|
|
809
872
|
);
|
|
810
873
|
}
|
|
811
|
-
function
|
|
812
|
-
return n(e, "engagement_id") && ("engagement" in e ?
|
|
874
|
+
function yt(e) {
|
|
875
|
+
return n(e, "engagement_id") && ("engagement" in e ? E(e.engagement) : !0) && ("rewards" in e ? a(e.rewards, ft) : !0);
|
|
813
876
|
}
|
|
814
|
-
function
|
|
877
|
+
function wt(e) {
|
|
815
878
|
return n(e, "reward_id", "reward_status");
|
|
816
879
|
}
|
|
817
|
-
function
|
|
818
|
-
return n(e, "claimed_items") && a(e.claimed_items,
|
|
880
|
+
function ht(e) {
|
|
881
|
+
return n(e, "claimed_items") && a(e.claimed_items, wt);
|
|
819
882
|
}
|
|
820
|
-
function
|
|
883
|
+
function vt(e) {
|
|
821
884
|
return n(e, "reward_status");
|
|
822
885
|
}
|
|
823
|
-
function
|
|
824
|
-
return n(e, "user_rewards") && a(e.user_rewards,
|
|
886
|
+
function kt(e) {
|
|
887
|
+
return n(e, "user_rewards") && a(e.user_rewards, G);
|
|
825
888
|
}
|
|
826
|
-
function
|
|
889
|
+
function bt(e) {
|
|
827
890
|
return n(e, "scene");
|
|
828
891
|
}
|
|
829
|
-
function
|
|
892
|
+
function qt(e) {
|
|
830
893
|
return n(e, "params");
|
|
831
894
|
}
|
|
832
|
-
function
|
|
895
|
+
function Rt(e) {
|
|
833
896
|
return n(e, "img") && typeof e.img == "string";
|
|
834
897
|
}
|
|
835
|
-
class
|
|
898
|
+
class Zt {
|
|
836
899
|
constructor(t, r) {
|
|
837
900
|
u(this, "token");
|
|
838
901
|
u(this, "event", 0);
|
|
@@ -845,7 +908,7 @@ class Nt {
|
|
|
845
908
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OWGSPF3Ysl
|
|
846
909
|
*/
|
|
847
910
|
async verifyMobileAllowed(t) {
|
|
848
|
-
const { data: r } = await this.req.get("verify-mobile-allowed",
|
|
911
|
+
const { data: r } = await this.req.get("verify-mobile-allowed", We, {
|
|
849
912
|
params: { mobile: t }
|
|
850
913
|
});
|
|
851
914
|
return r;
|
|
@@ -856,7 +919,7 @@ class Nt {
|
|
|
856
919
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=wFXxtdNKPm
|
|
857
920
|
*/
|
|
858
921
|
async getConfig() {
|
|
859
|
-
const { data: t } = await this.req.get(`event/${this.event}/event-config`,
|
|
922
|
+
const { data: t } = await this.req.get(`event/${this.event}/event-config`, De);
|
|
860
923
|
return t;
|
|
861
924
|
}
|
|
862
925
|
/**
|
|
@@ -865,7 +928,7 @@ class Nt {
|
|
|
865
928
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
866
929
|
*/
|
|
867
930
|
async getEngagementsUserCount(t) {
|
|
868
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`,
|
|
931
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, y, {
|
|
869
932
|
params: { feature_id: t, type: "user" }
|
|
870
933
|
});
|
|
871
934
|
return (r == null ? void 0 : r.count) ?? null;
|
|
@@ -876,7 +939,7 @@ class Nt {
|
|
|
876
939
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
877
940
|
*/
|
|
878
941
|
async getEngagementsCount(t) {
|
|
879
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`,
|
|
942
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagement-count`, y, {
|
|
880
943
|
params: { feature_id: t, type: "engagement" }
|
|
881
944
|
});
|
|
882
945
|
return (r == null ? void 0 : r.count) ?? null;
|
|
@@ -887,7 +950,7 @@ class Nt {
|
|
|
887
950
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=THtZ4ewIQW
|
|
888
951
|
*/
|
|
889
952
|
async getEngagements(t) {
|
|
890
|
-
const { data: r } = await this.req.get(`event/${this.event}/feature-engagements`,
|
|
953
|
+
const { data: r } = await this.req.get(`event/${this.event}/feature-engagements`, et, {
|
|
891
954
|
params: { feature_id: t }
|
|
892
955
|
});
|
|
893
956
|
return (r == null ? void 0 : r.engagements) || [];
|
|
@@ -902,7 +965,7 @@ class Nt {
|
|
|
902
965
|
const { data: r, code: i } = await this.req.post(
|
|
903
966
|
`event/${this.event}/visit`,
|
|
904
967
|
s(t || {}),
|
|
905
|
-
|
|
968
|
+
tt
|
|
906
969
|
);
|
|
907
970
|
return r ?? {
|
|
908
971
|
error: i
|
|
@@ -917,8 +980,9 @@ class Nt {
|
|
|
917
980
|
*/
|
|
918
981
|
async getUserFeatureStatus(t) {
|
|
919
982
|
if (!await this.token.autoLogin()) return [];
|
|
920
|
-
const { data: r } = await this.req.get("event/user-feature-status",
|
|
921
|
-
params: s({ ...t, event_id: this.event })
|
|
983
|
+
const { data: r } = await this.req.get("event/user-feature-status", rt, {
|
|
984
|
+
params: s({ ...t, event_id: this.event }),
|
|
985
|
+
message: !1
|
|
922
986
|
});
|
|
923
987
|
return (r == null ? void 0 : r.status) || [];
|
|
924
988
|
}
|
|
@@ -929,7 +993,7 @@ class Nt {
|
|
|
929
993
|
*/
|
|
930
994
|
async getUserEngagements(t) {
|
|
931
995
|
if (!await this.token.autoLogin()) return [];
|
|
932
|
-
const { data: r } = await this.req.get(`event/${this.event}/user-engagements`,
|
|
996
|
+
const { data: r } = await this.req.get(`event/${this.event}/user-engagements`, nt, {
|
|
933
997
|
params: { feature_id: t }
|
|
934
998
|
});
|
|
935
999
|
return (r == null ? void 0 : r.engagements) || [];
|
|
@@ -941,7 +1005,7 @@ class Nt {
|
|
|
941
1005
|
*/
|
|
942
1006
|
async engage(t) {
|
|
943
1007
|
await this.token.autoLogin();
|
|
944
|
-
const { data: r, code: i } = await this.req.post(`event/${this.event}/engame`, s(t),
|
|
1008
|
+
const { data: r, code: i } = await this.req.post(`event/${this.event}/engame`, s(t), yt);
|
|
945
1009
|
return r ?? {
|
|
946
1010
|
error: i
|
|
947
1011
|
};
|
|
@@ -956,7 +1020,7 @@ class Nt {
|
|
|
956
1020
|
const { data: r, code: i } = await this.req.post(
|
|
957
1021
|
`event/${this.event}/claim-rewards`,
|
|
958
1022
|
s(t),
|
|
959
|
-
|
|
1023
|
+
ht
|
|
960
1024
|
);
|
|
961
1025
|
return (r == null ? void 0 : r.claimed_items) ?? {
|
|
962
1026
|
error: i
|
|
@@ -972,7 +1036,7 @@ class Nt {
|
|
|
972
1036
|
const { data: r, code: i } = await this.req.post(
|
|
973
1037
|
`event/${this.event}/claim-weixin-hongbao`,
|
|
974
1038
|
{ reward_id: t },
|
|
975
|
-
|
|
1039
|
+
vt
|
|
976
1040
|
);
|
|
977
1041
|
return r ?? {
|
|
978
1042
|
error: i
|
|
@@ -988,7 +1052,7 @@ class Nt {
|
|
|
988
1052
|
const { data: r } = await this.req.post(
|
|
989
1053
|
"event/user-rewards",
|
|
990
1054
|
s({ ...t, event_id: this.event }),
|
|
991
|
-
|
|
1055
|
+
kt
|
|
992
1056
|
);
|
|
993
1057
|
return (r == null ? void 0 : r.user_rewards) || [];
|
|
994
1058
|
}
|
|
@@ -999,7 +1063,7 @@ class Nt {
|
|
|
999
1063
|
*/
|
|
1000
1064
|
async getUserItemCount(t) {
|
|
1001
1065
|
if (!await this.token.autoLogin()) return null;
|
|
1002
|
-
const { data: r } = await this.req.get(`event/${this.event}/user-item-count`,
|
|
1066
|
+
const { data: r } = await this.req.get(`event/${this.event}/user-item-count`, y, {
|
|
1003
1067
|
params: { item_id: t }
|
|
1004
1068
|
});
|
|
1005
1069
|
return (r == null ? void 0 : r.count) ?? null;
|
|
@@ -1023,7 +1087,7 @@ class Nt {
|
|
|
1023
1087
|
*/
|
|
1024
1088
|
async getUnlimitQrcodeScene(t) {
|
|
1025
1089
|
if (!await this.token.autoLogin()) return null;
|
|
1026
|
-
const { data: r } = await this.req.get("event/unlimit-qrcode-scene",
|
|
1090
|
+
const { data: r } = await this.req.get("event/unlimit-qrcode-scene", bt, {
|
|
1027
1091
|
params: { params: t }
|
|
1028
1092
|
});
|
|
1029
1093
|
return (r == null ? void 0 : r.scene) ?? null;
|
|
@@ -1036,7 +1100,7 @@ class Nt {
|
|
|
1036
1100
|
* @param scene - 小程序码 scene 值
|
|
1037
1101
|
*/
|
|
1038
1102
|
async getParamsByQrcodeScene(t) {
|
|
1039
|
-
const { data: r } = await this.req.get("event/params-by-qrcode-scene",
|
|
1103
|
+
const { data: r } = await this.req.get("event/params-by-qrcode-scene", qt, {
|
|
1040
1104
|
params: { scene: t }
|
|
1041
1105
|
});
|
|
1042
1106
|
return (r == null ? void 0 : r.params) ?? null;
|
|
@@ -1048,26 +1112,26 @@ class Nt {
|
|
|
1048
1112
|
*/
|
|
1049
1113
|
async generateUnlimitQrcode(t) {
|
|
1050
1114
|
if (!await this.token.autoLogin()) return null;
|
|
1051
|
-
const { data: r } = await this.req.post("event/unlimit-qrcode", s(t),
|
|
1115
|
+
const { data: r } = await this.req.post("event/unlimit-qrcode", s(t), Rt);
|
|
1052
1116
|
return (r == null ? void 0 : r.img) ?? null;
|
|
1053
1117
|
}
|
|
1054
1118
|
}
|
|
1055
1119
|
function F(e) {
|
|
1056
1120
|
return n(e, "forum_id", "icon_url", "name", "tags", "sort", "mode", "member_ids") && Array.isArray(e.tags) && Array.isArray(e.member_ids);
|
|
1057
1121
|
}
|
|
1058
|
-
function
|
|
1122
|
+
function xt(e) {
|
|
1059
1123
|
return n(e, "forums") && a(e.forums, F);
|
|
1060
1124
|
}
|
|
1061
|
-
function
|
|
1125
|
+
function b(e) {
|
|
1062
1126
|
return n(e, "topic_id", "cover_url", "name", "description", "tags", "post_num") && Array.isArray(e.tags);
|
|
1063
1127
|
}
|
|
1064
|
-
function
|
|
1065
|
-
return n(e, "topics") && a(e.topics,
|
|
1128
|
+
function At(e) {
|
|
1129
|
+
return n(e, "topics") && a(e.topics, b);
|
|
1066
1130
|
}
|
|
1067
|
-
function
|
|
1068
|
-
return n(e, "topic") &&
|
|
1131
|
+
function Lt(e) {
|
|
1132
|
+
return n(e, "topic") && b(e.topic);
|
|
1069
1133
|
}
|
|
1070
|
-
function
|
|
1134
|
+
function q(e) {
|
|
1071
1135
|
return n(
|
|
1072
1136
|
e,
|
|
1073
1137
|
"post_id",
|
|
@@ -1087,21 +1151,21 @@ function v(e) {
|
|
|
1087
1151
|
"is_highlighted",
|
|
1088
1152
|
"status",
|
|
1089
1153
|
"create_time"
|
|
1090
|
-
) && a(e.topics,
|
|
1154
|
+
) && a(e.topics, b) && F(e.forum);
|
|
1091
1155
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return n(e, "next_token", "posts") && a(e.posts,
|
|
1156
|
+
function P(e) {
|
|
1157
|
+
return n(e, "next_token", "posts") && a(e.posts, q);
|
|
1094
1158
|
}
|
|
1095
|
-
function
|
|
1096
|
-
return n(e, "post") &&
|
|
1159
|
+
function Ct(e) {
|
|
1160
|
+
return n(e, "post") && q(e.post);
|
|
1097
1161
|
}
|
|
1098
|
-
function
|
|
1162
|
+
function R(e) {
|
|
1099
1163
|
return n(e);
|
|
1100
1164
|
}
|
|
1101
|
-
function
|
|
1102
|
-
return n(e) && ("post" in e ?
|
|
1165
|
+
function Ut(e) {
|
|
1166
|
+
return n(e) && ("post" in e ? q(e.post) : !0) && ("antispam" in e ? R(e.antispam) : !0);
|
|
1103
1167
|
}
|
|
1104
|
-
function
|
|
1168
|
+
function g(e) {
|
|
1105
1169
|
return n(
|
|
1106
1170
|
e,
|
|
1107
1171
|
"comment_id",
|
|
@@ -1116,15 +1180,15 @@ function l(e) {
|
|
|
1116
1180
|
"image_url",
|
|
1117
1181
|
"create_time",
|
|
1118
1182
|
"status"
|
|
1119
|
-
) && ("replies" in e ? a(e.replies,
|
|
1183
|
+
) && ("replies" in e ? a(e.replies, x) : !0);
|
|
1120
1184
|
}
|
|
1121
|
-
function
|
|
1122
|
-
return n(e, "comment") &&
|
|
1185
|
+
function Pt(e) {
|
|
1186
|
+
return n(e, "comment") && g(e.comment);
|
|
1123
1187
|
}
|
|
1124
|
-
function
|
|
1125
|
-
return n(e, "comments") && a(e.comments,
|
|
1188
|
+
function $t(e) {
|
|
1189
|
+
return n(e, "comments") && a(e.comments, g);
|
|
1126
1190
|
}
|
|
1127
|
-
function
|
|
1191
|
+
function x(e) {
|
|
1128
1192
|
return n(
|
|
1129
1193
|
e,
|
|
1130
1194
|
"reply_id",
|
|
@@ -1137,27 +1201,27 @@ function b(e) {
|
|
|
1137
1201
|
"liked",
|
|
1138
1202
|
"reply_to",
|
|
1139
1203
|
"create_time"
|
|
1140
|
-
) &&
|
|
1204
|
+
) && St(e.reply_to);
|
|
1141
1205
|
}
|
|
1142
|
-
function
|
|
1206
|
+
function St(e) {
|
|
1143
1207
|
return n(e, "reply_id", "replied_by", "avatar_url", "nickname");
|
|
1144
1208
|
}
|
|
1145
|
-
function
|
|
1146
|
-
return n(e) && ("comment" in e ?
|
|
1209
|
+
function Dt(e) {
|
|
1210
|
+
return n(e) && ("comment" in e ? g(e.comment) : !0) && ("antispam" in e ? R(e.antispam) : !0);
|
|
1147
1211
|
}
|
|
1148
|
-
function
|
|
1149
|
-
return n(e, "replies") && a(e.replies,
|
|
1212
|
+
function Et(e) {
|
|
1213
|
+
return n(e, "replies") && a(e.replies, x);
|
|
1150
1214
|
}
|
|
1151
|
-
function
|
|
1152
|
-
return n(e, "reply") &&
|
|
1215
|
+
function Gt(e) {
|
|
1216
|
+
return n(e, "reply") && x(e.reply);
|
|
1153
1217
|
}
|
|
1154
|
-
function
|
|
1155
|
-
return n(e) && ("reply" in e ?
|
|
1218
|
+
function Ft(e) {
|
|
1219
|
+
return n(e) && ("reply" in e ? g(e.comment) : !0) && ("antispam" in e ? R(e.antispam) : !0);
|
|
1156
1220
|
}
|
|
1157
|
-
function
|
|
1221
|
+
function It(e) {
|
|
1158
1222
|
return n(e, "image_url", "upload_url", "existed") && typeof e.existed == "boolean";
|
|
1159
1223
|
}
|
|
1160
|
-
function
|
|
1224
|
+
function Bt(e) {
|
|
1161
1225
|
return n(
|
|
1162
1226
|
e,
|
|
1163
1227
|
"notification_id",
|
|
@@ -1169,14 +1233,14 @@ function Ft(e) {
|
|
|
1169
1233
|
"origin_user_avatar_url"
|
|
1170
1234
|
);
|
|
1171
1235
|
}
|
|
1172
|
-
function
|
|
1173
|
-
return n(e, "notifications") && a(e.notifications,
|
|
1236
|
+
function Vt(e) {
|
|
1237
|
+
return n(e, "notifications") && a(e.notifications, Bt);
|
|
1174
1238
|
}
|
|
1175
|
-
function
|
|
1239
|
+
function Qt(e) {
|
|
1176
1240
|
return n(e, "system", "comment", "like");
|
|
1177
1241
|
}
|
|
1178
|
-
var
|
|
1179
|
-
class
|
|
1242
|
+
var Mt = /* @__PURE__ */ ((e) => (e.All = "all", e.Limit = "limit", e))(Mt || {}), Ht = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Approved = "approved", e.Failed = "failed", e.Suspect = "suspect", e))(Ht || {}), Tt = /* @__PURE__ */ ((e) => (e.System = "system", e.Comment = "comment", e.Like = "like", e))(Tt || {}), jt = /* @__PURE__ */ ((e) => (e.System = "system", e.PostPinned = "post_pinned", e.PostHighlighted = "post_highlighted", e.PostDeleted = "post_deleted", e.PostCommented = "post_commented", e.PostLiked = "post_liked", e.CommentReplied = "comment_replied", e.CommentLiked = "comment_liked", e.CommentDeleted = "comment_deleted", e.ReplyReplied = "reply_replied", e.ReplyLiked = "reply_liked", e.ReplyDeleted = "reply_deleted", e))(jt || {});
|
|
1243
|
+
class Wt {
|
|
1180
1244
|
constructor(t) {
|
|
1181
1245
|
u(this, "token");
|
|
1182
1246
|
u(this, "req");
|
|
@@ -1188,7 +1252,7 @@ class Xt {
|
|
|
1188
1252
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=QaqUa2K0z0
|
|
1189
1253
|
*/
|
|
1190
1254
|
async getForums() {
|
|
1191
|
-
const { data: t } = await this.req.get("community/forums",
|
|
1255
|
+
const { data: t } = await this.req.get("community/forums", xt);
|
|
1192
1256
|
return (t == null ? void 0 : t.forums) || [];
|
|
1193
1257
|
}
|
|
1194
1258
|
/**
|
|
@@ -1197,7 +1261,7 @@ class Xt {
|
|
|
1197
1261
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=mIwpymAQom
|
|
1198
1262
|
*/
|
|
1199
1263
|
async getTopics() {
|
|
1200
|
-
const { data: t } = await this.req.get("community/topics",
|
|
1264
|
+
const { data: t } = await this.req.get("community/topics", At);
|
|
1201
1265
|
return (t == null ? void 0 : t.topics) || [];
|
|
1202
1266
|
}
|
|
1203
1267
|
/**
|
|
@@ -1206,7 +1270,7 @@ class Xt {
|
|
|
1206
1270
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=Jvw7xMK31K
|
|
1207
1271
|
*/
|
|
1208
1272
|
async getTopic(t) {
|
|
1209
|
-
const { data: r, code: i } = await this.req.get("community/topic",
|
|
1273
|
+
const { data: r, code: i } = await this.req.get("community/topic", Lt, {
|
|
1210
1274
|
params: { topic_id: t }
|
|
1211
1275
|
});
|
|
1212
1276
|
return (r == null ? void 0 : r.topic) ?? { error: i };
|
|
@@ -1217,7 +1281,7 @@ class Xt {
|
|
|
1217
1281
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=XKI9lDVrPq
|
|
1218
1282
|
*/
|
|
1219
1283
|
async getPosts(t) {
|
|
1220
|
-
const { data: r, code: i } = await this.req.get("community/posts",
|
|
1284
|
+
const { data: r, code: i } = await this.req.get("community/posts", P, {
|
|
1221
1285
|
params: s(t)
|
|
1222
1286
|
});
|
|
1223
1287
|
return r ?? { error: i };
|
|
@@ -1228,10 +1292,10 @@ class Xt {
|
|
|
1228
1292
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=yXubbZuDlC
|
|
1229
1293
|
*/
|
|
1230
1294
|
async getPinnedPosts(t, r, i) {
|
|
1231
|
-
const { data: c, code:
|
|
1295
|
+
const { data: c, code: d } = await this.req.get("community/pinned-posts", P, {
|
|
1232
1296
|
params: s({ forum_id: t, max_results: r, next_token: i })
|
|
1233
1297
|
});
|
|
1234
|
-
return c ?? { error:
|
|
1298
|
+
return c ?? { error: d };
|
|
1235
1299
|
}
|
|
1236
1300
|
/**
|
|
1237
1301
|
* 根据帖子 id 获取帖子详情
|
|
@@ -1239,7 +1303,7 @@ class Xt {
|
|
|
1239
1303
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=hj1AZy5rcP
|
|
1240
1304
|
*/
|
|
1241
1305
|
async getPost(t) {
|
|
1242
|
-
const { data: r, code: i } = await this.req.get("community/post",
|
|
1306
|
+
const { data: r, code: i } = await this.req.get("community/post", Ct, {
|
|
1243
1307
|
params: { post_id: t }
|
|
1244
1308
|
});
|
|
1245
1309
|
return (r == null ? void 0 : r.post) ?? { error: i };
|
|
@@ -1250,7 +1314,7 @@ class Xt {
|
|
|
1250
1314
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=M5okHBuaVk
|
|
1251
1315
|
*/
|
|
1252
1316
|
async post(t) {
|
|
1253
|
-
const { data: r, code: i } = await this.req.post("community/post", s(t),
|
|
1317
|
+
const { data: r, code: i } = await this.req.post("community/post", s(t), Ut);
|
|
1254
1318
|
return r ?? {
|
|
1255
1319
|
error: i
|
|
1256
1320
|
};
|
|
@@ -1261,7 +1325,7 @@ class Xt {
|
|
|
1261
1325
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=djKbX7lFdp
|
|
1262
1326
|
*/
|
|
1263
1327
|
async getComments(t) {
|
|
1264
|
-
const { data: r, code: i } = await this.req.get("community/comments",
|
|
1328
|
+
const { data: r, code: i } = await this.req.get("community/comments", $t, {
|
|
1265
1329
|
params: s(t)
|
|
1266
1330
|
});
|
|
1267
1331
|
return r ?? { error: i };
|
|
@@ -1272,7 +1336,7 @@ class Xt {
|
|
|
1272
1336
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=RIc7oxVGae
|
|
1273
1337
|
*/
|
|
1274
1338
|
async getComment(t) {
|
|
1275
|
-
const { data: r, code: i } = await this.req.get("community/comment",
|
|
1339
|
+
const { data: r, code: i } = await this.req.get("community/comment", Pt, {
|
|
1276
1340
|
params: { comment_id: t }
|
|
1277
1341
|
});
|
|
1278
1342
|
return (r == null ? void 0 : r.comment) ?? { error: i };
|
|
@@ -1284,7 +1348,7 @@ class Xt {
|
|
|
1284
1348
|
*/
|
|
1285
1349
|
async comment(t) {
|
|
1286
1350
|
await this.token.autoLogin();
|
|
1287
|
-
const { data: r, code: i } = await this.req.post("community/comment", s(t),
|
|
1351
|
+
const { data: r, code: i } = await this.req.post("community/comment", s(t), Dt);
|
|
1288
1352
|
return r ?? {
|
|
1289
1353
|
error: i
|
|
1290
1354
|
};
|
|
@@ -1295,7 +1359,7 @@ class Xt {
|
|
|
1295
1359
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=sVKBbY83MY
|
|
1296
1360
|
*/
|
|
1297
1361
|
async getReplies(t) {
|
|
1298
|
-
const { data: r } = await this.req.get("community/replies",
|
|
1362
|
+
const { data: r } = await this.req.get("community/replies", Et, {
|
|
1299
1363
|
params: s({ max_results: 20, ...t })
|
|
1300
1364
|
});
|
|
1301
1365
|
return r ?? { replies: [] };
|
|
@@ -1306,7 +1370,7 @@ class Xt {
|
|
|
1306
1370
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=kxhcSXD3MG
|
|
1307
1371
|
*/
|
|
1308
1372
|
async getReply(t) {
|
|
1309
|
-
const { data: r, code: i } = await this.req.get("community/reply",
|
|
1373
|
+
const { data: r, code: i } = await this.req.get("community/reply", Gt, {
|
|
1310
1374
|
params: { reply_id: t }
|
|
1311
1375
|
});
|
|
1312
1376
|
return (r == null ? void 0 : r.reply) ?? { error: i };
|
|
@@ -1318,7 +1382,7 @@ class Xt {
|
|
|
1318
1382
|
*/
|
|
1319
1383
|
async reply(t) {
|
|
1320
1384
|
await this.token.autoLogin();
|
|
1321
|
-
const { data: r, code: i } = await this.req.post("community/reply", s(t),
|
|
1385
|
+
const { data: r, code: i } = await this.req.post("community/reply", s(t), Ft);
|
|
1322
1386
|
return r ?? {
|
|
1323
1387
|
error: i
|
|
1324
1388
|
};
|
|
@@ -1354,7 +1418,7 @@ class Xt {
|
|
|
1354
1418
|
*/
|
|
1355
1419
|
async getMediaPresignUrl(t) {
|
|
1356
1420
|
await this.token.autoLogin();
|
|
1357
|
-
const { data: r } = await this.req.get("community/media-presign-url",
|
|
1421
|
+
const { data: r } = await this.req.get("community/media-presign-url", It, {
|
|
1358
1422
|
params: t
|
|
1359
1423
|
});
|
|
1360
1424
|
return r;
|
|
@@ -1368,7 +1432,7 @@ class Xt {
|
|
|
1368
1432
|
*/
|
|
1369
1433
|
async getNotifications(t) {
|
|
1370
1434
|
await this.token.autoLogin();
|
|
1371
|
-
const { data: r } = await this.req.get("community/notifications",
|
|
1435
|
+
const { data: r } = await this.req.get("community/notifications", Vt, {
|
|
1372
1436
|
params: s({ max_results: 20, ...t })
|
|
1373
1437
|
});
|
|
1374
1438
|
return r || { notifications: [] };
|
|
@@ -1380,7 +1444,7 @@ class Xt {
|
|
|
1380
1444
|
*/
|
|
1381
1445
|
async getUnreadNotificationsCount() {
|
|
1382
1446
|
if (!await this.token.autoLogin()) return null;
|
|
1383
|
-
const { data: t } = await this.req.get("community/unread-notifications-count",
|
|
1447
|
+
const { data: t } = await this.req.get("community/unread-notifications-count", Qt);
|
|
1384
1448
|
return t;
|
|
1385
1449
|
}
|
|
1386
1450
|
/**
|
|
@@ -1394,12 +1458,12 @@ class Xt {
|
|
|
1394
1458
|
return r;
|
|
1395
1459
|
}
|
|
1396
1460
|
}
|
|
1397
|
-
function
|
|
1461
|
+
function w(e) {
|
|
1398
1462
|
return n(e, "openid", "unionid", "weixin_token");
|
|
1399
1463
|
}
|
|
1400
|
-
var
|
|
1401
|
-
const
|
|
1402
|
-
class
|
|
1464
|
+
var zt = /* @__PURE__ */ ((e) => (e.RedirectUriDisMatch = "10003", e.AppidError = "10016", e.AuthorizationError = "10015", e.NoRightForScope = "10005", e.Frequently = "10009", e.AppBanded = "10004", e.ShouldFllow = "10006", e.ScopeNull = "10010", e.RedirectUriNull = "10011", e.AppidNull = "10012", e.StateNull = "10013", e))(zt || {});
|
|
1465
|
+
const $ = "wx_login_cache";
|
|
1466
|
+
class er {
|
|
1403
1467
|
/**
|
|
1404
1468
|
* 创建微信相关功能接口
|
|
1405
1469
|
*
|
|
@@ -1427,11 +1491,11 @@ class Yt {
|
|
|
1427
1491
|
* 也可以直接调用 login 方法,并传入 wxcode 的读取函数
|
|
1428
1492
|
*/
|
|
1429
1493
|
async getLoginCache() {
|
|
1430
|
-
const t =
|
|
1494
|
+
const t = this.token.storage.get($);
|
|
1431
1495
|
if (!t)
|
|
1432
1496
|
return null;
|
|
1433
|
-
const r =
|
|
1434
|
-
return
|
|
1497
|
+
const r = K(t);
|
|
1498
|
+
return w(r) ? (this.token.weixinToken = r.weixin_token, await this.token.autoLogin(), r) : null;
|
|
1435
1499
|
}
|
|
1436
1500
|
/**
|
|
1437
1501
|
* 小程序页面微信静默登录,获取 weixinToken / openid / unionid。
|
|
@@ -1447,20 +1511,20 @@ class Yt {
|
|
|
1447
1511
|
* - 微信公众号网页授权请使用 webLogin 方法
|
|
1448
1512
|
*
|
|
1449
1513
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=GwIZ0givCb
|
|
1450
|
-
*
|
|
1451
|
-
* @param wxLoginCodeGetter - 微信小程序调用 [wx.login](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html) 获得的登录凭证
|
|
1452
1514
|
*/
|
|
1453
|
-
async login(
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1515
|
+
async login() {
|
|
1516
|
+
if (!m.wx)
|
|
1517
|
+
throw new Error("当前环境非微信小程序");
|
|
1518
|
+
const t = await this.getLoginCache();
|
|
1519
|
+
if (t)
|
|
1520
|
+
return t;
|
|
1521
|
+
const r = await O(), { data: i, code: c } = await this.req.post(
|
|
1458
1522
|
"weixin/login",
|
|
1459
|
-
{ code:
|
|
1460
|
-
|
|
1523
|
+
{ code: r, appid: this.appid },
|
|
1524
|
+
w,
|
|
1461
1525
|
{ message: !1 }
|
|
1462
1526
|
);
|
|
1463
|
-
return
|
|
1527
|
+
return i && (this.token.weixinToken = i.weixin_token, this.token.storage.set($, JSON.stringify(i)), await this.token.autoLogin()), i ?? { error: c };
|
|
1464
1528
|
}
|
|
1465
1529
|
/**
|
|
1466
1530
|
* 在微信内嵌网页中调用微信公众号授权登录【暂未启用】
|
|
@@ -1479,27 +1543,27 @@ class Yt {
|
|
|
1479
1543
|
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、unionid、昵称、头像等信息,但用户也可能会拒绝授权
|
|
1480
1544
|
*/
|
|
1481
1545
|
async webLogin(t = "snsapi_userinfo") {
|
|
1482
|
-
const r =
|
|
1546
|
+
const r = h("code"), i = Date.now(), c = +h("state");
|
|
1483
1547
|
if (!r || !c || c < i - 1e3 * 60 * 5 || c > i) {
|
|
1484
|
-
const
|
|
1548
|
+
const B = A(["code", "state"]);
|
|
1485
1549
|
location.replace(
|
|
1486
|
-
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(
|
|
1550
|
+
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(B)}&response_type=code&scope=${t}&state=${i}#wechat_redirect`
|
|
1487
1551
|
);
|
|
1488
1552
|
return;
|
|
1489
1553
|
}
|
|
1490
1554
|
if (/^100\d{2}$/.test(r))
|
|
1491
1555
|
return { error: r };
|
|
1492
|
-
const
|
|
1493
|
-
"replaceState" in history && history.replaceState({}, "",
|
|
1494
|
-
const { data:
|
|
1556
|
+
const d = A(["code", "state"]);
|
|
1557
|
+
"replaceState" in history && history.replaceState({}, "", d);
|
|
1558
|
+
const { data: p, code: I } = await this.req.post(
|
|
1495
1559
|
"weixin/login",
|
|
1496
1560
|
{
|
|
1497
1561
|
code: r,
|
|
1498
1562
|
appid: this.appid
|
|
1499
1563
|
},
|
|
1500
|
-
|
|
1564
|
+
w
|
|
1501
1565
|
);
|
|
1502
|
-
return
|
|
1566
|
+
return p && (this.token.weixinToken = p.weixin_token, await this.token.autoLogin()), p ?? { error: I };
|
|
1503
1567
|
}
|
|
1504
1568
|
/**
|
|
1505
1569
|
* 关联游戏账号,无返回值,全程静默
|
|
@@ -1526,33 +1590,33 @@ class Yt {
|
|
|
1526
1590
|
}
|
|
1527
1591
|
}
|
|
1528
1592
|
export {
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1593
|
+
Xt as AuthToken,
|
|
1594
|
+
Le as CliamRewardStatus,
|
|
1595
|
+
Yt as ClubApi,
|
|
1596
|
+
ye as ClubCreditChangeSence,
|
|
1597
|
+
fe as ClubCreditChangeType,
|
|
1598
|
+
we as ClubItemType,
|
|
1599
|
+
he as ClubRedemptionStatus,
|
|
1600
|
+
Wt as CommunityApi,
|
|
1601
|
+
ke as EngageAccountType,
|
|
1602
|
+
Zt as EventApi,
|
|
1603
|
+
be as EventPeriodType,
|
|
1540
1604
|
o as FeatureType,
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1605
|
+
Mt as ForumMode,
|
|
1606
|
+
ve as GamerItemType,
|
|
1607
|
+
pe as Gender,
|
|
1608
|
+
Se as LotteryDrawAction,
|
|
1609
|
+
Pe as LotteryTicketStatus,
|
|
1610
|
+
Tt as NotificationCategory,
|
|
1611
|
+
jt as NotificationType,
|
|
1612
|
+
Ht as PostStatus,
|
|
1613
|
+
qe as QuestObjective,
|
|
1614
|
+
Ce as RewardSoure,
|
|
1615
|
+
xe as RewardStatusPrefix,
|
|
1616
|
+
Ae as RewardStatusSuffix,
|
|
1617
|
+
$e as TeamAction,
|
|
1618
|
+
Ue as TeamVisibility,
|
|
1619
|
+
Re as VoteOptionSource,
|
|
1620
|
+
er as WeixinApi,
|
|
1621
|
+
zt as WeixinWebLoginErrorCode
|
|
1558
1622
|
};
|