@chiyou/minigame-framework 1.0.2 → 1.0.3

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.
Files changed (114) hide show
  1. package/assets/Scripts/index.ts +2 -5
  2. package/package.json +5 -10
  3. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +0 -78
  4. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +0 -230
  5. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +0 -31
  6. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +0 -224
  7. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +0 -34
  8. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +0 -524
  9. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +0 -34
  10. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +0 -631
  11. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +0 -33
  12. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +0 -460
  13. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +0 -31
  14. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +0 -227
  15. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +0 -33
  16. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +0 -458
  17. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +0 -35
  18. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +0 -770
  19. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +0 -33
  20. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +0 -519
  21. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +0 -33
  22. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +0 -492
  23. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +0 -33
  24. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +0 -695
  25. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +0 -34
  26. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +0 -597
  27. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +0 -33
  28. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +0 -458
  29. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +0 -51
  30. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +0 -17
  31. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +0 -45
  32. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +0 -555
  33. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +0 -44
  34. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +0 -148
  35. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +0 -48
  36. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +0 -715
  37. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +0 -44
  38. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +0 -296
  39. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +0 -45
  40. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +0 -284
  41. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +0 -44
  42. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +0 -283
  43. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +0 -43
  44. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +0 -406
  45. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +0 -43
  46. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +0 -248
  47. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +0 -44
  48. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +0 -517
  49. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +0 -44
  50. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +0 -295
  51. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +0 -55
  52. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +0 -964
  53. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +0 -44
  54. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +0 -295
  55. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +0 -44
  56. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +0 -393
  57. package/dist/Framework/Definition/AdDefinition.d.ts +0 -130
  58. package/dist/Framework/Definition/AdDefinition.js +0 -208
  59. package/dist/Framework/Definition/FrameworkBase.d.ts +0 -13
  60. package/dist/Framework/Definition/FrameworkBase.js +0 -23
  61. package/dist/Framework/Definition/PrivacyDefinition.d.ts +0 -51
  62. package/dist/Framework/Definition/PrivacyDefinition.js +0 -70
  63. package/dist/Framework/Definition/SocialDefinition.d.ts +0 -16
  64. package/dist/Framework/Definition/SocialDefinition.js +0 -2
  65. package/dist/Framework/Definition/SystemDefinition.d.ts +0 -43
  66. package/dist/Framework/Definition/SystemDefinition.js +0 -28
  67. package/dist/Framework/Definition/UIDefinition.d.ts +0 -6
  68. package/dist/Framework/Definition/UIDefinition.js +0 -7
  69. package/dist/Framework/Definition/UserDefinition.d.ts +0 -14
  70. package/dist/Framework/Definition/UserDefinition.js +0 -10
  71. package/dist/Framework/Manager/AdMgr.d.ts +0 -57
  72. package/dist/Framework/Manager/AdMgr.js +0 -684
  73. package/dist/Framework/Manager/AudioMgr.d.ts +0 -28
  74. package/dist/Framework/Manager/AudioMgr.js +0 -265
  75. package/dist/Framework/Manager/BaseMgr.d.ts +0 -18
  76. package/dist/Framework/Manager/BaseMgr.js +0 -114
  77. package/dist/Framework/Manager/EventMgr.d.ts +0 -18
  78. package/dist/Framework/Manager/EventMgr.js +0 -90
  79. package/dist/Framework/Manager/ExcelMgr.d.ts +0 -24
  80. package/dist/Framework/Manager/ExcelMgr.js +0 -156
  81. package/dist/Framework/Manager/LifeCycleMgr.d.ts +0 -20
  82. package/dist/Framework/Manager/LifeCycleMgr.js +0 -110
  83. package/dist/Framework/Manager/NodePoolMgr.d.ts +0 -53
  84. package/dist/Framework/Manager/NodePoolMgr.js +0 -279
  85. package/dist/Framework/Manager/PrivacyMgr.d.ts +0 -15
  86. package/dist/Framework/Manager/PrivacyMgr.js +0 -176
  87. package/dist/Framework/Manager/ResMgr.d.ts +0 -49
  88. package/dist/Framework/Manager/ResMgr.js +0 -337
  89. package/dist/Framework/Manager/SocialMgr.d.ts +0 -23
  90. package/dist/Framework/Manager/SocialMgr.js +0 -220
  91. package/dist/Framework/Manager/SystemMgr.d.ts +0 -24
  92. package/dist/Framework/Manager/SystemMgr.js +0 -222
  93. package/dist/Framework/Manager/TimerMgr.d.ts +0 -11
  94. package/dist/Framework/Manager/TimerMgr.js +0 -63
  95. package/dist/Framework/Manager/UIMgr.d.ts +0 -33
  96. package/dist/Framework/Manager/UIMgr.js +0 -223
  97. package/dist/Framework/Manager/UserMgr.d.ts +0 -15
  98. package/dist/Framework/Manager/UserMgr.js +0 -148
  99. package/dist/Framework/Utils/BezierUtils.d.ts +0 -49
  100. package/dist/Framework/Utils/BezierUtils.js +0 -247
  101. package/dist/Framework/Utils/CSVUtils.d.ts +0 -35
  102. package/dist/Framework/Utils/CSVUtils.js +0 -341
  103. package/dist/Framework/Utils/LogUtils.d.ts +0 -7
  104. package/dist/Framework/Utils/LogUtils.js +0 -32
  105. package/dist/Framework/Utils/NumberUtils.d.ts +0 -16
  106. package/dist/Framework/Utils/NumberUtils.js +0 -44
  107. package/dist/Framework/Utils/TaskUtils.d.ts +0 -10
  108. package/dist/Framework/Utils/TaskUtils.js +0 -24
  109. package/dist/Framework/Utils/TimeUtils.d.ts +0 -19
  110. package/dist/Framework/Utils/TimeUtils.js +0 -33
  111. package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +0 -12
  112. package/dist/Framework/Utils/WXBizDataCryptUtils.js +0 -37
  113. package/dist/index.d.ts +0 -30
  114. package/dist/index.js +0 -35
