b12f9ec9-fe2f-4f96-a891-dfc5f34eec8f.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. "use strict";
  2. cc._RF.push(module, 'b12f97J/i9PlqiR38XzTuyP', 'RecommendGamesNode');
  3. // common-plugin/Scripts/RecommendGamesNode.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 YZ_Constant_1 = require("./YZ_Constant");
  27. var PlatUtils_1 = require("./PlatUtils");
  28. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  29. var RecommendGamesNode = /** @class */ (function (_super) {
  30. __extends(RecommendGamesNode, _super);
  31. function RecommendGamesNode() {
  32. var _this = _super !== null && _super.apply(this, arguments) || this;
  33. _this.prefab = null;
  34. _this.prefab1 = null;
  35. _this.moreGamesPanel = null;
  36. _this._pageView = null;
  37. _this._content = null;
  38. _this._gamePageNode = null;
  39. _this._dataDirty = false;
  40. _this._isContentFilled = false;
  41. _this._scrollInterval = 3;
  42. _this._timeTmp = 0;
  43. _this._gameList = null;
  44. _this.moreGame = null;
  45. return _this;
  46. }
  47. RecommendGamesNode.prototype.onLoad = function () {
  48. var pageViewNode = this.node.getChildByName("PageView");
  49. this.moreGame = cc.find("bg/BtnMore", this.node);
  50. this._pageView = pageViewNode.getComponent(cc.PageView);
  51. this._content = this._pageView.content;
  52. this._gamePageNode = this._content.getChildByName("GamePage");
  53. this._content.removeAllChildren();
  54. };
  55. RecommendGamesNode.prototype.init = function (data) {
  56. this._gameList = data;
  57. if (this._gameList && this._gameList.length > 0) {
  58. this._dataDirty = true;
  59. }
  60. else {
  61. this.node.active = false;
  62. }
  63. };
  64. RecommendGamesNode.prototype.onEnable = function () {
  65. var self = this;
  66. this.moreGame.on(cc.Node.EventType.TOUCH_START, function (event) {
  67. if (PlatUtils_1.default.IsDouyin) {
  68. Utils_1.utils.Tool_Douyin.showMoreGamesModal();
  69. }
  70. else if (!PlatUtils_1.default.IsOPPO || (Utils_1.utils.ServerConfig.recommend_bar_show_pannel && Utils_1.utils.ServerConfig.recommend_bar_show_pannel == "true")) {
  71. var panel = void 0;
  72. if (Utils_1.utils.ServerConfig.more_game_skin == 2) {
  73. panel = cc.instantiate(self.prefab1);
  74. panel.zIndex = 999;
  75. self.moreGamesPanel = panel.getComponent("MoreGamesPanel1");
  76. }
  77. else {
  78. panel = cc.instantiate(self.prefab);
  79. panel.zIndex = 999;
  80. self.moreGamesPanel = panel.getComponent("MoreGamesPanel");
  81. }
  82. cc.director.getScene().addChild(panel);
  83. self.moreGamesPanel._location = YZ_Constant_1.SubLocation.isScrollbar;
  84. self.moreGamesPanel.init(self._gameList);
  85. self.moreGamesPanel.show();
  86. }
  87. else {
  88. Utils_1.utils.showLog("服务器未配置显示更多游戏面板!");
  89. }
  90. });
  91. };
  92. RecommendGamesNode.prototype.onDisable = function () {
  93. this.moreGame.targetOff(this);
  94. };
  95. RecommendGamesNode.prototype.update = function (dt) {
  96. if (this._dataDirty) {
  97. this._dataDirty = false;
  98. this._updateContent();
  99. }
  100. };
  101. RecommendGamesNode.prototype._updateContent = function () {
  102. if (this._gameList) {
  103. Utils_1.utils.postRecommentShowData(YZ_Constant_1.SubLocation.isScrollbar);
  104. var length = Math.floor(this._gameList.length / 4);
  105. var index = 0;
  106. for (var i = 0; i < length; i++) {
  107. var gamePageList = [];
  108. for (var j = 0; j < 4; j++) {
  109. gamePageList.push(this._gameList[index]);
  110. index++;
  111. }
  112. var gamePageNode = cc.instantiate(this._gamePageNode);
  113. var gamePage = gamePageNode.getComponent("GamePage");
  114. gamePage.init(gamePageList);
  115. this._pageView.addPage(gamePageNode);
  116. }
  117. this._gamePageNode.destroy();
  118. this._isContentFilled = true;
  119. this.autoRefrshPageView();
  120. }
  121. };
  122. RecommendGamesNode.prototype.autoRefrshPageView = function () {
  123. var _this = this;
  124. this.unscheduleAllCallbacks();
  125. var interval = 3.5;
  126. this.schedule(function () {
  127. var count = _this._pageView.getPages().length;
  128. var index = _this._pageView.getCurrentPageIndex();
  129. index = ((index < count) && (index + 1 !== count)) ? (index + 1) : 0;
  130. if (index == 0) {
  131. _this._pageView.scrollToPage(index, 0);
  132. }
  133. else {
  134. _this._pageView.scrollToPage(index, 2.5);
  135. }
  136. }, interval); //10秒一换
  137. };
  138. __decorate([
  139. property(cc.Prefab)
  140. ], RecommendGamesNode.prototype, "prefab", void 0);
  141. __decorate([
  142. property(cc.Prefab)
  143. ], RecommendGamesNode.prototype, "prefab1", void 0);
  144. RecommendGamesNode = __decorate([
  145. ccclass
  146. ], RecommendGamesNode);
  147. return RecommendGamesNode;
  148. }(cc.Component));
  149. exports.default = RecommendGamesNode;
  150. cc._RF.pop();