205254b1-fa83-43d8-a117-4ec31e2786db.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. "use strict";
  2. cc._RF.push(module, '20525Sx+oND2KEXTsMeJ4bb', 'QCrossWidget6');
  3. // common-plugin/Scripts/QCrossWidget6.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 AldUtils_1 = require("./AldUtils");
  27. var YZ_Constant_1 = require("./YZ_Constant");
  28. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  29. var QCrossWidget6 = /** @class */ (function (_super) {
  30. __extends(QCrossWidget6, _super);
  31. function QCrossWidget6() {
  32. var _this = _super !== null && _super.apply(this, arguments) || this;
  33. _this._pageView = null;
  34. _this._pageItem = null;
  35. _this._pageRecItem = null;
  36. _this._jumpList = null;
  37. _this._items = [];
  38. return _this;
  39. }
  40. QCrossWidget6.prototype.onLoad = function () {
  41. this._pageView = this.node.getChildByName("PageView").getComponent(cc.PageView);
  42. this._pageItem = this._pageView.content.getChildByName("Panel");
  43. this._pageRecItem = this._pageItem.children[0];
  44. this._pageView.content.removeAllChildren();
  45. // for (let i = 0; i < 6; i++) {
  46. // let item: cc.Node = panel.getChildByName(`Item${i}`);
  47. // let qcrossWidgetItem: QCrossWidgetItem = item.getComponent("QCrossWidgetItem");
  48. // qcrossWidgetItem._location = "isQCross";
  49. // this._items.push(item.getComponent("QCrossWidgetItem"));
  50. // }
  51. AldUtils_1.default.SendEvent("显示6元素交叉推广组件");
  52. };
  53. QCrossWidget6.prototype.start = function () {
  54. this._jumpList = Utils_1.utils.getRecommondGameList();
  55. if (this._jumpList && this._jumpList.length > 0) {
  56. this._initWidget();
  57. }
  58. else {
  59. cc.warn("交叉推广数据为null, 6元素交叉推广组件不显示!");
  60. this.node.destroy();
  61. }
  62. };
  63. QCrossWidget6.prototype._initWidget = function () {
  64. var totalPage = Math.ceil(this._jumpList.length / 6);
  65. // utils.showLog(`qcrosswidget >>> totalPage = ${totalPage}`);
  66. Utils_1.utils.showLog("qcrosswidget >>> totalPage = " + totalPage);
  67. var indx = 0;
  68. for (var i = 0; i < totalPage; i++) {
  69. var page = cc.instantiate(this._pageItem);
  70. page.removeAllChildren();
  71. this._pageView.addPage(page);
  72. for (var j = 0; j < 6; j++) {
  73. if (!this._jumpList[indx])
  74. break;
  75. var tempNode = cc.instantiate(this._pageRecItem);
  76. page.addChild(tempNode);
  77. var qcrossWidgetItem = tempNode.getComponent("QCrossWidgetItem");
  78. qcrossWidgetItem._location = YZ_Constant_1.SubLocation.isQCross;
  79. var data = this._jumpList[indx];
  80. tempNode.getComponent("QCrossWidgetItem").init(data);
  81. indx++;
  82. }
  83. }
  84. this.autoRefrshPageView();
  85. // for (let i = 0; i < this._jumpList.length; i++) {
  86. // let data: any = this._jumpList[i];
  87. // if (data && data.logo) {
  88. // let itemIdx: number = idx;
  89. // if (itemIdx >= this._items.length) {
  90. // return;
  91. // }
  92. // idx++;
  93. // this._items[itemIdx].init(data);
  94. // }
  95. // }
  96. };
  97. QCrossWidget6.prototype.autoRefrshPageView = function () {
  98. var _this = this;
  99. this.unscheduleAllCallbacks();
  100. var interval = 3;
  101. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.statement_auto_refresh) {
  102. interval = Utils_1.utils.ServerConfig.statement_auto_refresh;
  103. }
  104. Utils_1.utils.showLog("\u7ED3\u7B97\u4EA4\u53C9\u63A8\u5E7F\u7EC4\u4EF6" + interval + "\u79D2\u81EA\u52A8\u5237\u65B0");
  105. this.schedule(function () {
  106. var count = _this._pageView.getPages().length;
  107. var index = _this._pageView.getCurrentPageIndex();
  108. index = ((index < count) && (index + 1 !== count)) ? (index + 1) : 0;
  109. if (index == 0) {
  110. _this._pageView.scrollToPage(index, 0);
  111. }
  112. else {
  113. _this._pageView.scrollToPage(index, 2);
  114. }
  115. }, interval);
  116. };
  117. QCrossWidget6 = __decorate([
  118. ccclass
  119. ], QCrossWidget6);
  120. return QCrossWidget6;
  121. }(cc.Component));
  122. exports.default = QCrossWidget6;
  123. cc._RF.pop();