@@ -1,964 +0,0 @@
1
- import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
- import { LogUtils } from '../../Utils/LogUtils';
3
- import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
4
- import { ScreenInfo } from '../../Definition/SystemDefinition';
5
- import { AdMgr } from '../../Manager/AdMgr';
6
- class PortalGame {
7
- constructor() {
8
- this.reset();
9
- }
10
- reset() {
11
- this.pageManager = null;
12
- this.errorListener = null;
13
- this.showListener = null;
14
- this.destroyListener = null;
15
- this.isLoaded = false;
16
- }
17
- }
18
- class GameClub {
19
- constructor() {
20
- this.reset();
21
- }
22
- reset() {
23
- this.pageManager = null;
24
- this.errorListener = null;
25
- this.isLoaded = false;
26
- }
27
- }
28
- class RecommendToFriend {
29
- constructor() {
30
- this.reset();
31
- }
32
- reset() {
33
- this.pageManager = null;
34
- this.errorListener = null;
35
- this.showListener = null;
36
- this.destroyListener = null;
37
- this.isLoaded = false;
38
- }
39
- }
40
- class RecommendToGameClub {
41
- constructor() {
42
- this.reset();
43
- }
44
- reset() {
45
- this.pageManager = null;
46
- this.errorListener = null;
47
- this.isLoaded = false;
48
- }
49
- }
50
- class WeiXinPlatformBusiness {
51
- constructor() {
52
- this.portalGame_cpsId = "";
53
- this.gameClub_openLink = "";
54
- this.recommendToGameClub_openLink = "";
55
- }
56
- }
57
- export class PlatformAdapterWeiXin extends AbsPlatformAdapter {
58
- constructor() {
59
- super(...arguments);
60
- this.portalGame = new PortalGame();
61
- this.gameClub = new GameClub();
62
- this.recommendToFriend = new RecommendToFriend();
63
- this.recommendToGameClub = new RecommendToGameClub();
64
- this.business = new WeiXinPlatformBusiness();
65
- // Private
66
- this.MiniGameCenter = null;
67
- }
68
- // Common
69
- init() {
70
- }
71
- onLoadingStart() {
72
- }
73
- onLoadingFinish(args) {
74
- this.business.portalGame_cpsId = args[0];
75
- this.business.gameClub_openLink = args[1];
76
- this.business.recommendToGameClub_openLink = args[2];
77
- this.initPortalGame();
78
- this.initGameClub();
79
- this.initRecommendToFriend();
80
- this.initRecommendToGameClub();
81
- this.createMiniGameCenter(
82
- // open
83
- () => {
84
- AdMgr.Instance.hideAllPermanentAd();
85
- },
86
- // close
87
- () => {
88
- AdMgr.Instance.showAllPermanentAd();
89
- });
90
- }
91
- exitGame() {
92
- if (window["wx"] && window["wx"].exitMiniProgram) {
93
- LogUtils.Instance.log("wx.exitMiniProgram");
94
- window["wx"].exitMiniProgram({});
95
- }
96
- }
97
- getSDKVersion() {
98
- if (window["wx"] && window["wx"].getAppBaseInfo) {
99
- LogUtils.Instance.log("wx.getAppBaseInfo");
100
- let appBaseInfo = window["wx"].getAppBaseInfo();
101
- if (appBaseInfo !== null) {
102
- return appBaseInfo.SDKVersion;
103
- }
104
- }
105
- return "";
106
- }
107
- requestGet(url, success, fail) {
108
- if (window["wx"] && window["wx"].request) {
109
- LogUtils.Instance.log("wx.request");
110
- window["wx"].request({
111
- url: url,
112
- dataType: '其他',
113
- success: (res) => {
114
- LogUtils.Instance.log("", "success");
115
- if (success) {
116
- success(res.data);
117
- }
118
- },
119
- fail: (err) => {
120
- LogUtils.Instance.log("", "fail");
121
- if (err) {
122
- LogUtils.Instance.log("", err);
123
- }
124
- if (fail) {
125
- fail(err);
126
- }
127
- }
128
- });
129
- }
130
- }
131
- requestPost(url, data, success, fail) {
132
- if (window["wx"] && window["wx"].request) {
133
- LogUtils.Instance.log("wx.request");
134
- window["wx"].request({
135
- url: url,
136
- method: "POST",
137
- data: data,
138
- dataType: "其他",
139
- success: (res) => {
140
- LogUtils.Instance.log("", "success");
141
- if (success) {
142
- success(res.data);
143
- }
144
- },
145
- fail: (err) => {
146
- LogUtils.Instance.log("", "fail");
147
- if (err) {
148
- LogUtils.Instance.log("", err);
149
- }
150
- if (fail) {
151
- fail(err);
152
- }
153
- }
154
- });
155
- }
156
- }
157
- downloadFile(fileUrl, success, fail) {
158
- if (window["wx"] && window["wx"].downloadFile) {
159
- LogUtils.Instance.log("wx.downloadFile");
160
- window["wx"].downloadFile({
161
- url: fileUrl,
162
- success: (res) => {
163
- LogUtils.Instance.log("", "success");
164
- LogUtils.Instance.log("", res);
165
- if (res) {
166
- success(res.tempFilePath);
167
- }
168
- },
169
- fail: (err) => {
170
- LogUtils.Instance.log("", "fail");
171
- if (err) {
172
- LogUtils.Instance.log("", err);
173
- }
174
- if (fail) {
175
- fail(err);
176
- }
177
- },
178
- });
179
- }
180
- }
181
- configPassiveShare(title, desc, imageUrl, templateId, query) {
182
- if (window["wx"] && window["wx"].showShareMenu) {
183
- LogUtils.Instance.log("wx.showShareMenu");
184
- window["wx"].showShareMenu({
185
- menus: ["shareAppMessage", "shareTimeline"]
186
- });
187
- }
188
- if (window["wx"] && window["wx"].onShareAppMessage) {
189
- window["wx"].onShareAppMessage(() => {
190
- LogUtils.Instance.log("wx.onShareAppMessage");
191
- return {
192
- title: title,
193
- imageUrl: imageUrl,
194
- imageUrlId: templateId,
195
- query: query,
196
- };
197
- });
198
- }
199
- if (window["wx"] && window["wx"].onShareTimeline) {
200
- window["wx"].onShareTimeline(() => {
201
- LogUtils.Instance.log("wx.onShareTimeline");
202
- return {
203
- title: title,
204
- imageUrl: imageUrl,
205
- imageUrlId: templateId,
206
- query: query,
207
- };
208
- });
209
- }
210
- }
211
- activeShareToFriend(callback, title, desc, imageUrl, templateId, query) {
212
- // 通过onShow回调
213
- if (window["wx"] && window["wx"].shareAppMessage) {
214
- LogUtils.Instance.log("wx.shareAppMessage");
215
- window["wx"].shareAppMessage({
216
- title: title,
217
- imageUrl: imageUrl,
218
- imageUrlId: templateId,
219
- query: query,
220
- });
221
- }
222
- }
223
- getScreenInfo() {
224
- if (window["wx"] && window["wx"].getWindowInfo) {
225
- LogUtils.Instance.log("wx.getWindowInfo");
226
- let windowInfo = window["wx"].getWindowInfo();
227
- if (windowInfo !== null) {
228
- return new ScreenInfo(windowInfo.windowWidth, windowInfo.windowHeight, windowInfo.screenWidth, windowInfo.screenHeight);
229
- }
230
- }
231
- return new ScreenInfo(0, 0, 0, 0);
232
- }
233
- navigateToMiniProgram(appid, path) {
234
- if (window["wx"] && window["wx"].navigateToMiniProgram) {
235
- LogUtils.Instance.log("wx.navigateToMiniProgram");
236
- window["wx"].navigateToMiniProgram({
237
- appId: appid,
238
- path: path,
239
- success: (res) => {
240
- LogUtils.Instance.log("", "success");
241
- if (res) {
242
- LogUtils.Instance.log("", res);
243
- }
244
- },
245
- fail: (err) => {
246
- LogUtils.Instance.log("", "fail");
247
- if (err) {
248
- LogUtils.Instance.log("", err);
249
- }
250
- }
251
- });
252
- }
253
- }
254
- reportEvent(eventId, data) {
255
- if (window["wx"] && window["wx"].reportEvent) {
256
- LogUtils.Instance.log("wx.reportEvent");
257
- window["wx"].reportEvent(eventId, data);
258
- }
259
- }
260
- getScreenBrightness(callback) {
261
- if (callback === null) {
262
- return;
263
- }
264
- if (!(window["wx"] && window["wx"].getScreenBrightness)) {
265
- callback(0);
266
- return;
267
- }
268
- LogUtils.Instance.log("wx.getScreenBrightness");
269
- window["wx"].getScreenBrightness({
270
- success: (res) => {
271
- LogUtils.Instance.log("", "success");
272
- if (res) {
273
- LogUtils.Instance.log("", res);
274
- callback(res.value);
275
- }
276
- else {
277
- callback(0);
278
- }
279
- },
280
- fail: (err) => {
281
- LogUtils.Instance.log("", "fail");
282
- if (err) {
283
- LogUtils.Instance.log("", err);
284
- }
285
- callback(0);
286
- },
287
- });
288
- }
289
- setScreenBrightness(value) {
290
- if (window["wx"] && window["wx"].setScreenBrightness) {
291
- LogUtils.Instance.log("wx.setScreenBrightness");
292
- window["wx"].setScreenBrightness({
293
- value: value,
294
- });
295
- }
296
- }
297
- setKeepScreenOn(keepScreenOn) {
298
- if (window["wx"] && window["wx"].setKeepScreenOn) {
299
- LogUtils.Instance.log("wx.setKeepScreenOn");
300
- window["wx"].setKeepScreenOn({
301
- keepScreenOn: keepScreenOn,
302
- });
303
- }
304
- }
305
- updateColdStartScene() {
306
- this.coldStartOptions = null;
307
- this.coldStartScene = "";
308
- if (window["wx"] && window["wx"].getLaunchOptionsSync) {
309
- this.coldStartOptions = window["wx"].getLaunchOptionsSync();
310
- if (this.coldStartOptions !== null && this.coldStartOptions["scene"]) {
311
- this.coldStartScene = this.coldStartOptions["scene"].toString();
312
- }
313
- }
314
- LogUtils.Instance.log("wx updateColdStartScene", "scene=" + this.coldStartScene);
315
- }
316
- updateWarmStartScene(warmStartOptions) {
317
- this.warmStartOptions = warmStartOptions;
318
- this.warmStartScene = "";
319
- if (this.warmStartOptions !== null && this.warmStartOptions["scene"]) {
320
- this.warmStartScene = this.warmStartOptions["scene"].toString();
321
- }
322
- LogUtils.Instance.log("wx updateWarmStartScene", "scene=" + this.warmStartScene);
323
- }
324
- onShow(fn) {
325
- if (window["wx"] && window["wx"].onShow) {
326
- window["wx"].onShow(fn);
327
- }
328
- }
329
- offShow(fn) {
330
- if (window["wx"] && window["wx"].offShow) {
331
- window["wx"].offShow(fn);
332
- }
333
- }
334
- onHide(fn) {
335
- if (window["wx"] && window["wx"].onHide) {
336
- window["wx"].onHide(fn);
337
- }
338
- }
339
- offHide(fn) {
340
- if (window["wx"] && window["wx"].offHide) {
341
- window["wx"].offHide(fn);
342
- }
343
- }
344
- isNavigateToRecentUseAvailable(callback) {
345
- if (callback === null) {
346
- return;
347
- }
348
- callback(false);
349
- }
350
- navigateToRecentUse() {
351
- }
352
- isLaunchFromRecentUse() {
353
- let recentUseSceneSet = new Set([
354
- "1001",
355
- "1089",
356
- "1256",
357
- "1103",
358
- "1104",
359
- "1257",
360
- ]);
361
- let isLaunchFromRecentUse = recentUseSceneSet.has(this.coldStartScene) || recentUseSceneSet.has(this.warmStartScene);
362
- LogUtils.Instance.log("wx isLaunchFromRecentUse", isLaunchFromRecentUse);
363
- return isLaunchFromRecentUse;
364
- }
365
- isLaunchFromDesktopShortcut() {
366
- let desktopShortcutSceneSet = new Set([
367
- "1023",
368
- "1223",
369
- ]);
370
- let isLaunchFromDesktopShortcut = desktopShortcutSceneSet.has(this.coldStartScene) || desktopShortcutSceneSet.has(this.warmStartScene);
371
- LogUtils.Instance.log("wx isLaunchFromDesktopShortcut", isLaunchFromDesktopShortcut);
372
- return isLaunchFromDesktopShortcut;
373
- }
374
- isLaunchFromAdvertisement() {
375
- let advertisementSceneSet = new Set([
376
- "1045", "1046", "1067", "1068", "1084", "1095",
377
- "1189", "1200", "1201", "1215", "1228", "1230",
378
- "1232", "1238", "1274", "1295",
379
- ]);
380
- let isLaunchFromAdvertisement = advertisementSceneSet.has(this.coldStartScene);
381
- LogUtils.Instance.log("wx isLaunchFromAdvertisement", isLaunchFromAdvertisement);
382
- return isLaunchFromAdvertisement;
383
- }
384
- checkSession(success, fail) {
385
- if (window["wx"] && window["wx"].checkSession) {
386
- LogUtils.Instance.log("wx.checkSession");
387
- window["wx"].checkSession({
388
- success: (res) => {
389
- LogUtils.Instance.log("", "success");
390
- if (res) {
391
- LogUtils.Instance.log("", res);
392
- }
393
- if (success) {
394
- success();
395
- }
396
- },
397
- fail: (err) => {
398
- LogUtils.Instance.log("", "fail");
399
- if (err) {
400
- LogUtils.Instance.log("", err);
401
- }
402
- if (fail) {
403
- fail();
404
- }
405
- },
406
- });
407
- }
408
- else {
409
- LogUtils.Instance.log("wx.checkSession", "no function");
410
- if (fail) {
411
- fail();
412
- }
413
- }
414
- }
415
- login(success, fail) {
416
- if (window["wx"] && window["wx"].login) {
417
- LogUtils.Instance.log("wx.login");
418
- window["wx"].login({
419
- success: (res) => {
420
- LogUtils.Instance.log("", "success");
421
- if (res) {
422
- LogUtils.Instance.log("", res);
423
- }
424
- if (success) {
425
- success(res.code, "");
426
- }
427
- },
428
- fail: (err) => {
429
- LogUtils.Instance.log("", "fail");
430
- if (err) {
431
- LogUtils.Instance.log("", err);
432
- }
433
- if (fail) {
434
- fail(true);
435
- }
436
- },
437
- });
438
- }
439
- else {
440
- LogUtils.Instance.log("wx.login", "no function");
441
- if (fail) {
442
- fail(true);
443
- }
444
- }
445
- }
446
- requirePrivacyAuthorize(callback) {
447
- if (callback === null) {
448
- return;
449
- }
450
- if (!window["wx"] || !window["wx"].requirePrivacyAuthorize) {
451
- callback(false);
452
- return;
453
- }
454
- LogUtils.Instance.log("wx.requirePrivacyAuthorize");
455
- window["wx"].requirePrivacyAuthorize({
456
- success: () => {
457
- LogUtils.Instance.log("", "success");
458
- callback(true);
459
- },
460
- fail: () => {
461
- LogUtils.Instance.log("", "fail");
462
- callback(false);
463
- },
464
- });
465
- }
466
- getSetting(scope, callback) {
467
- if (callback === null) {
468
- return;
469
- }
470
- if (!window["wx"] || !window["wx"].getSetting) {
471
- callback(GetSettingResult.Result_SettingNotAvailable);
472
- return;
473
- }
474
- LogUtils.Instance.log("wx.getSetting", "scope=" + scope);
475
- window["wx"].getSetting({
476
- success: (res) => {
477
- LogUtils.Instance.log("", "success");
478
- if (res) {
479
- LogUtils.Instance.log("", res);
480
- }
481
- if (res?.authSetting?.hasOwnProperty(scope)) {
482
- if (res.authSetting[scope]) {
483
- callback(GetSettingResult.Result_Authorized);
484
- }
485
- else {
486
- callback(GetSettingResult.Result_Rejected);
487
- }
488
- }
489
- else {
490
- callback(GetSettingResult.Result_NotExist_AuthorizeAvailable);
491
- }
492
- },
493
- fail: (err) => {
494
- LogUtils.Instance.log("", "fail");
495
- if (err) {
496
- LogUtils.Instance.log("", err);
497
- }
498
- callback(GetSettingResult.Result_Rejected);
499
- },
500
- });
501
- }
502
- openSetting(scope, callback) {
503
- if (callback === null) {
504
- return;
505
- }
506
- if (!window["wx"] || !window["wx"].openSetting) {
507
- callback(-1);
508
- return;
509
- }
510
- LogUtils.Instance.log("wx.openSetting", "scope=" + scope);
511
- window["wx"].openSetting({
512
- success: (res) => {
513
- LogUtils.Instance.log("", "success");
514
- if (res) {
515
- LogUtils.Instance.log("", res);
516
- }
517
- if (res?.authSetting?.hasOwnProperty(scope)) {
518
- if (res.authSetting[scope]) {
519
- callback(1);
520
- }
521
- else {
522
- callback(0);
523
- }
524
- }
525
- else {
526
- callback(0);
527
- }
528
- },
529
- fail: (err) => {
530
- LogUtils.Instance.log("", "fail");
531
- if (err) {
532
- LogUtils.Instance.log("", err);
533
- }
534
- callback(0);
535
- },
536
- });
537
- }
538
- authorize(scope, callback) {
539
- if (callback === null) {
540
- return;
541
- }
542
- if (!window["wx"] || !window["wx"].authorize) {
543
- callback(AuthorizeResult.Result_AuthorizeNotAvailable);
544
- return;
545
- }
546
- LogUtils.Instance.log("wx.authorize", "scope=" + scope);
547
- window["wx"].authorize({
548
- scope: scope,
549
- success: (res) => {
550
- LogUtils.Instance.log("", "success");
551
- if (res) {
552
- LogUtils.Instance.log("", res);
553
- }
554
- callback(AuthorizeResult.Result_Authorized);
555
- },
556
- fail: (err) => {
557
- LogUtils.Instance.log("", "fail");
558
- if (err) {
559
- LogUtils.Instance.log("", err);
560
- }
561
- callback(AuthorizeResult.Result_Rejected);
562
- },
563
- });
564
- }
565
- setRankData(args) {
566
- let rankId = args[0];
567
- let value = args[1];
568
- let cloudData = [{
569
- key: rankId,
570
- value: JSON.stringify({
571
- "wxgame": {
572
- "score": value,
573
- "update_time": Math.floor(new Date().getTime() / 1000),
574
- }
575
- })
576
- }];
577
- if (window["wx"] && window["wx"].setUserCloudStorage) {
578
- LogUtils.Instance.log("wx.setUserCloudStorage");
579
- LogUtils.Instance.log("", cloudData);
580
- window["wx"].setUserCloudStorage({
581
- KVDataList: cloudData,
582
- success: (res) => {
583
- LogUtils.Instance.log("success");
584
- if (res) {
585
- LogUtils.Instance.log("", res);
586
- }
587
- },
588
- fail: (err) => {
589
- LogUtils.Instance.log("fail");
590
- if (err) {
591
- LogUtils.Instance.log("", err);
592
- }
593
- }
594
- });
595
- }
596
- }
597
- showRankList(args) {
598
- let itemList = ["rank"];
599
- let openItem = "rank";
600
- if (!window["GameGlobal"] || !window["wx"]) {
601
- return;
602
- }
603
- if (!window["GameGlobal"].minigameCenter) {
604
- return;
605
- }
606
- window["GameGlobal"].minigameCenter.show();
607
- window["GameGlobal"].minigameCenter.setTabs(itemList);
608
- window["GameGlobal"].minigameCenter.open(openItem);
609
- }
610
- initPortalGame() {
611
- if (this.business.portalGame_cpsId === "") {
612
- return;
613
- }
614
- if (!window["wx"] || !window["wx"].createPageManager) {
615
- return;
616
- }
617
- if (this.portalGame.isLoaded) {
618
- return;
619
- }
620
- if (this.portalGame.pageManager !== null) {
621
- this.portalGame.reset();
622
- }
623
- LogUtils.Instance.log("wx.createPageManager");
624
- this.portalGame.pageManager = window["wx"].createPageManager();
625
- if (this.portalGame.pageManager === null) {
626
- return;
627
- }
628
- this.portalGame.errorListener = (err) => {
629
- LogUtils.Instance.log("", "portalGame.pageManager.onError()");
630
- if (err) {
631
- LogUtils.Instance.log("", err);
632
- }
633
- };
634
- this.portalGame.pageManager.on('error', this.portalGame.errorListener);
635
- this.portalGame.showListener = () => {
636
- LogUtils.Instance.log("", "portalGame.pageManager.onShow()");
637
- };
638
- this.portalGame.pageManager.on('show', this.portalGame.showListener);
639
- this.portalGame.destroyListener = () => {
640
- LogUtils.Instance.log("", "portalGame.pageManager.onDestroy()");
641
- this.portalGame.isLoaded = false;
642
- this.initPortalGame();
643
- };
644
- this.portalGame.pageManager.on('destroy', this.portalGame.destroyListener);
645
- LogUtils.Instance.log("", "portalGame.pageManager.load()");
646
- this.portalGame.pageManager.load({
647
- openlink: "wFFX1cDJnwJCet72QGUJJvBpa9z9lfAob-7EYHwzFENHJ_tNECj5LquvJqnbm82RktAcRyg7gORaUSh0yRSiuYF21JvF84j7-SgazajvTW-ScbwFiQccq8FWsrzHVPox1dr90HHv_CTrgRJD4HOdiRJFeLNRrDu0Pj3vsIGuonI",
648
- query: {
649
- id: this.business.portalGame_cpsId,
650
- }
651
- }).then(() => {
652
- LogUtils.Instance.log("", "portalGame.pageManager.load() success");
653
- this.portalGame.isLoaded = true;
654
- }).catch((err) => {
655
- LogUtils.Instance.log("", "portalGame.pageManager.load() fail");
656
- if (err) {
657
- LogUtils.Instance.log("", err);
658
- }
659
- });
660
- }
661
- openPortalGame() {
662
- if (this.business.portalGame_cpsId === "") {
663
- return;
664
- }
665
- LogUtils.Instance.log("", "portalGame.pageManager.show()");
666
- let promise = null;
667
- if (this.portalGame.isLoaded) {
668
- promise = this.portalGame.pageManager.show();
669
- }
670
- else {
671
- promise = this.portalGame.pageManager.show({
672
- openlink: "wFFX1cDJnwJCet72QGUJJvBpa9z9lfAob-7EYHwzFENHJ_tNECj5LquvJqnbm82RktAcRyg7gORaUSh0yRSiuYF21JvF84j7-SgazajvTW-ScbwFiQccq8FWsrzHVPox1dr90HHv_CTrgRJD4HOdiRJFeLNRrDu0Pj3vsIGuonI",
673
- query: {
674
- id: this.business.portalGame_cpsId,
675
- }
676
- });
677
- }
678
- promise.then(() => {
679
- LogUtils.Instance.log("", "portalGame.pageManager.show() success");
680
- }).catch((err) => {
681
- LogUtils.Instance.log("", "portalGame.pageManager.show() fail");
682
- if (err) {
683
- LogUtils.Instance.log("", err);
684
- }
685
- });
686
- }
687
- initGameClub() {
688
- if (this.business.gameClub_openLink === "") {
689
- return;
690
- }
691
- if (!window["wx"] || !window["wx"].createPageManager) {
692
- return;
693
- }
694
- if (this.gameClub.isLoaded) {
695
- return;
696
- }
697
- if (this.gameClub.pageManager !== null) {
698
- this.gameClub.reset();
699
- }
700
- LogUtils.Instance.log("wx.createPageManager");
701
- this.gameClub.pageManager = window["wx"].createPageManager();
702
- if (this.gameClub.pageManager === null) {
703
- return;
704
- }
705
- this.gameClub.errorListener = (err) => {
706
- LogUtils.Instance.log("", "gameClub.pageManager.onError()");
707
- if (err) {
708
- LogUtils.Instance.log("", err);
709
- }
710
- };
711
- this.gameClub.pageManager.on('error', this.gameClub.errorListener);
712
- LogUtils.Instance.log("", "gameClub.pageManager.load()");
713
- this.gameClub.pageManager.load({
714
- openlink: this.business.gameClub_openLink,
715
- }).then(() => {
716
- LogUtils.Instance.log("", "gameClub.pageManager.load() success");
717
- this.gameClub.isLoaded = true;
718
- }).catch((err) => {
719
- LogUtils.Instance.log("", "gameClub.pageManager.load() fail");
720
- if (err) {
721
- LogUtils.Instance.log("", err);
722
- }
723
- });
724
- }
725
- openGameClub() {
726
- if (this.business.gameClub_openLink === "") {
727
- return;
728
- }
729
- LogUtils.Instance.log("", "gameClub.pageManager.show()");
730
- let promise = null;
731
- if (this.gameClub.isLoaded) {
732
- promise = this.gameClub.pageManager.show();
733
- }
734
- else {
735
- promise = this.gameClub.pageManager.show({
736
- openlink: this.business.gameClub_openLink,
737
- });
738
- }
739
- promise.then(() => {
740
- LogUtils.Instance.log("", "gameClub.pageManager.show() success");
741
- }).catch((err) => {
742
- LogUtils.Instance.log("", "gameClub.pageManager.show() fail");
743
- if (err) {
744
- LogUtils.Instance.log("", err);
745
- }
746
- });
747
- }
748
- initRecommendToFriend() {
749
- if (!window["wx"] || !window["wx"].createPageManager) {
750
- return;
751
- }
752
- if (this.recommendToFriend.isLoaded) {
753
- return;
754
- }
755
- if (this.recommendToFriend.pageManager !== null) {
756
- this.recommendToFriend.reset();
757
- }
758
- LogUtils.Instance.log("wx.createPageManager");
759
- this.recommendToFriend.pageManager = window["wx"].createPageManager();
760
- if (this.recommendToFriend.pageManager === null) {
761
- return;
762
- }
763
- this.recommendToFriend.errorListener = (err) => {
764
- LogUtils.Instance.log("", "recommendToFriend.pageManager.onError()");
765
- if (err) {
766
- LogUtils.Instance.log("", err);
767
- }
768
- };
769
- this.recommendToFriend.pageManager.on('error', this.recommendToFriend.errorListener);
770
- this.recommendToFriend.showListener = () => {
771
- LogUtils.Instance.log("", "recommendToFriend.pageManager.onShow()");
772
- };
773
- this.recommendToFriend.pageManager.on('show', this.recommendToFriend.showListener);
774
- this.recommendToFriend.destroyListener = (res) => {
775
- let isRecommended = (res !== null) ? res.isRecommended : false;
776
- LogUtils.Instance.log("", "recommendToFriend.pageManager.onDestroy() isRecommended=" + isRecommended);
777
- this.recommendToFriend.isLoaded = false;
778
- this.initRecommendToFriend();
779
- };
780
- this.recommendToFriend.pageManager.on('destroy', this.recommendToFriend.destroyListener);
781
- LogUtils.Instance.log("", "recommendToFriend.pageManager.load()");
782
- this.recommendToFriend.pageManager.load({
783
- openlink: 'TWFRCqV5WeM2AkMXhKwJ03MhfPOieJfAsvXKUbWvQFQtLyyA5etMPabBehga950uzfZcH3Vi3QeEh41xRGEVFw',
784
- }).then(() => {
785
- LogUtils.Instance.log("", "recommendToFriend.pageManager.load() success");
786
- this.recommendToFriend.isLoaded = true;
787
- }).catch((err) => {
788
- LogUtils.Instance.log("", "recommendToFriend.pageManager.load() fail");
789
- if (err) {
790
- LogUtils.Instance.log("", err);
791
- }
792
- });
793
- }
794
- openRecommendToFriend() {
795
- LogUtils.Instance.log("", "recommendToFriend.pageManager.show()");
796
- let promise = null;
797
- if (this.recommendToFriend.isLoaded) {
798
- promise = this.recommendToFriend.pageManager.show();
799
- }
800
- else {
801
- promise = this.recommendToFriend.pageManager.show({
802
- openlink: 'TWFRCqV5WeM2AkMXhKwJ03MhfPOieJfAsvXKUbWvQFQtLyyA5etMPabBehga950uzfZcH3Vi3QeEh41xRGEVFw',
803
- });
804
- }
805
- promise.then(() => {
806
- LogUtils.Instance.log("", "recommendToFriend.pageManager.show() success");
807
- }).catch((err) => {
808
- LogUtils.Instance.log("", "recommendToFriend.pageManager.show() fail");
809
- if (err) {
810
- LogUtils.Instance.log("", err);
811
- }
812
- });
813
- }
814
- initRecommendToGameClub() {
815
- if (this.business.recommendToGameClub_openLink === "") {
816
- return;
817
- }
818
- if (this.recommendToGameClub.isLoaded) {
819
- return;
820
- }
821
- if (this.recommendToGameClub.pageManager !== null) {
822
- this.recommendToGameClub.reset();
823
- }
824
- LogUtils.Instance.log("wx.createPageManager");
825
- this.recommendToGameClub.pageManager = window["wx"].createPageManager();
826
- if (this.recommendToGameClub.pageManager === null) {
827
- return;
828
- }
829
- this.recommendToGameClub.errorListener = (err) => {
830
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.onError()");
831
- if (err) {
832
- LogUtils.Instance.log("", err);
833
- }
834
- };
835
- this.recommendToGameClub.pageManager.on('error', this.recommendToGameClub.errorListener);
836
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.load()");
837
- this.recommendToGameClub.pageManager.load({
838
- openlink: this.business.recommendToGameClub_openLink,
839
- }).then(() => {
840
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.load() success");
841
- this.recommendToGameClub.isLoaded = true;
842
- }).catch((err) => {
843
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.load() fail");
844
- if (err) {
845
- LogUtils.Instance.log("", err);
846
- }
847
- });
848
- }
849
- openRecommendToGameClub() {
850
- if (this.business.recommendToGameClub_openLink === "") {
851
- return;
852
- }
853
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.show()");
854
- let promise = null;
855
- if (this.recommendToGameClub.isLoaded) {
856
- promise = this.recommendToGameClub.pageManager.show();
857
- }
858
- else {
859
- promise = this.recommendToGameClub.pageManager.show({
860
- openlink: this.business.recommendToGameClub_openLink,
861
- });
862
- }
863
- promise.then(() => {
864
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.show() success");
865
- }).catch((err) => {
866
- LogUtils.Instance.log("", "recommendToGameClub.pageManager.show() fail");
867
- if (err) {
868
- LogUtils.Instance.log("", err);
869
- }
870
- });
871
- }
872
- createMiniGameCenter(openCallback, closeCallBack) {
873
- if (!window["GameGlobal"] || !window["wx"]) {
874
- return;
875
- }
876
- if (window["GameGlobal"].minigameCenter) {
877
- return;
878
- }
879
- try {
880
- let wx = window["wx"];
881
- let requirePlugin = window["GameGlobal"].requirePlugin;
882
- if (typeof requirePlugin !== 'undefined') {
883
- if (this.MiniGameCenter === null) {
884
- this.MiniGameCenter = requirePlugin('MiniGameCenter', {
885
- enableRequireHostModule: true,
886
- customEnv: {
887
- wx,
888
- },
889
- }).default;
890
- }
891
- if (!this.MiniGameCenter) {
892
- LogUtils.Instance.log("插件初始化失败");
893
- return;
894
- }
895
- let minigameCenter = new this.MiniGameCenter({
896
- autoShow: false,
897
- movable: false,
898
- enableSnap: false
899
- });
900
- if (typeof minigameCenter === 'undefined' || typeof minigameCenter.on === 'undefined') {
901
- // 插件初始化失败
902
- LogUtils.Instance.log("minigameCenter create error");
903
- }
904
- else {
905
- // 等待插件初始化完成
906
- minigameCenter.on('ready', () => {
907
- // 插件ready之后再在其他场景使用,后续通过是否存在GameGlobal.minigameCenter对象来判断组件是否初始化完成
908
- window["GameGlobal"].minigameCenter = minigameCenter;
909
- LogUtils.Instance.log('window["GameGlobal"].minigameCenter', "ready");
910
- LogUtils.Instance.log("", window["GameGlobal"].minigameCenter);
911
- });
912
- minigameCenter.on('error', (err) => {
913
- LogUtils.Instance.log('window["GameGlobal"].minigameCenter', "err");
914
- LogUtils.Instance.log("", err);
915
- minigameCenter.hide();
916
- });
917
- minigameCenter.on('show', (err) => {
918
- LogUtils.Instance.log('window["GameGlobal"].minigameCenter', "show");
919
- });
920
- minigameCenter.on('hide', (err) => {
921
- LogUtils.Instance.log('window["GameGlobal"].minigameCenter', "hide");
922
- });
923
- minigameCenter.on('open', (err) => {
924
- LogUtils.Instance.log('window["GameGlobal"].minigameCenter', "open");
925
- if (openCallback !== null) {
926
- openCallback();
927
- }
928
- });
929
- minigameCenter.on('close', (err) => {
930
- LogUtils.Instance.log('window["GameGlobal"].minigameCenter', "close");
931
- if (closeCallBack !== null) {
932
- closeCallBack();
933
- }
934
- minigameCenter.hide();
935
- });
936
- }
937
- }
938
- }
939
- catch (e) {
940
- // 基础库版本过低
941
- LogUtils.Instance.log("", e);
942
- }
943
- }
944
- requestSubscribeSystemMessage(msgTypeList) {
945
- if (window["wx"] && window["wx"].requestSubscribeSystemMessage) {
946
- LogUtils.Instance.log("wx.requestSubscribeSystemMessage");
947
- window["wx"].requestSubscribeSystemMessage({
948
- msgTypeList: msgTypeList,
949
- success: (res) => {
950
- LogUtils.Instance.log("success");
951
- if (res) {
952
- LogUtils.Instance.log("", res);
953
- }
954
- },
955
- fail: (err) => {
956
- LogUtils.Instance.log("fail");
957
- if (err) {
958
- LogUtils.Instance.log("", err);
959
- }
960
- }
961
- });
962
- }
963
- }
964
- }