455ab301-b095-4730-8f47-c53a04e05ebb.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. "use strict";
  2. cc._RF.push(module, '455abMBsJVHMI9HxToE4F67', 'MoreGamesWidget');
  3. // common-plugin/Scripts/MoreGamesWidget.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var Utils_1 = require("./Utils");
  26. var PlatUtils_1 = require("./PlatUtils");
  27. var AldUtils_1 = require("./AldUtils");
  28. var CompatibleTool_1 = require("./CompatibleTool");
  29. var YZ_Constant_1 = require("./YZ_Constant");
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var MoreGamesWidget = /** @class */ (function (_super) {
  32. __extends(MoreGamesWidget, _super);
  33. function MoreGamesWidget() {
  34. var _this = _super !== null && _super.apply(this, arguments) || this;
  35. _this.prefab = null;
  36. _this.prefab1 = null;
  37. _this.btnMoreGames = null;
  38. _this.moreGamesPanel = null;
  39. return _this;
  40. }
  41. MoreGamesWidget.prototype.onLoad = function () {
  42. var _this = this;
  43. this.btnMoreGames = this.node.getChildByName("Btn_MoreGames");
  44. this.btnMoreGames.active = false;
  45. var self = this;
  46. var back = this.btnMoreGames.getChildByName("Background").getComponent(cc.Sprite);
  47. var backUrl;
  48. if (Utils_1.utils.ServerConfig) {
  49. backUrl = Utils_1.utils.ServerConfig.more_game_icon;
  50. }
  51. else {
  52. cc.warn("没有服务器配置");
  53. }
  54. if (backUrl && !this.bgTexture) {
  55. CompatibleTool_1.default.LoadRes(backUrl, function (err, texture) {
  56. if (!err && cc.isValid(_this) && back.node) {
  57. var size = back.node.getContentSize();
  58. self.bgTexture = new cc.SpriteFrame(texture);
  59. back.spriteFrame = self.bgTexture;
  60. back.node.setContentSize(size);
  61. }
  62. });
  63. }
  64. };
  65. MoreGamesWidget.prototype.onEnable = function () {
  66. var _this = this;
  67. Utils_1.utils.registerServerInitEvent(function () {
  68. _this._setBtnVisible();
  69. }, this);
  70. };
  71. MoreGamesWidget.prototype.onDisable = function () {
  72. Utils_1.utils.unregisterServerInitEvent(this);
  73. };
  74. MoreGamesWidget.prototype._setBtnVisible = function () {
  75. var valid = true;
  76. if (Utils_1.utils.isShowMoreGamesWidget()) {
  77. if (PlatUtils_1.default.IsQQ) {
  78. this.btnMoreGames.active = true;
  79. }
  80. else if (PlatUtils_1.default.Is4399) {
  81. this.btnMoreGames.active = true;
  82. }
  83. else if (PlatUtils_1.default.IsNativeAndroid && Utils_1.utils.Tool_Native && Utils_1.utils.config.nativeAndroidConfig.channel == "oppo") {
  84. this.btnMoreGames.active = true;
  85. }
  86. else if (Utils_1.utils.ServerConfig.show_oppo_rec && Utils_1.utils.ServerConfig.show_oppo_rec == "true") {
  87. this.btnMoreGames.active = true;
  88. }
  89. else {
  90. var gameList = Utils_1.utils.getRecommondGameList();
  91. if (gameList) {
  92. if (gameList.length > 0 || CC_DEBUG) {
  93. this.btnMoreGames.active = true;
  94. }
  95. else {
  96. cc.warn("交叉推广数据列表长度为0, 更多游戏按钮不显示!");
  97. valid = false;
  98. }
  99. }
  100. else {
  101. cc.warn("交叉推广数据列表数据为null, 更多游戏按钮不显示!");
  102. valid = false;
  103. }
  104. }
  105. }
  106. else {
  107. valid = false;
  108. }
  109. if (!valid) {
  110. this.node.destroy();
  111. }
  112. };
  113. MoreGamesWidget.prototype.onBtnClickedHandler = function (event, data) {
  114. if (PlatUtils_1.default.IsQQ) {
  115. Utils_1.utils.adManager.ShowAppBox(true);
  116. return;
  117. }
  118. else if (PlatUtils_1.default.Is4399) {
  119. Utils_1.utils.Tool_4399.showRecommend();
  120. return;
  121. }
  122. else if (PlatUtils_1.default.IsNativeAndroid && Utils_1.utils.Tool_Native && Utils_1.utils.Tool_Native.moreGameShowType == 1) {
  123. //如果是原生平台,判断显示的类型
  124. Utils_1.utils.Tool_Native.showMoreGames();
  125. Utils_1.utils.postDataByLocation("123", YZ_Constant_1.SubLocation.isMoreGame, 0);
  126. }
  127. else if (PlatUtils_1.default.IsDouyin) {
  128. Utils_1.utils.Tool_Douyin.showMoreGamesModal();
  129. }
  130. // else if (PlatUtils.IsOPPO) {
  131. // utils.oppoTool.showOppoGamePortal();
  132. // }
  133. else {
  134. if (Utils_1.utils.ServerConfig.show_oppo_rec && Utils_1.utils.ServerConfig.show_oppo_rec == "true") {
  135. Utils_1.utils.showLog("服务器配置显示官方互推!");
  136. Utils_1.utils.oppoTool.showOppoGamePortal();
  137. return;
  138. }
  139. var jumpList = Utils_1.utils.getRecommondGameList();
  140. if (jumpList && jumpList.length > 0) {
  141. Utils_1.utils.showLog("MoreGamePanel 交叉推广数据:", JSON.stringify(jumpList));
  142. var panel = void 0;
  143. if (Utils_1.utils.ServerConfig.more_game_skin == 2 || CC_DEBUG) {
  144. panel = cc.instantiate(this.prefab1);
  145. panel.zIndex = 999999;
  146. this.moreGamesPanel = panel.getComponent("MoreGamesPanel1");
  147. }
  148. else {
  149. panel = cc.instantiate(this.prefab);
  150. panel.zIndex = 999999;
  151. this.moreGamesPanel = panel.getComponent("MoreGamesPanel");
  152. }
  153. cc.director.getScene().addChild(panel);
  154. this.moreGamesPanel._location = YZ_Constant_1.SubLocation.isMoreGame;
  155. this.moreGamesPanel.init(jumpList);
  156. this.moreGamesPanel.show();
  157. AldUtils_1.default.SendEvent("点击更多游戏按钮");
  158. }
  159. else {
  160. Utils_1.utils.showLog("获取交叉推广数据失败!");
  161. }
  162. }
  163. };
  164. __decorate([
  165. property(cc.Prefab)
  166. ], MoreGamesWidget.prototype, "prefab", void 0);
  167. __decorate([
  168. property(cc.Prefab)
  169. ], MoreGamesWidget.prototype, "prefab1", void 0);
  170. MoreGamesWidget = __decorate([
  171. ccclass
  172. ], MoreGamesWidget);
  173. return MoreGamesWidget;
  174. }(cc.Component));
  175. exports.default = MoreGamesWidget;
  176. cc._RF.pop();