@seayoo-web/gamer-api 1.1.16 → 1.1.18
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/index.js +935 -833
- package/package.json +4 -4
- package/types/src/club.d.ts +8 -2
- package/types/src/club.define.d.ts +0 -2
- package/types/src/club.enums.d.ts +7 -2
- package/types/src/club.guards.d.ts +27 -27
- package/types/src/community.d.ts +26 -14
- package/types/src/community.define.d.ts +14 -8
- package/types/src/community.enums.d.ts +4 -0
- package/types/src/community.guards.d.ts +36 -49
- package/types/src/event.config.d.ts +1 -1
- package/types/src/event.d.ts +1 -1
- package/types/src/event.enums.d.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { isComboWebView as
|
|
5
|
-
import { isPlainObject as
|
|
1
|
+
var se = Object.defineProperty;
|
|
2
|
+
var oe = (e, r, n) => r in e ? se(e, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[r] = n;
|
|
3
|
+
var c = (e, r, n) => oe(e, typeof r != "symbol" ? r + "" : r, n);
|
|
4
|
+
import { isComboWebView as ae } from "@seayoo-web/combo-webview";
|
|
5
|
+
import { isPlainObject as i, useConsole as ue, Support as d, usePromise as ce, pruneURL as me, queryString as A, pruneObject as a, v as t, typedObjectGuard as o, isArray as _, parseJSON as le, removePara as D } from "@seayoo-web/utils";
|
|
6
6
|
import "@seayoo-web/request";
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function ge(e) {
|
|
8
|
+
return i(e, "gamer_token") && typeof e.gamer_token == "string";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function V(e) {
|
|
11
|
+
return i(e);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
13
|
+
const p = ue("GamerApiSDK");
|
|
14
|
+
function de(e) {
|
|
15
15
|
return /^\/[a-z\d-]+$/.test(e);
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
18
|
-
const { promise: e, resolve:
|
|
17
|
+
async function _e() {
|
|
18
|
+
const { promise: e, resolve: r } = ce();
|
|
19
19
|
return wx.login({
|
|
20
|
-
success(
|
|
21
|
-
|
|
20
|
+
success(n) {
|
|
21
|
+
r(n);
|
|
22
22
|
},
|
|
23
23
|
fail() {
|
|
24
|
-
|
|
24
|
+
r("");
|
|
25
25
|
}
|
|
26
26
|
}), await e;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const pe = {
|
|
29
29
|
get(e) {
|
|
30
30
|
return localStorage.getItem(e) || "";
|
|
31
31
|
},
|
|
32
|
-
set(e,
|
|
33
|
-
localStorage.setItem(e,
|
|
32
|
+
set(e, r) {
|
|
33
|
+
localStorage.setItem(e, r);
|
|
34
34
|
},
|
|
35
35
|
remove(e) {
|
|
36
36
|
localStorage.removeItem(e);
|
|
37
37
|
}
|
|
38
|
-
},
|
|
38
|
+
}, ye = {
|
|
39
39
|
get(e) {
|
|
40
40
|
try {
|
|
41
|
-
if (
|
|
42
|
-
} catch (
|
|
43
|
-
|
|
41
|
+
if (d.wx) return wx.getStorageSync(e) || "";
|
|
42
|
+
} catch (r) {
|
|
43
|
+
p.error("getStorageSyncError", r);
|
|
44
44
|
}
|
|
45
45
|
return "";
|
|
46
46
|
},
|
|
47
|
-
set(e,
|
|
47
|
+
set(e, r) {
|
|
48
48
|
try {
|
|
49
|
-
|
|
50
|
-
} catch (
|
|
51
|
-
|
|
49
|
+
d.wx && wx.setStorageSync(e, r);
|
|
50
|
+
} catch (n) {
|
|
51
|
+
p.error("setStorageSyncError", n);
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
remove(e) {
|
|
55
55
|
try {
|
|
56
|
-
|
|
57
|
-
} catch (
|
|
58
|
-
|
|
56
|
+
d.wx && wx.removeStorageSync(e);
|
|
57
|
+
} catch (r) {
|
|
58
|
+
p.error("removeStorageSync", r);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
},
|
|
62
|
-
class
|
|
63
|
-
constructor(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.storage =
|
|
70
|
-
const
|
|
71
|
-
this.req =
|
|
72
|
-
baseURL: `${
|
|
61
|
+
}, y = "gamer_token";
|
|
62
|
+
class wr {
|
|
63
|
+
constructor(r, n) {
|
|
64
|
+
c(this, "$idToken", "");
|
|
65
|
+
c(this, "$weixinToken", "");
|
|
66
|
+
c(this, "$gamerToken", "");
|
|
67
|
+
c(this, "req");
|
|
68
|
+
c(this, "storage");
|
|
69
|
+
this.storage = d.wx ? ye : pe;
|
|
70
|
+
const s = de(r) ? r : `https://${me(r)}`;
|
|
71
|
+
this.req = n({
|
|
72
|
+
baseURL: `${s}/v1`,
|
|
73
73
|
timeout: 1e4,
|
|
74
74
|
responseRule: {
|
|
75
75
|
ok: { resolve: "body" },
|
|
@@ -80,21 +80,21 @@ class rr {
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
// 使用箭头函数绑定执行上下文
|
|
83
|
-
requestTransformer: (
|
|
84
|
-
this.$gamerToken && (
|
|
83
|
+
requestTransformer: (l) => {
|
|
84
|
+
this.$gamerToken && (l.headers.Authorization = `Bearer ${this.$gamerToken}`);
|
|
85
85
|
}
|
|
86
|
-
}),
|
|
86
|
+
}), ae() ? this.$gamerToken = A("gamer_token") : this.loadGamerTokenCache();
|
|
87
87
|
}
|
|
88
88
|
loadGamerTokenCache() {
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
this.$gamerToken =
|
|
89
|
+
const n = this.storage.get(y).match(/^(\d{12,})#(.{8,})$/);
|
|
90
|
+
if (n) {
|
|
91
|
+
const s = parseInt(n[1]), l = n[2];
|
|
92
|
+
if (s > Date.now() - (24 * 3600 - 10) * 1e3) {
|
|
93
|
+
this.$gamerToken = l;
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
this.storage.remove(
|
|
97
|
+
this.storage.remove(y);
|
|
98
98
|
}
|
|
99
99
|
/** 当前是否为登录状态,即是否拥有 gamerToken */
|
|
100
100
|
get isLogined() {
|
|
@@ -105,8 +105,8 @@ class rr {
|
|
|
105
105
|
return this.$idToken;
|
|
106
106
|
}
|
|
107
107
|
/** 设置从登录组件获取的 Id Token,用于后续请求自动置换 Gamer Token */
|
|
108
|
-
set idToken(
|
|
109
|
-
this.$idToken !==
|
|
108
|
+
set idToken(r) {
|
|
109
|
+
this.$idToken !== r && (this.$idToken = r, this.gamerToken = "");
|
|
110
110
|
}
|
|
111
111
|
/** 读取设置 wexinToken */
|
|
112
112
|
get weixinToken() {
|
|
@@ -117,8 +117,8 @@ class rr {
|
|
|
117
117
|
*
|
|
118
118
|
* 仅仅在微信小程序模式下有效
|
|
119
119
|
*/
|
|
120
|
-
set weixinToken(
|
|
121
|
-
this.$weixinToken !==
|
|
120
|
+
set weixinToken(r) {
|
|
121
|
+
this.$weixinToken !== r && (this.$weixinToken = r, this.gamerToken = "");
|
|
122
122
|
}
|
|
123
123
|
/** 读取自动置换的 gamerToken */
|
|
124
124
|
get gamerToken() {
|
|
@@ -127,8 +127,8 @@ class rr {
|
|
|
127
127
|
/**
|
|
128
128
|
* 直接写入 Gamer Token,并更新缓存
|
|
129
129
|
*/
|
|
130
|
-
set gamerToken(
|
|
131
|
-
this.$gamerToken =
|
|
130
|
+
set gamerToken(r) {
|
|
131
|
+
this.$gamerToken = r, r ? this.storage.set(y, `${Date.now()}#${r}`) : this.storage.remove(y);
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* 退出登录,销毁相关 Token
|
|
@@ -156,16 +156,16 @@ class rr {
|
|
|
156
156
|
if (this.gamerToken)
|
|
157
157
|
return !0;
|
|
158
158
|
if (!this.idToken)
|
|
159
|
-
return
|
|
160
|
-
if (
|
|
161
|
-
return
|
|
162
|
-
const { code:
|
|
159
|
+
return p.error("Missing idToken when call autoLogin()"), !1;
|
|
160
|
+
if (d.wx && !this.weixinToken)
|
|
161
|
+
return p.error("Missing weixinToken when call autoLogin()"), !1;
|
|
162
|
+
const { code: r, data: n } = await this.req.post(
|
|
163
163
|
"login-with-token",
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
a({ id_token: this.idToken, weixin_token: d.wx ? this.weixinToken : null }),
|
|
165
|
+
ge,
|
|
166
166
|
{ message: !1 }
|
|
167
167
|
);
|
|
168
|
-
switch (
|
|
168
|
+
switch (r) {
|
|
169
169
|
case "invalid_id_token":
|
|
170
170
|
this.idToken = "";
|
|
171
171
|
break;
|
|
@@ -173,7 +173,7 @@ class rr {
|
|
|
173
173
|
this.weixinToken = "";
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
|
-
return this.gamerToken = (
|
|
176
|
+
return this.gamerToken = (n == null ? void 0 : n.gamer_token) || "", !!this.gamerToken;
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
179
|
* 获取当前登录用户的 Session 的信息
|
|
@@ -184,224 +184,218 @@ class rr {
|
|
|
184
184
|
*/
|
|
185
185
|
async getSession() {
|
|
186
186
|
if (!await this.autoLogin()) return null;
|
|
187
|
-
const { data:
|
|
187
|
+
const { data: r } = await this.req.get("session", V, {
|
|
188
188
|
message: !1
|
|
189
189
|
});
|
|
190
|
-
return
|
|
190
|
+
return r;
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* 实名认证
|
|
194
194
|
*
|
|
195
195
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=kZYnwX6RcF
|
|
196
196
|
*/
|
|
197
|
-
async authRealName(
|
|
197
|
+
async authRealName(r) {
|
|
198
198
|
if (!await this.autoLogin()) return null;
|
|
199
|
-
const { data:
|
|
200
|
-
return
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
var fe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Male = "male", e.Female = "female", e))(fe || {}), we = /* @__PURE__ */ ((e) => (e.Increase = "increase", e.Decrease = "decrease", e.Expired = "expired", e))(we || {}), ye = /* @__PURE__ */ ((e) => (e.Order = "order", e.Consumption = "consumption", e.Redeem = "redeem", e.Expire = "expire", e.Admin = "admin", e.Event = "event", e))(ye || {}), he = /* @__PURE__ */ ((e) => (e.GameReward = "game_reward", e.Physical = "physical", e.Virtual = "virtual", e))(he || {}), ve = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.issued = "issued", e.failed = "failed", e))(ve || {});
|
|
400
|
-
class nr {
|
|
401
|
-
constructor(t) {
|
|
402
|
-
u(this, "token");
|
|
403
|
-
u(this, "req");
|
|
404
|
-
this.token = t, this.req = t.req;
|
|
199
|
+
const { data: n } = await this.req.post("auth-real-name", a(r), V);
|
|
200
|
+
return n;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
var fe = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Male = "male", e.Female = "female", e))(fe || {});
|
|
204
|
+
const we = t.string().enum(
|
|
205
|
+
"unknown",
|
|
206
|
+
"male",
|
|
207
|
+
"female"
|
|
208
|
+
/* Female */
|
|
209
|
+
);
|
|
210
|
+
var he = /* @__PURE__ */ ((e) => (e.Increase = "increase", e.Decrease = "decrease", e.Expired = "expired", e))(he || {});
|
|
211
|
+
const be = t.string().enum(
|
|
212
|
+
"increase",
|
|
213
|
+
"decrease",
|
|
214
|
+
"expired"
|
|
215
|
+
/* Expired */
|
|
216
|
+
);
|
|
217
|
+
var ke = /* @__PURE__ */ ((e) => (e.Order = "order", e.Consumption = "consumption", e.Redeem = "redeem", e.Expire = "expire", e.Admin = "admin", e.Event = "event", e))(ke || {});
|
|
218
|
+
const ve = t.string().enum(
|
|
219
|
+
"order",
|
|
220
|
+
"consumption",
|
|
221
|
+
"redeem",
|
|
222
|
+
"expire",
|
|
223
|
+
"admin",
|
|
224
|
+
"event"
|
|
225
|
+
/* Event */
|
|
226
|
+
);
|
|
227
|
+
var qe = /* @__PURE__ */ ((e) => (e.GameReward = "game_reward", e.Physical = "physical", e.Virtual = "virtual", e))(qe || {});
|
|
228
|
+
const T = t.string().enum(
|
|
229
|
+
"game_reward",
|
|
230
|
+
"physical",
|
|
231
|
+
"virtual"
|
|
232
|
+
/* Virtual */
|
|
233
|
+
);
|
|
234
|
+
var Re = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Issued = "issued", e.Failed = "failed", e))(Re || {});
|
|
235
|
+
const xe = t.string().enum(
|
|
236
|
+
"pending",
|
|
237
|
+
"issued",
|
|
238
|
+
"failed"
|
|
239
|
+
/* Failed */
|
|
240
|
+
), Ce = o({
|
|
241
|
+
default_avatar_url: t.string(),
|
|
242
|
+
official_avatar_urls: t.array(t.string()),
|
|
243
|
+
default_nickname: t.string(),
|
|
244
|
+
default_bio: t.string(),
|
|
245
|
+
default_role_avatar_url: t.string(),
|
|
246
|
+
level_configs: t.array(t.object({ exp: t.number(), level: t.number(), title: t.string() })),
|
|
247
|
+
level_valid_days: t.number(),
|
|
248
|
+
benefit_description: t.string(),
|
|
249
|
+
exp_description: t.string(),
|
|
250
|
+
credit_description: t.string(),
|
|
251
|
+
send_role_mail_rate_limit: t.number()
|
|
252
|
+
}), M = t.object({
|
|
253
|
+
member_id: t.string(),
|
|
254
|
+
player_id: t.string(),
|
|
255
|
+
exp: t.number(),
|
|
256
|
+
level: t.number(),
|
|
257
|
+
credit: t.number(),
|
|
258
|
+
credit_expiring: t.number(),
|
|
259
|
+
level_change_time: t.number(),
|
|
260
|
+
level_expire_time: t.number()
|
|
261
|
+
});
|
|
262
|
+
t.guard(M);
|
|
263
|
+
const E = o({ player: M }), Q = t.shape({
|
|
264
|
+
role_id: t.string().disallow(""),
|
|
265
|
+
role_name: t.string(),
|
|
266
|
+
role_level: t.number(),
|
|
267
|
+
server_id: t.string(),
|
|
268
|
+
server_name: t.string(),
|
|
269
|
+
last_login_time: t.number()
|
|
270
|
+
}), H = t.object(Q);
|
|
271
|
+
t.guard(H);
|
|
272
|
+
const Le = o({ roles: t.array(H) }), N = t.object({
|
|
273
|
+
...Q,
|
|
274
|
+
role_fighting: t.number(),
|
|
275
|
+
kin_id: t.string().optional(),
|
|
276
|
+
kin_name: t.string().optional(),
|
|
277
|
+
kin_position: t.string().optional()
|
|
278
|
+
});
|
|
279
|
+
t.guard(N);
|
|
280
|
+
const q = o({ role_card: N }), G = o({
|
|
281
|
+
name: t.string(),
|
|
282
|
+
avatar_url: t.string(),
|
|
283
|
+
bio: t.string(),
|
|
284
|
+
gender: we,
|
|
285
|
+
birthday: t.object({
|
|
286
|
+
year: t.number(),
|
|
287
|
+
month: t.number(),
|
|
288
|
+
day: t.number()
|
|
289
|
+
})
|
|
290
|
+
}), z = t.object({
|
|
291
|
+
address_id: t.number(),
|
|
292
|
+
recipient: t.string(),
|
|
293
|
+
mobile: t.string(),
|
|
294
|
+
province: t.string(),
|
|
295
|
+
city: t.string(),
|
|
296
|
+
district: t.string(),
|
|
297
|
+
address: t.string(),
|
|
298
|
+
is_default: t.bool()
|
|
299
|
+
}), I = t.guard(z), Ae = o({ addresses: t.array(z) }), Pe = o({
|
|
300
|
+
increased_credit: t.number(),
|
|
301
|
+
decreased_credit: t.number(),
|
|
302
|
+
expired_credit: t.number(),
|
|
303
|
+
balance_credit: t.number()
|
|
304
|
+
}), J = t.object({
|
|
305
|
+
id: t.number(),
|
|
306
|
+
change_time: t.number(),
|
|
307
|
+
change_type: be,
|
|
308
|
+
change_credit: t.number(),
|
|
309
|
+
balance: t.number(),
|
|
310
|
+
change_scene: ve
|
|
311
|
+
});
|
|
312
|
+
t.guard(J);
|
|
313
|
+
const Ue = o({
|
|
314
|
+
credit_logs: t.array(J),
|
|
315
|
+
next_token: t.string().optional()
|
|
316
|
+
}), P = t.shape({
|
|
317
|
+
product_id: t.number(),
|
|
318
|
+
catalog_id: t.number(),
|
|
319
|
+
catalog_name: t.string(),
|
|
320
|
+
item_type: T,
|
|
321
|
+
name: t.string(),
|
|
322
|
+
img_url: t.string(),
|
|
323
|
+
description: t.string(),
|
|
324
|
+
tag: t.string(),
|
|
325
|
+
price: t.number(),
|
|
326
|
+
stock: t.number(),
|
|
327
|
+
redeem_quantity: t.number(),
|
|
328
|
+
not_visible_after: t.number(),
|
|
329
|
+
not_visible_before: t.number(),
|
|
330
|
+
not_after: t.number(),
|
|
331
|
+
not_before: t.number(),
|
|
332
|
+
min_level: t.number(),
|
|
333
|
+
max_level: t.number(),
|
|
334
|
+
limit_daily: t.number(),
|
|
335
|
+
limit_monthly: t.number(),
|
|
336
|
+
limit_yearly: t.number(),
|
|
337
|
+
limit_total: t.number(),
|
|
338
|
+
weight: t.number(),
|
|
339
|
+
created_at: t.number(),
|
|
340
|
+
updated_at: t.number()
|
|
341
|
+
});
|
|
342
|
+
o(P);
|
|
343
|
+
const $e = o({ products: t.array(t.object(P)) }), K = t.shape({
|
|
344
|
+
benefit_id: t.number(),
|
|
345
|
+
name: t.string(),
|
|
346
|
+
img_url: t.string(),
|
|
347
|
+
description: t.string(),
|
|
348
|
+
min_level: t.number(),
|
|
349
|
+
max_level: t.number(),
|
|
350
|
+
product_id: t.number()
|
|
351
|
+
}), O = t.object({ ...K, tag: t.string() });
|
|
352
|
+
t.guard(O);
|
|
353
|
+
const je = o({ benefits: t.array(O) }), X = t.object({
|
|
354
|
+
...K,
|
|
355
|
+
product: t.object(P).optional()
|
|
356
|
+
});
|
|
357
|
+
t.guard(X);
|
|
358
|
+
const Se = o({ benefit: X }), Y = t.object({
|
|
359
|
+
redemption_id: t.number(),
|
|
360
|
+
player_id: t.string(),
|
|
361
|
+
product_id: t.number(),
|
|
362
|
+
name: t.string(),
|
|
363
|
+
img_url: t.string(),
|
|
364
|
+
item_type: T,
|
|
365
|
+
catalog_id: t.number(),
|
|
366
|
+
catalog_name: t.string(),
|
|
367
|
+
quantity: t.number(),
|
|
368
|
+
amount: t.number(),
|
|
369
|
+
status: xe,
|
|
370
|
+
created_at: t.number(),
|
|
371
|
+
extra_data: t.union(
|
|
372
|
+
t.object({
|
|
373
|
+
recipient: t.string(),
|
|
374
|
+
mobile: t.string(),
|
|
375
|
+
province: t.string(),
|
|
376
|
+
city: t.string(),
|
|
377
|
+
district: t.string(),
|
|
378
|
+
express_company: t.string(),
|
|
379
|
+
express_number: t.string(),
|
|
380
|
+
address: t.string()
|
|
381
|
+
}),
|
|
382
|
+
t.object({
|
|
383
|
+
server_id: t.string(),
|
|
384
|
+
role_id: t.string(),
|
|
385
|
+
role_name: t.string()
|
|
386
|
+
})
|
|
387
|
+
).optional()
|
|
388
|
+
});
|
|
389
|
+
t.guard(Y);
|
|
390
|
+
const De = o({
|
|
391
|
+
redemptions: t.array(Y),
|
|
392
|
+
next_token: t.string().optional()
|
|
393
|
+
});
|
|
394
|
+
class hr {
|
|
395
|
+
constructor(r) {
|
|
396
|
+
c(this, "token");
|
|
397
|
+
c(this, "req");
|
|
398
|
+
this.token = r, this.req = r.req;
|
|
405
399
|
}
|
|
406
400
|
/**
|
|
407
401
|
* 获取俱乐部配置
|
|
@@ -409,8 +403,8 @@ class nr {
|
|
|
409
403
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=tuhsPt3ihp
|
|
410
404
|
*/
|
|
411
405
|
async getConfig() {
|
|
412
|
-
const { data:
|
|
413
|
-
return
|
|
406
|
+
const { data: r } = await this.req.get("club/config", Ce);
|
|
407
|
+
return r;
|
|
414
408
|
}
|
|
415
409
|
/**
|
|
416
410
|
* 用于游戏内嵌 Web 页面和微信小程序获取当前登录的游戏账号在俱乐部中的信息。
|
|
@@ -419,8 +413,8 @@ class nr {
|
|
|
419
413
|
*/
|
|
420
414
|
async getCurrentPlayer() {
|
|
421
415
|
await this.token.autoLogin();
|
|
422
|
-
const { data:
|
|
423
|
-
return (
|
|
416
|
+
const { data: r, code: n } = await this.req.get("club/current-player", E);
|
|
417
|
+
return (r == null ? void 0 : r.player) ?? { error: n };
|
|
424
418
|
}
|
|
425
419
|
/**
|
|
426
420
|
* 俱乐部用户关联游戏账号
|
|
@@ -429,15 +423,15 @@ class nr {
|
|
|
429
423
|
*/
|
|
430
424
|
async linkPlayer() {
|
|
431
425
|
await this.token.autoLogin();
|
|
432
|
-
const { data:
|
|
426
|
+
const { data: r, code: n } = await this.req.post(
|
|
433
427
|
"club/link-player",
|
|
434
428
|
{
|
|
435
429
|
id_token: this.token.idToken
|
|
436
430
|
},
|
|
437
|
-
|
|
431
|
+
E
|
|
438
432
|
);
|
|
439
|
-
return (
|
|
440
|
-
error:
|
|
433
|
+
return (r == null ? void 0 : r.player) ?? {
|
|
434
|
+
error: n
|
|
441
435
|
};
|
|
442
436
|
}
|
|
443
437
|
/**
|
|
@@ -445,33 +439,33 @@ class nr {
|
|
|
445
439
|
*
|
|
446
440
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=nwu4FiGM9V
|
|
447
441
|
*/
|
|
448
|
-
async getRoles(
|
|
442
|
+
async getRoles(r, n) {
|
|
449
443
|
if (!await this.token.autoLogin()) return [];
|
|
450
|
-
const { data:
|
|
451
|
-
params:
|
|
444
|
+
const { data: s } = await this.req.get("club/roles", Le, {
|
|
445
|
+
params: a({ player_id: r, refresh: n })
|
|
452
446
|
});
|
|
453
|
-
return (
|
|
447
|
+
return (s == null ? void 0 : s.roles) || [];
|
|
454
448
|
}
|
|
455
449
|
/**
|
|
456
450
|
* 获取俱乐部会员的角色卡片数据
|
|
457
451
|
*
|
|
458
452
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=A1Wr7kUXnS
|
|
459
453
|
*/
|
|
460
|
-
async getRoleCard(
|
|
461
|
-
const { data:
|
|
462
|
-
params: { member_id:
|
|
454
|
+
async getRoleCard(r) {
|
|
455
|
+
const { data: n } = await this.req.get("club/role-card", q, {
|
|
456
|
+
params: { member_id: r }
|
|
463
457
|
});
|
|
464
|
-
return (
|
|
458
|
+
return (n == null ? void 0 : n.role_card) ?? null;
|
|
465
459
|
}
|
|
466
460
|
/**
|
|
467
461
|
* 设置自己的角色卡片
|
|
468
462
|
*
|
|
469
463
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=XgMf6OFE5i
|
|
470
464
|
*/
|
|
471
|
-
async setRoleCard(
|
|
465
|
+
async setRoleCard(r) {
|
|
472
466
|
if (!await this.token.autoLogin()) return null;
|
|
473
|
-
const { data:
|
|
474
|
-
return (
|
|
467
|
+
const { data: n } = await this.req.post("club/role-card", r, q);
|
|
468
|
+
return (n == null ? void 0 : n.role_card) ?? null;
|
|
475
469
|
}
|
|
476
470
|
/**
|
|
477
471
|
* 强制刷新自己的角色卡片,从游戏内获取最新数据
|
|
@@ -480,30 +474,30 @@ class nr {
|
|
|
480
474
|
*/
|
|
481
475
|
async refreshRoleCard() {
|
|
482
476
|
if (!await this.token.autoLogin()) return null;
|
|
483
|
-
const { data:
|
|
484
|
-
return (
|
|
477
|
+
const { data: r } = await this.req.post("club/refresh-role-card", {}, q);
|
|
478
|
+
return (r == null ? void 0 : r.role_card) ?? null;
|
|
485
479
|
}
|
|
486
480
|
/**
|
|
487
481
|
* 获取俱乐部用户的信息
|
|
488
482
|
*
|
|
489
483
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=TMWBCFcOr2
|
|
490
484
|
*/
|
|
491
|
-
async getUserProfile(
|
|
492
|
-
const { data:
|
|
493
|
-
params: { member_id:
|
|
485
|
+
async getUserProfile(r) {
|
|
486
|
+
const { data: n } = await this.req.get("club/user-profile", G, {
|
|
487
|
+
params: { member_id: r }
|
|
494
488
|
});
|
|
495
|
-
return
|
|
489
|
+
return n;
|
|
496
490
|
}
|
|
497
491
|
/**
|
|
498
492
|
* 修改自己的俱乐部用户信息
|
|
499
493
|
*
|
|
500
494
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=Qt822A57jd
|
|
501
495
|
*/
|
|
502
|
-
async updateUserProfile(
|
|
496
|
+
async updateUserProfile(r) {
|
|
503
497
|
await this.token.autoLogin();
|
|
504
|
-
const { data:
|
|
505
|
-
return
|
|
506
|
-
error:
|
|
498
|
+
const { data: n, code: s } = await this.req.post("club/user-profile", r, G);
|
|
499
|
+
return n ?? {
|
|
500
|
+
error: s
|
|
507
501
|
};
|
|
508
502
|
}
|
|
509
503
|
/**
|
|
@@ -513,60 +507,60 @@ class nr {
|
|
|
513
507
|
*/
|
|
514
508
|
async getAddresses() {
|
|
515
509
|
if (!await this.token.autoLogin()) return [];
|
|
516
|
-
const { data:
|
|
517
|
-
return (
|
|
510
|
+
const { data: r } = await this.req.get("club/addresses", Ae);
|
|
511
|
+
return (r == null ? void 0 : r.addresses) ?? [];
|
|
518
512
|
}
|
|
519
513
|
/**
|
|
520
514
|
* 增加俱乐部收货地址
|
|
521
515
|
*
|
|
522
516
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=TaGIIYDRYA
|
|
523
517
|
*/
|
|
524
|
-
async addAddress(
|
|
518
|
+
async addAddress(r) {
|
|
525
519
|
if (!await this.token.autoLogin()) return null;
|
|
526
|
-
const { data:
|
|
527
|
-
return
|
|
520
|
+
const { data: n } = await this.req.post("/club/add-address", a(r), I);
|
|
521
|
+
return n;
|
|
528
522
|
}
|
|
529
523
|
/**
|
|
530
524
|
* 修改自己的俱乐部收货地址
|
|
531
525
|
*
|
|
532
526
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=p9FlJhHnWN
|
|
533
527
|
*/
|
|
534
|
-
async updateAddress(
|
|
528
|
+
async updateAddress(r) {
|
|
535
529
|
await this.token.autoLogin();
|
|
536
|
-
const { data:
|
|
537
|
-
return
|
|
530
|
+
const { data: n, code: s } = await this.req.post("club/update-address", a(r), I);
|
|
531
|
+
return n ?? { error: s };
|
|
538
532
|
}
|
|
539
533
|
/**
|
|
540
534
|
* 删除自己的俱乐部收货地址
|
|
541
535
|
*
|
|
542
536
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=MEEOBdf8rm
|
|
543
537
|
*/
|
|
544
|
-
async deleteAddress(
|
|
538
|
+
async deleteAddress(r) {
|
|
545
539
|
if (!await this.token.autoLogin()) return null;
|
|
546
|
-
const { ok:
|
|
547
|
-
return
|
|
540
|
+
const { ok: n } = await this.req.post("club/delete-address", { address_id: r });
|
|
541
|
+
return n;
|
|
548
542
|
}
|
|
549
543
|
/**
|
|
550
544
|
* 获取俱乐部积分统计信息
|
|
551
545
|
*
|
|
552
546
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=x4uxtGstRL
|
|
553
547
|
*/
|
|
554
|
-
async getUserCredit(
|
|
548
|
+
async getUserCredit(r) {
|
|
555
549
|
await this.token.autoLogin();
|
|
556
|
-
const { data:
|
|
557
|
-
return
|
|
550
|
+
const { data: n, code: s } = await this.req.get("club/user-credit", Pe, { params: a(r) });
|
|
551
|
+
return n ?? { error: s };
|
|
558
552
|
}
|
|
559
553
|
/**
|
|
560
554
|
* 获取自己的俱乐部积分变动记录
|
|
561
555
|
*
|
|
562
556
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=lQFgF689P8
|
|
563
557
|
*/
|
|
564
|
-
async getCreditLogs(
|
|
558
|
+
async getCreditLogs(r) {
|
|
565
559
|
await this.token.autoLogin();
|
|
566
|
-
const { data:
|
|
567
|
-
params:
|
|
560
|
+
const { data: n } = await this.req.get("club/credit-logs", Ue, {
|
|
561
|
+
params: a({ max_results: 20, ...r })
|
|
568
562
|
});
|
|
569
|
-
return
|
|
563
|
+
return { credit_logs: (n == null ? void 0 : n.credit_logs) || [], next_token: n == null ? void 0 : n.next_token };
|
|
570
564
|
}
|
|
571
565
|
/**
|
|
572
566
|
* 获取自己的俱乐部权益列表
|
|
@@ -575,20 +569,20 @@ class nr {
|
|
|
575
569
|
*/
|
|
576
570
|
async getBenefits() {
|
|
577
571
|
if (!await this.token.autoLogin()) return [];
|
|
578
|
-
const { data:
|
|
579
|
-
return (
|
|
572
|
+
const { data: r } = await this.req.get("club/benefits", je);
|
|
573
|
+
return (r == null ? void 0 : r.benefits) || [];
|
|
580
574
|
}
|
|
581
575
|
/**
|
|
582
576
|
* 获取某个权益详细信息
|
|
583
577
|
*
|
|
584
578
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=XKto0MeaHF
|
|
585
579
|
*/
|
|
586
|
-
async getBenefit(
|
|
580
|
+
async getBenefit(r) {
|
|
587
581
|
if (!await this.token.autoLogin()) return null;
|
|
588
|
-
const { data:
|
|
589
|
-
params: { benefit_id:
|
|
582
|
+
const { data: n } = await this.req.get("club/benefit", Se, {
|
|
583
|
+
params: { benefit_id: r }
|
|
590
584
|
});
|
|
591
|
-
return (
|
|
585
|
+
return (n == null ? void 0 : n.benefit) || null;
|
|
592
586
|
}
|
|
593
587
|
/**
|
|
594
588
|
* 获取商城商品列表
|
|
@@ -596,19 +590,19 @@ class nr {
|
|
|
596
590
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=r3vC3PzfMQ
|
|
597
591
|
*/
|
|
598
592
|
async getProducts() {
|
|
599
|
-
const { data:
|
|
600
|
-
return (
|
|
593
|
+
const { data: r } = await this.req.get("club/products", $e);
|
|
594
|
+
return (r == null ? void 0 : r.products) || [];
|
|
601
595
|
}
|
|
602
596
|
/**
|
|
603
597
|
* 兑换商城商品
|
|
604
598
|
*
|
|
605
599
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=LWcMVwX3OY
|
|
606
600
|
*/
|
|
607
|
-
async redeemProduct(
|
|
601
|
+
async redeemProduct(r) {
|
|
608
602
|
await this.token.autoLogin();
|
|
609
|
-
const { ok:
|
|
610
|
-
return
|
|
611
|
-
error:
|
|
603
|
+
const { ok: n, code: s } = await this.req.post("club/redeem-product", a(r));
|
|
604
|
+
return n || {
|
|
605
|
+
error: s
|
|
612
606
|
};
|
|
613
607
|
}
|
|
614
608
|
/**
|
|
@@ -616,59 +610,60 @@ class nr {
|
|
|
616
610
|
*
|
|
617
611
|
* https://kdocs.cn/l/cgp4gSBMbOf1?linkname=Ml6mLgT4cM
|
|
618
612
|
*/
|
|
619
|
-
async getRedemptions(
|
|
613
|
+
async getRedemptions(r) {
|
|
620
614
|
await this.token.autoLogin();
|
|
621
|
-
const { data:
|
|
622
|
-
params:
|
|
615
|
+
const { data: n } = await this.req.get("club/redemptions", De, {
|
|
616
|
+
params: a({ max_results: 20, ...r })
|
|
623
617
|
});
|
|
624
|
-
return
|
|
618
|
+
return { redemptions: (n == null ? void 0 : n.redemptions) || [], next_token: n == null ? void 0 : n.next_token };
|
|
625
619
|
}
|
|
626
620
|
}
|
|
627
|
-
var
|
|
628
|
-
function
|
|
629
|
-
return
|
|
621
|
+
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 || {}), Ee = /* @__PURE__ */ ((e) => (e.UserId = "user_id", e.RoleId = "role_id", e))(Ee || {}), Ge = /* @__PURE__ */ ((e) => (e.None = "none", e.Daily = "daily", e.Weekly = "weekly", e.Monthly = "monthly", e))(Ge || {}), u = /* @__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.CheckIn = "check_in", e))(u || {}), Ie = /* @__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))(Ie || {}), Fe = /* @__PURE__ */ ((e) => (e.System = "system", e.UserSubmission = "user_submission", e.Shortlisted = "shortlisted", e))(Fe || {}), Be = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unclaimed = "unaccalimed", e.Received = "received", e))(Be || {}), Te = /* @__PURE__ */ ((e) => (e.Unclaimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e.Delivered = "delivered", e))(Te || {}), Me = /* @__PURE__ */ ((e) => (e.Unclaimed = "unclaimed", e.Received = "received", e.Failed = "failed", e.Delivered = "delivered", e))(Me || {}), Qe = /* @__PURE__ */ ((e) => (e.Ineligible = "ineligible", e.Unaccalimed = "unaccalimed", e.Received = "received", e.Failed = "failed", e))(Qe || {}), He = /* @__PURE__ */ ((e) => (e.Output = "output", e.Engage = "engage", e))(He || {}), Ne = /* @__PURE__ */ ((e) => (e.Private = "private", e.Public = "public", e))(Ne || {}), ze = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.Pending = "pending", e.Drawn = "drawn", e.Claimed = "claimed", e.Fail = "fail", e))(ze || {}), Je = /* @__PURE__ */ ((e) => (e.Assemble = "assemble", e.Join = "join", e.Disband = "disband", e.ChangeVisibility = "change_visibility", e.Query = "query", e))(Je || {}), Ke = /* @__PURE__ */ ((e) => (e.Query = "query", e.Draw = "draw", e.Claim = "claim", e))(Ke || {});
|
|
622
|
+
function Oe(e) {
|
|
623
|
+
return i(e, "event_name", "rules", "since", "until", "features") && Array.isArray(e.features) && e.features.every(Xe);
|
|
630
624
|
}
|
|
631
|
-
function
|
|
632
|
-
if (!
|
|
625
|
+
function Xe(e) {
|
|
626
|
+
if (!We(e))
|
|
633
627
|
return !1;
|
|
634
628
|
switch (e.feature_type) {
|
|
635
|
-
case
|
|
636
|
-
case
|
|
637
|
-
case
|
|
638
|
-
case
|
|
629
|
+
case u.Preregister:
|
|
630
|
+
case u.ClaimRewards:
|
|
631
|
+
case u.Register:
|
|
632
|
+
case u.InvitedRegister:
|
|
633
|
+
case u.CheckIn:
|
|
639
634
|
return !0;
|
|
640
|
-
case
|
|
641
|
-
return Te(e.config);
|
|
642
|
-
case a.Survey:
|
|
643
|
-
return Me(e.config);
|
|
644
|
-
case a.Invite:
|
|
645
|
-
return He(e.config);
|
|
646
|
-
case a.Share:
|
|
647
|
-
return je(e.config);
|
|
648
|
-
case a.Follow:
|
|
649
|
-
return ze(e.config);
|
|
650
|
-
case a.Subscribe:
|
|
651
|
-
return Je(e.config);
|
|
652
|
-
case a.Comment:
|
|
653
|
-
return Ke(e.config);
|
|
654
|
-
case a.Vote:
|
|
655
|
-
return Ne(e.config);
|
|
656
|
-
case a.Cashback:
|
|
657
|
-
return Xe(e.config);
|
|
658
|
-
case a.GiftCode:
|
|
659
|
-
return Ye(e.config);
|
|
660
|
-
case a.Quest:
|
|
661
|
-
return We(e.config);
|
|
662
|
-
case a.Team:
|
|
663
|
-
return et(e.config);
|
|
664
|
-
case a.LotteryDraw:
|
|
635
|
+
case u.Lottery:
|
|
665
636
|
return tt(e.config);
|
|
637
|
+
case u.Survey:
|
|
638
|
+
return rt(e.config);
|
|
639
|
+
case u.Invite:
|
|
640
|
+
return nt(e.config);
|
|
641
|
+
case u.Share:
|
|
642
|
+
return it(e.config);
|
|
643
|
+
case u.Follow:
|
|
644
|
+
return st(e.config);
|
|
645
|
+
case u.Subscribe:
|
|
646
|
+
return ot(e.config);
|
|
647
|
+
case u.Comment:
|
|
648
|
+
return at(e.config);
|
|
649
|
+
case u.Vote:
|
|
650
|
+
return ut(e.config);
|
|
651
|
+
case u.Cashback:
|
|
652
|
+
return mt(e.config);
|
|
653
|
+
case u.GiftCode:
|
|
654
|
+
return lt(e.config);
|
|
655
|
+
case u.Quest:
|
|
656
|
+
return dt(e.config);
|
|
657
|
+
case u.Team:
|
|
658
|
+
return _t(e.config);
|
|
659
|
+
case u.LotteryDraw:
|
|
660
|
+
return pt(e.config);
|
|
666
661
|
default:
|
|
667
662
|
return !1;
|
|
668
663
|
}
|
|
669
664
|
}
|
|
670
|
-
function
|
|
671
|
-
return
|
|
665
|
+
function U(e) {
|
|
666
|
+
return i(
|
|
672
667
|
e,
|
|
673
668
|
"reward_item_id",
|
|
674
669
|
"reward_amount",
|
|
@@ -678,14 +673,14 @@ function k(e) {
|
|
|
678
673
|
"reward_item_rating"
|
|
679
674
|
);
|
|
680
675
|
}
|
|
681
|
-
function
|
|
682
|
-
return
|
|
676
|
+
function Ye(e) {
|
|
677
|
+
return i(e, "engage_count", "rewards") && Array.isArray(e.rewards) && e.rewards.every(U);
|
|
683
678
|
}
|
|
684
|
-
function
|
|
685
|
-
return
|
|
679
|
+
function Ze(e) {
|
|
680
|
+
return i(e, "feature_reward_type", "reward_details") && (e.feature_reward_type === "every" ? Array.isArray(e.reward_details) && e.reward_details.every(U) : e.feature_reward_type === "regular" ? Array.isArray(e.reward_details) && e.reward_details.every(Ye) : !1);
|
|
686
681
|
}
|
|
687
|
-
function
|
|
688
|
-
return
|
|
682
|
+
function We(e) {
|
|
683
|
+
return i(
|
|
689
684
|
e,
|
|
690
685
|
"feature_id",
|
|
691
686
|
"feature_name",
|
|
@@ -696,10 +691,10 @@ function Ve(e) {
|
|
|
696
691
|
"since",
|
|
697
692
|
"until",
|
|
698
693
|
"engage_account"
|
|
699
|
-
) && ("feature_rewards" in e ?
|
|
694
|
+
) && ("feature_rewards" in e ? Ze(e.feature_rewards) : !0);
|
|
700
695
|
}
|
|
701
|
-
function
|
|
702
|
-
return
|
|
696
|
+
function et(e) {
|
|
697
|
+
return i(
|
|
703
698
|
e,
|
|
704
699
|
"reward_item_id",
|
|
705
700
|
"reward_item_name",
|
|
@@ -709,36 +704,36 @@ function Qe(e) {
|
|
|
709
704
|
"reward_remaining_stock"
|
|
710
705
|
);
|
|
711
706
|
}
|
|
712
|
-
function
|
|
713
|
-
return
|
|
707
|
+
function tt(e) {
|
|
708
|
+
return i(
|
|
714
709
|
e,
|
|
715
710
|
"consume_item_id",
|
|
716
711
|
"consume_item_name",
|
|
717
712
|
"consume_item_icon_url",
|
|
718
713
|
"consume_item_count",
|
|
719
714
|
"rewards"
|
|
720
|
-
) && Array.isArray(e.rewards) && e.rewards.every(
|
|
715
|
+
) && Array.isArray(e.rewards) && e.rewards.every(et);
|
|
721
716
|
}
|
|
722
|
-
function
|
|
723
|
-
return
|
|
717
|
+
function rt(e) {
|
|
718
|
+
return i(e, "survey_id", "survey_url");
|
|
724
719
|
}
|
|
725
|
-
function
|
|
726
|
-
return
|
|
720
|
+
function nt(e) {
|
|
721
|
+
return i(e, "share_url");
|
|
727
722
|
}
|
|
728
|
-
function
|
|
729
|
-
return
|
|
723
|
+
function it(e) {
|
|
724
|
+
return i(e, "share_platform");
|
|
730
725
|
}
|
|
731
|
-
function
|
|
732
|
-
return
|
|
726
|
+
function st(e) {
|
|
727
|
+
return i(e, "platform");
|
|
733
728
|
}
|
|
734
|
-
function
|
|
735
|
-
return
|
|
729
|
+
function ot(e) {
|
|
730
|
+
return i(e, "weixin_template_ids") && Array.isArray(e.weixin_template_ids) && e.weixin_template_ids.every((r) => typeof r == "string");
|
|
736
731
|
}
|
|
737
|
-
function
|
|
738
|
-
return
|
|
732
|
+
function at(e) {
|
|
733
|
+
return i(e, "comments", "send_rate") && Array.isArray(e.comments) && e.comments.every((r) => typeof r == "string");
|
|
739
734
|
}
|
|
740
|
-
function
|
|
741
|
-
return
|
|
735
|
+
function ut(e) {
|
|
736
|
+
return i(
|
|
742
737
|
e,
|
|
743
738
|
"vote_feature_ids",
|
|
744
739
|
"submission_feature_ids",
|
|
@@ -746,13 +741,13 @@ function Ne(e) {
|
|
|
746
741
|
"source",
|
|
747
742
|
"options",
|
|
748
743
|
"rewards"
|
|
749
|
-
) && Array.isArray(e.vote_feature_ids) && Array.isArray(e.submission_feature_ids) && Array.isArray(e.options) && e.options.every(
|
|
744
|
+
) && Array.isArray(e.vote_feature_ids) && Array.isArray(e.submission_feature_ids) && Array.isArray(e.options) && e.options.every(ct) && Array.isArray(e.rewards) && e.rewards.every(U);
|
|
750
745
|
}
|
|
751
|
-
function
|
|
752
|
-
return
|
|
746
|
+
function ct(e) {
|
|
747
|
+
return i(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);
|
|
753
748
|
}
|
|
754
|
-
function
|
|
755
|
-
return
|
|
749
|
+
function mt(e) {
|
|
750
|
+
return i(
|
|
756
751
|
e,
|
|
757
752
|
"order_start_time",
|
|
758
753
|
"order_end_time",
|
|
@@ -760,43 +755,43 @@ function Xe(e) {
|
|
|
760
755
|
"claim_rewards_end_time"
|
|
761
756
|
);
|
|
762
757
|
}
|
|
763
|
-
function
|
|
764
|
-
return
|
|
758
|
+
function lt(e) {
|
|
759
|
+
return i(e, "gift_items") && Array.isArray(e.gift_items) && e.gift_items.every(gt);
|
|
765
760
|
}
|
|
766
|
-
function
|
|
767
|
-
return
|
|
761
|
+
function gt(e) {
|
|
762
|
+
return i(e, "name", "count", "icon_url");
|
|
768
763
|
}
|
|
769
|
-
function
|
|
770
|
-
return
|
|
764
|
+
function dt(e) {
|
|
765
|
+
return i(e, "objective", "completion_value") && ("team" in e ? i(e.team, "completion_value") : !0);
|
|
771
766
|
}
|
|
772
|
-
function
|
|
773
|
-
return
|
|
767
|
+
function _t(e) {
|
|
768
|
+
return i(e, "min_members", "max_members");
|
|
774
769
|
}
|
|
775
|
-
function
|
|
776
|
-
return
|
|
770
|
+
function pt(e) {
|
|
771
|
+
return i(e, "draw_not_after", "draw_not_before");
|
|
777
772
|
}
|
|
778
|
-
function
|
|
779
|
-
return
|
|
773
|
+
function yt(e) {
|
|
774
|
+
return i(e, "allowed", "registered");
|
|
780
775
|
}
|
|
781
|
-
function
|
|
782
|
-
return
|
|
776
|
+
function R(e) {
|
|
777
|
+
return i(e, "count");
|
|
783
778
|
}
|
|
784
|
-
function
|
|
785
|
-
return
|
|
786
|
-
(
|
|
787
|
-
) || e.engagements.every((
|
|
779
|
+
function ft(e) {
|
|
780
|
+
return i(e, "engagements") && Array.isArray(e.engagements) && (e.engagements.every(
|
|
781
|
+
(r) => i(r, "user_id", "name", "avatar_url", "comment", "video_note", "created_at")
|
|
782
|
+
) || e.engagements.every((r) => i(r, "team_code", "leader_name", "total_members")));
|
|
788
783
|
}
|
|
789
|
-
function
|
|
790
|
-
return
|
|
784
|
+
function wt(e) {
|
|
785
|
+
return i(e, "first_visit") && typeof e.first_visit == "boolean";
|
|
791
786
|
}
|
|
792
|
-
function
|
|
793
|
-
return
|
|
787
|
+
function ht(e) {
|
|
788
|
+
return i(e, "status") && Array.isArray(e.status) && e.status.every((r) => i(r, "feature_id", "can_engage", "has_unclaimed_rewards"));
|
|
794
789
|
}
|
|
795
|
-
function
|
|
796
|
-
return
|
|
790
|
+
function bt(e) {
|
|
791
|
+
return i(e, "engagements") && _(e.engagements, Z);
|
|
797
792
|
}
|
|
798
|
-
function
|
|
799
|
-
if (!
|
|
793
|
+
function Z(e) {
|
|
794
|
+
if (!i(
|
|
800
795
|
e,
|
|
801
796
|
"engagement_id",
|
|
802
797
|
"sequence",
|
|
@@ -814,17 +809,17 @@ function S(e) {
|
|
|
814
809
|
return !1;
|
|
815
810
|
if (!("data" in e))
|
|
816
811
|
return !0;
|
|
817
|
-
const
|
|
818
|
-
return
|
|
812
|
+
const r = e.data;
|
|
813
|
+
return Rt(r) || xt(r) || Ct(r) || Lt(r) || At(r) || Pt(r) || Ut(r) || $t(r) || jt(r) || St(r) || Dt(r) || Vt(r);
|
|
819
814
|
}
|
|
820
|
-
function
|
|
821
|
-
return
|
|
815
|
+
function kt(e) {
|
|
816
|
+
return i(e, "engagements") && _(e.engagements, vt);
|
|
822
817
|
}
|
|
823
|
-
function
|
|
824
|
-
return
|
|
818
|
+
function vt(e) {
|
|
819
|
+
return i(e, "engagement_id", "sequence", "feature_id", "created_at", "user_id") && ("rewards" in e ? _(e.rewards, qt) : !0);
|
|
825
820
|
}
|
|
826
|
-
function
|
|
827
|
-
return
|
|
821
|
+
function qt(e) {
|
|
822
|
+
return i(
|
|
828
823
|
e,
|
|
829
824
|
"reward_id",
|
|
830
825
|
"reward_item_id",
|
|
@@ -835,52 +830,52 @@ function ct(e) {
|
|
|
835
830
|
"reward_count",
|
|
836
831
|
"reward_status",
|
|
837
832
|
"receive_time"
|
|
838
|
-
) && ("extra_data" in e ?
|
|
833
|
+
) && ("extra_data" in e ? i(e.extra_data) : !0);
|
|
839
834
|
}
|
|
840
|
-
function
|
|
841
|
-
return
|
|
835
|
+
function Rt(e) {
|
|
836
|
+
return i(e, "platforms") && Array.isArray(e.platforms);
|
|
842
837
|
}
|
|
843
|
-
function
|
|
844
|
-
return
|
|
838
|
+
function xt(e) {
|
|
839
|
+
return i(e, "lottery_count");
|
|
845
840
|
}
|
|
846
|
-
function
|
|
847
|
-
return
|
|
841
|
+
function Ct(e) {
|
|
842
|
+
return i(e, "serial_number");
|
|
848
843
|
}
|
|
849
|
-
function
|
|
850
|
-
return
|
|
844
|
+
function Lt(e) {
|
|
845
|
+
return i(e, "user_id");
|
|
851
846
|
}
|
|
852
|
-
function
|
|
853
|
-
return
|
|
847
|
+
function At(e) {
|
|
848
|
+
return i(e, "platform");
|
|
854
849
|
}
|
|
855
|
-
function
|
|
856
|
-
return
|
|
850
|
+
function Pt(e) {
|
|
851
|
+
return i(e, "option_sn");
|
|
857
852
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
853
|
+
function Ut(e) {
|
|
854
|
+
return i(e, "weixin_openid");
|
|
860
855
|
}
|
|
861
|
-
function
|
|
862
|
-
return
|
|
856
|
+
function $t(e) {
|
|
857
|
+
return i(e, "cashback_total_amount", "game_item_count", "order_total_amount");
|
|
863
858
|
}
|
|
864
|
-
function
|
|
865
|
-
return
|
|
859
|
+
function jt(e) {
|
|
860
|
+
return i(e, "gift_code");
|
|
866
861
|
}
|
|
867
|
-
function
|
|
868
|
-
return
|
|
869
|
-
(
|
|
862
|
+
function St(e) {
|
|
863
|
+
return i(e, "team_code", "visibility", "members") && Array.isArray(e.members) && e.members.every(
|
|
864
|
+
(r) => i(r, "is_leader", "role_name", "server_name")
|
|
870
865
|
);
|
|
871
866
|
}
|
|
872
|
-
function
|
|
873
|
-
return
|
|
874
|
-
(
|
|
875
|
-
|
|
867
|
+
function Dt(e) {
|
|
868
|
+
return i(e, "objective", "progress") ? "team" in e ? i(e.team, "progress", "players") && Array.isArray(e.team.players) && e.team.players.every(
|
|
869
|
+
(r) => i(
|
|
870
|
+
r,
|
|
876
871
|
"user_id",
|
|
877
872
|
"role_name",
|
|
878
873
|
"is_leader"
|
|
879
874
|
)
|
|
880
875
|
) : !0 : !1;
|
|
881
876
|
}
|
|
882
|
-
function
|
|
883
|
-
return
|
|
877
|
+
function W(e) {
|
|
878
|
+
return i(
|
|
884
879
|
e,
|
|
885
880
|
"reward_id",
|
|
886
881
|
"reward_item_id",
|
|
@@ -896,13 +891,13 @@ function G(e) {
|
|
|
896
891
|
"engagement_id",
|
|
897
892
|
"feature_type",
|
|
898
893
|
"receive_time"
|
|
899
|
-
) && ("extra_data" in e ?
|
|
894
|
+
) && ("extra_data" in e ? i(e.extra_data) : !0);
|
|
900
895
|
}
|
|
901
|
-
function
|
|
902
|
-
return !
|
|
896
|
+
function Vt(e) {
|
|
897
|
+
return !i(e, "tickets") || !("status" in e) ? !1 : e.status === "unknown" || e.status === "pending" ? !0 : "reward" in e ? W(e.reward) : !1;
|
|
903
898
|
}
|
|
904
|
-
function
|
|
905
|
-
return
|
|
899
|
+
function Et(e) {
|
|
900
|
+
return i(
|
|
906
901
|
e,
|
|
907
902
|
"reward_id",
|
|
908
903
|
"reward_item_id",
|
|
@@ -914,47 +909,47 @@ function bt(e) {
|
|
|
914
909
|
"reward_source"
|
|
915
910
|
);
|
|
916
911
|
}
|
|
917
|
-
function
|
|
918
|
-
return
|
|
912
|
+
function Gt(e) {
|
|
913
|
+
return i(e, "engagement_id") && ("engagement" in e ? Z(e.engagement) : !0) && ("rewards" in e ? _(e.rewards, Et) : !0);
|
|
919
914
|
}
|
|
920
|
-
function
|
|
921
|
-
return
|
|
915
|
+
function It(e) {
|
|
916
|
+
return i(e, "reward_id", "reward_status");
|
|
922
917
|
}
|
|
923
|
-
function
|
|
924
|
-
return
|
|
918
|
+
function Ft(e) {
|
|
919
|
+
return i(e, "claimed_items") && _(e.claimed_items, It);
|
|
925
920
|
}
|
|
926
|
-
function
|
|
927
|
-
return
|
|
921
|
+
function Bt(e) {
|
|
922
|
+
return i(e, "reward_status");
|
|
928
923
|
}
|
|
929
|
-
function
|
|
930
|
-
return
|
|
924
|
+
function Tt(e) {
|
|
925
|
+
return i(e, "user_rewards") && _(e.user_rewards, W);
|
|
931
926
|
}
|
|
932
|
-
function
|
|
933
|
-
return
|
|
927
|
+
function Mt(e) {
|
|
928
|
+
return i(e, "scene");
|
|
934
929
|
}
|
|
935
|
-
function
|
|
936
|
-
return
|
|
930
|
+
function Qt(e) {
|
|
931
|
+
return i(e, "params");
|
|
937
932
|
}
|
|
938
|
-
function
|
|
939
|
-
return
|
|
933
|
+
function Ht(e) {
|
|
934
|
+
return i(e, "img") && typeof e.img == "string";
|
|
940
935
|
}
|
|
941
|
-
class
|
|
942
|
-
constructor(
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
this.token =
|
|
936
|
+
class br {
|
|
937
|
+
constructor(r, n) {
|
|
938
|
+
c(this, "token");
|
|
939
|
+
c(this, "event", 0);
|
|
940
|
+
c(this, "req");
|
|
941
|
+
this.token = r, this.event = n, this.req = r.req;
|
|
947
942
|
}
|
|
948
943
|
/**
|
|
949
944
|
* 根据手机号白名单,检查手机号是否允许登录某个游戏
|
|
950
945
|
*
|
|
951
946
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=OWGSPF3Ysl
|
|
952
947
|
*/
|
|
953
|
-
async verifyMobileAllowed(
|
|
954
|
-
const { data:
|
|
955
|
-
params: { mobile:
|
|
948
|
+
async verifyMobileAllowed(r, n) {
|
|
949
|
+
const { data: s } = await this.req.get("verify-mobile-allowed", yt, {
|
|
950
|
+
params: { game_id: r, mobile: n }
|
|
956
951
|
});
|
|
957
|
-
return
|
|
952
|
+
return s;
|
|
958
953
|
}
|
|
959
954
|
/**
|
|
960
955
|
* 获取运营活动的基础配置信息
|
|
@@ -962,56 +957,56 @@ class ir {
|
|
|
962
957
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=wFXxtdNKPm
|
|
963
958
|
*/
|
|
964
959
|
async getConfig() {
|
|
965
|
-
const { data:
|
|
966
|
-
return
|
|
960
|
+
const { data: r } = await this.req.get(`event/${this.event}/event-config`, Oe);
|
|
961
|
+
return r;
|
|
967
962
|
}
|
|
968
963
|
/**
|
|
969
964
|
* 获取某个玩法参与用户数量
|
|
970
965
|
*
|
|
971
966
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
972
967
|
*/
|
|
973
|
-
async getEngagementsUserCount(
|
|
974
|
-
const { data:
|
|
975
|
-
params: { feature_id:
|
|
968
|
+
async getEngagementsUserCount(r) {
|
|
969
|
+
const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, R, {
|
|
970
|
+
params: { feature_id: r, type: "user" }
|
|
976
971
|
});
|
|
977
|
-
return (
|
|
972
|
+
return (n == null ? void 0 : n.count) ?? null;
|
|
978
973
|
}
|
|
979
974
|
/**
|
|
980
975
|
* 获取某个玩法参与次数
|
|
981
976
|
*
|
|
982
977
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=ejPOcWMvT1
|
|
983
978
|
*/
|
|
984
|
-
async getEngagementsCount(
|
|
985
|
-
const { data:
|
|
986
|
-
params: { feature_id:
|
|
979
|
+
async getEngagementsCount(r) {
|
|
980
|
+
const { data: n } = await this.req.get(`event/${this.event}/feature-engagement-count`, R, {
|
|
981
|
+
params: { feature_id: r, type: "engagement" }
|
|
987
982
|
});
|
|
988
|
-
return (
|
|
983
|
+
return (n == null ? void 0 : n.count) ?? null;
|
|
989
984
|
}
|
|
990
985
|
/**
|
|
991
986
|
* 获取某个玩法的参与记录(和特定用户无关)
|
|
992
987
|
*
|
|
993
988
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=THtZ4ewIQW
|
|
994
989
|
*/
|
|
995
|
-
async getEngagements(
|
|
996
|
-
const { data:
|
|
997
|
-
params: { feature_id:
|
|
990
|
+
async getEngagements(r) {
|
|
991
|
+
const { data: n } = await this.req.get(`event/${this.event}/feature-engagements`, ft, {
|
|
992
|
+
params: { feature_id: r }
|
|
998
993
|
});
|
|
999
|
-
return (
|
|
994
|
+
return (n == null ? void 0 : n.engagements) || [];
|
|
1000
995
|
}
|
|
1001
996
|
/**
|
|
1002
997
|
* 用户访问某个活动或玩法
|
|
1003
998
|
*
|
|
1004
999
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=DWtJrnrBCn
|
|
1005
1000
|
*/
|
|
1006
|
-
async visit(
|
|
1001
|
+
async visit(r) {
|
|
1007
1002
|
await this.token.autoLogin();
|
|
1008
|
-
const { data:
|
|
1003
|
+
const { data: n, code: s } = await this.req.post(
|
|
1009
1004
|
`event/${this.event}/visit`,
|
|
1010
|
-
|
|
1011
|
-
|
|
1005
|
+
a(r || {}),
|
|
1006
|
+
wt
|
|
1012
1007
|
);
|
|
1013
|
-
return
|
|
1014
|
-
error:
|
|
1008
|
+
return n ?? {
|
|
1009
|
+
error: s
|
|
1015
1010
|
};
|
|
1016
1011
|
}
|
|
1017
1012
|
/**
|
|
@@ -1023,13 +1018,13 @@ class ir {
|
|
|
1023
1018
|
*
|
|
1024
1019
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=WzX5BrMNpL
|
|
1025
1020
|
*/
|
|
1026
|
-
async getUserFeatureStatus(
|
|
1021
|
+
async getUserFeatureStatus(r) {
|
|
1027
1022
|
if (!await this.token.autoLogin()) return [];
|
|
1028
|
-
const { data:
|
|
1029
|
-
params:
|
|
1023
|
+
const { data: n } = await this.req.get("event/user-feature-status", ht, {
|
|
1024
|
+
params: a({ ...r, event_id: this.event }),
|
|
1030
1025
|
message: !1
|
|
1031
1026
|
});
|
|
1032
|
-
return (
|
|
1027
|
+
return (n == null ? void 0 : n.status) || [];
|
|
1033
1028
|
}
|
|
1034
1029
|
/**
|
|
1035
1030
|
* 获取当前登录用户参与某个玩法的记录
|
|
@@ -1038,35 +1033,35 @@ class ir {
|
|
|
1038
1033
|
*
|
|
1039
1034
|
* @deprecated 请改用 getUserEngagementsV2
|
|
1040
1035
|
*/
|
|
1041
|
-
async getUserEngagements(
|
|
1036
|
+
async getUserEngagements(r) {
|
|
1042
1037
|
if (!await this.token.autoLogin()) return [];
|
|
1043
|
-
const { data:
|
|
1044
|
-
params: { feature_id:
|
|
1038
|
+
const { data: n } = await this.req.get(`event/${this.event}/user-engagements`, bt, {
|
|
1039
|
+
params: { feature_id: r }
|
|
1045
1040
|
});
|
|
1046
|
-
return (
|
|
1041
|
+
return (n == null ? void 0 : n.engagements) || [];
|
|
1047
1042
|
}
|
|
1048
1043
|
/**
|
|
1049
1044
|
* 获取当前登录用户参与某个玩法的记录
|
|
1050
1045
|
*
|
|
1051
1046
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=NFDdV1dwWb
|
|
1052
1047
|
*/
|
|
1053
|
-
async getUserEngagementsV2(
|
|
1048
|
+
async getUserEngagementsV2(r, n) {
|
|
1054
1049
|
if (!await this.token.autoLogin()) return [];
|
|
1055
|
-
const { data:
|
|
1056
|
-
params:
|
|
1050
|
+
const { data: s } = await this.req.get("event/user-engagements", kt, {
|
|
1051
|
+
params: a({ max_results: 10, ...n, event_id: this.event, feature_id: r })
|
|
1057
1052
|
});
|
|
1058
|
-
return (
|
|
1053
|
+
return (s == null ? void 0 : s.engagements) || [];
|
|
1059
1054
|
}
|
|
1060
1055
|
/**
|
|
1061
1056
|
* 用户参与某个玩法(需要先调用 visit 接口)
|
|
1062
1057
|
*
|
|
1063
1058
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=vuOyrcry3S
|
|
1064
1059
|
*/
|
|
1065
|
-
async engage(
|
|
1060
|
+
async engage(r) {
|
|
1066
1061
|
await this.token.autoLogin();
|
|
1067
|
-
const { data:
|
|
1068
|
-
return
|
|
1069
|
-
error:
|
|
1062
|
+
const { data: n, code: s } = await this.req.post(`event/${this.event}/engage`, a(r), Gt);
|
|
1063
|
+
return n ?? {
|
|
1064
|
+
error: s
|
|
1070
1065
|
};
|
|
1071
1066
|
}
|
|
1072
1067
|
/**
|
|
@@ -1074,11 +1069,11 @@ class ir {
|
|
|
1074
1069
|
*
|
|
1075
1070
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=lCGuqgvUDP
|
|
1076
1071
|
*/
|
|
1077
|
-
async claimRewards(
|
|
1072
|
+
async claimRewards(r) {
|
|
1078
1073
|
await this.token.autoLogin();
|
|
1079
|
-
const { data:
|
|
1080
|
-
return (
|
|
1081
|
-
error:
|
|
1074
|
+
const { data: n, code: s } = await this.req.post("event/claim-rewards", a(r), Ft);
|
|
1075
|
+
return (n == null ? void 0 : n.claimed_items) ?? {
|
|
1076
|
+
error: s
|
|
1082
1077
|
};
|
|
1083
1078
|
}
|
|
1084
1079
|
/**
|
|
@@ -1086,15 +1081,15 @@ class ir {
|
|
|
1086
1081
|
*
|
|
1087
1082
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=aQLhlOAB4Q
|
|
1088
1083
|
*/
|
|
1089
|
-
async claimWeixinHongbao(
|
|
1084
|
+
async claimWeixinHongbao(r) {
|
|
1090
1085
|
await this.token.autoLogin();
|
|
1091
|
-
const { data:
|
|
1086
|
+
const { data: n, code: s } = await this.req.post(
|
|
1092
1087
|
`event/${this.event}/claim-weixin-hongbao`,
|
|
1093
|
-
{ reward_id:
|
|
1094
|
-
|
|
1088
|
+
{ reward_id: r },
|
|
1089
|
+
Bt
|
|
1095
1090
|
);
|
|
1096
|
-
return
|
|
1097
|
-
error:
|
|
1091
|
+
return n ?? {
|
|
1092
|
+
error: s
|
|
1098
1093
|
};
|
|
1099
1094
|
}
|
|
1100
1095
|
/**
|
|
@@ -1102,36 +1097,36 @@ class ir {
|
|
|
1102
1097
|
*
|
|
1103
1098
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=qj12eIgYQG
|
|
1104
1099
|
*/
|
|
1105
|
-
async getUserRewards(
|
|
1100
|
+
async getUserRewards(r) {
|
|
1106
1101
|
if (!await this.token.autoLogin()) return [];
|
|
1107
|
-
const { data:
|
|
1102
|
+
const { data: n } = await this.req.post(
|
|
1108
1103
|
"event/user-rewards",
|
|
1109
|
-
|
|
1110
|
-
|
|
1104
|
+
a({ ...r, event_id: this.event }),
|
|
1105
|
+
Tt
|
|
1111
1106
|
);
|
|
1112
|
-
return (
|
|
1107
|
+
return (n == null ? void 0 : n.user_rewards) || [];
|
|
1113
1108
|
}
|
|
1114
1109
|
/**
|
|
1115
1110
|
* 查询用户活动道具数量。注意,这里只能是活动道具
|
|
1116
1111
|
*
|
|
1117
1112
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=mnGCTeTgMb
|
|
1118
1113
|
*/
|
|
1119
|
-
async getUserItemCount(
|
|
1114
|
+
async getUserItemCount(r) {
|
|
1120
1115
|
if (!await this.token.autoLogin()) return null;
|
|
1121
|
-
const { data:
|
|
1122
|
-
params: { item_id:
|
|
1116
|
+
const { data: n } = await this.req.get(`event/${this.event}/user-item-count`, R, {
|
|
1117
|
+
params: { item_id: r }
|
|
1123
1118
|
});
|
|
1124
|
-
return (
|
|
1119
|
+
return (n == null ? void 0 : n.count) ?? null;
|
|
1125
1120
|
}
|
|
1126
1121
|
/**
|
|
1127
1122
|
* 填写实物奖励收货地址
|
|
1128
1123
|
*
|
|
1129
1124
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=QIwGhnaexb
|
|
1130
1125
|
*/
|
|
1131
|
-
async submitUserRewardAddress(
|
|
1126
|
+
async submitUserRewardAddress(r) {
|
|
1132
1127
|
if (!await this.token.autoLogin()) return null;
|
|
1133
|
-
const { ok:
|
|
1134
|
-
return
|
|
1128
|
+
const { ok: n } = await this.req.post(`event/${this.event}/user-reward-address`, r);
|
|
1129
|
+
return n;
|
|
1135
1130
|
}
|
|
1136
1131
|
/**
|
|
1137
1132
|
* 小程序码携带参数最多 32 个可见字符,若前端携带参数过长,则将参数保存在 api 中,并返回符合小程序码要求的 scene
|
|
@@ -1140,12 +1135,12 @@ class ir {
|
|
|
1140
1135
|
*
|
|
1141
1136
|
* @param params - 前端扫描二维码打开小程序所需参数
|
|
1142
1137
|
*/
|
|
1143
|
-
async getUnlimitQrcodeScene(
|
|
1138
|
+
async getUnlimitQrcodeScene(r) {
|
|
1144
1139
|
if (!await this.token.autoLogin()) return null;
|
|
1145
|
-
const { data:
|
|
1146
|
-
params: { params:
|
|
1140
|
+
const { data: n } = await this.req.get("event/unlimit-qrcode-scene", Mt, {
|
|
1141
|
+
params: { params: r }
|
|
1147
1142
|
});
|
|
1148
|
-
return (
|
|
1143
|
+
return (n == null ? void 0 : n.scene) ?? null;
|
|
1149
1144
|
}
|
|
1150
1145
|
/**
|
|
1151
1146
|
* 根据小程序码携带 scene 值,获取对应的前端所需参数
|
|
@@ -1154,152 +1149,250 @@ class ir {
|
|
|
1154
1149
|
*
|
|
1155
1150
|
* @param scene - 小程序码 scene 值
|
|
1156
1151
|
*/
|
|
1157
|
-
async getParamsByQrcodeScene(
|
|
1158
|
-
const { data:
|
|
1159
|
-
params: { scene:
|
|
1152
|
+
async getParamsByQrcodeScene(r) {
|
|
1153
|
+
const { data: n } = await this.req.get("event/params-by-qrcode-scene", Qt, {
|
|
1154
|
+
params: { scene: r }
|
|
1160
1155
|
});
|
|
1161
|
-
return (
|
|
1156
|
+
return (n == null ? void 0 : n.params) ?? null;
|
|
1162
1157
|
}
|
|
1163
1158
|
/**
|
|
1164
1159
|
* 生成不限制的带参数的小程序码(data URI格式的小程序码)
|
|
1165
1160
|
*
|
|
1166
1161
|
* https://kdocs.cn/l/ckWFDcOsYEUA?linkname=Rvmoq8iIy0
|
|
1167
1162
|
*/
|
|
1168
|
-
async generateUnlimitQrcode(
|
|
1163
|
+
async generateUnlimitQrcode(r) {
|
|
1169
1164
|
if (!await this.token.autoLogin()) return null;
|
|
1170
|
-
const { data:
|
|
1171
|
-
return (
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
)
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1165
|
+
const { data: n } = await this.req.post("event/unlimit-qrcode", a(r), Ht);
|
|
1166
|
+
return (n == null ? void 0 : n.img) ?? null;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
var Nt = /* @__PURE__ */ ((e) => (e.All = "all", e.Limit = "limit", e))(Nt || {});
|
|
1170
|
+
const zt = t.string().enum(
|
|
1171
|
+
"all",
|
|
1172
|
+
"limit"
|
|
1173
|
+
/* Limit */
|
|
1174
|
+
);
|
|
1175
|
+
var Jt = /* @__PURE__ */ ((e) => (e.Pending = "pending", e.Approved = "approved", e.Failed = "failed", e.Suspect = "suspect", e))(Jt || {});
|
|
1176
|
+
const ee = t.string().enum(
|
|
1177
|
+
"pending",
|
|
1178
|
+
"approved",
|
|
1179
|
+
"failed",
|
|
1180
|
+
"suspect"
|
|
1181
|
+
/* Suspect */
|
|
1182
|
+
);
|
|
1183
|
+
var Kt = /* @__PURE__ */ ((e) => (e.System = "system", e.Comment = "comment", e.Like = "like", e))(Kt || {});
|
|
1184
|
+
const kr = t.string().enum(
|
|
1185
|
+
"system",
|
|
1186
|
+
"comment",
|
|
1187
|
+
"like"
|
|
1188
|
+
/* Like */
|
|
1189
|
+
);
|
|
1190
|
+
var m = /* @__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))(m || {});
|
|
1191
|
+
const Ot = t.string().enum(
|
|
1192
|
+
"system",
|
|
1193
|
+
"post_pinned",
|
|
1194
|
+
"post_highlighted",
|
|
1195
|
+
"post_deleted",
|
|
1196
|
+
"post_commented",
|
|
1197
|
+
"post_liked",
|
|
1198
|
+
"comment_replied",
|
|
1199
|
+
"comment_liked",
|
|
1200
|
+
"comment_deleted",
|
|
1201
|
+
"reply_replied",
|
|
1202
|
+
"reply_liked",
|
|
1203
|
+
"reply_deleted"
|
|
1204
|
+
/* ReplyDeleted */
|
|
1205
|
+
), $ = t.object({
|
|
1206
|
+
forum_id: t.number(),
|
|
1207
|
+
icon_url: t.string(),
|
|
1208
|
+
name: t.string(),
|
|
1209
|
+
tags: t.array(t.string()),
|
|
1210
|
+
sort: t.number(),
|
|
1211
|
+
mode: zt,
|
|
1212
|
+
member_ids: t.array(t.number())
|
|
1213
|
+
});
|
|
1214
|
+
t.guard($);
|
|
1215
|
+
const Xt = o({ forums: t.array($) }), w = t.object({
|
|
1216
|
+
topic_id: t.number(),
|
|
1217
|
+
cover_url: t.string(),
|
|
1218
|
+
name: t.string(),
|
|
1219
|
+
description: t.string(),
|
|
1220
|
+
tags: t.array(t.string()),
|
|
1221
|
+
post_num: t.number()
|
|
1222
|
+
});
|
|
1223
|
+
t.guard(w);
|
|
1224
|
+
const Yt = o({ topics: t.array(w) }), Zt = o({ topic: w }), te = t.shape({
|
|
1225
|
+
post_id: t.number(),
|
|
1226
|
+
forum: $,
|
|
1227
|
+
posted_by: t.string(),
|
|
1228
|
+
nickname: t.string(),
|
|
1229
|
+
avatar_url: t.string(),
|
|
1230
|
+
title: t.string().optional(),
|
|
1231
|
+
content: t.string(),
|
|
1232
|
+
summary: t.string(),
|
|
1233
|
+
like_num: t.number(),
|
|
1234
|
+
comments_num: t.number(),
|
|
1235
|
+
liked: t.bool(),
|
|
1236
|
+
image_urls: t.array(t.string()),
|
|
1237
|
+
topics: t.array(w),
|
|
1238
|
+
event_ids: t.array(t.number()),
|
|
1239
|
+
is_pinned: t.bool(),
|
|
1240
|
+
is_highlighted: t.bool(),
|
|
1241
|
+
status: ee,
|
|
1242
|
+
create_time: t.number()
|
|
1243
|
+
}), j = t.object(te);
|
|
1244
|
+
t.guard(j);
|
|
1245
|
+
const F = o({
|
|
1246
|
+
posts: t.array(j),
|
|
1247
|
+
next_token: t.string().optional()
|
|
1248
|
+
}), Wt = o({ post: j }), S = t.object({ err_msg: t.string().optional() }), er = t.guard(S), tr = o({
|
|
1249
|
+
post: t.object(te).optional(),
|
|
1250
|
+
antispam: S
|
|
1251
|
+
}), re = t.object({
|
|
1252
|
+
reply_id: t.number(),
|
|
1253
|
+
reply_content: t.string().optional(),
|
|
1254
|
+
replied_by: t.string(),
|
|
1255
|
+
nickname: t.string(),
|
|
1256
|
+
avatar_url: t.string()
|
|
1257
|
+
});
|
|
1258
|
+
t.guard(re);
|
|
1259
|
+
const h = t.object({
|
|
1260
|
+
reply_id: t.number(),
|
|
1261
|
+
comment_id: t.number(),
|
|
1262
|
+
comment_content: t.string().optional(),
|
|
1263
|
+
commented_by: t.string().optional(),
|
|
1264
|
+
commented_by_nickname: t.string().optional(),
|
|
1265
|
+
commented_by_avatar_url: t.string().optional(),
|
|
1266
|
+
replied_by: t.string(),
|
|
1267
|
+
nickname: t.string(),
|
|
1268
|
+
avatar_url: t.string(),
|
|
1269
|
+
content: t.string(),
|
|
1270
|
+
like_num: t.number(),
|
|
1271
|
+
liked: t.bool(),
|
|
1272
|
+
reply_to: re,
|
|
1273
|
+
create_time: t.number()
|
|
1274
|
+
});
|
|
1275
|
+
t.guard(h);
|
|
1276
|
+
const rr = o({
|
|
1277
|
+
replies: t.array(h),
|
|
1278
|
+
next_token: t.string().optional()
|
|
1279
|
+
}), nr = o({ reply: h });
|
|
1280
|
+
function ir(e) {
|
|
1281
|
+
return i(e) && ("reply" in e ? sr(e.comment) : !0) && ("antispam" in e ? er(e.antispam) : !0);
|
|
1282
|
+
}
|
|
1283
|
+
const b = t.object({
|
|
1284
|
+
comment_id: t.number(),
|
|
1285
|
+
post_id: t.number(),
|
|
1286
|
+
post_subject: t.string().optional(),
|
|
1287
|
+
post_summary: t.string().optional(),
|
|
1288
|
+
post_image_url: t.string().optional(),
|
|
1289
|
+
posted_by: t.string().optional(),
|
|
1290
|
+
posted_by_nickname: t.string().optional(),
|
|
1291
|
+
posted_by_avatar_url: t.string().optional(),
|
|
1292
|
+
commented_by: t.string(),
|
|
1293
|
+
nickname: t.string(),
|
|
1294
|
+
avatar_url: t.string(),
|
|
1295
|
+
content: t.string(),
|
|
1296
|
+
like_num: t.number(),
|
|
1297
|
+
reply_num: t.number(),
|
|
1298
|
+
liked: t.bool(),
|
|
1299
|
+
image_url: t.string(),
|
|
1300
|
+
create_time: t.number(),
|
|
1301
|
+
status: ee,
|
|
1302
|
+
replies: t.array(h).optional()
|
|
1303
|
+
}), sr = t.guard(b), or = o({ comment: b }), ar = o({
|
|
1304
|
+
comments: t.array(b),
|
|
1305
|
+
next_token: t.string().optional()
|
|
1306
|
+
}), ur = o({
|
|
1307
|
+
comment: b.clone().optional(),
|
|
1308
|
+
antispam: S.clone().optional()
|
|
1309
|
+
}), cr = o({
|
|
1310
|
+
image_url: t.string(),
|
|
1311
|
+
upload_url: t.string(),
|
|
1312
|
+
existed: t.bool()
|
|
1313
|
+
}), g = t.shape({
|
|
1314
|
+
notification_id: t.string(),
|
|
1315
|
+
notification_type: Ot,
|
|
1316
|
+
is_read: t.bool(),
|
|
1317
|
+
create_time: t.number(),
|
|
1318
|
+
origin_user_id: t.string(),
|
|
1319
|
+
origin_user_name: t.string(),
|
|
1320
|
+
origin_user_avatar_url: t.string()
|
|
1321
|
+
}), x = t.shape({
|
|
1322
|
+
post_id: t.number(),
|
|
1323
|
+
post_subject: t.string(),
|
|
1324
|
+
post_summary: t.string(),
|
|
1325
|
+
post_image_url: t.string()
|
|
1326
|
+
}), f = t.shape({
|
|
1327
|
+
comment_id: t.number(),
|
|
1328
|
+
comment_content: t.string()
|
|
1329
|
+
}), C = t.shape({
|
|
1330
|
+
reply_id: t.number(),
|
|
1331
|
+
reply_content: t.string()
|
|
1332
|
+
}), mr = t.guard(
|
|
1333
|
+
t.union(
|
|
1334
|
+
t.object({
|
|
1335
|
+
...g,
|
|
1336
|
+
notification_type: t.string().enum(m.System),
|
|
1337
|
+
system_message_content: t.string(),
|
|
1338
|
+
system_message_subject: t.string()
|
|
1339
|
+
}),
|
|
1340
|
+
t.object({
|
|
1341
|
+
...g,
|
|
1342
|
+
...x,
|
|
1343
|
+
notification_type: t.string().enum(
|
|
1344
|
+
m.PostPinned,
|
|
1345
|
+
m.PostHighlighted,
|
|
1346
|
+
m.PostDeleted,
|
|
1347
|
+
m.PostLiked
|
|
1348
|
+
)
|
|
1349
|
+
}),
|
|
1350
|
+
t.object({
|
|
1351
|
+
...g,
|
|
1352
|
+
...x,
|
|
1353
|
+
...f,
|
|
1354
|
+
notification_type: t.string().enum(m.PostCommented)
|
|
1355
|
+
}),
|
|
1356
|
+
t.object({
|
|
1357
|
+
...g,
|
|
1358
|
+
...f,
|
|
1359
|
+
...C,
|
|
1360
|
+
notification_type: t.string().enum(m.CommentReplied)
|
|
1361
|
+
}),
|
|
1362
|
+
t.object({
|
|
1363
|
+
...g,
|
|
1364
|
+
...f,
|
|
1365
|
+
...x,
|
|
1366
|
+
notification_type: t.string().enum(m.CommentLiked, m.CommentDeleted)
|
|
1367
|
+
}),
|
|
1368
|
+
t.object({
|
|
1369
|
+
...g,
|
|
1370
|
+
...C,
|
|
1371
|
+
reply_to_reply_content: t.string(),
|
|
1372
|
+
reply_to_reply_id: t.number(),
|
|
1373
|
+
comment_id: t.number(),
|
|
1374
|
+
notification_type: t.string().enum(m.ReplyReplied)
|
|
1375
|
+
}),
|
|
1376
|
+
t.object({
|
|
1377
|
+
...g,
|
|
1378
|
+
...C,
|
|
1379
|
+
...f,
|
|
1380
|
+
notification_type: t.string().enum(m.ReplyLiked, m.ReplyDeleted)
|
|
1381
|
+
})
|
|
1382
|
+
)
|
|
1383
|
+
), lr = o({
|
|
1384
|
+
notifications: t.array(t.custom("Notification", mr)),
|
|
1385
|
+
next_token: t.string().optional()
|
|
1386
|
+
}), gr = o({
|
|
1387
|
+
system: t.number(),
|
|
1388
|
+
comment: t.number(),
|
|
1389
|
+
like: t.number()
|
|
1390
|
+
});
|
|
1391
|
+
class vr {
|
|
1392
|
+
constructor(r) {
|
|
1393
|
+
c(this, "token");
|
|
1394
|
+
c(this, "req");
|
|
1395
|
+
this.token = r, this.req = r.req;
|
|
1303
1396
|
}
|
|
1304
1397
|
/**
|
|
1305
1398
|
* 获取社区版块列表,仅返回启用状态的版块
|
|
@@ -1307,8 +1400,8 @@ class sr {
|
|
|
1307
1400
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=QaqUa2K0z0
|
|
1308
1401
|
*/
|
|
1309
1402
|
async getForums() {
|
|
1310
|
-
const { data:
|
|
1311
|
-
return (
|
|
1403
|
+
const { data: r } = await this.req.get("community/forums", Xt);
|
|
1404
|
+
return (r == null ? void 0 : r.forums) || [];
|
|
1312
1405
|
}
|
|
1313
1406
|
/**
|
|
1314
1407
|
* 获取社区话题列表,仅返回启用状态的话题
|
|
@@ -1316,62 +1409,62 @@ class sr {
|
|
|
1316
1409
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=mIwpymAQom
|
|
1317
1410
|
*/
|
|
1318
1411
|
async getTopics() {
|
|
1319
|
-
const { data:
|
|
1320
|
-
return (
|
|
1412
|
+
const { data: r } = await this.req.get("community/topics", Yt);
|
|
1413
|
+
return (r == null ? void 0 : r.topics) || [];
|
|
1321
1414
|
}
|
|
1322
1415
|
/**
|
|
1323
1416
|
* 根据话题 ID 获取社区话题信息
|
|
1324
1417
|
*
|
|
1325
1418
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=Jvw7xMK31K
|
|
1326
1419
|
*/
|
|
1327
|
-
async getTopic(
|
|
1328
|
-
const { data:
|
|
1329
|
-
params: { topic_id:
|
|
1420
|
+
async getTopic(r) {
|
|
1421
|
+
const { data: n, code: s } = await this.req.get("community/topic", Zt, {
|
|
1422
|
+
params: { topic_id: r }
|
|
1330
1423
|
});
|
|
1331
|
-
return (
|
|
1424
|
+
return (n == null ? void 0 : n.topic) ?? { error: s };
|
|
1332
1425
|
}
|
|
1333
1426
|
/**
|
|
1334
1427
|
* 获取社区帖子列表
|
|
1335
1428
|
*
|
|
1336
1429
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=XKI9lDVrPq
|
|
1337
1430
|
*/
|
|
1338
|
-
async getPosts(
|
|
1339
|
-
const { data:
|
|
1340
|
-
params:
|
|
1431
|
+
async getPosts(r) {
|
|
1432
|
+
const { data: n, code: s } = await this.req.get("community/posts", F, {
|
|
1433
|
+
params: a(r)
|
|
1341
1434
|
});
|
|
1342
|
-
return
|
|
1435
|
+
return n ?? { error: s };
|
|
1343
1436
|
}
|
|
1344
1437
|
/**
|
|
1345
1438
|
* 获取社区置顶帖子列表
|
|
1346
1439
|
*
|
|
1347
1440
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=yXubbZuDlC
|
|
1348
1441
|
*/
|
|
1349
|
-
async getPinnedPosts(
|
|
1350
|
-
const { data:
|
|
1351
|
-
params:
|
|
1442
|
+
async getPinnedPosts(r, n, s) {
|
|
1443
|
+
const { data: l, code: k } = await this.req.get("community/pinned-posts", F, {
|
|
1444
|
+
params: a({ forum_id: r, max_results: n, next_token: s })
|
|
1352
1445
|
});
|
|
1353
|
-
return
|
|
1446
|
+
return l ?? { error: k };
|
|
1354
1447
|
}
|
|
1355
1448
|
/**
|
|
1356
1449
|
* 根据帖子 id 获取帖子详情
|
|
1357
1450
|
*
|
|
1358
1451
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=hj1AZy5rcP
|
|
1359
1452
|
*/
|
|
1360
|
-
async getPost(
|
|
1361
|
-
const { data:
|
|
1362
|
-
params: { post_id:
|
|
1453
|
+
async getPost(r) {
|
|
1454
|
+
const { data: n, code: s } = await this.req.get("community/post", Wt, {
|
|
1455
|
+
params: { post_id: r }
|
|
1363
1456
|
});
|
|
1364
|
-
return (
|
|
1457
|
+
return (n == null ? void 0 : n.post) ?? { error: s };
|
|
1365
1458
|
}
|
|
1366
1459
|
/**
|
|
1367
1460
|
* 发布帖子
|
|
1368
1461
|
*
|
|
1369
1462
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=M5okHBuaVk
|
|
1370
1463
|
*/
|
|
1371
|
-
async post(
|
|
1372
|
-
const { data:
|
|
1373
|
-
return
|
|
1374
|
-
error:
|
|
1464
|
+
async post(r) {
|
|
1465
|
+
const { data: n, code: s } = await this.req.post("community/post", a(r), tr);
|
|
1466
|
+
return n ?? {
|
|
1467
|
+
error: s
|
|
1375
1468
|
};
|
|
1376
1469
|
}
|
|
1377
1470
|
/**
|
|
@@ -1379,33 +1472,33 @@ class sr {
|
|
|
1379
1472
|
*
|
|
1380
1473
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=djKbX7lFdp
|
|
1381
1474
|
*/
|
|
1382
|
-
async getComments(
|
|
1383
|
-
const { data:
|
|
1384
|
-
params:
|
|
1475
|
+
async getComments(r) {
|
|
1476
|
+
const { data: n, code: s } = await this.req.get("community/comments", ar, {
|
|
1477
|
+
params: a(r)
|
|
1385
1478
|
});
|
|
1386
|
-
return
|
|
1479
|
+
return n ?? { error: s };
|
|
1387
1480
|
}
|
|
1388
1481
|
/**
|
|
1389
1482
|
* 根据评论 id 获取评论详情
|
|
1390
1483
|
*
|
|
1391
1484
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=RIc7oxVGae
|
|
1392
1485
|
*/
|
|
1393
|
-
async getComment(
|
|
1394
|
-
const { data:
|
|
1395
|
-
params: { comment_id:
|
|
1486
|
+
async getComment(r) {
|
|
1487
|
+
const { data: n, code: s } = await this.req.get("community/comment", or, {
|
|
1488
|
+
params: { comment_id: r }
|
|
1396
1489
|
});
|
|
1397
|
-
return (
|
|
1490
|
+
return (n == null ? void 0 : n.comment) ?? { error: s };
|
|
1398
1491
|
}
|
|
1399
1492
|
/**
|
|
1400
1493
|
* 帖子下发表评论
|
|
1401
1494
|
*
|
|
1402
1495
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=Nv7lk0nTmr
|
|
1403
1496
|
*/
|
|
1404
|
-
async comment(
|
|
1497
|
+
async comment(r) {
|
|
1405
1498
|
await this.token.autoLogin();
|
|
1406
|
-
const { data:
|
|
1407
|
-
return
|
|
1408
|
-
error:
|
|
1499
|
+
const { data: n, code: s } = await this.req.post("community/comment", a(r), ur);
|
|
1500
|
+
return n ?? {
|
|
1501
|
+
error: s
|
|
1409
1502
|
};
|
|
1410
1503
|
}
|
|
1411
1504
|
/**
|
|
@@ -1413,33 +1506,33 @@ class sr {
|
|
|
1413
1506
|
*
|
|
1414
1507
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=sVKBbY83MY
|
|
1415
1508
|
*/
|
|
1416
|
-
async getReplies(
|
|
1417
|
-
const { data:
|
|
1418
|
-
params:
|
|
1509
|
+
async getReplies(r) {
|
|
1510
|
+
const { data: n } = await this.req.get("community/replies", rr, {
|
|
1511
|
+
params: a({ max_results: 20, ...r })
|
|
1419
1512
|
});
|
|
1420
|
-
return
|
|
1513
|
+
return n ?? { replies: [] };
|
|
1421
1514
|
}
|
|
1422
1515
|
/**
|
|
1423
1516
|
* 根据回复 id 获取回复详情
|
|
1424
1517
|
*
|
|
1425
1518
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=kxhcSXD3MG
|
|
1426
1519
|
*/
|
|
1427
|
-
async getReply(
|
|
1428
|
-
const { data:
|
|
1429
|
-
params: { reply_id:
|
|
1520
|
+
async getReply(r) {
|
|
1521
|
+
const { data: n, code: s } = await this.req.get("community/reply", nr, {
|
|
1522
|
+
params: { reply_id: r }
|
|
1430
1523
|
});
|
|
1431
|
-
return (
|
|
1524
|
+
return (n == null ? void 0 : n.reply) ?? { error: s };
|
|
1432
1525
|
}
|
|
1433
1526
|
/**
|
|
1434
1527
|
* 回复帖子评论或回复
|
|
1435
1528
|
*
|
|
1436
1529
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=KA8WpTX2pg
|
|
1437
1530
|
*/
|
|
1438
|
-
async reply(
|
|
1531
|
+
async reply(r) {
|
|
1439
1532
|
await this.token.autoLogin();
|
|
1440
|
-
const { data:
|
|
1441
|
-
return
|
|
1442
|
-
error:
|
|
1533
|
+
const { data: n, code: s } = await this.req.post("community/reply", a(r), ir);
|
|
1534
|
+
return n ?? {
|
|
1535
|
+
error: s
|
|
1443
1536
|
};
|
|
1444
1537
|
}
|
|
1445
1538
|
/**
|
|
@@ -1447,11 +1540,11 @@ class sr {
|
|
|
1447
1540
|
*
|
|
1448
1541
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=CR3m6PyXfZ
|
|
1449
1542
|
*/
|
|
1450
|
-
async like(
|
|
1543
|
+
async like(r) {
|
|
1451
1544
|
await this.token.autoLogin();
|
|
1452
|
-
const { ok:
|
|
1453
|
-
return
|
|
1454
|
-
error:
|
|
1545
|
+
const { ok: n, code: s } = await this.req.post("community/like", { ...r, action: "like" });
|
|
1546
|
+
return n || {
|
|
1547
|
+
error: s
|
|
1455
1548
|
};
|
|
1456
1549
|
}
|
|
1457
1550
|
/**
|
|
@@ -1459,11 +1552,11 @@ class sr {
|
|
|
1459
1552
|
*
|
|
1460
1553
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=CR3m6PyXfZ
|
|
1461
1554
|
*/
|
|
1462
|
-
async unlike(
|
|
1555
|
+
async unlike(r) {
|
|
1463
1556
|
await this.token.autoLogin();
|
|
1464
|
-
const { ok:
|
|
1465
|
-
return
|
|
1466
|
-
error:
|
|
1557
|
+
const { ok: n, code: s } = await this.req.post("community/like", { ...r, action: "unlike" });
|
|
1558
|
+
return n || {
|
|
1559
|
+
error: s
|
|
1467
1560
|
};
|
|
1468
1561
|
}
|
|
1469
1562
|
/**
|
|
@@ -1471,12 +1564,12 @@ class sr {
|
|
|
1471
1564
|
*
|
|
1472
1565
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=dWWhpoShxZ
|
|
1473
1566
|
*/
|
|
1474
|
-
async getMediaPresignUrl(
|
|
1567
|
+
async getMediaPresignUrl(r) {
|
|
1475
1568
|
await this.token.autoLogin();
|
|
1476
|
-
const { data:
|
|
1477
|
-
params:
|
|
1569
|
+
const { data: n } = await this.req.get("community/media-presign-url", cr, {
|
|
1570
|
+
params: r
|
|
1478
1571
|
});
|
|
1479
|
-
return
|
|
1572
|
+
return n;
|
|
1480
1573
|
}
|
|
1481
1574
|
/**
|
|
1482
1575
|
* 获取用户社区通知
|
|
@@ -1485,12 +1578,12 @@ class sr {
|
|
|
1485
1578
|
*
|
|
1486
1579
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=W5lceDgbBG
|
|
1487
1580
|
*/
|
|
1488
|
-
async getNotifications(
|
|
1581
|
+
async getNotifications(r) {
|
|
1489
1582
|
await this.token.autoLogin();
|
|
1490
|
-
const { data:
|
|
1491
|
-
params:
|
|
1583
|
+
const { data: n } = await this.req.get("community/notifications", lr, {
|
|
1584
|
+
params: a({ max_results: 20, ...r })
|
|
1492
1585
|
});
|
|
1493
|
-
return
|
|
1586
|
+
return n || { notifications: [] };
|
|
1494
1587
|
}
|
|
1495
1588
|
/**
|
|
1496
1589
|
* 获取用户未读通知数量
|
|
@@ -1499,26 +1592,26 @@ class sr {
|
|
|
1499
1592
|
*/
|
|
1500
1593
|
async getUnreadNotificationsCount() {
|
|
1501
1594
|
if (!await this.token.autoLogin()) return null;
|
|
1502
|
-
const { data:
|
|
1503
|
-
return
|
|
1595
|
+
const { data: r } = await this.req.get("community/unread-notifications-count", gr);
|
|
1596
|
+
return r;
|
|
1504
1597
|
}
|
|
1505
1598
|
/**
|
|
1506
1599
|
* 社区用户将通知标为已读
|
|
1507
1600
|
*
|
|
1508
1601
|
* https://kdocs.cn/l/cbggfJodHLIz?linkname=TCJQxnOjJe
|
|
1509
1602
|
*/
|
|
1510
|
-
async clearUnreadNotifications(
|
|
1603
|
+
async clearUnreadNotifications(r) {
|
|
1511
1604
|
if (!await this.token.autoLogin()) return !1;
|
|
1512
|
-
const { ok:
|
|
1513
|
-
return
|
|
1605
|
+
const { ok: n } = await this.req.post("community/clear-unread-notifications", { category: r });
|
|
1606
|
+
return n;
|
|
1514
1607
|
}
|
|
1515
1608
|
}
|
|
1516
|
-
function
|
|
1517
|
-
return
|
|
1609
|
+
function L(e) {
|
|
1610
|
+
return i(e, "openid", "unionid", "weixin_token");
|
|
1518
1611
|
}
|
|
1519
|
-
var
|
|
1520
|
-
const
|
|
1521
|
-
class
|
|
1612
|
+
var dr = /* @__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))(dr || {});
|
|
1613
|
+
const B = "wx_login_cache";
|
|
1614
|
+
class qr {
|
|
1522
1615
|
/**
|
|
1523
1616
|
* 创建微信相关功能接口
|
|
1524
1617
|
*
|
|
@@ -1532,11 +1625,11 @@ class or {
|
|
|
1532
1625
|
*
|
|
1533
1626
|
* https://developers.weixin.qq.com/miniprogram/dev/api/open-api/account-info/wx.getAccountInfoSync.html
|
|
1534
1627
|
*/
|
|
1535
|
-
constructor(
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
this.token =
|
|
1628
|
+
constructor(r, n) {
|
|
1629
|
+
c(this, "token");
|
|
1630
|
+
c(this, "appid");
|
|
1631
|
+
c(this, "req");
|
|
1632
|
+
this.token = r, this.req = r.req, this.appid = n, this.getLoginCache();
|
|
1540
1633
|
}
|
|
1541
1634
|
/**
|
|
1542
1635
|
* 检查缓存中的登录数据
|
|
@@ -1546,11 +1639,11 @@ class or {
|
|
|
1546
1639
|
* 也可以直接调用 login 方法,并传入 wxcode 的读取函数
|
|
1547
1640
|
*/
|
|
1548
1641
|
async getLoginCache() {
|
|
1549
|
-
const
|
|
1550
|
-
if (!
|
|
1642
|
+
const r = this.token.storage.get(B);
|
|
1643
|
+
if (!r)
|
|
1551
1644
|
return null;
|
|
1552
|
-
const
|
|
1553
|
-
return
|
|
1645
|
+
const n = le(r);
|
|
1646
|
+
return L(n) ? (this.token.weixinToken = n.weixin_token, await this.token.autoLogin(), n) : null;
|
|
1554
1647
|
}
|
|
1555
1648
|
/**
|
|
1556
1649
|
* 小程序页面微信静默登录,获取 weixinToken / openid / unionid。
|
|
@@ -1570,18 +1663,18 @@ class or {
|
|
|
1570
1663
|
* https://kdocs.cn/l/cf2mO2uRLqh9?linkname=GwIZ0givCb
|
|
1571
1664
|
*/
|
|
1572
1665
|
async login() {
|
|
1573
|
-
if (!
|
|
1666
|
+
if (!d.wx)
|
|
1574
1667
|
throw new Error("当前环境非微信小程序");
|
|
1575
|
-
const
|
|
1576
|
-
if (
|
|
1577
|
-
return
|
|
1578
|
-
const
|
|
1668
|
+
const r = await this.getLoginCache();
|
|
1669
|
+
if (r)
|
|
1670
|
+
return r;
|
|
1671
|
+
const n = await _e(), { data: s, code: l } = await this.req.post(
|
|
1579
1672
|
"weixin/login",
|
|
1580
|
-
{ code:
|
|
1581
|
-
|
|
1673
|
+
{ code: n, appid: this.appid },
|
|
1674
|
+
L,
|
|
1582
1675
|
{ message: !1 }
|
|
1583
1676
|
);
|
|
1584
|
-
return
|
|
1677
|
+
return s && (this.token.weixinToken = s.weixin_token, this.token.storage.set(B, JSON.stringify(s)), await this.token.autoLogin()), s ?? { error: l };
|
|
1585
1678
|
}
|
|
1586
1679
|
/**
|
|
1587
1680
|
* 在微信内嵌网页中调用微信公众号授权登录【暂未启用】
|
|
@@ -1599,28 +1692,28 @@ class or {
|
|
|
1599
1692
|
* - snsapi_base 不弹出授权页面,用户无感知,只能获取用户 openid,如果需要获取 unionid 则需要 snsapi_userinfo
|
|
1600
1693
|
* - snsapi_userinfo 【默认】弹出授权页面,可拿到 openid、unionid、昵称、头像等信息,但用户也可能会拒绝授权
|
|
1601
1694
|
*/
|
|
1602
|
-
async webLogin(
|
|
1603
|
-
const
|
|
1604
|
-
if (!
|
|
1605
|
-
const
|
|
1695
|
+
async webLogin(r = "snsapi_userinfo") {
|
|
1696
|
+
const n = A("code"), s = Date.now(), l = +A("state");
|
|
1697
|
+
if (!n || !l || l < s - 1e3 * 60 * 5 || l > s) {
|
|
1698
|
+
const ie = D(["code", "state"]);
|
|
1606
1699
|
location.replace(
|
|
1607
|
-
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(
|
|
1700
|
+
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.appid}&redirect_uri=${encodeURIComponent(ie)}&response_type=code&scope=${r}&state=${s}#wechat_redirect`
|
|
1608
1701
|
);
|
|
1609
1702
|
return;
|
|
1610
1703
|
}
|
|
1611
|
-
if (/^100\d{2}$/.test(
|
|
1612
|
-
return { error:
|
|
1613
|
-
const
|
|
1614
|
-
"replaceState" in history && history.replaceState({}, "",
|
|
1615
|
-
const { data:
|
|
1704
|
+
if (/^100\d{2}$/.test(n))
|
|
1705
|
+
return { error: n };
|
|
1706
|
+
const k = D(["code", "state"]);
|
|
1707
|
+
"replaceState" in history && history.replaceState({}, "", k);
|
|
1708
|
+
const { data: v, code: ne } = await this.req.post(
|
|
1616
1709
|
"weixin/login",
|
|
1617
1710
|
{
|
|
1618
|
-
code:
|
|
1711
|
+
code: n,
|
|
1619
1712
|
appid: this.appid
|
|
1620
1713
|
},
|
|
1621
|
-
|
|
1714
|
+
L
|
|
1622
1715
|
);
|
|
1623
|
-
return
|
|
1716
|
+
return v && (this.token.weixinToken = v.weixin_token, await this.token.autoLogin()), v ?? { error: ne };
|
|
1624
1717
|
}
|
|
1625
1718
|
/**
|
|
1626
1719
|
* 关联游戏账号,无返回值,全程静默
|
|
@@ -1634,42 +1727,51 @@ class or {
|
|
|
1634
1727
|
* @param weixinToken 调用 login 后,得到的 weixinToken,如果 weixinToken 为空则跳过不处理
|
|
1635
1728
|
* @param gameCode 从游戏内跳转至小程序时,通过请求参数 query 携带的 game_code,如果值为空则跳过不处理
|
|
1636
1729
|
*/
|
|
1637
|
-
async linkPlayer(
|
|
1638
|
-
!
|
|
1730
|
+
async linkPlayer(r, n) {
|
|
1731
|
+
!r || !n || await this.req.post("weixin/link-player", { weixin_token: r, game_code: n }, null, {
|
|
1639
1732
|
message: !1
|
|
1640
1733
|
});
|
|
1641
1734
|
}
|
|
1642
1735
|
}
|
|
1643
1736
|
export {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
he as
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1737
|
+
wr as AuthToken,
|
|
1738
|
+
Qe as CliamRewardStatus,
|
|
1739
|
+
hr as ClubApi,
|
|
1740
|
+
ke as ClubCreditChangeSence,
|
|
1741
|
+
ve as ClubCreditChangeSenceValidator,
|
|
1742
|
+
he as ClubCreditChangeType,
|
|
1743
|
+
be as ClubCreditChangeTypeValidator,
|
|
1744
|
+
qe as ClubItemType,
|
|
1745
|
+
T as ClubItemTypeValidator,
|
|
1746
|
+
Re as ClubRedemptionStatus,
|
|
1747
|
+
xe as ClubRedemptionStatusValidator,
|
|
1748
|
+
vr as CommunityApi,
|
|
1749
|
+
Ee as EngageAccountType,
|
|
1750
|
+
br as EventApi,
|
|
1751
|
+
Ge as EventPeriodType,
|
|
1752
|
+
u as FeatureType,
|
|
1753
|
+
Nt as ForumMode,
|
|
1754
|
+
zt as ForumModeValidator,
|
|
1755
|
+
Ve as GamerItemType,
|
|
1658
1756
|
fe as Gender,
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1757
|
+
we as GenderValidator,
|
|
1758
|
+
Ke as LotteryDrawAction,
|
|
1759
|
+
ze as LotteryTicketStatus,
|
|
1760
|
+
Kt as NotificationCategory,
|
|
1761
|
+
kr as NotificationCategoryValidator,
|
|
1762
|
+
m as NotificationType,
|
|
1763
|
+
Ot as NotificationTypeValidator,
|
|
1764
|
+
Jt as PostStatus,
|
|
1765
|
+
ee as PostStatusValidator,
|
|
1766
|
+
Ie as QuestObjective,
|
|
1767
|
+
He as RewardSoure,
|
|
1768
|
+
Be as RewardStatusPrefix,
|
|
1769
|
+
Te as RewardStatusSuffix,
|
|
1770
|
+
Me as RewardStatusSuffixV2,
|
|
1771
|
+
Je as TeamAction,
|
|
1772
|
+
Ne as TeamVisibility,
|
|
1773
|
+
Fe as VoteOptionSource,
|
|
1774
|
+
qr as WeixinApi,
|
|
1775
|
+
dr as WeixinWebLoginErrorCode,
|
|
1776
|
+
Oe as isEventConfig
|
|
1675
1777
|
};
|