e93749a2-59a1-4f92-898f-bc97459e54e4.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. "use strict";
  2. cc._RF.push(module, 'e9374miWaFPkomPvJdFnlTk', 'VerticalRecommentPanel');
  3. // common-plugin/Scripts/VerticalRecommentPanel.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 CompatibleTool_1 = require("./CompatibleTool");
  29. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  30. var VerticalRecommentPanel = /** @class */ (function (_super) {
  31. __extends(VerticalRecommentPanel, _super);
  32. function VerticalRecommentPanel() {
  33. var _this = _super !== null && _super.apply(this, arguments) || this;
  34. _this._recommendNode = null;
  35. _this._isInit = false;
  36. _this._gameList = [];
  37. _this._data = null;
  38. _this._curIndex = 0;
  39. return _this;
  40. }
  41. VerticalRecommentPanel_1 = VerticalRecommentPanel;
  42. VerticalRecommentPanel.prototype.onLoad = function () {
  43. this._recommendNode = cc.find("Panel/RecommendGamesNode", this.node);
  44. this._recommendNode.active = false;
  45. for (var i = 0; i < this._recommendNode.childrenCount; i++) {
  46. var gameItem = this._recommendNode.children[i].getComponent("GameItem");
  47. this._gameList.push(gameItem);
  48. }
  49. };
  50. VerticalRecommentPanel.prototype.onEnable = function () {
  51. var _this = this;
  52. Utils_1.utils.registerServerInitEvent(function () {
  53. _this._initWidget();
  54. }, this);
  55. };
  56. VerticalRecommentPanel.prototype.onDisable = function () {
  57. Utils_1.utils.unregisterServerInitEvent(this);
  58. };
  59. VerticalRecommentPanel.prototype._initWidget = function () {
  60. if (this._isInit)
  61. return;
  62. var valid = true;
  63. if (Utils_1.utils.isVerticalRecommentPanel()) {
  64. if (PlatUtils_1.default.IsDouyin) {
  65. if (!Utils_1.utils.Tool_Douyin.isShowMoreGamesModal()) {
  66. this.node.destroy();
  67. }
  68. }
  69. this._data = Utils_1.utils.getRecommondGameList();
  70. if (this.node.parent.getComponentsInChildren(VerticalRecommentPanel_1).length > 1) {
  71. var temp = [];
  72. for (var i = this._data.length - 1; i >= 0; i--) {
  73. temp.push(this._data[i]);
  74. }
  75. this._data = temp;
  76. }
  77. if (this._data) {
  78. if (this._data.length > 0) {
  79. this._isInit = true;
  80. this._initData();
  81. this._recommendNode.active = true;
  82. this.schedule(this._initData, 3);
  83. }
  84. else {
  85. console.warn("交叉推广数据长度为0");
  86. valid = false;
  87. }
  88. }
  89. else {
  90. console.warn("交叉推广数据为null!");
  91. valid = false;
  92. }
  93. }
  94. if (!valid) {
  95. this.node.destroy();
  96. }
  97. };
  98. VerticalRecommentPanel.prototype._initData = function () {
  99. var _this = this;
  100. this._gameList.forEach(function (gameItem) {
  101. if (_this._curIndex > _this._data.length - 1) {
  102. _this._curIndex = 0;
  103. }
  104. gameItem.init(_this._data[_this._curIndex], YZ_Constant_1.SubLocation.isVerticalPanel);
  105. var duration = 0.03;
  106. if (CompatibleTool_1.default.engineVersion >= 220) {
  107. // let action = cc.repeat(cc.sequence(cc.rotateTo(duration, 85), cc.rotateTo(duration, 90), cc.rotateTo(duration, 95), cc.rotateTo(duration, 90)), 5);
  108. // gameItem.node.runAction(action);
  109. //@ts-ignore
  110. cc.tween(gameItem.node)
  111. //@ts-ignore
  112. .repeat(5, cc.tween()
  113. .to(duration, { angle: 85 })
  114. .to(duration, { angle: 90 })
  115. .to(duration, { angle: 95 })
  116. .to(duration, { angle: 90 }))
  117. .start();
  118. }
  119. else {
  120. var action = cc.repeat(cc.sequence(cc.rotateTo(duration, -85), cc.rotateTo(duration, -90), cc.rotateTo(duration, -95), cc.rotateTo(duration, -90)), 5);
  121. gameItem.node.runAction(action);
  122. }
  123. _this._curIndex++;
  124. });
  125. };
  126. var VerticalRecommentPanel_1;
  127. VerticalRecommentPanel = VerticalRecommentPanel_1 = __decorate([
  128. ccclass
  129. ], VerticalRecommentPanel);
  130. return VerticalRecommentPanel;
  131. }(cc.Component));
  132. exports.default = VerticalRecommentPanel;
  133. cc._RF.pop();