@polyv/product-sdk 1.0.0-rc-20250612.4 → 1.2.0-rc-20250724.2

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/index.es.js CHANGED
@@ -1,7 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var PolyvApiUrl = /* @__PURE__ */ ((PolyvApiUrl2) => {
1
+ var PolyvApiUrl = /* @__PURE__ */ function(PolyvApiUrl2) {
5
2
  PolyvApiUrl2["GetProductTagList"] = "/live/v4/watch/channel/product/tag/list";
6
3
  PolyvApiUrl2["GetProductListByShowId"] = "/live/v3/sdk/watch/interactive/product/list-by-showId";
7
4
  PolyvApiUrl2["GetProductListByTag"] = "/live/v4/watch/channel/product/list";
@@ -19,101 +16,704 @@ var PolyvApiUrl = /* @__PURE__ */ ((PolyvApiUrl2) => {
19
16
  PolyvApiUrl2["UpdateAddress"] = "/live/v4/watch/channel/viewer/address/update";
20
17
  PolyvApiUrl2["DeleteAddress"] = "/live/v4/watch/channel/viewer/address/delete";
21
18
  return PolyvApiUrl2;
22
- })(PolyvApiUrl || {});
19
+ }({});
23
20
  function boolToYN(o) {
24
21
  if ("boolean" != typeof o) throw new Error("The value argument must be a boolean type");
25
22
  return o ? "Y" : "N";
26
23
  }
27
24
  function ynToBool(o, n) {
28
- let e = String(o).toUpperCase();
25
+ var e = String(o).toUpperCase();
29
26
  if ("Y" !== e && "N" !== e) {
30
27
  if (null == n) throw new Error('The value argument must be "Y" or "N"');
31
28
  e = String(n).toUpperCase();
32
29
  }
33
30
  return "Y" === e;
34
31
  }
35
- var ProductType = /* @__PURE__ */ ((ProductType2) => {
32
+ function canMatchKeywords(e, t) {
33
+ e = e.toLowerCase();
34
+ var n = /[/\s;_-]/, s = /[/\s;_-]/;
35
+ return t.some(function(t2) {
36
+ var o = e.indexOf(t2.toLowerCase());
37
+ if (-1 !== o && (n.test(e[o - 1]) || 0 === o) && (s.test(e[o + t2.length]) || o + t2.length >= e.length)) return true;
38
+ });
39
+ }
40
+ function canMatchModelRule(e, t) {
41
+ return !!/;\s*([^;)]*?)(?:\s+Build\/[^;)]+)?(?:;(?:\s*wv)?)?\)/.test(e) && t.test(RegExp.$1);
42
+ }
43
+ function execRules(e, t) {
44
+ var n;
45
+ return t.some(function(t2) {
46
+ var s, o = false;
47
+ return t2.regExp ? (o = t2.regExp.test(e), o && (s = RegExp.$1)) : t2.keywords ? o = canMatchKeywords(e, t2.keywords) : t2.modelRegExp && (o = canMatchModelRule(e, t2.modelRegExp)), o && (n = {
48
+ name: t2.name,
49
+ version: s
50
+ }), o;
51
+ }), n;
52
+ }
53
+ var osRules = [{
54
+ name: "windows",
55
+ regExp: /\bWindows\s?NT\s?(([\d.]+))\b/
56
+ }, {
57
+ name: "ios",
58
+ regExp: /\bOS(?:\s([\d_.]+))?\slike\sMac\sOS\sX\b/
59
+ }, {
60
+ name: "macos",
61
+ regExp: /\bMac\sOS\sX(?:\s([\d_.]+))?/
62
+ }, {
63
+ name: "openharmony",
64
+ regExp: /\bOpenHarmony\s([\d.]+)\b/
65
+ }, {
66
+ name: "android",
67
+ regExp: /\bAndroid;?(?:[-/\s]([\d.]+))?(?:\b|_)/
68
+ }, {
69
+ name: "android",
70
+ regExp: /\bAdr\s([\d.]+)(?:\b|_)/
71
+ }];
72
+ function _typeof$8(o) {
73
+ "@babel/helpers - typeof";
74
+ return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
75
+ return typeof o2;
76
+ } : function(o2) {
77
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
78
+ }, _typeof$8(o);
79
+ }
80
+ function _classCallCheck$a(a, n) {
81
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
82
+ }
83
+ function _defineProperties$5(e, r) {
84
+ for (var t = 0; t < r.length; t++) {
85
+ var o = r[t];
86
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$7(o.key), o);
87
+ }
88
+ }
89
+ function _createClass$a(e, r, t) {
90
+ return r && _defineProperties$5(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
91
+ }
92
+ function _toPropertyKey$7(t) {
93
+ var i = _toPrimitive$7(t, "string");
94
+ return "symbol" == _typeof$8(i) ? i : i + "";
95
+ }
96
+ function _toPrimitive$7(t, r) {
97
+ if ("object" != _typeof$8(t) || !t) return t;
98
+ var e = t[Symbol.toPrimitive];
99
+ if (void 0 !== e) {
100
+ var i = e.call(t, r);
101
+ if ("object" != _typeof$8(i)) return i;
102
+ throw new TypeError("@@toPrimitive must return a primitive value.");
103
+ }
104
+ return String(t);
105
+ }
106
+ function compareVersions(r, e) {
107
+ var t = /(\.0+)+$/, n = String(r).replace(t, "").split("."), s = String(e).replace(t, "").split("."), i = Math.min(n.length, s.length);
108
+ for (var _r2 = 0; _r2 < i; _r2++) {
109
+ var _e = parseInt(n[_r2]) - parseInt(s[_r2]);
110
+ if (_e) return _e;
111
+ }
112
+ return n.length - s.length;
113
+ }
114
+ var Version = /* @__PURE__ */ function() {
115
+ function Version2(r) {
116
+ _classCallCheck$a(this, Version2);
117
+ this._ver = (r || "").replace(/_/g, ".").replace(/\.+$/, ""), Object.freeze(this);
118
+ }
119
+ return _createClass$a(Version2, [{
120
+ key: "_compare",
121
+ value: function _compare(r, e) {
122
+ if (!this._ver || !r) return false;
123
+ var t = Array.isArray(e) ? e : [e], n = compareVersions(this._ver, r);
124
+ return t.some(function(r2) {
125
+ return n * r2 > 0 || 0 === n && 0 === r2;
126
+ });
127
+ }
128
+ }, {
129
+ key: "gt",
130
+ value: function gt(r) {
131
+ return this._compare(r, 1);
132
+ }
133
+ }, {
134
+ key: "gte",
135
+ value: function gte(r) {
136
+ return this._compare(r, [1, 0]);
137
+ }
138
+ }, {
139
+ key: "lt",
140
+ value: function lt(r) {
141
+ return this._compare(r, -1);
142
+ }
143
+ }, {
144
+ key: "lte",
145
+ value: function lte(r) {
146
+ return this._compare(r, [-1, 0]);
147
+ }
148
+ }, {
149
+ key: "eq",
150
+ value: function eq(r) {
151
+ return this._compare(r, 0);
152
+ }
153
+ }, {
154
+ key: "toString",
155
+ value: function toString() {
156
+ return this._ver;
157
+ }
158
+ }]);
159
+ }();
160
+ function _createClass$9(e, r, t) {
161
+ return Object.defineProperty(e, "prototype", { writable: false }), e;
162
+ }
163
+ function _classCallCheck$9(a, n) {
164
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
165
+ }
166
+ var propMap$3 = {
167
+ ios: "isIOS",
168
+ openharmony: "isOpenHarmony",
169
+ android: "isAndroid",
170
+ windows: "isWindows",
171
+ macos: "isMacOS"
172
+ };
173
+ function platformToOS(s) {
174
+ switch (s) {
175
+ case "Android":
176
+ return "android";
177
+ case "iPad":
178
+ case "iPhone":
179
+ case "iPod":
180
+ return "ios";
181
+ case "MacIntel":
182
+ return "macos";
183
+ case "Win32":
184
+ return "windows";
185
+ }
186
+ }
187
+ var OSInfo = /* @__PURE__ */ _createClass$9(function OSInfo2(s, o) {
188
+ _classCallCheck$9(this, OSInfo2);
189
+ var i;
190
+ var e;
191
+ if (this.isIOS = false, this.isAndroid = false, this.isHarmonyOS = false, this.isOpenHarmony = false, this.isWindows = false, this.isMacOS = false, null == o ? void 0 : o.platform) {
192
+ var _s = platformToOS(o.platform);
193
+ void 0 !== _s && (e = {
194
+ name: _s,
195
+ version: ""
196
+ });
197
+ }
198
+ var n = null !== (i = execRules(s, osRules)) && void 0 !== i ? i : e;
199
+ n ? (e && e.name !== n.name && (n = e), "macos" === n.name && (null == o ? void 0 : o.maxTouchPoints) && (n.name = "ios", n.version = ""), this[propMap$3[n.name]] = true, this.version = new Version(n.version), this.isAndroid && /\bHarmonyOS\b/.test(s) && (this.isHarmonyOS = true), Object.freeze(this)) : this.version = Object.freeze(new Version(""));
200
+ });
201
+ var appleRules = [{
202
+ name: "ipad",
203
+ regExp: /iPad/
204
+ }, {
205
+ name: "ipod",
206
+ regExp: /iPod/
207
+ }, {
208
+ name: "iphone",
209
+ regExp: /iPhone/
210
+ }];
211
+ var androidRules = [{
212
+ name: "huawei",
213
+ regExp: /\b(?:huawei|honor)/i
214
+ }, {
215
+ name: "huawei",
216
+ keywords: ["ideahub", "figi"]
217
+ }, {
218
+ name: "vivo",
219
+ keywords: ["vivo"]
220
+ }, {
221
+ name: "oppo",
222
+ keywords: ["oppo"]
223
+ }, {
224
+ name: "mi",
225
+ keywords: ["redmi", "hongmi", "shark", "Mi", "MIX", "POCO", "POCOPHONE"]
226
+ }, {
227
+ name: "mi",
228
+ regExp: /\bxiaomi/i
229
+ }, {
230
+ name: "samsung",
231
+ keywords: ["samsung", "galaxy"]
232
+ }, {
233
+ name: "oneplus",
234
+ keywords: ["oneplus", "one"]
235
+ }, {
236
+ name: "huawei",
237
+ modelRegExp: /^Mate\s*\d{2}/i
238
+ }, {
239
+ name: "huawei",
240
+ modelRegExp: /^Nova\s\d$/
241
+ }, {
242
+ name: "huawei",
243
+ regExp: /\b(?:Hi)?MatePad/i
244
+ }, {
245
+ name: "huawei",
246
+ regExp: /\b(?:Liantong|UNICOMVSENS)VP\d{3}\b/
247
+ }, {
248
+ name: "huawei",
249
+ regExp: /\bCMDCSP\d{3}\b/
250
+ }, {
251
+ name: "huawei",
252
+ regExp: /\bTDTECH/i
253
+ }, {
254
+ name: "huawei",
255
+ modelRegExp: /^[A-Z]{3}\d?-W[0-5]9[A-Z]*$/
256
+ }, {
257
+ name: "huawei",
258
+ modelRegExp: /^[A-Z][A-Za-z]{2,3}-(?:AN|BD|BX|AL|TL)\d{2}[A-Za-z]*$/
259
+ }, {
260
+ name: "huawei",
261
+ modelRegExp: /^TYH\d+[A-Z]?$/
262
+ }, {
263
+ name: "huawei",
264
+ modelRegExp: /^H60-L0[12]$/
265
+ }, {
266
+ name: "mi",
267
+ modelRegExp: /^MI\s?(?:\d|CC|Note|MAX|PLAY|PAD)/i
268
+ }, {
269
+ name: "mi",
270
+ modelRegExp: /^(?:AWM|SKR|SKW|DLT)-/
271
+ }, {
272
+ name: "mi",
273
+ modelRegExp: /^XIG\d{2}$/
274
+ }, {
275
+ name: "mi",
276
+ modelRegExp: /^M\d{4}[A-Z]\d{1,2}[A-Z]{1,3}$/
277
+ }, {
278
+ name: "mi",
279
+ modelRegExp: /^2\d{3}[A-Z0-9]{6}$/
280
+ }, {
281
+ name: "mi",
282
+ modelRegExp: /^2\d{5}[0-9A-Z]{2}[A-Z]$/
283
+ }, {
284
+ name: "mi",
285
+ modelRegExp: /^2\d{6}[A-Z]$/
286
+ }, {
287
+ name: "mi",
288
+ modelRegExp: /^2\d{7}[A-Z]{2,3}$/
289
+ }, {
290
+ name: "samsung",
291
+ modelRegExp: /^S(?:M|[CGP]H)-[A-Za-z0-9]+$/
292
+ }, {
293
+ name: "samsung",
294
+ modelRegExp: /^SCV3\d$/
295
+ }, {
296
+ name: "samsung",
297
+ modelRegExp: /^SC-\d{2}[A-Z]$/
298
+ }, {
299
+ name: "samsung",
300
+ modelRegExp: /^SH[WV]-/
301
+ }, {
302
+ name: "samsung",
303
+ modelRegExp: /^GT[-_][A-Z][A-Z0-9]{3,}$/i
304
+ }, {
305
+ name: "oppo",
306
+ modelRegExp: /^(?:CPH|OPD|iPA)\d{4}$/
307
+ }, {
308
+ name: "oppo",
309
+ modelRegExp: /^OPG\d{2}$/
310
+ }, {
311
+ name: "oppo",
312
+ modelRegExp: /^A[1-5]0[1-9]OP$/
313
+ }, {
314
+ name: "oneplus",
315
+ modelRegExp: /^(?:KB|HD|IN|GM|NE|LE|MT)\d{4}$/
316
+ }, {
317
+ name: "vivo",
318
+ modelRegExp: /^V[12]\d{3}[A-Z]{0,2}$/
319
+ }];
320
+ function _createClass$8(e, r, t) {
321
+ return Object.defineProperty(e, "prototype", { writable: false }), e;
322
+ }
323
+ function _classCallCheck$8(a, n) {
324
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
325
+ }
326
+ var propMap$2 = {
327
+ ipod: "isIPod",
328
+ iphone: "isIPhone",
329
+ ipad: "isIPad",
330
+ huawei: "isHuawei",
331
+ mi: "isMi",
332
+ oppo: "isOppo",
333
+ vivo: "isVivo",
334
+ oneplus: "isOnePlus",
335
+ samsung: "isSamsung"
336
+ };
337
+ var BrandInfo = /* @__PURE__ */ _createClass$8(function BrandInfo2(i, s) {
338
+ _classCallCheck$8(this, BrandInfo2);
339
+ var e;
340
+ if (this.isHuawei = false, this.isMi = false, this.isOppo = false, this.isVivo = false, this.isOnePlus = false, this.isSamsung = false, this.isIPod = false, this.isIPhone = false, this.isIPad = false, this.isMac = false, this.isApple = false, s.isIOS ? (e = appleRules, this.isApple = true) : s.isMacOS ? (this.isMac = true, this.isApple = true) : (s.isAndroid || s.isOpenHarmony) && (e = androidRules), e) {
341
+ var o = execRules(i, e);
342
+ o ? this[propMap$2[o.name]] = true : s.isIOS && (this.isIPad = true);
343
+ }
344
+ Object.freeze(this);
345
+ });
346
+ var browserRules = [{
347
+ name: "edge",
348
+ regExp: /\bEdge\/([\d.]+)/
349
+ }, {
350
+ name: "chrome",
351
+ regExp: /\b(?:Chrome|CrMo|CriOS)\/([\d.]+)/
352
+ }, {
353
+ name: "safari",
354
+ regExp: /\b(?:Version\/([\d.]+).*\s?)?Safari\b/
355
+ }, {
356
+ name: "ie",
357
+ regExp: /\bMSIE\s(\d+)/i
358
+ }, {
359
+ name: "ie",
360
+ regExp: /\bTrident\/.*;\srv:(\d+)/
361
+ }, {
362
+ name: "firefox",
363
+ regExp: /\bFirefox\/([\d.]+)/
364
+ }, {
365
+ name: "opera-presto",
366
+ regExp: /\bOpera\/([\d.]+)/
367
+ }];
368
+ function _createClass$7(e, r, t) {
369
+ return Object.defineProperty(e, "prototype", { writable: false }), e;
370
+ }
371
+ function _classCallCheck$7(a, n) {
372
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
373
+ }
374
+ var propMap$1 = {
375
+ chrome: "isChrome",
376
+ safari: "isSafari",
377
+ edge: "isEdge",
378
+ ie: "isIE",
379
+ firefox: "isFirefox",
380
+ "opera-presto": "isPrestoOpera"
381
+ };
382
+ var BrowserInfo = /* @__PURE__ */ _createClass$7(function BrowserInfo2(e) {
383
+ _classCallCheck$7(this, BrowserInfo2);
384
+ this.isChrome = false, this.isSafari = false, this.isEdge = false, this.isIE = false, this.isFirefox = false, this.isPrestoOpera = false;
385
+ var s = execRules(e, browserRules);
386
+ s ? (this[propMap$1[s.name]] = true, this.version = new Version(s.version)) : this.version = new Version(""), Object.freeze(this);
387
+ });
388
+ var clientRules = [{
389
+ name: "wxwork",
390
+ regExp: /\bwxwork\/([\d.]+)/
391
+ }, {
392
+ name: "wx",
393
+ regExp: /\bMicroMessenger\/([\d.]+)/
394
+ }, {
395
+ name: "ding",
396
+ regExp: /\bDingTalk\/([\d.]+)/
397
+ }, {
398
+ name: "qq",
399
+ regExp: /\bQQ\/([\d.]+)/
400
+ }, {
401
+ name: "qq",
402
+ regExp: /\bIPadQQ\b/
403
+ }, {
404
+ name: "weibo",
405
+ regExp: /(?:\b|_)Weibo(?:\b|_)/i
406
+ }, {
407
+ name: "edge",
408
+ regExp: /\bEdge?\/([\d.]+)/
409
+ }, {
410
+ name: "opera-blink",
411
+ regExp: /\bOPR\/([\d.]+)/
412
+ }, {
413
+ name: "qqbrowser",
414
+ regExp: /\bM?QQBrowser(?:\/([\d.]+))?/i
415
+ }, {
416
+ name: "ucbrowser",
417
+ regExp: /\b(?:UCBrowser|UCWEB)(?:-CMCC)?\/?\s?([\d.]+)/
418
+ }, {
419
+ name: "ucbrowser",
420
+ regExp: /\bUC\b/
421
+ }, {
422
+ name: "quark",
423
+ regExp: /\bQuark\/([\d.]+)/
424
+ }, {
425
+ name: "maxthon",
426
+ regExp: /\b(?:Maxthon|MxBrowser)(?:[/\s]([\d.]+))?/
427
+ }, {
428
+ name: "theworld",
429
+ regExp: /\bTheWorld(?:\s([\d.]+))?/i
430
+ }, {
431
+ name: "baidubrowser",
432
+ regExp: /\b(?:baidubrowser|bdbrowser_i18n|BIDUBrowser)(?:[/\s]([\d.]+))?/i
433
+ }, {
434
+ name: "baidubrowser",
435
+ regExp: /\bbaidubrowserpad\b/
436
+ }, {
437
+ name: "baiduapp",
438
+ regExp: /\bbaiduboxapp\b\/([\d.]+)?/i
439
+ }, {
440
+ name: "baiduapp",
441
+ regExp: /\bbaiduboxpad\b/i
442
+ }];
443
+ clientRules = clientRules.concat(browserRules);
444
+ function _createClass$6(e, r, t) {
445
+ return Object.defineProperty(e, "prototype", { writable: false }), e;
446
+ }
447
+ function _classCallCheck$6(a, n) {
448
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
449
+ }
450
+ var propMap = {
451
+ wxwork: "isWxWork",
452
+ wx: "isWx",
453
+ ding: "isDing",
454
+ qq: "isQQ",
455
+ weibo: "isWeibo",
456
+ edge: "isEdge",
457
+ "opera-blink": "isOpera",
458
+ "opera-presto": "isOpera",
459
+ qqbrowser: "isQQBrowser",
460
+ ucbrowser: "isUCBrowser",
461
+ quark: "isQuark",
462
+ maxthon: "isMaxthon",
463
+ theworld: "isTheWorld",
464
+ baidubrowser: "isBaiduBrowser",
465
+ baiduapp: "isBaiduApp",
466
+ chrome: "isChrome",
467
+ safari: "isSafari",
468
+ ie: "isIE",
469
+ firefox: "isFirefox"
470
+ };
471
+ var ClientInfo = /* @__PURE__ */ _createClass$6(function ClientInfo2(i) {
472
+ _classCallCheck$6(this, ClientInfo2);
473
+ this.isWxWork = false, this.isWx = false, this.isWxMiniProgram = false, this.isDing = false, this.isQQ = false, this.isWeibo = false, this.isEdge = false, this.isOpera = false, this.isQQBrowser = false, this.isUCBrowser = false, this.isQuark = false, this.isMaxthon = false, this.isTheWorld = false, this.isBaiduBrowser = false, this.isBaiduApp = false, this.isChrome = false, this.isSafari = false, this.isIE = false, this.isFirefox = false;
474
+ var s = execRules(i, clientRules);
475
+ s ? (this[propMap[s.name]] = true, this.version = new Version(s.version)) : this.version = new Version(""), this.isWxMiniProgram = (this.isWx || this.isWxWork) && /\bMiniProgramEnv\b/.test(i), Object.freeze(this);
476
+ });
477
+ function _createClass$5(e, r, t) {
478
+ return Object.defineProperty(e, "prototype", { writable: false }), e;
479
+ }
480
+ function _classCallCheck$5(a, n) {
481
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
482
+ }
483
+ var UAInfo = /* @__PURE__ */ _createClass$5(function UAInfo2(t, i) {
484
+ _classCallCheck$5(this, UAInfo2);
485
+ this.os = Object.freeze(new OSInfo(t, i)), this.brand = Object.freeze(new BrandInfo(t, this.os)), this.browser = Object.freeze(new BrowserInfo(t)), this.client = Object.freeze(new ClientInfo(t)), this.isTablet = this.brand.isIPad || /\bTablet\b/i.test(t) || this.os.isAndroid && !/\bMobile\b/i.test(t), this.os.isIOS || this.os.isAndroid || this.isTablet ? this.isPortable = true : /\(X11[;)]/i.test(t) || /\b(Windows\sNT|Macintosh)\b/.test(t) ? this.isPortable = false : this.isPortable = /mobile|android/i.test(t), Object.freeze(this);
486
+ });
487
+ var currentUAInfo;
488
+ function getCurrentUAInfo() {
489
+ return currentUAInfo || (currentUAInfo = Object.freeze("undefined" != typeof window ? new UAInfo(window.navigator.userAgent, window.navigator) : new UAInfo(""))), currentUAInfo;
490
+ }
491
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
492
+ function hasOwnProp(r, n) {
493
+ return hasOwnProperty.call(r, n);
494
+ }
495
+ function assignProps(r) {
496
+ if (null == r) throw new TypeError("Cannot convert undefined or null to object");
497
+ for (var o = 0; o < (arguments.length <= 1 ? 0 : arguments.length - 1); o++) {
498
+ var t = o + 1 < 1 || arguments.length <= o + 1 ? void 0 : arguments[o + 1];
499
+ if (null != t) for (var n in t) "__proto__" !== n && hasOwnProp(t, n) && (r[n] = t[n]);
500
+ }
501
+ return r;
502
+ }
503
+ function _typeof$7(o) {
504
+ "@babel/helpers - typeof";
505
+ return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
506
+ return typeof o2;
507
+ } : function(o2) {
508
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
509
+ }, _typeof$7(o);
510
+ }
511
+ function addToResult(n, o, e, t) {
512
+ if (null == e && (e = ""), "" !== e || !t.ignoreEmpty) {
513
+ if ("function" == typeof t.encode) {
514
+ o = t.encode(o);
515
+ e = -1 !== ["boolean", "string", "number"].indexOf(_typeof$7(e)) ? t.encode(String(e)) : "";
516
+ }
517
+ n.push(o + "=" + e);
518
+ }
519
+ }
520
+ function handleMultiValues(n, o, e, t) {
521
+ e.forEach(function(e2) {
522
+ addToResult(n, o, e2, t);
523
+ });
524
+ }
525
+ function stringify(n, o) {
526
+ var e = assignProps({
527
+ encode: encodeURIComponent
528
+ }, o), t = [];
529
+ var i, r;
530
+ for (i in n) hasOwnProp(n, i) && (r = n[i], Array.isArray(r) ? handleMultiValues(t, i, r, e) : addToResult(t, i, r, e));
531
+ return t.join("&");
532
+ }
533
+ function splitURL(e) {
534
+ var t = {
535
+ leftContext: ""
536
+ };
537
+ var n = e.indexOf("#");
538
+ return -1 !== n && (t.hash = e.slice(n + 1), e = e.slice(0, n)), n = e.indexOf("?"), -1 !== n && (t.search = e.slice(n + 1), e = e.slice(0, n)), t.leftContext = e, t;
539
+ }
540
+ function joinURL(e) {
541
+ var t = e.leftContext;
542
+ return null != e.search && (t += "?" + e.search), null != e.hash && (t += "#" + e.hash), t;
543
+ }
544
+ function concat(i, r, t) {
545
+ if (i = String(i), null == r) return i;
546
+ if (!(r = "string" == typeof r ? r.replace(/^[?&]/, "") : stringify(r, t))) return i;
547
+ var n = splitURL(i);
548
+ var e = n.search || "";
549
+ return e && "&" !== e.slice(-1) && (e += "&"), e += r, n.search = e, joinURL(n);
550
+ }
551
+ (function(i, n, o, t) {
552
+ return new (o || (o = Promise))(function(e, a) {
553
+ function r(i2) {
554
+ try {
555
+ k(t.next(i2));
556
+ } catch (i3) {
557
+ a(i3);
558
+ }
559
+ }
560
+ function l(i2) {
561
+ try {
562
+ k(t["throw"](i2));
563
+ } catch (i3) {
564
+ a(i3);
565
+ }
566
+ }
567
+ function k(i2) {
568
+ var n2;
569
+ i2.done ? e(i2.value) : (n2 = i2.value, n2 instanceof o ? n2 : new o(function(i3) {
570
+ i3(n2);
571
+ })).then(r, l);
572
+ }
573
+ k((t = t.apply(i, n || [])).next());
574
+ });
575
+ });
576
+ var uaInfo = getCurrentUAInfo();
577
+ uaInfo.os.isAndroid;
578
+ uaInfo.os.isIOS;
579
+ var LinkType;
580
+ !function(i) {
581
+ i[i.Normal = 10] = "Normal", i[i.MultiPlatform = 11] = "MultiPlatform", i[i.Native = 12] = "Native";
582
+ }(LinkType || (LinkType = {}));
583
+ var LinkJumpWay;
584
+ !function(i) {
585
+ i.PopUp = "POP_UP", i.NewWindow = "NEW_WINDOW", i.CurrentWindow = "CURRENT_WINDOW";
586
+ }(LinkJumpWay || (LinkJumpWay = {}));
587
+ var ProductType = /* @__PURE__ */ function(ProductType2) {
36
588
  ProductType2["Normal"] = "normal";
37
589
  ProductType2["Finance"] = "finance";
38
590
  ProductType2["Position"] = "position";
39
591
  return ProductType2;
40
- })(ProductType || {});
41
- var ProductLinkType = /* @__PURE__ */ ((ProductLinkType2) => {
592
+ }({});
593
+ var ProductLinkType = /* @__PURE__ */ function(ProductLinkType2) {
42
594
  ProductLinkType2[ProductLinkType2["Normal"] = 10] = "Normal";
43
595
  ProductLinkType2[ProductLinkType2["MultiPlatform"] = 11] = "MultiPlatform";
44
596
  ProductLinkType2[ProductLinkType2["Native"] = 12] = "Native";
45
597
  return ProductLinkType2;
46
- })(ProductLinkType || {});
47
- var ProductLinkJumpWay = /* @__PURE__ */ ((ProductLinkJumpWay2) => {
598
+ }({});
599
+ var ProductLinkJumpWay = /* @__PURE__ */ function(ProductLinkJumpWay2) {
48
600
  ProductLinkJumpWay2["PopUp"] = "POP_UP";
49
601
  ProductLinkJumpWay2["NewWindow"] = "NEW_WINDOW";
50
602
  ProductLinkJumpWay2["CurrentWindow"] = "CURRENT_WINDOW";
51
603
  return ProductLinkJumpWay2;
52
- })(ProductLinkJumpWay || {});
53
- var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
604
+ }({});
605
+ var ProductStatus = /* @__PURE__ */ function(ProductStatus2) {
54
606
  ProductStatus2[ProductStatus2["OnSale"] = 1] = "OnSale";
55
607
  ProductStatus2[ProductStatus2["OffSale"] = 0] = "OffSale";
56
608
  return ProductStatus2;
57
- })(ProductStatus || {});
58
- var ProductMediaType = /* @__PURE__ */ ((ProductMediaType2) => {
609
+ }({});
610
+ var ProductMediaType = /* @__PURE__ */ function(ProductMediaType2) {
59
611
  ProductMediaType2["Image"] = "image";
60
612
  ProductMediaType2["MaterialVideo"] = "material-video";
61
613
  return ProductMediaType2;
62
- })(ProductMediaType || {});
63
- var ProductExplainStatus = /* @__PURE__ */ ((ProductExplainStatus2) => {
614
+ }({});
615
+ var ProductExplainStatus = /* @__PURE__ */ function(ProductExplainStatus2) {
64
616
  ProductExplainStatus2["NotExplained"] = "notExplained";
65
617
  ProductExplainStatus2["Explaining"] = "explaining";
66
618
  ProductExplainStatus2["Explained"] = "explained";
67
619
  return ProductExplainStatus2;
68
- })(ProductExplainStatus || {});
69
- var ProductExplainType = /* @__PURE__ */ ((ProductExplainType2) => {
620
+ }({});
621
+ var ProductExplainType = /* @__PURE__ */ function(ProductExplainType2) {
70
622
  ProductExplainType2["Live"] = "live";
71
623
  ProductExplainType2["Playback"] = "recordFile";
72
624
  return ProductExplainType2;
73
- })(ProductExplainType || {});
74
- var ProductBuyType = /* @__PURE__ */ ((ProductBuyType2) => {
625
+ }({});
626
+ var ProductBuyType = /* @__PURE__ */ function(ProductBuyType2) {
75
627
  ProductBuyType2["DirectBuy"] = "inner";
76
628
  ProductBuyType2["Link"] = "link";
77
629
  return ProductBuyType2;
78
- })(ProductBuyType || {});
79
- var ProductPriceType = /* @__PURE__ */ ((ProductPriceType2) => {
630
+ }({});
631
+ var ProductPriceType = /* @__PURE__ */ function(ProductPriceType2) {
80
632
  ProductPriceType2["Amount"] = "AMOUNT";
81
633
  ProductPriceType2["Custom"] = "CUSTOM";
82
634
  return ProductPriceType2;
83
- })(ProductPriceType || {});
84
- var ProductDeliveryType = /* @__PURE__ */ ((ProductDeliveryType2) => {
635
+ }({});
636
+ var ProductDeliveryType = /* @__PURE__ */ function(ProductDeliveryType2) {
85
637
  ProductDeliveryType2["Express"] = "express";
86
638
  ProductDeliveryType2["Virtual"] = "virtual";
87
639
  return ProductDeliveryType2;
88
- })(ProductDeliveryType || {});
89
- var ProductServiceType = /* @__PURE__ */ ((ProductServiceType2) => {
640
+ }({});
641
+ var ProductServiceType = /* @__PURE__ */ function(ProductServiceType2) {
90
642
  ProductServiceType2["WxWorkCode"] = "wxWorkCode";
91
643
  ProductServiceType2["Custom"] = "custom";
92
644
  return ProductServiceType2;
93
- })(ProductServiceType || {});
94
- var AuthType = /* @__PURE__ */ ((AuthType2) => {
645
+ }({});
646
+ var AuthType = /* @__PURE__ */ function(AuthType2) {
95
647
  AuthType2["None"] = "none";
96
648
  AuthType2["Custom"] = "custom";
97
649
  AuthType2["External"] = "external";
98
650
  AuthType2["Direct"] = "direct";
99
651
  AuthType2["EnterpriseWeChat"] = "enterpriseWeChat";
100
652
  return AuthType2;
101
- })(AuthType || {});
653
+ }({});
654
+ function _typeof$6(o) {
655
+ "@babel/helpers - typeof";
656
+ return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
657
+ return typeof o2;
658
+ } : function(o2) {
659
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
660
+ }, _typeof$6(o);
661
+ }
662
+ function ownKeys$4(e, r) {
663
+ var t = Object.keys(e);
664
+ if (Object.getOwnPropertySymbols) {
665
+ var o = Object.getOwnPropertySymbols(e);
666
+ r && (o = o.filter(function(r2) {
667
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
668
+ })), t.push.apply(t, o);
669
+ }
670
+ return t;
671
+ }
672
+ function _objectSpread$4(e) {
673
+ for (var r = 1; r < arguments.length; r++) {
674
+ var t = null != arguments[r] ? arguments[r] : {};
675
+ r % 2 ? ownKeys$4(Object(t), true).forEach(function(r2) {
676
+ _defineProperty$5(e, r2, t[r2]);
677
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function(r2) {
678
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
679
+ });
680
+ }
681
+ return e;
682
+ }
683
+ function _defineProperty$5(e, r, t) {
684
+ return (r = _toPropertyKey$6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
685
+ }
686
+ function _toPropertyKey$6(t) {
687
+ var i = _toPrimitive$6(t, "string");
688
+ return "symbol" == _typeof$6(i) ? i : i + "";
689
+ }
690
+ function _toPrimitive$6(t, r) {
691
+ if ("object" != _typeof$6(t) || !t) return t;
692
+ var e = t[Symbol.toPrimitive];
693
+ if (void 0 !== e) {
694
+ var i = e.call(t, r);
695
+ if ("object" != _typeof$6(i)) return i;
696
+ throw new TypeError("@@toPrimitive must return a primitive value.");
697
+ }
698
+ return ("string" === r ? String : Number)(t);
699
+ }
102
700
  function parseFeature(features) {
103
- let list = [];
701
+ var list = [];
104
702
  if (!features) {
105
703
  return list;
106
704
  }
107
705
  try {
108
- const arr = JSON.parse(features);
109
- list = arr.filter((i) => !!i);
706
+ var arr = JSON.parse(features);
707
+ list = arr.filter(function(i) {
708
+ return !!i;
709
+ });
110
710
  } catch (e) {
111
711
  console.error("parseFeature error", e);
112
712
  }
113
713
  return list;
114
714
  }
115
715
  function filterInternalData(internalData) {
116
- const basicData = {
716
+ var basicData = {
117
717
  productId: internalData.productId,
118
718
  cover: internalData.cover,
119
719
  coverList: [internalData.cover],
@@ -125,11 +725,14 @@ function filterInternalData(internalData) {
125
725
  status: internalData.status,
126
726
  displayNumber: internalData.showId,
127
727
  buttonText: internalData.btnShow,
128
- featureTags: parseFeature(internalData.features)
728
+ featureTags: parseFeature(internalData.features),
729
+ pushRule: internalData.productPushRule,
730
+ pushLogId: internalData.logId,
731
+ originalData: internalData
129
732
  };
130
- const linkData = {
733
+ var linkData = {
131
734
  linkType: internalData.linkType,
132
- jumpWay: ProductLinkJumpWay.NewWindow,
735
+ jumpWay: LinkJumpWay.NewWindow,
133
736
  link: internalData.link,
134
737
  pcLink: internalData.pcLink,
135
738
  mobileLink: internalData.mobileLink,
@@ -143,18 +746,20 @@ function filterInternalData(internalData) {
143
746
  };
144
747
  if (internalData.ext) {
145
748
  try {
146
- const extData = JSON.parse(internalData.ext);
749
+ var extData = JSON.parse(internalData.ext);
147
750
  basicData.coverList = extData.coverList || [internalData.cover];
148
- basicData.videoList = (extData.videoList || []).map((item) => item.videoId);
751
+ basicData.videoList = (extData.videoList || []).map(function(item) {
752
+ return item.videoId;
753
+ });
149
754
  linkData.jumpWay = extData.jumpWay;
150
- const mediaList = [];
151
- basicData.videoList.forEach((item) => {
755
+ var mediaList = [];
756
+ basicData.videoList.forEach(function(item) {
152
757
  mediaList.push({
153
758
  type: ProductMediaType.MaterialVideo,
154
759
  materialId: item
155
760
  });
156
761
  });
157
- basicData.coverList.forEach((item) => {
762
+ basicData.coverList.forEach(function(item) {
158
763
  mediaList.push({
159
764
  type: ProductMediaType.Image,
160
765
  url: item
@@ -165,60 +770,54 @@ function filterInternalData(internalData) {
165
770
  console.error("filterInternlData error", e);
166
771
  }
167
772
  }
168
- const explainData = {
773
+ var explainData = {
169
774
  explainStatus: internalData.explainStatus,
170
775
  explainType: internalData.explainType
171
776
  };
172
- let productData;
173
- const productType = internalData.productType;
777
+ var productData;
778
+ var productType = internalData.productType;
174
779
  switch (productType) {
175
780
  case ProductType.Normal: {
176
- productData = {
177
- ...basicData,
178
- ...linkData,
179
- ...explainData,
781
+ productData = _objectSpread$4(_objectSpread$4(_objectSpread$4(_objectSpread$4({}, basicData), linkData), explainData), {}, {
180
782
  productType: ProductType.Normal,
181
783
  priceType: internalData.priceType,
182
784
  buyType: internalData.buyType,
183
785
  realPrice: internalData.realPrice,
184
786
  originPrice: internalData.price,
787
+ originPriceType: internalData.originalPriceType || ProductPriceType.Amount,
788
+ customOriginalPrice: internalData.customOriginalPrice,
185
789
  customPrice: internalData.customPrice,
186
790
  priceVisible: ynToBool(internalData.openPriceEnable, "Y"),
187
791
  deliveryType: internalData.deliveryType,
188
792
  customerServiceContact: internalData.customerServiceContact,
189
793
  customerServiceType: internalData.customerServiceType,
794
+ forceShowSoldOut: ynToBool(internalData.markAsSoldout, "N"),
190
795
  stockEnabled: ynToBool(internalData.stockEnabled, "N"),
191
796
  stock: internalData.stock
192
- };
797
+ });
193
798
  break;
194
799
  }
195
800
  case ProductType.Finance: {
196
- productData = {
197
- ...basicData,
198
- ...linkData,
199
- ...explainData,
801
+ productData = _objectSpread$4(_objectSpread$4(_objectSpread$4(_objectSpread$4({}, basicData), linkData), explainData), {}, {
200
802
  productType: ProductType.Finance,
201
- yield: internalData.yield
202
- };
803
+ "yield": internalData["yield"]
804
+ });
203
805
  break;
204
806
  }
205
807
  case ProductType.Position: {
206
808
  basicData.description = "";
207
809
  basicData.detail = internalData.productDesc;
208
- let treatment = "";
810
+ var treatment = "";
209
811
  try {
210
- const params = JSON.parse(internalData.params);
812
+ var params = JSON.parse(internalData.params);
211
813
  treatment = params.treatment;
212
814
  } catch (e) {
213
815
  console.error(e);
214
816
  }
215
- productData = {
216
- ...basicData,
217
- ...linkData,
218
- ...explainData,
817
+ productData = _objectSpread$4(_objectSpread$4(_objectSpread$4(_objectSpread$4({}, basicData), linkData), explainData), {}, {
219
818
  productType: ProductType.Position,
220
819
  treatment
221
- };
820
+ });
222
821
  break;
223
822
  }
224
823
  }
@@ -227,85 +826,99 @@ function filterInternalData(internalData) {
227
826
  }
228
827
  return productData;
229
828
  }
230
- class EventEmitter {
231
- constructor() {
232
- this.__eventStore = {};
233
- }
234
- __addOnEvent(t, e, n, o) {
235
- if (!e || !n) return;
236
- let r = this.__eventStore[e];
237
- r || (r = []), r.push({ type: t, handler: n, callbackHandler: n.bind(o) }), this.__eventStore[e] = r;
238
- }
239
- on(t, e, n = this) {
240
- this.__addOnEvent("normal", t, e, n);
241
- }
242
- once(t, e, n = this) {
243
- this.__addOnEvent("once", t, e, n);
244
- }
245
- off(t, e) {
246
- let n = this.__eventStore[t];
247
- n && (n = n.filter((t2) => t2.handler !== e), this.__eventStore[t] = n);
248
- }
249
- emit(t, e) {
250
- const n = this.__eventStore[t];
251
- n && n.forEach((n2) => {
252
- const { type: o, handler: r, callbackHandler: _ } = n2;
253
- "function" == typeof _ && _(e), "once" === o && this.off(t, r);
254
- });
255
- }
256
- destroy() {
257
- this.__eventStore = {};
258
- }
259
- }
260
- const hasOwnProperty = Object.prototype.hasOwnProperty;
261
- function hasOwnProp(r, n) {
262
- return hasOwnProperty.call(r, n);
829
+ function _typeof$5(o) {
830
+ "@babel/helpers - typeof";
831
+ return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
832
+ return typeof o2;
833
+ } : function(o2) {
834
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
835
+ }, _typeof$5(o);
263
836
  }
264
- function assignProps(r, ...n) {
265
- if (null == r) throw new TypeError("Cannot convert undefined or null to object");
266
- for (let o = 0; o < n.length; o++) {
267
- const t = n[o];
268
- if (null != t) for (const n2 in t) "__proto__" !== n2 && hasOwnProp(t, n2) && (r[n2] = t[n2]);
269
- }
270
- return r;
837
+ function _classCallCheck$4(a, n) {
838
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
271
839
  }
272
- function addToResult(n, o, e, t) {
273
- if (null == e && (e = ""), "" !== e || !t.ignoreEmpty) {
274
- if ("function" == typeof t.encode) {
275
- o = t.encode(o);
276
- e = -1 !== ["boolean", "string", "number"].indexOf(typeof e) ? t.encode(String(e)) : "";
277
- }
278
- n.push(o + "=" + e);
840
+ function _defineProperties$4(e, r) {
841
+ for (var t = 0; t < r.length; t++) {
842
+ var o = r[t];
843
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$5(o.key), o);
279
844
  }
280
845
  }
281
- function handleMultiValues(n, o, e, t) {
282
- e.forEach((e2) => {
283
- addToResult(n, o, e2, t);
284
- });
285
- }
286
- function stringify(n, o) {
287
- const e = assignProps({ encode: encodeURIComponent }, o), t = [];
288
- let i, r;
289
- for (i in n) hasOwnProp(n, i) && (r = n[i], Array.isArray(r) ? handleMultiValues(t, i, r, e) : addToResult(t, i, r, e));
290
- return t.join("&");
291
- }
292
- function splitURL(e) {
293
- const t = { leftContext: "" };
294
- let n = e.indexOf("#");
295
- return -1 !== n && (t.hash = e.slice(n + 1), e = e.slice(0, n)), n = e.indexOf("?"), -1 !== n && (t.search = e.slice(n + 1), e = e.slice(0, n)), t.leftContext = e, t;
846
+ function _createClass$4(e, r, t) {
847
+ return r && _defineProperties$4(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
296
848
  }
297
- function joinURL(e) {
298
- let t = e.leftContext;
299
- return null != e.search && (t += "?" + e.search), null != e.hash && (t += "#" + e.hash), t;
849
+ function _toPropertyKey$5(t) {
850
+ var i = _toPrimitive$5(t, "string");
851
+ return "symbol" == _typeof$5(i) ? i : i + "";
300
852
  }
301
- function concat(i, r, t) {
302
- if (i = String(i), null == r) return i;
303
- if (!(r = "string" == typeof r ? r.replace(/^[?&]/, "") : stringify(r, t))) return i;
304
- const n = splitURL(i);
305
- let e = n.search || "";
306
- return e && "&" !== e.slice(-1) && (e += "&"), e += r, n.search = e, joinURL(n);
853
+ function _toPrimitive$5(t, r) {
854
+ if ("object" != _typeof$5(t) || !t) return t;
855
+ var e = t[Symbol.toPrimitive];
856
+ if (void 0 !== e) {
857
+ var i = e.call(t, r);
858
+ if ("object" != _typeof$5(i)) return i;
859
+ throw new TypeError("@@toPrimitive must return a primitive value.");
860
+ }
861
+ return String(t);
307
862
  }
308
- var ProductEvents = /* @__PURE__ */ ((ProductEvents2) => {
863
+ var EventEmitter = /* @__PURE__ */ function() {
864
+ function EventEmitter2() {
865
+ _classCallCheck$4(this, EventEmitter2);
866
+ this.__eventStore = {};
867
+ }
868
+ return _createClass$4(EventEmitter2, [{
869
+ key: "__addOnEvent",
870
+ value: function __addOnEvent(t, e, n, o) {
871
+ if (!e || !n) return;
872
+ var r = this.__eventStore[e];
873
+ r || (r = []), r.push({
874
+ type: t,
875
+ handler: n,
876
+ callbackHandler: n.bind(o)
877
+ }), this.__eventStore[e] = r;
878
+ }
879
+ }, {
880
+ key: "on",
881
+ value: function on(t, e) {
882
+ var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : this;
883
+ this.__addOnEvent("normal", t, e, n);
884
+ }
885
+ }, {
886
+ key: "once",
887
+ value: function once(t, e) {
888
+ var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : this;
889
+ this.__addOnEvent("once", t, e, n);
890
+ }
891
+ }, {
892
+ key: "off",
893
+ value: function off(t, e) {
894
+ var n = this.__eventStore[t];
895
+ n && (n = n.filter(function(t2) {
896
+ return t2.handler !== e;
897
+ }), this.__eventStore[t] = n);
898
+ }
899
+ }, {
900
+ key: "emit",
901
+ value: function emit(t, e) {
902
+ var _this = this;
903
+ var n = this.__eventStore[t];
904
+ n && n.forEach(function(n2) {
905
+ var o = n2.type, r = n2.handler, _ = n2.callbackHandler;
906
+ "function" == typeof _ && _(e), "once" === o && _this.off(t, r);
907
+ });
908
+ }
909
+ }, {
910
+ key: "destroy",
911
+ value: function destroy() {
912
+ this.__eventStore = {};
913
+ }
914
+ }]);
915
+ }();
916
+ var ProductPushRule = /* @__PURE__ */ function(ProductPushRule2) {
917
+ ProductPushRule2["BigCard"] = "bigCard";
918
+ ProductPushRule2["SmallCard"] = "smallCard";
919
+ return ProductPushRule2;
920
+ }({});
921
+ var ProductEvents = /* @__PURE__ */ function(ProductEvents2) {
309
922
  ProductEvents2["OnSaleProduct"] = "OnSaleProduct";
310
923
  ProductEvents2["OffSaleProduct"] = "OffSaleProduct";
311
924
  ProductEvents2["AddProduct"] = "AddProduct";
@@ -321,128 +934,296 @@ var ProductEvents = /* @__PURE__ */ ((ProductEvents2) => {
321
934
  ProductEvents2["ProductClick"] = "ProductClick";
322
935
  ProductEvents2["ProductClickTimes"] = "ProductClickTimes";
323
936
  return ProductEvents2;
324
- })(ProductEvents || {});
325
- const appName = "product";
326
- class Product {
327
- constructor(iarCore, config) {
328
- __publicField(this, "ProductType", ProductType);
329
- __publicField(this, "ProductLinkType", ProductLinkType);
330
- __publicField(this, "ProductLinkJumpWay", ProductLinkJumpWay);
331
- __publicField(this, "ProductBuyType", ProductBuyType);
332
- __publicField(this, "ProductStatus", ProductStatus);
333
- __publicField(this, "ProductEvents", ProductEvents);
334
- __publicField(this, "ProductPriceType", ProductPriceType);
335
- __publicField(this, "ProductExplainStatus", ProductExplainStatus);
336
- __publicField(this, "ProductMediaType", ProductMediaType);
337
- __publicField(this, "ProductDeliveryType", ProductDeliveryType);
338
- __publicField(this, "ProductServiceType", ProductServiceType);
339
- __publicField(this, "eventEmitter", new EventEmitter());
340
- __publicField(this, "__handleProductMessage", (socketData) => {
341
- const status = Number(socketData.status);
937
+ }({});
938
+ function _typeof$4(o) {
939
+ "@babel/helpers - typeof";
940
+ return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
941
+ return typeof o2;
942
+ } : function(o2) {
943
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
944
+ }, _typeof$4(o);
945
+ }
946
+ function ownKeys$3(e, r) {
947
+ var t = Object.keys(e);
948
+ if (Object.getOwnPropertySymbols) {
949
+ var o = Object.getOwnPropertySymbols(e);
950
+ r && (o = o.filter(function(r2) {
951
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
952
+ })), t.push.apply(t, o);
953
+ }
954
+ return t;
955
+ }
956
+ function _objectSpread$3(e) {
957
+ for (var r = 1; r < arguments.length; r++) {
958
+ var t = null != arguments[r] ? arguments[r] : {};
959
+ r % 2 ? ownKeys$3(Object(t), true).forEach(function(r2) {
960
+ _defineProperty$4(e, r2, t[r2]);
961
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r2) {
962
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
963
+ });
964
+ }
965
+ return e;
966
+ }
967
+ function _regenerator$3() {
968
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
969
+ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag";
970
+ function i(r2, n2, o2, i2) {
971
+ var c2 = n2 && n2.prototype instanceof Generator ? n2 : Generator, u2 = Object.create(c2.prototype);
972
+ return _regeneratorDefine2$3(u2, "_invoke", function(r3, n3, o3) {
973
+ var i3, c3, u3, f2 = 0, p = o3 || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d2(t2, r4) {
974
+ return i3 = t2, c3 = 0, u3 = e, G.n = r4, a;
975
+ } };
976
+ function d(r4, n4) {
977
+ for (c3 = r4, u3 = n4, t = 0; !y && f2 && !o4 && t < p.length; t++) {
978
+ var o4, i4 = p[t], d2 = G.p, l = i4[2];
979
+ r4 > 3 ? (o4 = l === n4) && (u3 = i4[(c3 = i4[4]) ? 5 : (c3 = 3, 3)], i4[4] = i4[5] = e) : i4[0] <= d2 && ((o4 = r4 < 2 && d2 < i4[1]) ? (c3 = 0, G.v = n4, G.n = i4[1]) : d2 < l && (o4 = r4 < 3 || i4[0] > n4 || n4 > l) && (i4[4] = r4, i4[5] = n4, G.n = l, c3 = 0));
980
+ }
981
+ if (o4 || r4 > 1) return a;
982
+ throw y = true, n4;
983
+ }
984
+ return function(o4, p2, l) {
985
+ if (f2 > 1) throw TypeError("Generator is already running");
986
+ for (y && 1 === p2 && d(p2, l), c3 = p2, u3 = l; (t = c3 < 2 ? e : u3) || !y; ) {
987
+ i3 || (c3 ? c3 < 3 ? (c3 > 1 && (G.n = -1), d(c3, u3)) : G.n = u3 : G.v = u3);
988
+ try {
989
+ if (f2 = 2, i3) {
990
+ if (c3 || (o4 = "next"), t = i3[o4]) {
991
+ if (!(t = t.call(i3, u3))) throw TypeError("iterator result is not an object");
992
+ if (!t.done) return t;
993
+ u3 = t.value, c3 < 2 && (c3 = 0);
994
+ } else 1 === c3 && (t = i3["return"]) && t.call(i3), c3 < 2 && (u3 = TypeError("The iterator does not provide a '" + o4 + "' method"), c3 = 1);
995
+ i3 = e;
996
+ } else if ((t = (y = G.n < 0) ? u3 : r3.call(n3, G)) !== a) break;
997
+ } catch (t2) {
998
+ i3 = e, c3 = 1, u3 = t2;
999
+ } finally {
1000
+ f2 = 1;
1001
+ }
1002
+ }
1003
+ return { value: t, done: y };
1004
+ };
1005
+ }(r2, o2, i2), true), u2;
1006
+ }
1007
+ var a = {};
1008
+ function Generator() {
1009
+ }
1010
+ function GeneratorFunction() {
1011
+ }
1012
+ function GeneratorFunctionPrototype() {
1013
+ }
1014
+ t = Object.getPrototypeOf;
1015
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2$3(t = {}, n, function() {
1016
+ return this;
1017
+ }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
1018
+ function f(e2) {
1019
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e2, GeneratorFunctionPrototype) : (e2.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2$3(e2, o, "GeneratorFunction")), e2.prototype = Object.create(u), e2;
1020
+ }
1021
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2$3(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2$3(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2$3(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2$3(u), _regeneratorDefine2$3(u, o, "Generator"), _regeneratorDefine2$3(u, n, function() {
1022
+ return this;
1023
+ }), _regeneratorDefine2$3(u, "toString", function() {
1024
+ return "[object Generator]";
1025
+ }), (_regenerator$3 = function _regenerator2() {
1026
+ return { w: i, m: f };
1027
+ })();
1028
+ }
1029
+ function _regeneratorDefine2$3(e, r, n, t) {
1030
+ var i = Object.defineProperty;
1031
+ try {
1032
+ i({}, "", {});
1033
+ } catch (e2) {
1034
+ i = 0;
1035
+ }
1036
+ _regeneratorDefine2$3 = function _regeneratorDefine(e2, r2, n2, t2) {
1037
+ if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
1038
+ else {
1039
+ var o = function o2(r3, n3) {
1040
+ _regeneratorDefine2$3(e2, r3, function(e3) {
1041
+ return this._invoke(r3, n3, e3);
1042
+ });
1043
+ };
1044
+ o("next", 0), o("throw", 1), o("return", 2);
1045
+ }
1046
+ }, _regeneratorDefine2$3(e, r, n, t);
1047
+ }
1048
+ function asyncGeneratorStep$3(n, t, e, r, o, a, c) {
1049
+ try {
1050
+ var i = n[a](c), u = i.value;
1051
+ } catch (n2) {
1052
+ return void e(n2);
1053
+ }
1054
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
1055
+ }
1056
+ function _asyncToGenerator$3(n) {
1057
+ return function() {
1058
+ var t = this, e = arguments;
1059
+ return new Promise(function(r, o) {
1060
+ var a = n.apply(t, e);
1061
+ function _next(n2) {
1062
+ asyncGeneratorStep$3(a, r, o, _next, _throw, "next", n2);
1063
+ }
1064
+ function _throw(n2) {
1065
+ asyncGeneratorStep$3(a, r, o, _next, _throw, "throw", n2);
1066
+ }
1067
+ _next(void 0);
1068
+ });
1069
+ };
1070
+ }
1071
+ function _classCallCheck$3(a, n) {
1072
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
1073
+ }
1074
+ function _defineProperties$3(e, r) {
1075
+ for (var t = 0; t < r.length; t++) {
1076
+ var o = r[t];
1077
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$4(o.key), o);
1078
+ }
1079
+ }
1080
+ function _createClass$3(e, r, t) {
1081
+ return r && _defineProperties$3(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
1082
+ }
1083
+ function _defineProperty$4(e, r, t) {
1084
+ return (r = _toPropertyKey$4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
1085
+ }
1086
+ function _toPropertyKey$4(t) {
1087
+ var i = _toPrimitive$4(t, "string");
1088
+ return "symbol" == _typeof$4(i) ? i : i + "";
1089
+ }
1090
+ function _toPrimitive$4(t, r) {
1091
+ if ("object" != _typeof$4(t) || !t) return t;
1092
+ var e = t[Symbol.toPrimitive];
1093
+ if (void 0 !== e) {
1094
+ var i = e.call(t, r);
1095
+ if ("object" != _typeof$4(i)) return i;
1096
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1097
+ }
1098
+ return String(t);
1099
+ }
1100
+ var appName = "product";
1101
+ var Product = /* @__PURE__ */ function() {
1102
+ function Product2(iarCore, config) {
1103
+ var _this = this;
1104
+ _classCallCheck$3(this, Product2);
1105
+ _defineProperty$4(this, "ProductType", ProductType);
1106
+ _defineProperty$4(this, "ProductLinkType", ProductLinkType);
1107
+ _defineProperty$4(this, "ProductLinkJumpWay", ProductLinkJumpWay);
1108
+ _defineProperty$4(this, "ProductBuyType", ProductBuyType);
1109
+ _defineProperty$4(this, "ProductStatus", ProductStatus);
1110
+ _defineProperty$4(this, "ProductEvents", ProductEvents);
1111
+ _defineProperty$4(this, "ProductPriceType", ProductPriceType);
1112
+ _defineProperty$4(this, "ProductExplainStatus", ProductExplainStatus);
1113
+ _defineProperty$4(this, "ProductMediaType", ProductMediaType);
1114
+ _defineProperty$4(this, "ProductDeliveryType", ProductDeliveryType);
1115
+ _defineProperty$4(this, "ProductServiceType", ProductServiceType);
1116
+ _defineProperty$4(this, "ProductPushRule", ProductPushRule);
1117
+ _defineProperty$4(this, "eventEmitter", new EventEmitter());
1118
+ _defineProperty$4(this, "__isPushingProduct", false);
1119
+ _defineProperty$4(this, "__handleProductMessage", function(socketData) {
1120
+ var status = Number(socketData.status);
342
1121
  switch (status) {
343
1122
  // 上架商品
344
1123
  case 1: {
345
- this.eventEmitter.emit(ProductEvents.OnSaleProduct, {
1124
+ _this.eventEmitter.emit(ProductEvents.OnSaleProduct, {
346
1125
  productData: filterInternalData(socketData.content)
347
1126
  });
348
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
349
1127
  break;
350
1128
  }
351
1129
  // 下架商品
352
1130
  case 2: {
353
- this.eventEmitter.emit(ProductEvents.OffSaleProduct, {
1131
+ _this.eventEmitter.emit(ProductEvents.OffSaleProduct, {
354
1132
  productData: filterInternalData(socketData.content)
355
1133
  });
356
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
357
1134
  break;
358
1135
  }
359
1136
  // 删除商品
360
1137
  case 3: {
361
- this.eventEmitter.emit(ProductEvents.DeleteProduct, {
1138
+ if (_this.__currentPushingProductId === socketData.content.productId) {
1139
+ _this.__clearCurrentPushingProduct();
1140
+ }
1141
+ _this.eventEmitter.emit(ProductEvents.DeleteProduct, {
362
1142
  productId: socketData.content.productId
363
1143
  });
364
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
365
1144
  break;
366
1145
  }
367
1146
  // 添加商品
368
1147
  case 4: {
369
- this.eventEmitter.emit(ProductEvents.AddProduct, {
1148
+ _this.eventEmitter.emit(ProductEvents.AddProduct, {
370
1149
  productData: filterInternalData(socketData.content)
371
1150
  });
372
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
373
1151
  break;
374
1152
  }
375
1153
  // 修改商品,例如商品开价
376
1154
  case 5: {
377
- this.eventEmitter.emit(ProductEvents.ChangeProduct, {
1155
+ _this.eventEmitter.emit(ProductEvents.ChangeProduct, {
378
1156
  productData: filterInternalData(socketData.content)
379
1157
  });
380
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
381
1158
  break;
382
1159
  }
383
1160
  // 移动商品
384
1161
  case 6:
385
1162
  case 7: {
386
- const content = socketData.content;
387
- const targetProducts = [
388
- filterInternalData(content[0]),
389
- filterInternalData(content[1])
390
- ];
391
- this.eventEmitter.emit(ProductEvents.MoveProduct, {
1163
+ var content = socketData.content;
1164
+ var targetProducts = [filterInternalData(content[0]), filterInternalData(content[1])];
1165
+ _this.eventEmitter.emit(ProductEvents.MoveProduct, {
392
1166
  targetProducts
393
1167
  });
394
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
395
1168
  break;
396
1169
  }
397
1170
  // 修改排序
398
1171
  case 15: {
399
- this.eventEmitter.emit(ProductEvents.ChangeProductRank, {
1172
+ _this.eventEmitter.emit(ProductEvents.ChangeProductRank, {
400
1173
  productData: filterInternalData(socketData.content)
401
1174
  });
402
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
403
1175
  break;
404
1176
  }
405
1177
  // 推送商品
406
1178
  case 9: {
407
- const content = socketData.content;
408
- this.eventEmitter.emit(ProductEvents.PushProduct, {
409
- productData: filterInternalData(content),
410
- pushRule: content.productPushRule
1179
+ var _content = socketData.content;
1180
+ _this.__currentPushingProductId = _content.productId;
1181
+ _this.__currentPushingProductPushRule = _content.productPushRule;
1182
+ _this.__isPushingProduct = true;
1183
+ _this.eventEmitter.emit(ProductEvents.PushProduct, {
1184
+ productData: filterInternalData(_content),
1185
+ pushRule: _content.productPushRule
411
1186
  });
412
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
413
1187
  break;
414
1188
  }
415
1189
  // 商品列表开关
416
1190
  case 10: {
417
- const content = socketData.content;
418
- this.eventEmitter.emit(ProductEvents.ProductListEnabled, {
419
- enabled: content.enabled === "Y"
1191
+ var _content2 = socketData.content;
1192
+ _this.eventEmitter.emit(ProductEvents.ProductListEnabled, {
1193
+ enabled: _content2.enabled === "Y"
420
1194
  });
421
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
422
1195
  break;
423
1196
  }
424
1197
  // 取消推送
425
1198
  case 11: {
426
- this.eventEmitter.emit(ProductEvents.CancelPushProduct, {
1199
+ _this.__clearCurrentPushingProduct();
1200
+ _this.__isPushingProduct = true;
1201
+ _this.eventEmitter.emit(ProductEvents.CancelPushProduct, {
1202
+ productId: socketData.content.productId
1203
+ });
1204
+ break;
1205
+ }
1206
+ // 商品售罄
1207
+ case 12: {
1208
+ _this.eventEmitter.emit(ProductEvents.ProductSoldOut, {
427
1209
  productId: socketData.content.productId
428
1210
  });
429
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
430
1211
  break;
431
1212
  }
432
1213
  }
433
1214
  });
434
- __publicField(this, "__handleRefreshProductList", () => {
435
- this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
1215
+ _defineProperty$4(this, "__handleRefreshProductList", function() {
1216
+ _this.eventEmitter.emit(ProductEvents.RefreshProductList, {});
436
1217
  });
437
- __publicField(this, "__handleProductClickEvent", (socketData) => {
438
- this.eventEmitter.emit(ProductEvents.ProductClick, {
1218
+ _defineProperty$4(this, "__handleProductClickEvent", function(socketData) {
1219
+ _this.eventEmitter.emit(ProductEvents.ProductClick, {
439
1220
  productId: socketData.productId,
440
1221
  name: socketData.positionName,
441
1222
  productType: socketData.type
442
1223
  });
443
1224
  });
444
- __publicField(this, "__handleProductClickTimes", (socketData) => {
445
- this.eventEmitter.emit(ProductEvents.ProductClickTimes, {
1225
+ _defineProperty$4(this, "__handleProductClickTimes", function(socketData) {
1226
+ _this.eventEmitter.emit(ProductEvents.ProductClickTimes, {
446
1227
  productId: socketData.productId,
447
1228
  name: socketData.positionName,
448
1229
  productType: socketData.type,
@@ -460,241 +1241,440 @@ class Product {
460
1241
  PRODUCT_CLICK_TIMES: this.__handleProductClickTimes
461
1242
  }, "product");
462
1243
  }
463
- /**
464
- * 获取商品标签列表
465
- * @param params 获取参数
466
- * @example
467
- * ```js
468
- * const data = await productTarget.getProductTagList({ pageNumber: 1 });
469
- * console.log('标签列表', data.contents);
470
- * ```
471
- */
472
- async getProductTagList(params = {}) {
473
- const pageNumber = params.pageNumber ?? 1;
474
- const pageSize = params.pageSize ?? 10;
475
- return this.iarCore.polyvApi.get(
476
- PolyvApiUrl.GetProductTagList,
477
- {
478
- pageNumber,
479
- pageSize
480
- }
481
- );
482
- }
483
- /**
484
- * 获取商品列表
485
- *
486
- * 该方法可通过 **商品序号**、**标签 id + 关键词** 两种方式获取商品列表,
487
- * @param params 获取参数
488
- * @example
489
- * ```js
490
- * // 通过商品序号获取:获取 12 号商品之后的商品列表
491
- * const data = await productTarget.getProductList({ displayNumber: 12 });
492
- *
493
- * // 通过标签 id 或关键词获取:获取标签 id 为 8 的商品列表,并根据关键词 '水果' 进行搜索,页数为第 2 页
494
- * const data = await productTarget.getProductList({ tagId: 8, keyword: '水果', page: 2 });
495
- * ```
496
- */
497
- async getProductList(params = {}) {
498
- const { count = 10 } = params;
499
- let productList = [];
500
- let toppingProduct;
501
- let total = 0;
502
- if (params.keyword || params.tagId) {
503
- const { page = 1 } = params;
504
- const data = await this.iarCore.polyvApi.get(
505
- PolyvApiUrl.GetProductListByTag,
506
- {
507
- keyword: params.keyword,
508
- tagId: params.tagId,
509
- pageNumber: page,
510
- pageSize: count
511
- }
512
- );
513
- productList = data.contents;
514
- total = data.totalItems;
515
- } else {
516
- const data = await this.iarCore.polyvApi.get(
517
- PolyvApiUrl.GetProductListByShowId,
518
- {
519
- count,
520
- showId: params.displayNumber
521
- },
522
- {
523
- useAESDecrypt: true
524
- }
525
- );
526
- productList = data.content;
527
- toppingProduct = data.toppingProduct;
528
- total = data.total;
1244
+ return _createClass$3(Product2, [{
1245
+ key: "__clearCurrentPushingProduct",
1246
+ value: function __clearCurrentPushingProduct() {
1247
+ this.__currentPushingProductId = void 0;
1248
+ this.__currentPushingProductPushRule = void 0;
529
1249
  }
530
- return {
531
- contents: productList.map((data) => {
532
- return filterInternalData(data);
533
- }),
534
- toppingProduct: toppingProduct ? filterInternalData(toppingProduct) : void 0,
535
- total
536
- };
537
- }
538
- /**
539
- * 获取商品数据
540
- * @param productId 商品 id
541
- */
542
- async getProductData(productId) {
543
- var _a;
544
- const data = await this.iarCore.polyvApi.get(
545
- PolyvApiUrl.GetProductDataById,
546
- {
547
- productId
548
- },
549
- {
550
- useAESDecrypt: true
1250
+ /**
1251
+ * 获取商品标签列表
1252
+ * @param params 获取参数
1253
+ * @example
1254
+ * ```js
1255
+ * const data = await productTarget.getProductTagList({ pageNumber: 1 });
1256
+ * console.log('标签列表', data.contents);
1257
+ * ```
1258
+ */
1259
+ }, {
1260
+ key: "getProductTagList",
1261
+ value: function() {
1262
+ var _getProductTagList = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee() {
1263
+ var _params$pageNumber, _params$pageSize;
1264
+ var params, pageNumber, pageSize, _args = arguments;
1265
+ return _regenerator$3().w(function(_context) {
1266
+ while (1) switch (_context.n) {
1267
+ case 0:
1268
+ params = _args.length > 0 && _args[0] !== void 0 ? _args[0] : {};
1269
+ pageNumber = (_params$pageNumber = params.pageNumber) !== null && _params$pageNumber !== void 0 ? _params$pageNumber : 1;
1270
+ pageSize = (_params$pageSize = params.pageSize) !== null && _params$pageSize !== void 0 ? _params$pageSize : 10;
1271
+ return _context.a(2, this.iarCore.polyvApi.get(PolyvApiUrl.GetProductTagList, {
1272
+ pageNumber,
1273
+ pageSize
1274
+ }));
1275
+ }
1276
+ }, _callee, this);
1277
+ }));
1278
+ function getProductTagList() {
1279
+ return _getProductTagList.apply(this, arguments);
551
1280
  }
552
- );
553
- const productData = filterInternalData(data);
554
- if ((_a = productData.detail) == null ? void 0 : _a.endsWith(".json")) {
555
- const res = await this.iarCore.otherApi.get(productData.detail, {});
556
- productData.detail = res.productDetail;
557
- }
558
- return productData;
559
- }
560
- /**
561
- * 发送商品点击事件
562
- *
563
- * 当观众点击商品时,调用该方法发送商品点击事件
564
- * @param params 发送参数
565
- * @example
566
- * ```js
567
- * await productTarget.sendProductClickEvent({
568
- * productId: 123,
569
- * name: '商品名称',
570
- * productType: 'normal',
571
- * });
572
- * ```
573
- */
574
- async sendProductClickEvent(params) {
575
- const userInfo = await this.iarCore.getUserInfo();
576
- const channelInfo = await this.iarCore.getChannelInfo();
577
- this.iarCore.emitSocket({
578
- EVENT: "PRODUCT_CLICK",
579
- data: {
580
- productId: params.productId,
581
- type: params.productType,
582
- nickName: userInfo.nick,
583
- positionName: params.name
584
- },
585
- roomId: channelInfo.channelId
586
- }, "product");
587
- }
588
- /**
589
- * 关闭当前正在推送中的商品
590
- *
591
- * 当需要关闭 UI 层的推送节点时,调用该方法关闭当前正在推送中的商品
592
- * @example
593
- * ```js
594
- * await productTarget.closeProductPush();
595
- * ```
596
- */
597
- closeProductPush() {
598
- this.eventEmitter.emit(ProductEvents.CancelPushProduct, {});
599
- }
600
- /**
601
- * 获取商品讲解开关
602
- *
603
- * 获取当前频道是否开启商品讲解
604
- * @example
605
- * ```js
606
- * const enabled = await productTarget.getProductExplainEnabled();
607
- * console.log('商品讲解开关', enabled);
608
- * ```
609
- */
610
- async getProductExplainEnabled() {
611
- const channelConfig = await this.config.getProductConfig();
612
- return (channelConfig == null ? void 0 : channelConfig.productExplainEnabled) ?? false;
613
- }
614
- /**
615
- * 获取当前频道是否开启点击"外链购买"商品的封面/标题区域直接跳转外链
616
- * @example
617
- * ```js
618
- * const enabled = await productTarget.getOutLinkProductRedirectEnabled();
619
- * console.log('商品点击直接跳转外链开关', enabled);
620
- * ```
621
- */
622
- async getOutLinkProductRedirectEnabled() {
623
- const channelConfig = await this.config.getProductConfig();
624
- return (channelConfig == null ? void 0 : channelConfig.outLinkProductRedirectEnabled) ?? false;
625
- }
626
- /**
627
- * 生成商品讲解页面地址
628
- * @param params url 携带参数
629
- * @example
630
- * ```js
631
- * const url = await productTarget.generateProductExplainPageUrl({ productId: 123 });
632
- * console.log('商品讲解页面地址', url);
633
- * ```
634
- */
635
- async generateProductExplainPageUrl(params) {
636
- const domainInfo = this.iarCore.getDomainInfo();
637
- const channelInfo = await this.iarCore.getChannelInfo();
638
- const queryParams = {
639
- channelId: channelInfo.channelId,
640
- ...params || {}
641
- };
642
- return concat(`${domainInfo.watchPageDomain}/landing/product/explain`, queryParams);
643
- }
644
- /**
645
- * 获取商品支付订单是否开启
646
- * @example
647
- * ```js
648
- * const enabled = await productTarget.getProductPayOrderEnabled();
649
- * console.log('商品支付订单是否开启', enabled);
650
- * ```
651
- */
652
- async getProductPayOrderEnabled() {
653
- const channelConfig = await this.config.getProductConfig();
654
- if (!channelConfig) return false;
655
- return channelConfig.productPayOrderEnabled;
656
- }
657
- async getCurrentPushingProduct() {
658
- const channelConfig = await this.config.getProductConfig();
659
- if (!channelConfig) return;
660
- return channelConfig.channelProductPushingStatusVO;
661
- }
662
- /**
663
- * 判断当前用户是否支持直接购买商品
664
- * @example
665
- * ```js
666
- * const supported = await productTarget.getSupportToDirectBuy();
667
- * console.log('是否支持直接购买', supported);
668
- * ```
669
- */
670
- async getSupportToDirectBuy() {
671
- if (!await this.getProductPayOrderEnabled()) {
672
- return false;
673
- }
674
- const userInfo = await this.iarCore.getUserInfo();
675
- if (!userInfo.unionId) return false;
676
- const authType = userInfo.authType;
677
- if (!authType || authType === AuthType.None) {
678
- return true;
1281
+ return getProductTagList;
1282
+ }()
1283
+ }, {
1284
+ key: "getProductList",
1285
+ value: function() {
1286
+ var _getProductList = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee2() {
1287
+ var params, _params$count, count, productList, toppingProduct, total, _params$page, page, data, _data, _args2 = arguments;
1288
+ return _regenerator$3().w(function(_context2) {
1289
+ while (1) switch (_context2.n) {
1290
+ case 0:
1291
+ params = _args2.length > 0 && _args2[0] !== void 0 ? _args2[0] : {};
1292
+ _params$count = params.count, count = _params$count === void 0 ? 10 : _params$count;
1293
+ productList = [];
1294
+ total = 0;
1295
+ if (!(params.keyword || params.tagId)) {
1296
+ _context2.n = 2;
1297
+ break;
1298
+ }
1299
+ _params$page = params.page, page = _params$page === void 0 ? 1 : _params$page;
1300
+ _context2.n = 1;
1301
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetProductListByTag, {
1302
+ keyword: params.keyword,
1303
+ tagId: params.tagId,
1304
+ pageNumber: page,
1305
+ pageSize: count
1306
+ });
1307
+ case 1:
1308
+ data = _context2.v;
1309
+ productList = data.contents;
1310
+ total = data.totalItems;
1311
+ _context2.n = 4;
1312
+ break;
1313
+ case 2:
1314
+ _context2.n = 3;
1315
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetProductListByShowId, {
1316
+ count,
1317
+ showId: params.displayNumber
1318
+ }, {
1319
+ useAESDecrypt: true
1320
+ });
1321
+ case 3:
1322
+ _data = _context2.v;
1323
+ productList = _data.content;
1324
+ toppingProduct = _data.toppingProduct;
1325
+ total = _data.total;
1326
+ case 4:
1327
+ return _context2.a(2, {
1328
+ contents: productList.map(function(data2) {
1329
+ return filterInternalData(data2);
1330
+ }),
1331
+ toppingProduct: toppingProduct ? filterInternalData(toppingProduct) : void 0,
1332
+ total
1333
+ });
1334
+ }
1335
+ }, _callee2, this);
1336
+ }));
1337
+ function getProductList() {
1338
+ return _getProductList.apply(this, arguments);
1339
+ }
1340
+ return getProductList;
1341
+ }()
1342
+ }, {
1343
+ key: "getProductData",
1344
+ value: function() {
1345
+ var _getProductData = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee3(productId) {
1346
+ var _productData$detail;
1347
+ var data, productData, res;
1348
+ return _regenerator$3().w(function(_context3) {
1349
+ while (1) switch (_context3.n) {
1350
+ case 0:
1351
+ _context3.n = 1;
1352
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetProductDataById, {
1353
+ productId
1354
+ }, {
1355
+ useAESDecrypt: true
1356
+ });
1357
+ case 1:
1358
+ data = _context3.v;
1359
+ productData = filterInternalData(data);
1360
+ if (!((_productData$detail = productData.detail) !== null && _productData$detail !== void 0 && _productData$detail.endsWith(".json"))) {
1361
+ _context3.n = 3;
1362
+ break;
1363
+ }
1364
+ _context3.n = 2;
1365
+ return this.iarCore.otherApi.get(productData.detail, {});
1366
+ case 2:
1367
+ res = _context3.v;
1368
+ productData.detail = res.productDetail;
1369
+ case 3:
1370
+ return _context3.a(2, productData);
1371
+ }
1372
+ }, _callee3, this);
1373
+ }));
1374
+ function getProductData(_x) {
1375
+ return _getProductData.apply(this, arguments);
1376
+ }
1377
+ return getProductData;
1378
+ }()
1379
+ }, {
1380
+ key: "sendProductClickEvent",
1381
+ value: function() {
1382
+ var _sendProductClickEvent = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee4(params) {
1383
+ var userInfo, channelInfo, productConfig;
1384
+ return _regenerator$3().w(function(_context4) {
1385
+ while (1) switch (_context4.n) {
1386
+ case 0:
1387
+ _context4.n = 1;
1388
+ return this.iarCore.getUserInfo();
1389
+ case 1:
1390
+ userInfo = _context4.v;
1391
+ _context4.n = 2;
1392
+ return this.iarCore.getChannelInfo();
1393
+ case 2:
1394
+ channelInfo = _context4.v;
1395
+ _context4.n = 3;
1396
+ return this.config.getProductConfig();
1397
+ case 3:
1398
+ productConfig = _context4.v;
1399
+ if (!(!productConfig.productHotEffectEnabled && !productConfig.productLinkJumpTipEnabled)) {
1400
+ _context4.n = 4;
1401
+ break;
1402
+ }
1403
+ return _context4.a(2);
1404
+ case 4:
1405
+ this.iarCore.emitSocket({
1406
+ EVENT: "PRODUCT_CLICK",
1407
+ data: {
1408
+ productId: params.productId,
1409
+ type: params.productType,
1410
+ nickName: userInfo.nick,
1411
+ positionName: params.name
1412
+ },
1413
+ roomId: channelInfo.channelId
1414
+ }, "product");
1415
+ case 5:
1416
+ return _context4.a(2);
1417
+ }
1418
+ }, _callee4, this);
1419
+ }));
1420
+ function sendProductClickEvent(_x2) {
1421
+ return _sendProductClickEvent.apply(this, arguments);
1422
+ }
1423
+ return sendProductClickEvent;
1424
+ }()
1425
+ }, {
1426
+ key: "closeProductPush",
1427
+ value: function closeProductPush() {
1428
+ this.eventEmitter.emit(ProductEvents.CancelPushProduct, {});
679
1429
  }
680
- const notSupportAuthTypes = [
681
- AuthType.Custom,
682
- AuthType.External,
683
- AuthType.Direct,
684
- AuthType.EnterpriseWeChat
685
- ];
686
- if (notSupportAuthTypes.includes(authType)) {
687
- return false;
1430
+ /**
1431
+ * 获取商品讲解开关
1432
+ *
1433
+ * 获取当前频道是否开启商品讲解
1434
+ * @example
1435
+ * ```js
1436
+ * const enabled = await productTarget.getProductExplainEnabled();
1437
+ * console.log('商品讲解开关', enabled);
1438
+ * ```
1439
+ */
1440
+ }, {
1441
+ key: "getProductExplainEnabled",
1442
+ value: function() {
1443
+ var _getProductExplainEnabled = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee5() {
1444
+ var _productConfig$produc;
1445
+ var productConfig;
1446
+ return _regenerator$3().w(function(_context5) {
1447
+ while (1) switch (_context5.n) {
1448
+ case 0:
1449
+ _context5.n = 1;
1450
+ return this.config.getProductConfig();
1451
+ case 1:
1452
+ productConfig = _context5.v;
1453
+ return _context5.a(2, (_productConfig$produc = productConfig === null || productConfig === void 0 ? void 0 : productConfig.productExplainEnabled) !== null && _productConfig$produc !== void 0 ? _productConfig$produc : false);
1454
+ }
1455
+ }, _callee5, this);
1456
+ }));
1457
+ function getProductExplainEnabled() {
1458
+ return _getProductExplainEnabled.apply(this, arguments);
1459
+ }
1460
+ return getProductExplainEnabled;
1461
+ }()
1462
+ }, {
1463
+ key: "generateProductExplainPageUrl",
1464
+ value: function() {
1465
+ var _generateProductExplainPageUrl = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee6(params) {
1466
+ var domainInfo, channelInfo, queryParams;
1467
+ return _regenerator$3().w(function(_context6) {
1468
+ while (1) switch (_context6.n) {
1469
+ case 0:
1470
+ domainInfo = this.iarCore.getDomainInfo();
1471
+ _context6.n = 1;
1472
+ return this.iarCore.getChannelInfo();
1473
+ case 1:
1474
+ channelInfo = _context6.v;
1475
+ queryParams = _objectSpread$3({
1476
+ channelId: channelInfo.channelId
1477
+ }, params || {});
1478
+ return _context6.a(2, concat("".concat(domainInfo.watchPageDomain, "/landing/product/explain"), queryParams));
1479
+ }
1480
+ }, _callee6, this);
1481
+ }));
1482
+ function generateProductExplainPageUrl(_x3) {
1483
+ return _generateProductExplainPageUrl.apply(this, arguments);
1484
+ }
1485
+ return generateProductExplainPageUrl;
1486
+ }()
1487
+ }, {
1488
+ key: "getOutLinkProductRedirectEnabled",
1489
+ value: function() {
1490
+ var _getOutLinkProductRedirectEnabled = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee7() {
1491
+ var _productConfig$outLin;
1492
+ var productConfig;
1493
+ return _regenerator$3().w(function(_context7) {
1494
+ while (1) switch (_context7.n) {
1495
+ case 0:
1496
+ _context7.n = 1;
1497
+ return this.config.getProductConfig();
1498
+ case 1:
1499
+ productConfig = _context7.v;
1500
+ return _context7.a(2, (_productConfig$outLin = productConfig === null || productConfig === void 0 ? void 0 : productConfig.outLinkProductRedirectEnabled) !== null && _productConfig$outLin !== void 0 ? _productConfig$outLin : false);
1501
+ }
1502
+ }, _callee7, this);
1503
+ }));
1504
+ function getOutLinkProductRedirectEnabled() {
1505
+ return _getOutLinkProductRedirectEnabled.apply(this, arguments);
1506
+ }
1507
+ return getOutLinkProductRedirectEnabled;
1508
+ }()
1509
+ }, {
1510
+ key: "getProductPayOrderEnabled",
1511
+ value: function() {
1512
+ var _getProductPayOrderEnabled = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee8() {
1513
+ var productConfig;
1514
+ return _regenerator$3().w(function(_context8) {
1515
+ while (1) switch (_context8.n) {
1516
+ case 0:
1517
+ _context8.n = 1;
1518
+ return this.config.getProductConfig();
1519
+ case 1:
1520
+ productConfig = _context8.v;
1521
+ if (productConfig) {
1522
+ _context8.n = 2;
1523
+ break;
1524
+ }
1525
+ return _context8.a(2, false);
1526
+ case 2:
1527
+ return _context8.a(2, productConfig.productPayOrderEnabled);
1528
+ }
1529
+ }, _callee8, this);
1530
+ }));
1531
+ function getProductPayOrderEnabled() {
1532
+ return _getProductPayOrderEnabled.apply(this, arguments);
1533
+ }
1534
+ return getProductPayOrderEnabled;
1535
+ }()
1536
+ }, {
1537
+ key: "getProductHotSaleConfig",
1538
+ value: function() {
1539
+ var _getProductHotSaleConfig = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee9() {
1540
+ var _productConfig$produc2;
1541
+ var productConfig;
1542
+ return _regenerator$3().w(function(_context9) {
1543
+ while (1) switch (_context9.n) {
1544
+ case 0:
1545
+ _context9.n = 1;
1546
+ return this.config.getProductConfig();
1547
+ case 1:
1548
+ productConfig = _context9.v;
1549
+ if (productConfig) {
1550
+ _context9.n = 2;
1551
+ break;
1552
+ }
1553
+ return _context9.a(2);
1554
+ case 2:
1555
+ return _context9.a(2, {
1556
+ productHotEffectEnabled: (_productConfig$produc2 = productConfig.productHotEffectEnabled) !== null && _productConfig$produc2 !== void 0 ? _productConfig$produc2 : false,
1557
+ productHotEffectTips: productConfig.productHotEffectTips
1558
+ });
1559
+ }
1560
+ }, _callee9, this);
1561
+ }));
1562
+ function getProductHotSaleConfig() {
1563
+ return _getProductHotSaleConfig.apply(this, arguments);
1564
+ }
1565
+ return getProductHotSaleConfig;
1566
+ }()
1567
+ }, {
1568
+ key: "getCurrentPushingProductId",
1569
+ value: function getCurrentPushingProductId() {
1570
+ return this.__currentPushingProductId;
688
1571
  }
689
- return true;
690
- }
691
- }
692
- var PaymentProvider = /* @__PURE__ */ ((PaymentProvider2) => {
1572
+ /**
1573
+ * 获取当前推送中的商品数据
1574
+ * @example
1575
+ * ```js
1576
+ * const productData = await productTarget.getCurrentPushingProduct();
1577
+ * console.log('当前推送中的商品数据', productData);
1578
+ * ```
1579
+ */
1580
+ }, {
1581
+ key: "getCurrentPushingProduct",
1582
+ value: function() {
1583
+ var _getCurrentPushingProduct = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee0(productId) {
1584
+ var productConfig, pid, pushRule, _productConfig$channe, _productConfig$channe2, result;
1585
+ return _regenerator$3().w(function(_context0) {
1586
+ while (1) switch (_context0.n) {
1587
+ case 0:
1588
+ _context0.n = 1;
1589
+ return this.config.getProductConfig();
1590
+ case 1:
1591
+ productConfig = _context0.v;
1592
+ if (this.__isPushingProduct) {
1593
+ pid = this.__currentPushingProductId;
1594
+ pushRule = this.__currentPushingProductPushRule;
1595
+ } else {
1596
+ pid = productId !== null && productId !== void 0 ? productId : (_productConfig$channe = productConfig.channelProductPushingStatusVO) === null || _productConfig$channe === void 0 ? void 0 : _productConfig$channe.productId;
1597
+ pushRule = (_productConfig$channe2 = productConfig.channelProductPushingStatusVO) === null || _productConfig$channe2 === void 0 ? void 0 : _productConfig$channe2.pushRule;
1598
+ }
1599
+ if (pid) {
1600
+ _context0.n = 2;
1601
+ break;
1602
+ }
1603
+ return _context0.a(2);
1604
+ case 2:
1605
+ _context0.n = 3;
1606
+ return this.getProductData(pid);
1607
+ case 3:
1608
+ result = _context0.v;
1609
+ return _context0.a(2, _objectSpread$3(_objectSpread$3({}, result), {}, {
1610
+ pushRule
1611
+ }));
1612
+ }
1613
+ }, _callee0, this);
1614
+ }));
1615
+ function getCurrentPushingProduct(_x4) {
1616
+ return _getCurrentPushingProduct.apply(this, arguments);
1617
+ }
1618
+ return getCurrentPushingProduct;
1619
+ }()
1620
+ }, {
1621
+ key: "getSupportToDirectBuy",
1622
+ value: function() {
1623
+ var _getSupportToDirectBuy = _asyncToGenerator$3(/* @__PURE__ */ _regenerator$3().m(function _callee1() {
1624
+ var userInfo, authType, notSupportAuthTypes;
1625
+ return _regenerator$3().w(function(_context1) {
1626
+ while (1) switch (_context1.n) {
1627
+ case 0:
1628
+ _context1.n = 1;
1629
+ return this.getProductPayOrderEnabled();
1630
+ case 1:
1631
+ if (_context1.v) {
1632
+ _context1.n = 2;
1633
+ break;
1634
+ }
1635
+ return _context1.a(2, false);
1636
+ case 2:
1637
+ _context1.n = 3;
1638
+ return this.iarCore.getUserInfo();
1639
+ case 3:
1640
+ userInfo = _context1.v;
1641
+ if (userInfo.unionId) {
1642
+ _context1.n = 4;
1643
+ break;
1644
+ }
1645
+ return _context1.a(2, false);
1646
+ case 4:
1647
+ authType = userInfo.authType;
1648
+ if (!(!authType || authType === AuthType.None)) {
1649
+ _context1.n = 5;
1650
+ break;
1651
+ }
1652
+ return _context1.a(2, true);
1653
+ case 5:
1654
+ notSupportAuthTypes = [AuthType.Custom, AuthType.External, AuthType.Direct, AuthType.EnterpriseWeChat];
1655
+ if (!notSupportAuthTypes.includes(authType)) {
1656
+ _context1.n = 6;
1657
+ break;
1658
+ }
1659
+ return _context1.a(2, false);
1660
+ case 6:
1661
+ return _context1.a(2, true);
1662
+ }
1663
+ }, _callee1, this);
1664
+ }));
1665
+ function getSupportToDirectBuy() {
1666
+ return _getSupportToDirectBuy.apply(this, arguments);
1667
+ }
1668
+ return getSupportToDirectBuy;
1669
+ }()
1670
+ }]);
1671
+ }();
1672
+ var PaymentProvider = /* @__PURE__ */ function(PaymentProvider2) {
693
1673
  PaymentProvider2["Wechat"] = "WECHAT";
694
1674
  PaymentProvider2["Alipay"] = "ALIPAY";
695
1675
  return PaymentProvider2;
696
- })(PaymentProvider || {});
697
- var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
1676
+ }({});
1677
+ var OrderStatus = /* @__PURE__ */ function(OrderStatus2) {
698
1678
  OrderStatus2["WaitPay"] = "wait_pay";
699
1679
  OrderStatus2["WaitDelivery"] = "wait_delivery";
700
1680
  OrderStatus2["Delivering"] = "delivering";
@@ -703,27 +1683,73 @@ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
703
1683
  OrderStatus2["Refunding"] = "refunding";
704
1684
  OrderStatus2["Refunded"] = "refunded";
705
1685
  return OrderStatus2;
706
- })(OrderStatus || {});
707
- var PayStatus = /* @__PURE__ */ ((PayStatus2) => {
1686
+ }({});
1687
+ var PayStatus = /* @__PURE__ */ function(PayStatus2) {
708
1688
  PayStatus2["WaitPay"] = "wait_pay";
709
1689
  PayStatus2["Payed"] = "payed";
710
1690
  PayStatus2["Free"] = "free";
711
1691
  return PayStatus2;
712
- })(PayStatus || {});
713
- var RefundStatus = /* @__PURE__ */ ((RefundStatus2) => {
1692
+ }({});
1693
+ var RefundStatus = /* @__PURE__ */ function(RefundStatus2) {
714
1694
  RefundStatus2["Success"] = "SUCCESS";
715
1695
  RefundStatus2["Fail"] = "FAIL";
716
1696
  RefundStatus2["Processing"] = "PROCESSING";
717
1697
  return RefundStatus2;
718
- })(RefundStatus || {});
719
- var CreateOrderFailReason = /* @__PURE__ */ ((CreateOrderFailReason2) => {
1698
+ }({});
1699
+ var CreateOrderFailReason = /* @__PURE__ */ function(CreateOrderFailReason2) {
720
1700
  CreateOrderFailReason2["Unknown"] = "unknown";
721
1701
  return CreateOrderFailReason2;
722
- })(CreateOrderFailReason || {});
723
- var OrderRefundFailReason = /* @__PURE__ */ ((OrderRefundFailReason2) => {
1702
+ }({});
1703
+ var OrderRefundFailReason = /* @__PURE__ */ function(OrderRefundFailReason2) {
724
1704
  OrderRefundFailReason2["Unknown"] = "unknown";
725
1705
  return OrderRefundFailReason2;
726
- })(OrderRefundFailReason || {});
1706
+ }({});
1707
+ function _typeof$3(o) {
1708
+ "@babel/helpers - typeof";
1709
+ return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
1710
+ return typeof o2;
1711
+ } : function(o2) {
1712
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
1713
+ }, _typeof$3(o);
1714
+ }
1715
+ function ownKeys$2(e, r) {
1716
+ var t = Object.keys(e);
1717
+ if (Object.getOwnPropertySymbols) {
1718
+ var o = Object.getOwnPropertySymbols(e);
1719
+ r && (o = o.filter(function(r2) {
1720
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
1721
+ })), t.push.apply(t, o);
1722
+ }
1723
+ return t;
1724
+ }
1725
+ function _objectSpread$2(e) {
1726
+ for (var r = 1; r < arguments.length; r++) {
1727
+ var t = null != arguments[r] ? arguments[r] : {};
1728
+ r % 2 ? ownKeys$2(Object(t), true).forEach(function(r2) {
1729
+ _defineProperty$3(e, r2, t[r2]);
1730
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function(r2) {
1731
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
1732
+ });
1733
+ }
1734
+ return e;
1735
+ }
1736
+ function _defineProperty$3(e, r, t) {
1737
+ return (r = _toPropertyKey$3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
1738
+ }
1739
+ function _toPropertyKey$3(t) {
1740
+ var i = _toPrimitive$3(t, "string");
1741
+ return "symbol" == _typeof$3(i) ? i : i + "";
1742
+ }
1743
+ function _toPrimitive$3(t, r) {
1744
+ if ("object" != _typeof$3(t) || !t) return t;
1745
+ var e = t[Symbol.toPrimitive];
1746
+ if (void 0 !== e) {
1747
+ var i = e.call(t, r);
1748
+ if ("object" != _typeof$3(i)) return i;
1749
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1750
+ }
1751
+ return ("string" === r ? String : Number)(t);
1752
+ }
727
1753
  function mapInternalProductToOrderProduct(internalProduct) {
728
1754
  return {
729
1755
  customerServiceContact: internalProduct.customerServiceContact,
@@ -757,7 +1783,7 @@ function mapInternalAddressToExpressInfo(internalAddress) {
757
1783
  };
758
1784
  }
759
1785
  function mapInternalOrderToOrderData(internalOrder) {
760
- const basicDataForList = {
1786
+ var basicDataForList = {
761
1787
  amount: internalOrder.amount,
762
1788
  channelId: internalOrder.channelId,
763
1789
  products: internalOrder.products.map(mapInternalProductToOrderProduct),
@@ -766,27 +1792,24 @@ function mapInternalOrderToOrderData(internalOrder) {
766
1792
  };
767
1793
  switch (internalOrder.status) {
768
1794
  case OrderStatus.WaitPay:
769
- return {
770
- ...basicDataForList,
1795
+ return _objectSpread$2(_objectSpread$2({}, basicDataForList), {}, {
771
1796
  status: OrderStatus.WaitPay,
772
1797
  expiredAt: internalOrder.expireTime
773
- };
1798
+ });
774
1799
  case OrderStatus.Close:
775
- return {
776
- ...basicDataForList,
1800
+ return _objectSpread$2(_objectSpread$2({}, basicDataForList), {}, {
777
1801
  status: OrderStatus.Close,
778
1802
  expiredAt: internalOrder.expireTime
779
- };
1803
+ });
780
1804
  default:
781
- return {
782
- ...basicDataForList,
1805
+ return _objectSpread$2(_objectSpread$2({}, basicDataForList), {}, {
783
1806
  status: internalOrder.status
784
- };
1807
+ });
785
1808
  }
786
1809
  }
787
1810
  function mapInternalOrderDetailToOrderData(detail) {
788
- const expressInfo = mapInternalAddressToExpressInfo(detail.addressExt);
789
- const basicData = {
1811
+ var expressInfo = mapInternalAddressToExpressInfo(detail.addressExt);
1812
+ var basicData = {
790
1813
  amount: detail.amount,
791
1814
  channelId: null,
792
1815
  products: detail.products.map(mapInternalProductToOrderProduct),
@@ -798,61 +1821,53 @@ function mapInternalOrderDetailToOrderData(detail) {
798
1821
  };
799
1822
  switch (detail.status) {
800
1823
  case OrderStatus.WaitPay:
801
- return {
802
- ...basicData,
1824
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
803
1825
  status: OrderStatus.WaitPay,
804
1826
  expiredAt: detail.expireTime
805
- };
1827
+ });
806
1828
  case OrderStatus.WaitDelivery:
807
- return {
808
- ...basicData,
1829
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
809
1830
  status: OrderStatus.WaitDelivery,
810
1831
  payAt: detail.payTime
811
- };
1832
+ });
812
1833
  case OrderStatus.Delivering:
813
- return {
814
- ...basicData,
1834
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
815
1835
  status: OrderStatus.Delivering,
816
1836
  payAt: detail.payTime,
817
1837
  deliveryAt: detail.deliveryTime
818
- };
1838
+ });
819
1839
  case OrderStatus.Finish:
820
- return {
821
- ...basicData,
1840
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
822
1841
  status: OrderStatus.Finish,
823
1842
  payAt: detail.payTime,
824
1843
  deliveryAt: detail.deliveryTime,
825
1844
  finishAt: detail.finishTime
826
- };
1845
+ });
827
1846
  case OrderStatus.Close:
828
- return {
829
- ...basicData,
1847
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
830
1848
  status: OrderStatus.Close,
831
1849
  expiredAt: detail.expireTime
832
- };
1850
+ });
833
1851
  case OrderStatus.Refunding:
834
- return {
835
- ...basicData,
1852
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
836
1853
  status: OrderStatus.Refunding,
837
1854
  payAt: detail.payTime,
838
1855
  refundAt: detail.refundTime,
839
1856
  deliveryAt: detail.deliveryTime
840
- };
1857
+ });
841
1858
  case OrderStatus.Refunded:
842
- return {
843
- ...basicData,
1859
+ return _objectSpread$2(_objectSpread$2({}, basicData), {}, {
844
1860
  status: OrderStatus.Refunded,
845
1861
  payAt: detail.payTime,
846
1862
  refundAt: detail.refundTime,
847
1863
  deliveryAt: detail.deliveryTime,
848
1864
  expiredAt: detail.expireTime
849
- };
1865
+ });
850
1866
  default: {
851
- console.error(`Unknown order status:${detail.status}`);
852
- const fallback = {
853
- ...basicData,
1867
+ console.error("Unknown order status:".concat(detail.status));
1868
+ var fallback = _objectSpread$2(_objectSpread$2({}, basicData), {}, {
854
1869
  status: detail.status
855
- };
1870
+ });
856
1871
  return fallback;
857
1872
  }
858
1873
  }
@@ -865,144 +1880,333 @@ function mapInternalCreateOrderResponse(data) {
865
1880
  payStatus: data.payStatus,
866
1881
  wxAppId: data.appId,
867
1882
  nonceStr: data.nonceStr,
868
- package: data.prepayId,
1883
+ "package": data.prepayId,
869
1884
  paySign: data.paySign,
870
1885
  signType: data.signType,
871
1886
  timeStamp: Number(data.timeStamp),
872
1887
  payProvider: data.payProvider
873
1888
  };
874
1889
  }
875
- class Order {
876
- constructor(iarCore, config) {
877
- __publicField(this, "OrderStatus", OrderStatus);
878
- __publicField(this, "PayStatus", PayStatus);
879
- __publicField(this, "PaymentProvider", PaymentProvider);
880
- __publicField(this, "ProductBuyType", ProductBuyType);
881
- __publicField(this, "ProductType", ProductType);
882
- __publicField(this, "ProductDeliveryType", ProductDeliveryType);
883
- __publicField(this, "RefundStatus", RefundStatus);
884
- __publicField(this, "CreateOrderFailReason", CreateOrderFailReason);
885
- __publicField(this, "OrderRefundFailReason", OrderRefundFailReason);
886
- this.iarCore = iarCore;
887
- this.config = config;
1890
+ function _typeof$2(o) {
1891
+ "@babel/helpers - typeof";
1892
+ return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
1893
+ return typeof o2;
1894
+ } : function(o2) {
1895
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
1896
+ }, _typeof$2(o);
1897
+ }
1898
+ function ownKeys$1(e, r) {
1899
+ var t = Object.keys(e);
1900
+ if (Object.getOwnPropertySymbols) {
1901
+ var o = Object.getOwnPropertySymbols(e);
1902
+ r && (o = o.filter(function(r2) {
1903
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
1904
+ })), t.push.apply(t, o);
888
1905
  }
889
- /**
890
- * 获取订单列表
891
- * @param params 获取参数
892
- * @example
893
- * ```js
894
- * const data = await orderTarget.getOrderList({ pageNumber: 1, pageSize: 10 });
895
- * console.log('订单列表', data.contents);
896
- * ```
897
- */
898
- async getOrderList(params = {}) {
899
- const { pageNumber = 1, pageSize = 10, orderStatus } = params;
900
- const res = await this.iarCore.polyvApi.get(
901
- PolyvApiUrl.GetOrderList,
902
- {
903
- pageNumber,
904
- pageSize,
905
- orderStatus
906
- }
907
- );
908
- return {
909
- pageNumber: res.pageNumber,
910
- pageSize: res.pageSize,
911
- totalItems: res.totalItems,
912
- totalPages: res.totalPages,
913
- contents: res.contents.map(mapInternalOrderToOrderData)
914
- };
1906
+ return t;
1907
+ }
1908
+ function _objectSpread$1(e) {
1909
+ for (var r = 1; r < arguments.length; r++) {
1910
+ var t = null != arguments[r] ? arguments[r] : {};
1911
+ r % 2 ? ownKeys$1(Object(t), true).forEach(function(r2) {
1912
+ _defineProperty$2(e, r2, t[r2]);
1913
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r2) {
1914
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
1915
+ });
915
1916
  }
916
- /**
917
- * 获取订单详情
918
- * @param params 获取参数
919
- * @example
920
- * ```js
921
- * const data = await orderTarget.getOrderDetail({ orderNo: '1234567890' });
922
- * console.log('订单详情', data);
923
- * ```
924
- */
925
- async getOrderDetail(params) {
926
- const internalDetail = await this.iarCore.polyvApi.get(
927
- PolyvApiUrl.GetOrderDetail,
928
- {
929
- orderNo: params.orderNo,
930
- syncPayStatus: boolToYN(params.syncPayStatus)
1917
+ return e;
1918
+ }
1919
+ function _regenerator$2() {
1920
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
1921
+ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag";
1922
+ function i(r2, n2, o2, i2) {
1923
+ var c2 = n2 && n2.prototype instanceof Generator ? n2 : Generator, u2 = Object.create(c2.prototype);
1924
+ return _regeneratorDefine2$2(u2, "_invoke", function(r3, n3, o3) {
1925
+ var i3, c3, u3, f2 = 0, p = o3 || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d2(t2, r4) {
1926
+ return i3 = t2, c3 = 0, u3 = e, G.n = r4, a;
1927
+ } };
1928
+ function d(r4, n4) {
1929
+ for (c3 = r4, u3 = n4, t = 0; !y && f2 && !o4 && t < p.length; t++) {
1930
+ var o4, i4 = p[t], d2 = G.p, l = i4[2];
1931
+ r4 > 3 ? (o4 = l === n4) && (u3 = i4[(c3 = i4[4]) ? 5 : (c3 = 3, 3)], i4[4] = i4[5] = e) : i4[0] <= d2 && ((o4 = r4 < 2 && d2 < i4[1]) ? (c3 = 0, G.v = n4, G.n = i4[1]) : d2 < l && (o4 = r4 < 3 || i4[0] > n4 || n4 > l) && (i4[4] = r4, i4[5] = n4, G.n = l, c3 = 0));
1932
+ }
1933
+ if (o4 || r4 > 1) return a;
1934
+ throw y = true, n4;
931
1935
  }
932
- );
933
- return mapInternalOrderDetailToOrderData(internalDetail);
934
- }
935
- /**
936
- * 创建订单
937
- * @param params 创建订单参数
938
- * @example
939
- * ```js
940
- * const res = await orderTarget.createOrder({ address: { name: '张三', mobile: '13800138000', area: '广东省 广州市 天河区', address: '天河路1号' }, products: [{ productId: 1, quantity: 1 }], payProvider: PaymentProvider.Wechat });
941
- * if (res.success) {
942
- * console.log('创建订单成功', res.orderNo);
943
- * } else {
944
- * console.log('创建订单失败', res.failReason, res.failMessage);
945
- * }
946
- * ```
947
- */
948
- async createOrder(params) {
949
- try {
950
- const res = await this.iarCore.polyvApi.post(
951
- PolyvApiUrl.CreateOrder,
952
- params
953
- );
954
- return {
955
- success: true,
956
- ...mapInternalCreateOrderResponse(res)
957
- };
958
- } catch (err) {
959
- return {
960
- success: false,
961
- failReason: CreateOrderFailReason.Unknown,
962
- failMessage: err instanceof Error ? err.message : void 0
1936
+ return function(o4, p2, l) {
1937
+ if (f2 > 1) throw TypeError("Generator is already running");
1938
+ for (y && 1 === p2 && d(p2, l), c3 = p2, u3 = l; (t = c3 < 2 ? e : u3) || !y; ) {
1939
+ i3 || (c3 ? c3 < 3 ? (c3 > 1 && (G.n = -1), d(c3, u3)) : G.n = u3 : G.v = u3);
1940
+ try {
1941
+ if (f2 = 2, i3) {
1942
+ if (c3 || (o4 = "next"), t = i3[o4]) {
1943
+ if (!(t = t.call(i3, u3))) throw TypeError("iterator result is not an object");
1944
+ if (!t.done) return t;
1945
+ u3 = t.value, c3 < 2 && (c3 = 0);
1946
+ } else 1 === c3 && (t = i3["return"]) && t.call(i3), c3 < 2 && (u3 = TypeError("The iterator does not provide a '" + o4 + "' method"), c3 = 1);
1947
+ i3 = e;
1948
+ } else if ((t = (y = G.n < 0) ? u3 : r3.call(n3, G)) !== a) break;
1949
+ } catch (t2) {
1950
+ i3 = e, c3 = 1, u3 = t2;
1951
+ } finally {
1952
+ f2 = 1;
1953
+ }
1954
+ }
1955
+ return { value: t, done: y };
963
1956
  };
964
- }
1957
+ }(r2, o2, i2), true), u2;
965
1958
  }
966
- /**
967
- * 确认收货
968
- * @param orderNo 订单号
969
- * @example
970
- * ```js
971
- * await orderTarget.confirmOrder('1234567890');
972
- * ```
973
- */
974
- async confirmOrder(orderNo) {
975
- return this.iarCore.polyvApi.post(concat(PolyvApiUrl.ConfirmOrder, { orderNo }), {});
976
- }
977
- /**
978
- * 申请退款
979
- * @param orderNo 订单号
980
- * @example
981
- * ```js
982
- * const res = await orderTarget.applyOrderRefund('1234567890');
983
- * if (res.success) {
984
- * console.log('退款成功', res);
985
- * } else {
986
- * console.log('退款失败', res.failReason, res.failMessage);
987
- * }
988
- * ```
989
- */
990
- async applyOrderRefund(orderNo) {
991
- try {
992
- const res = await this.iarCore.polyvApi.post(PolyvApiUrl.ApplyOrderRefund, { orderNo });
993
- return {
994
- success: true,
995
- ...res
996
- };
997
- } catch (err) {
998
- return {
999
- success: false,
1000
- failReason: OrderRefundFailReason.Unknown,
1001
- failMessage: err instanceof Error ? err.message : void 0
1959
+ var a = {};
1960
+ function Generator() {
1961
+ }
1962
+ function GeneratorFunction() {
1963
+ }
1964
+ function GeneratorFunctionPrototype() {
1965
+ }
1966
+ t = Object.getPrototypeOf;
1967
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2$2(t = {}, n, function() {
1968
+ return this;
1969
+ }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
1970
+ function f(e2) {
1971
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e2, GeneratorFunctionPrototype) : (e2.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2$2(e2, o, "GeneratorFunction")), e2.prototype = Object.create(u), e2;
1972
+ }
1973
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2$2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2$2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2$2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2$2(u), _regeneratorDefine2$2(u, o, "Generator"), _regeneratorDefine2$2(u, n, function() {
1974
+ return this;
1975
+ }), _regeneratorDefine2$2(u, "toString", function() {
1976
+ return "[object Generator]";
1977
+ }), (_regenerator$2 = function _regenerator2() {
1978
+ return { w: i, m: f };
1979
+ })();
1980
+ }
1981
+ function _regeneratorDefine2$2(e, r, n, t) {
1982
+ var i = Object.defineProperty;
1983
+ try {
1984
+ i({}, "", {});
1985
+ } catch (e2) {
1986
+ i = 0;
1987
+ }
1988
+ _regeneratorDefine2$2 = function _regeneratorDefine(e2, r2, n2, t2) {
1989
+ if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
1990
+ else {
1991
+ var o = function o2(r3, n3) {
1992
+ _regeneratorDefine2$2(e2, r3, function(e3) {
1993
+ return this._invoke(r3, n3, e3);
1994
+ });
1002
1995
  };
1996
+ o("next", 0), o("throw", 1), o("return", 2);
1003
1997
  }
1998
+ }, _regeneratorDefine2$2(e, r, n, t);
1999
+ }
2000
+ function asyncGeneratorStep$2(n, t, e, r, o, a, c) {
2001
+ try {
2002
+ var i = n[a](c), u = i.value;
2003
+ } catch (n2) {
2004
+ return void e(n2);
2005
+ }
2006
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
2007
+ }
2008
+ function _asyncToGenerator$2(n) {
2009
+ return function() {
2010
+ var t = this, e = arguments;
2011
+ return new Promise(function(r, o) {
2012
+ var a = n.apply(t, e);
2013
+ function _next(n2) {
2014
+ asyncGeneratorStep$2(a, r, o, _next, _throw, "next", n2);
2015
+ }
2016
+ function _throw(n2) {
2017
+ asyncGeneratorStep$2(a, r, o, _next, _throw, "throw", n2);
2018
+ }
2019
+ _next(void 0);
2020
+ });
2021
+ };
2022
+ }
2023
+ function _classCallCheck$2(a, n) {
2024
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
2025
+ }
2026
+ function _defineProperties$2(e, r) {
2027
+ for (var t = 0; t < r.length; t++) {
2028
+ var o = r[t];
2029
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$2(o.key), o);
2030
+ }
2031
+ }
2032
+ function _createClass$2(e, r, t) {
2033
+ return r && _defineProperties$2(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
2034
+ }
2035
+ function _defineProperty$2(e, r, t) {
2036
+ return (r = _toPropertyKey$2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
2037
+ }
2038
+ function _toPropertyKey$2(t) {
2039
+ var i = _toPrimitive$2(t, "string");
2040
+ return "symbol" == _typeof$2(i) ? i : i + "";
2041
+ }
2042
+ function _toPrimitive$2(t, r) {
2043
+ if ("object" != _typeof$2(t) || !t) return t;
2044
+ var e = t[Symbol.toPrimitive];
2045
+ if (void 0 !== e) {
2046
+ var i = e.call(t, r);
2047
+ if ("object" != _typeof$2(i)) return i;
2048
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1004
2049
  }
2050
+ return String(t);
1005
2051
  }
2052
+ var Order = /* @__PURE__ */ function() {
2053
+ function Order2(iarCore, config) {
2054
+ _classCallCheck$2(this, Order2);
2055
+ _defineProperty$2(this, "OrderStatus", OrderStatus);
2056
+ _defineProperty$2(this, "PayStatus", PayStatus);
2057
+ _defineProperty$2(this, "PaymentProvider", PaymentProvider);
2058
+ _defineProperty$2(this, "ProductBuyType", ProductBuyType);
2059
+ _defineProperty$2(this, "ProductType", ProductType);
2060
+ _defineProperty$2(this, "ProductDeliveryType", ProductDeliveryType);
2061
+ _defineProperty$2(this, "RefundStatus", RefundStatus);
2062
+ _defineProperty$2(this, "CreateOrderFailReason", CreateOrderFailReason);
2063
+ _defineProperty$2(this, "OrderRefundFailReason", OrderRefundFailReason);
2064
+ this.iarCore = iarCore;
2065
+ this.config = config;
2066
+ }
2067
+ return _createClass$2(Order2, [{
2068
+ key: "getOrderList",
2069
+ value: function() {
2070
+ var _getOrderList = _asyncToGenerator$2(/* @__PURE__ */ _regenerator$2().m(function _callee() {
2071
+ var params, _params$pageNumber, pageNumber, _params$pageSize, pageSize, orderStatus, res, _args = arguments;
2072
+ return _regenerator$2().w(function(_context) {
2073
+ while (1) switch (_context.n) {
2074
+ case 0:
2075
+ params = _args.length > 0 && _args[0] !== void 0 ? _args[0] : {};
2076
+ _params$pageNumber = params.pageNumber, pageNumber = _params$pageNumber === void 0 ? 1 : _params$pageNumber, _params$pageSize = params.pageSize, pageSize = _params$pageSize === void 0 ? 10 : _params$pageSize, orderStatus = params.orderStatus;
2077
+ _context.n = 1;
2078
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetOrderList, {
2079
+ pageNumber,
2080
+ pageSize,
2081
+ orderStatus
2082
+ });
2083
+ case 1:
2084
+ res = _context.v;
2085
+ return _context.a(2, {
2086
+ pageNumber: res.pageNumber,
2087
+ pageSize: res.pageSize,
2088
+ totalItems: res.totalItems,
2089
+ totalPages: res.totalPages,
2090
+ contents: res.contents.map(mapInternalOrderToOrderData)
2091
+ });
2092
+ }
2093
+ }, _callee, this);
2094
+ }));
2095
+ function getOrderList() {
2096
+ return _getOrderList.apply(this, arguments);
2097
+ }
2098
+ return getOrderList;
2099
+ }()
2100
+ }, {
2101
+ key: "getOrderDetail",
2102
+ value: function() {
2103
+ var _getOrderDetail = _asyncToGenerator$2(/* @__PURE__ */ _regenerator$2().m(function _callee2(params) {
2104
+ var internalDetail;
2105
+ return _regenerator$2().w(function(_context2) {
2106
+ while (1) switch (_context2.n) {
2107
+ case 0:
2108
+ _context2.n = 1;
2109
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetOrderDetail, {
2110
+ orderNo: params.orderNo,
2111
+ syncPayStatus: boolToYN(params.syncPayStatus)
2112
+ });
2113
+ case 1:
2114
+ internalDetail = _context2.v;
2115
+ return _context2.a(2, mapInternalOrderDetailToOrderData(internalDetail));
2116
+ }
2117
+ }, _callee2, this);
2118
+ }));
2119
+ function getOrderDetail(_x) {
2120
+ return _getOrderDetail.apply(this, arguments);
2121
+ }
2122
+ return getOrderDetail;
2123
+ }()
2124
+ }, {
2125
+ key: "createOrder",
2126
+ value: function() {
2127
+ var _createOrder = _asyncToGenerator$2(/* @__PURE__ */ _regenerator$2().m(function _callee3(params) {
2128
+ var res, _t;
2129
+ return _regenerator$2().w(function(_context3) {
2130
+ while (1) switch (_context3.n) {
2131
+ case 0:
2132
+ _context3.p = 0;
2133
+ _context3.n = 1;
2134
+ return this.iarCore.polyvApi.post(PolyvApiUrl.CreateOrder, params);
2135
+ case 1:
2136
+ res = _context3.v;
2137
+ return _context3.a(2, _objectSpread$1({
2138
+ success: true
2139
+ }, mapInternalCreateOrderResponse(res)));
2140
+ case 2:
2141
+ _context3.p = 2;
2142
+ _t = _context3.v;
2143
+ return _context3.a(2, {
2144
+ success: false,
2145
+ failReason: CreateOrderFailReason.Unknown,
2146
+ failMessage: _t instanceof Error ? _t.message : void 0
2147
+ });
2148
+ }
2149
+ }, _callee3, this, [[0, 2]]);
2150
+ }));
2151
+ function createOrder(_x2) {
2152
+ return _createOrder.apply(this, arguments);
2153
+ }
2154
+ return createOrder;
2155
+ }()
2156
+ }, {
2157
+ key: "confirmOrder",
2158
+ value: function() {
2159
+ var _confirmOrder = _asyncToGenerator$2(/* @__PURE__ */ _regenerator$2().m(function _callee4(orderNo) {
2160
+ return _regenerator$2().w(function(_context4) {
2161
+ while (1) switch (_context4.n) {
2162
+ case 0:
2163
+ return _context4.a(2, this.iarCore.polyvApi.post(concat(PolyvApiUrl.ConfirmOrder, {
2164
+ orderNo
2165
+ }), {}));
2166
+ }
2167
+ }, _callee4, this);
2168
+ }));
2169
+ function confirmOrder(_x3) {
2170
+ return _confirmOrder.apply(this, arguments);
2171
+ }
2172
+ return confirmOrder;
2173
+ }()
2174
+ }, {
2175
+ key: "applyOrderRefund",
2176
+ value: function() {
2177
+ var _applyOrderRefund = _asyncToGenerator$2(/* @__PURE__ */ _regenerator$2().m(function _callee5(orderNo) {
2178
+ var res, _t2;
2179
+ return _regenerator$2().w(function(_context5) {
2180
+ while (1) switch (_context5.n) {
2181
+ case 0:
2182
+ _context5.p = 0;
2183
+ _context5.n = 1;
2184
+ return this.iarCore.polyvApi.post(PolyvApiUrl.ApplyOrderRefund, {
2185
+ orderNo
2186
+ });
2187
+ case 1:
2188
+ res = _context5.v;
2189
+ return _context5.a(2, _objectSpread$1({
2190
+ success: true
2191
+ }, res));
2192
+ case 2:
2193
+ _context5.p = 2;
2194
+ _t2 = _context5.v;
2195
+ return _context5.a(2, {
2196
+ success: false,
2197
+ failReason: OrderRefundFailReason.Unknown,
2198
+ failMessage: _t2 instanceof Error ? _t2.message : void 0
2199
+ });
2200
+ }
2201
+ }, _callee5, this, [[0, 2]]);
2202
+ }));
2203
+ function applyOrderRefund(_x4) {
2204
+ return _applyOrderRefund.apply(this, arguments);
2205
+ }
2206
+ return applyOrderRefund;
2207
+ }()
2208
+ }]);
2209
+ }();
1006
2210
  function mapInternalAddressToAddressData(data) {
1007
2211
  if (!data) {
1008
2212
  return {
@@ -1021,160 +2225,505 @@ function mapInternalAddressToAddressData(data) {
1021
2225
  name: data.name
1022
2226
  };
1023
2227
  }
1024
- class Address {
1025
- constructor(iarCore, config) {
1026
- this.iarCore = iarCore;
1027
- this.config = config;
2228
+ function _typeof$1(o) {
2229
+ "@babel/helpers - typeof";
2230
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
2231
+ return typeof o2;
2232
+ } : function(o2) {
2233
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
2234
+ }, _typeof$1(o);
2235
+ }
2236
+ function _regenerator$1() {
2237
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
2238
+ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag";
2239
+ function i(r2, n2, o2, i2) {
2240
+ var c2 = n2 && n2.prototype instanceof Generator ? n2 : Generator, u2 = Object.create(c2.prototype);
2241
+ return _regeneratorDefine2$1(u2, "_invoke", function(r3, n3, o3) {
2242
+ var i3, c3, u3, f2 = 0, p = o3 || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d2(t2, r4) {
2243
+ return i3 = t2, c3 = 0, u3 = e, G.n = r4, a;
2244
+ } };
2245
+ function d(r4, n4) {
2246
+ for (c3 = r4, u3 = n4, t = 0; !y && f2 && !o4 && t < p.length; t++) {
2247
+ var o4, i4 = p[t], d2 = G.p, l = i4[2];
2248
+ r4 > 3 ? (o4 = l === n4) && (u3 = i4[(c3 = i4[4]) ? 5 : (c3 = 3, 3)], i4[4] = i4[5] = e) : i4[0] <= d2 && ((o4 = r4 < 2 && d2 < i4[1]) ? (c3 = 0, G.v = n4, G.n = i4[1]) : d2 < l && (o4 = r4 < 3 || i4[0] > n4 || n4 > l) && (i4[4] = r4, i4[5] = n4, G.n = l, c3 = 0));
2249
+ }
2250
+ if (o4 || r4 > 1) return a;
2251
+ throw y = true, n4;
2252
+ }
2253
+ return function(o4, p2, l) {
2254
+ if (f2 > 1) throw TypeError("Generator is already running");
2255
+ for (y && 1 === p2 && d(p2, l), c3 = p2, u3 = l; (t = c3 < 2 ? e : u3) || !y; ) {
2256
+ i3 || (c3 ? c3 < 3 ? (c3 > 1 && (G.n = -1), d(c3, u3)) : G.n = u3 : G.v = u3);
2257
+ try {
2258
+ if (f2 = 2, i3) {
2259
+ if (c3 || (o4 = "next"), t = i3[o4]) {
2260
+ if (!(t = t.call(i3, u3))) throw TypeError("iterator result is not an object");
2261
+ if (!t.done) return t;
2262
+ u3 = t.value, c3 < 2 && (c3 = 0);
2263
+ } else 1 === c3 && (t = i3["return"]) && t.call(i3), c3 < 2 && (u3 = TypeError("The iterator does not provide a '" + o4 + "' method"), c3 = 1);
2264
+ i3 = e;
2265
+ } else if ((t = (y = G.n < 0) ? u3 : r3.call(n3, G)) !== a) break;
2266
+ } catch (t2) {
2267
+ i3 = e, c3 = 1, u3 = t2;
2268
+ } finally {
2269
+ f2 = 1;
2270
+ }
2271
+ }
2272
+ return { value: t, done: y };
2273
+ };
2274
+ }(r2, o2, i2), true), u2;
2275
+ }
2276
+ var a = {};
2277
+ function Generator() {
2278
+ }
2279
+ function GeneratorFunction() {
2280
+ }
2281
+ function GeneratorFunctionPrototype() {
1028
2282
  }
1029
- /**
1030
- * 获取地址列表
1031
- * @param params 分页参数
1032
- * @example
1033
- * ```js
1034
- * const data = await addressTarget.getAddressList({ pageNumber: 1, pageSize: 10 });
1035
- * console.log('地址列表', data.contents);
1036
- * ```
1037
- */
1038
- async getAddressList(options = {}) {
1039
- const { pageNumber = 1, pageSize = 10 } = options;
1040
- const res = await this.iarCore.polyvApi.get(
1041
- PolyvApiUrl.GetAddressList,
1042
- {
1043
- pageNumber,
1044
- pageSize
2283
+ t = Object.getPrototypeOf;
2284
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2$1(t = {}, n, function() {
2285
+ return this;
2286
+ }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
2287
+ function f(e2) {
2288
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e2, GeneratorFunctionPrototype) : (e2.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2$1(e2, o, "GeneratorFunction")), e2.prototype = Object.create(u), e2;
2289
+ }
2290
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2$1(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2$1(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2$1(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2$1(u), _regeneratorDefine2$1(u, o, "Generator"), _regeneratorDefine2$1(u, n, function() {
2291
+ return this;
2292
+ }), _regeneratorDefine2$1(u, "toString", function() {
2293
+ return "[object Generator]";
2294
+ }), (_regenerator$1 = function _regenerator2() {
2295
+ return { w: i, m: f };
2296
+ })();
2297
+ }
2298
+ function _regeneratorDefine2$1(e, r, n, t) {
2299
+ var i = Object.defineProperty;
2300
+ try {
2301
+ i({}, "", {});
2302
+ } catch (e2) {
2303
+ i = 0;
2304
+ }
2305
+ _regeneratorDefine2$1 = function _regeneratorDefine(e2, r2, n2, t2) {
2306
+ if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
2307
+ else {
2308
+ var o = function o2(r3, n3) {
2309
+ _regeneratorDefine2$1(e2, r3, function(e3) {
2310
+ return this._invoke(r3, n3, e3);
2311
+ });
2312
+ };
2313
+ o("next", 0), o("throw", 1), o("return", 2);
2314
+ }
2315
+ }, _regeneratorDefine2$1(e, r, n, t);
2316
+ }
2317
+ function ownKeys(e, r) {
2318
+ var t = Object.keys(e);
2319
+ if (Object.getOwnPropertySymbols) {
2320
+ var o = Object.getOwnPropertySymbols(e);
2321
+ r && (o = o.filter(function(r2) {
2322
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
2323
+ })), t.push.apply(t, o);
2324
+ }
2325
+ return t;
2326
+ }
2327
+ function _objectSpread(e) {
2328
+ for (var r = 1; r < arguments.length; r++) {
2329
+ var t = null != arguments[r] ? arguments[r] : {};
2330
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
2331
+ _defineProperty$1(e, r2, t[r2]);
2332
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
2333
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
2334
+ });
2335
+ }
2336
+ return e;
2337
+ }
2338
+ function _defineProperty$1(e, r, t) {
2339
+ return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
2340
+ }
2341
+ function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
2342
+ try {
2343
+ var i = n[a](c), u = i.value;
2344
+ } catch (n2) {
2345
+ return void e(n2);
2346
+ }
2347
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
2348
+ }
2349
+ function _asyncToGenerator$1(n) {
2350
+ return function() {
2351
+ var t = this, e = arguments;
2352
+ return new Promise(function(r, o) {
2353
+ var a = n.apply(t, e);
2354
+ function _next(n2) {
2355
+ asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n2);
1045
2356
  }
1046
- );
1047
- return {
1048
- ...res,
1049
- contents: res.contents.map(mapInternalAddressToAddressData)
1050
- };
2357
+ function _throw(n2) {
2358
+ asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n2);
2359
+ }
2360
+ _next(void 0);
2361
+ });
2362
+ };
2363
+ }
2364
+ function _classCallCheck$1(a, n) {
2365
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
2366
+ }
2367
+ function _defineProperties$1(e, r) {
2368
+ for (var t = 0; t < r.length; t++) {
2369
+ var o = r[t];
2370
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey$1(o.key), o);
1051
2371
  }
1052
- /**
1053
- * 获取默认地址
1054
- * @example
1055
- * ```js
1056
- * const data = await addressTarget.getDefaultAddress();
1057
- * console.log('默认地址', data);
1058
- */
1059
- async getDefaultAddress() {
1060
- const res = await this.iarCore.polyvApi.get(
1061
- PolyvApiUrl.GetDefaultAddress,
1062
- {}
1063
- );
1064
- return mapInternalAddressToAddressData(res);
1065
- }
1066
- /**
1067
- * 新增地址
1068
- * @param params 新增地址参数
1069
- * @example
1070
- * ```js
1071
- * const data = await addressTarget.addAddress({
1072
- * phone: '13800138000',
1073
- * name: '张三',
1074
- * area: '广东省/广州市/番禺区',
1075
- * address: '国家创新创业基地',
1076
- * });
1077
- * console.log('新增地址', data);
1078
- */
1079
- async addAddress(params) {
1080
- const res = await this.iarCore.polyvApi.post(
1081
- PolyvApiUrl.AddAddress,
1082
- params
1083
- );
1084
- return mapInternalAddressToAddressData(res);
1085
- }
1086
- /**
1087
- * 修改地址
1088
- * @param params 修改地址参数
1089
- * @example
1090
- * ```js
1091
- * await addressTarget.updateAddress({
1092
- * id: '123',
1093
- * address: '国家创新创业基地',
1094
- * area: '广东省/广州市/番禺区',
1095
- * phone: '13800138000',
1096
- * name: '张三',
1097
- * });
1098
- */
1099
- async updateAddress(params) {
1100
- return await this.iarCore.polyvApi.post(
1101
- PolyvApiUrl.UpdateAddress,
1102
- params
1103
- );
1104
- }
1105
- /**
1106
- * 删除地址
1107
- * @param id 地址 id
1108
- * @example
1109
- * ```js
1110
- * await addressTarget.deleteAddress('123');
1111
- * ```
1112
- */
1113
- async deleteAddress(id) {
1114
- return await this.iarCore.polyvApi.post(
1115
- PolyvApiUrl.DeleteAddress,
1116
- { id }
1117
- );
1118
- }
1119
- }
1120
- class Payment {
1121
- constructor(iarCore, config) {
1122
- __publicField(this, "PaymentProvider", PaymentProvider);
1123
- /** 支付方式缓存 */
1124
- __publicField(this, "__payProviderCache");
2372
+ }
2373
+ function _createClass$1(e, r, t) {
2374
+ return r && _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
2375
+ }
2376
+ function _toPropertyKey$1(t) {
2377
+ var i = _toPrimitive$1(t, "string");
2378
+ return "symbol" == _typeof$1(i) ? i : i + "";
2379
+ }
2380
+ function _toPrimitive$1(t, r) {
2381
+ if ("object" != _typeof$1(t) || !t) return t;
2382
+ var e = t[Symbol.toPrimitive];
2383
+ if (void 0 !== e) {
2384
+ var i = e.call(t, r);
2385
+ if ("object" != _typeof$1(i)) return i;
2386
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2387
+ }
2388
+ return String(t);
2389
+ }
2390
+ var Address = /* @__PURE__ */ function() {
2391
+ function Address2(iarCore, config) {
2392
+ _classCallCheck$1(this, Address2);
1125
2393
  this.iarCore = iarCore;
1126
2394
  this.config = config;
1127
2395
  }
1128
- /**
1129
- * 获取微信/支付宝支付参数
1130
- * @param options 支付订单参数
1131
- * @example
1132
- * ```js
1133
- * const data = await paymentTarget.payOrder({ orderNo: '1234567890', payProvider: PaymentProvider.Wechat });
1134
- * console.log('支付参数', data);
1135
- * ```
1136
- */
1137
- async getPayOrderParams(options) {
1138
- const res = await this.iarCore.polyvApi.get(
1139
- PolyvApiUrl.PayOrder,
1140
- options
1141
- );
1142
- return mapInternalCreateOrderResponse(res);
1143
- }
1144
- /**
1145
- * 获取支付方式
1146
- * @example
1147
- * ```js
1148
- * const data = await paymentTarget.getPayProviders();
1149
- * console.log('支付方式', data);
1150
- * ```
1151
- */
1152
- async getPayProviders() {
1153
- if (this.__payProviderCache) {
1154
- return this.__payProviderCache;
2396
+ return _createClass$1(Address2, [{
2397
+ key: "getAddressList",
2398
+ value: function() {
2399
+ var _getAddressList = _asyncToGenerator$1(/* @__PURE__ */ _regenerator$1().m(function _callee() {
2400
+ var options, _options$pageNumber, pageNumber, _options$pageSize, pageSize, res, _args = arguments;
2401
+ return _regenerator$1().w(function(_context) {
2402
+ while (1) switch (_context.n) {
2403
+ case 0:
2404
+ options = _args.length > 0 && _args[0] !== void 0 ? _args[0] : {};
2405
+ _options$pageNumber = options.pageNumber, pageNumber = _options$pageNumber === void 0 ? 1 : _options$pageNumber, _options$pageSize = options.pageSize, pageSize = _options$pageSize === void 0 ? 10 : _options$pageSize;
2406
+ _context.n = 1;
2407
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetAddressList, {
2408
+ pageNumber,
2409
+ pageSize
2410
+ });
2411
+ case 1:
2412
+ res = _context.v;
2413
+ return _context.a(2, _objectSpread(_objectSpread({}, res), {}, {
2414
+ contents: res.contents.map(mapInternalAddressToAddressData)
2415
+ }));
2416
+ }
2417
+ }, _callee, this);
2418
+ }));
2419
+ function getAddressList() {
2420
+ return _getAddressList.apply(this, arguments);
2421
+ }
2422
+ return getAddressList;
2423
+ }()
2424
+ }, {
2425
+ key: "getDefaultAddress",
2426
+ value: function() {
2427
+ var _getDefaultAddress = _asyncToGenerator$1(/* @__PURE__ */ _regenerator$1().m(function _callee2() {
2428
+ var res;
2429
+ return _regenerator$1().w(function(_context2) {
2430
+ while (1) switch (_context2.n) {
2431
+ case 0:
2432
+ _context2.n = 1;
2433
+ return this.iarCore.polyvApi.get(PolyvApiUrl.GetDefaultAddress, {});
2434
+ case 1:
2435
+ res = _context2.v;
2436
+ return _context2.a(2, mapInternalAddressToAddressData(res));
2437
+ }
2438
+ }, _callee2, this);
2439
+ }));
2440
+ function getDefaultAddress() {
2441
+ return _getDefaultAddress.apply(this, arguments);
2442
+ }
2443
+ return getDefaultAddress;
2444
+ }()
2445
+ }, {
2446
+ key: "addAddress",
2447
+ value: function() {
2448
+ var _addAddress = _asyncToGenerator$1(/* @__PURE__ */ _regenerator$1().m(function _callee3(params) {
2449
+ var res;
2450
+ return _regenerator$1().w(function(_context3) {
2451
+ while (1) switch (_context3.n) {
2452
+ case 0:
2453
+ _context3.n = 1;
2454
+ return this.iarCore.polyvApi.post(PolyvApiUrl.AddAddress, params);
2455
+ case 1:
2456
+ res = _context3.v;
2457
+ return _context3.a(2, mapInternalAddressToAddressData(res));
2458
+ }
2459
+ }, _callee3, this);
2460
+ }));
2461
+ function addAddress(_x) {
2462
+ return _addAddress.apply(this, arguments);
2463
+ }
2464
+ return addAddress;
2465
+ }()
2466
+ }, {
2467
+ key: "updateAddress",
2468
+ value: function() {
2469
+ var _updateAddress = _asyncToGenerator$1(/* @__PURE__ */ _regenerator$1().m(function _callee4(params) {
2470
+ return _regenerator$1().w(function(_context4) {
2471
+ while (1) switch (_context4.n) {
2472
+ case 0:
2473
+ _context4.n = 1;
2474
+ return this.iarCore.polyvApi.post(PolyvApiUrl.UpdateAddress, params);
2475
+ case 1:
2476
+ return _context4.a(2, _context4.v);
2477
+ }
2478
+ }, _callee4, this);
2479
+ }));
2480
+ function updateAddress(_x2) {
2481
+ return _updateAddress.apply(this, arguments);
2482
+ }
2483
+ return updateAddress;
2484
+ }()
2485
+ }, {
2486
+ key: "deleteAddress",
2487
+ value: function() {
2488
+ var _deleteAddress = _asyncToGenerator$1(/* @__PURE__ */ _regenerator$1().m(function _callee5(id) {
2489
+ return _regenerator$1().w(function(_context5) {
2490
+ while (1) switch (_context5.n) {
2491
+ case 0:
2492
+ _context5.n = 1;
2493
+ return this.iarCore.polyvApi.post(PolyvApiUrl.DeleteAddress, {
2494
+ id
2495
+ });
2496
+ case 1:
2497
+ return _context5.a(2, _context5.v);
2498
+ }
2499
+ }, _callee5, this);
2500
+ }));
2501
+ function deleteAddress(_x3) {
2502
+ return _deleteAddress.apply(this, arguments);
2503
+ }
2504
+ return deleteAddress;
2505
+ }()
2506
+ }]);
2507
+ }();
2508
+ function _typeof(o) {
2509
+ "@babel/helpers - typeof";
2510
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
2511
+ return typeof o2;
2512
+ } : function(o2) {
2513
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
2514
+ }, _typeof(o);
2515
+ }
2516
+ function _regenerator() {
2517
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
2518
+ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag";
2519
+ function i(r2, n2, o2, i2) {
2520
+ var c2 = n2 && n2.prototype instanceof Generator ? n2 : Generator, u2 = Object.create(c2.prototype);
2521
+ return _regeneratorDefine2(u2, "_invoke", function(r3, n3, o3) {
2522
+ var i3, c3, u3, f2 = 0, p = o3 || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d2(t2, r4) {
2523
+ return i3 = t2, c3 = 0, u3 = e, G.n = r4, a;
2524
+ } };
2525
+ function d(r4, n4) {
2526
+ for (c3 = r4, u3 = n4, t = 0; !y && f2 && !o4 && t < p.length; t++) {
2527
+ var o4, i4 = p[t], d2 = G.p, l = i4[2];
2528
+ r4 > 3 ? (o4 = l === n4) && (u3 = i4[(c3 = i4[4]) ? 5 : (c3 = 3, 3)], i4[4] = i4[5] = e) : i4[0] <= d2 && ((o4 = r4 < 2 && d2 < i4[1]) ? (c3 = 0, G.v = n4, G.n = i4[1]) : d2 < l && (o4 = r4 < 3 || i4[0] > n4 || n4 > l) && (i4[4] = r4, i4[5] = n4, G.n = l, c3 = 0));
2529
+ }
2530
+ if (o4 || r4 > 1) return a;
2531
+ throw y = true, n4;
2532
+ }
2533
+ return function(o4, p2, l) {
2534
+ if (f2 > 1) throw TypeError("Generator is already running");
2535
+ for (y && 1 === p2 && d(p2, l), c3 = p2, u3 = l; (t = c3 < 2 ? e : u3) || !y; ) {
2536
+ i3 || (c3 ? c3 < 3 ? (c3 > 1 && (G.n = -1), d(c3, u3)) : G.n = u3 : G.v = u3);
2537
+ try {
2538
+ if (f2 = 2, i3) {
2539
+ if (c3 || (o4 = "next"), t = i3[o4]) {
2540
+ if (!(t = t.call(i3, u3))) throw TypeError("iterator result is not an object");
2541
+ if (!t.done) return t;
2542
+ u3 = t.value, c3 < 2 && (c3 = 0);
2543
+ } else 1 === c3 && (t = i3["return"]) && t.call(i3), c3 < 2 && (u3 = TypeError("The iterator does not provide a '" + o4 + "' method"), c3 = 1);
2544
+ i3 = e;
2545
+ } else if ((t = (y = G.n < 0) ? u3 : r3.call(n3, G)) !== a) break;
2546
+ } catch (t2) {
2547
+ i3 = e, c3 = 1, u3 = t2;
2548
+ } finally {
2549
+ f2 = 1;
2550
+ }
2551
+ }
2552
+ return { value: t, done: y };
2553
+ };
2554
+ }(r2, o2, i2), true), u2;
2555
+ }
2556
+ var a = {};
2557
+ function Generator() {
2558
+ }
2559
+ function GeneratorFunction() {
2560
+ }
2561
+ function GeneratorFunctionPrototype() {
2562
+ }
2563
+ t = Object.getPrototypeOf;
2564
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function() {
2565
+ return this;
2566
+ }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
2567
+ function f(e2) {
2568
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e2, GeneratorFunctionPrototype) : (e2.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e2, o, "GeneratorFunction")), e2.prototype = Object.create(u), e2;
2569
+ }
2570
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function() {
2571
+ return this;
2572
+ }), _regeneratorDefine2(u, "toString", function() {
2573
+ return "[object Generator]";
2574
+ }), (_regenerator = function _regenerator2() {
2575
+ return { w: i, m: f };
2576
+ })();
2577
+ }
2578
+ function _regeneratorDefine2(e, r, n, t) {
2579
+ var i = Object.defineProperty;
2580
+ try {
2581
+ i({}, "", {});
2582
+ } catch (e2) {
2583
+ i = 0;
2584
+ }
2585
+ _regeneratorDefine2 = function _regeneratorDefine(e2, r2, n2, t2) {
2586
+ if (r2) i ? i(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2;
2587
+ else {
2588
+ var o = function o2(r3, n3) {
2589
+ _regeneratorDefine2(e2, r3, function(e3) {
2590
+ return this._invoke(r3, n3, e3);
2591
+ });
2592
+ };
2593
+ o("next", 0), o("throw", 1), o("return", 2);
1155
2594
  }
1156
- const fetchPromise = this.iarCore.polyvApi.get(
1157
- PolyvApiUrl.GetOrderPaymentProviders,
1158
- {}
1159
- ).catch((error) => {
1160
- this.__payProviderCache = void 0;
1161
- throw error;
2595
+ }, _regeneratorDefine2(e, r, n, t);
2596
+ }
2597
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
2598
+ try {
2599
+ var i = n[a](c), u = i.value;
2600
+ } catch (n2) {
2601
+ return void e(n2);
2602
+ }
2603
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
2604
+ }
2605
+ function _asyncToGenerator(n) {
2606
+ return function() {
2607
+ var t = this, e = arguments;
2608
+ return new Promise(function(r, o) {
2609
+ var a = n.apply(t, e);
2610
+ function _next(n2) {
2611
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n2);
2612
+ }
2613
+ function _throw(n2) {
2614
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2);
2615
+ }
2616
+ _next(void 0);
1162
2617
  });
1163
- this.__payProviderCache = fetchPromise;
1164
- return await fetchPromise;
2618
+ };
2619
+ }
2620
+ function _classCallCheck(a, n) {
2621
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
2622
+ }
2623
+ function _defineProperties(e, r) {
2624
+ for (var t = 0; t < r.length; t++) {
2625
+ var o = r[t];
2626
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
1165
2627
  }
1166
2628
  }
1167
- var ProductPushRule = /* @__PURE__ */ ((ProductPushRule2) => {
1168
- ProductPushRule2["BigCard"] = "bigCard";
1169
- ProductPushRule2["SmallCard"] = "smallCard";
1170
- return ProductPushRule2;
1171
- })(ProductPushRule || {});
2629
+ function _createClass(e, r, t) {
2630
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e;
2631
+ }
2632
+ function _defineProperty(e, r, t) {
2633
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
2634
+ }
2635
+ function _toPropertyKey(t) {
2636
+ var i = _toPrimitive(t, "string");
2637
+ return "symbol" == _typeof(i) ? i : i + "";
2638
+ }
2639
+ function _toPrimitive(t, r) {
2640
+ if ("object" != _typeof(t) || !t) return t;
2641
+ var e = t[Symbol.toPrimitive];
2642
+ if (void 0 !== e) {
2643
+ var i = e.call(t, r);
2644
+ if ("object" != _typeof(i)) return i;
2645
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2646
+ }
2647
+ return String(t);
2648
+ }
2649
+ var Payment = /* @__PURE__ */ function() {
2650
+ function Payment2(iarCore, config) {
2651
+ _classCallCheck(this, Payment2);
2652
+ _defineProperty(this, "PaymentProvider", PaymentProvider);
2653
+ this.iarCore = iarCore;
2654
+ this.config = config;
2655
+ }
2656
+ return _createClass(Payment2, [{
2657
+ key: "getPayOrderParams",
2658
+ value: function() {
2659
+ var _getPayOrderParams = _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function _callee(options) {
2660
+ var res;
2661
+ return _regenerator().w(function(_context) {
2662
+ while (1) switch (_context.n) {
2663
+ case 0:
2664
+ _context.n = 1;
2665
+ return this.iarCore.polyvApi.get(PolyvApiUrl.PayOrder, options);
2666
+ case 1:
2667
+ res = _context.v;
2668
+ return _context.a(2, mapInternalCreateOrderResponse(res));
2669
+ }
2670
+ }, _callee, this);
2671
+ }));
2672
+ function getPayOrderParams(_x) {
2673
+ return _getPayOrderParams.apply(this, arguments);
2674
+ }
2675
+ return getPayOrderParams;
2676
+ }()
2677
+ }, {
2678
+ key: "getPayProviders",
2679
+ value: (
2680
+ /**
2681
+ * 获取支付方式
2682
+ * @example
2683
+ * ```js
2684
+ * const data = await paymentTarget.getPayProviders();
2685
+ * console.log('支付方式', data);
2686
+ * ```
2687
+ */
2688
+ function() {
2689
+ var _getPayProviders = _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function _callee2() {
2690
+ var _this = this;
2691
+ var fetchPromise;
2692
+ return _regenerator().w(function(_context2) {
2693
+ while (1) switch (_context2.n) {
2694
+ case 0:
2695
+ if (!this.__payProviderCache) {
2696
+ _context2.n = 1;
2697
+ break;
2698
+ }
2699
+ return _context2.a(2, this.__payProviderCache);
2700
+ case 1:
2701
+ fetchPromise = this.iarCore.polyvApi.get(PolyvApiUrl.GetOrderPaymentProviders, {})["catch"](function(error) {
2702
+ _this.__payProviderCache = void 0;
2703
+ throw error;
2704
+ });
2705
+ this.__payProviderCache = fetchPromise;
2706
+ _context2.n = 2;
2707
+ return fetchPromise;
2708
+ case 2:
2709
+ return _context2.a(2, _context2.v);
2710
+ }
2711
+ }, _callee2, this);
2712
+ }));
2713
+ function getPayProviders() {
2714
+ return _getPayProviders.apply(this, arguments);
2715
+ }
2716
+ return getPayProviders;
2717
+ }()
2718
+ )
2719
+ }]);
2720
+ }();
1172
2721
  ;
1173
2722
  console.log(
1174
2723
  "%c@polyv/product-sdk",
1175
2724
  "background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff",
1176
- "[version: 1.0.0-rc-20250612.4]",
1177
- "[buildTime: 2025-06-12 09:58:02]"
2725
+ "[version: 1.2.0-rc-20250724.2]",
2726
+ "[buildTime: 2025-07-24 03:56:56]"
1178
2727
  );
1179
2728
  export {
1180
2729
  Address,