7baa97d6-a1d2-4a6e-8ba9-02d7c1bcb9c6.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. "use strict";
  2. cc._RF.push(module, '7baa9fWodJKboupAtfBvLnG', 'YZ_GameExitDialog');
  3. // common-plugin/Scripts/YZ_GameExitDialog.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 _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  28. var YZ_GameExitDialog = /** @class */ (function (_super) {
  29. __extends(YZ_GameExitDialog, _super);
  30. function YZ_GameExitDialog() {
  31. var _this = _super !== null && _super.apply(this, arguments) || this;
  32. _this._jumpList = null;
  33. _this._items = [];
  34. _this._pageView = null;
  35. _this._pageItem = null;
  36. _this._pageRecItem = null;
  37. _this._btnCanel = null;
  38. _this._btnOk = null;
  39. _this._panel = null;
  40. _this.nativeData = null;
  41. _this._nativeIsShow = false;
  42. return _this;
  43. }
  44. YZ_GameExitDialog.prototype.onLoad = function () {
  45. this._panel = this.node.getChildByName("Panel");
  46. this._pageView = this._panel.getChildByName("PageView").getComponent(cc.PageView);
  47. this._pageItem = this._pageView.content.getChildByName("Panel");
  48. this._pageRecItem = this._pageItem.children[0];
  49. this._pageView.content.removeAllChildren();
  50. this._btnCanel = this._panel.getChildByName("btnCancel");
  51. this._btnOk = this._panel.getChildByName("btnOk");
  52. if (Utils_1.utils.otherConfig && Utils_1.utils.otherConfig.group) {
  53. this.node.group = Utils_1.utils.otherConfig.group;
  54. }
  55. var ratio = 1;
  56. if (cc.winSize.height < cc.winSize.width) {
  57. // 横屏游戏
  58. ratio = cc.winSize.width / 1920 * 0.7;
  59. }
  60. else {
  61. ratio = cc.winSize.width / 1080;
  62. }
  63. this._panel.scale = ratio;
  64. };
  65. YZ_GameExitDialog.prototype.start = function () {
  66. this._jumpList = Utils_1.utils.getRecommondGameList();
  67. if (this._jumpList && this._jumpList.length > 0) {
  68. this._initWidget();
  69. }
  70. };
  71. YZ_GameExitDialog.prototype.hideLastNode = function () {
  72. for (var i = 5; i > 2; i--) {
  73. this._items[i].node.active = false;
  74. }
  75. };
  76. YZ_GameExitDialog.prototype.onBtnCanelHandler = function (event, data) {
  77. Utils_1.utils.showLog("点击取消按钮!");
  78. this.node.destroy();
  79. };
  80. YZ_GameExitDialog.prototype.onBtnOkHandler = function (event, data) {
  81. Utils_1.utils.showLog("点击确定按钮!");
  82. Utils_1.utils.Tool_Native.GameExit();
  83. };
  84. YZ_GameExitDialog.prototype._initWidget = function () {
  85. Utils_1.utils.postRecommentShowData(YZ_Constant_1.SubLocation.isGameExitDialog);
  86. var totalPage = Math.floor(this._jumpList.length / 6);
  87. // utils.showLog(`qcrosswidget >>> totalPage = ${totalPage}`);
  88. Utils_1.utils.showLog("qcrosswidget >>> totalPage = " + totalPage);
  89. var indx = 0;
  90. for (var i = 0; i < totalPage; i++) {
  91. var page = cc.instantiate(this._pageItem);
  92. page.removeAllChildren();
  93. this._pageView.addPage(page);
  94. for (var j = 0; j < 6; j++) {
  95. if (!this._jumpList[indx])
  96. break;
  97. var tempNode = cc.instantiate(this._pageRecItem);
  98. page.addChild(tempNode);
  99. var qcrossWidgetItem = tempNode.getComponent("QCrossWidgetItem");
  100. qcrossWidgetItem._location = YZ_Constant_1.SubLocation.isStatement;
  101. var data = this._jumpList[indx];
  102. tempNode.getComponent("QCrossWidgetItem").init(data);
  103. indx++;
  104. }
  105. }
  106. this.autoRefrshPageView();
  107. // let idx: number = 0;
  108. // for (let i = 0; i < this._jumpList.length; i++) {
  109. // let data: any = this._jumpList[i];
  110. // if (data && data.logo) {
  111. // let itemIdx: number = idx;
  112. // if (itemIdx >= this._items.length) {
  113. // return;
  114. // }
  115. // idx++;
  116. // this._items[itemIdx].init(data);
  117. // }
  118. // }
  119. };
  120. YZ_GameExitDialog.prototype.autoRefrshPageView = function () {
  121. var _this = this;
  122. this.unscheduleAllCallbacks();
  123. // utils.showLog(">>>>>>> autoRefrshPageView");
  124. var interval = 3;
  125. if (Utils_1.utils.ServerConfig && Utils_1.utils.ServerConfig.statement_auto_refresh) {
  126. interval = Utils_1.utils.ServerConfig.statement_auto_refresh;
  127. }
  128. Utils_1.utils.showLog("\u9000\u51FA\u5F39\u7A97\u7EC4\u4EF6" + interval + "\u79D2\u81EA\u52A8\u5237\u65B0");
  129. this.schedule(function () {
  130. var count = _this._pageView.getPages().length;
  131. var index = _this._pageView.getCurrentPageIndex();
  132. index = ((index < count) && (index + 1 !== count)) ? (index + 1) : 0;
  133. if (index == 0) {
  134. _this._pageView.scrollToPage(index, 0);
  135. }
  136. else {
  137. _this._pageView.scrollToPage(index, 2);
  138. }
  139. }, interval); //10秒一换
  140. };
  141. YZ_GameExitDialog = __decorate([
  142. ccclass
  143. ], YZ_GameExitDialog);
  144. return YZ_GameExitDialog;
  145. }(cc.Component));
  146. exports.default = YZ_GameExitDialog;
  147. cc._RF.pop();