54f949f5-25b4-4a66-9bd8-2a53ace13f20.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. "use strict";
  2. cc._RF.push(module, '54f94n1JbRKZpvYKlOs4T8g', 'RewardShortCutPanel');
  3. // common-plugin/Scripts/RewardShortCutPanel.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. /**
  30. * 分享录屏面板
  31. */
  32. var RewardShortCutPanel = /** @class */ (function (_super) {
  33. __extends(RewardShortCutPanel, _super);
  34. function RewardShortCutPanel() {
  35. var _this = _super !== null && _super.apply(this, arguments) || this;
  36. _this.bg = null;
  37. _this.btnOk = null;
  38. _this.btnCancel = null;
  39. _this.glodNode = null;
  40. _this.glodLabel = null;
  41. /**
  42. * 奖励回调
  43. */
  44. _this.rewardCallFunc = null;
  45. /**
  46. * 奖励值
  47. */
  48. _this.rewardValue = 0;
  49. _this._showBanner = false;
  50. return _this;
  51. // update (dt) {}
  52. }
  53. RewardShortCutPanel.prototype.onLoad = function () {
  54. Utils_1.utils.SendEvent("结算前广告-创建快捷桌面-展示成功!");
  55. var shortcutCreated = false;
  56. if (PlatUtils_1.default.IsOPPO) {
  57. shortcutCreated = Utils_1.utils.oppoTool._shortcutCreated;
  58. }
  59. else if (PlatUtils_1.default.IsVIVO) {
  60. shortcutCreated = Utils_1.utils.Tool_Vivo._shortcutCreated;
  61. }
  62. if (shortcutCreated) {
  63. Utils_1.utils.showLog("已经存在桌面快捷方式,当前窗口直接销毁!");
  64. Utils_1.utils.SendEvent("结算前广告-创建快捷桌面-已经存在桌面快捷方式!");
  65. this.node.destroy();
  66. return;
  67. }
  68. // cc.log(`utils.ServerConfig.auto_desktop>${utils.ServerConfig.auto_desktop === 0},${utils.ServerConfig.auto_desktop == 0}<`);
  69. if (Utils_1.utils.ServerConfig.auto_desktop != undefined && Utils_1.utils.ServerConfig.auto_desktop === 0) {
  70. Utils_1.utils.showLog("服务器配置直接创建桌面,不显示弹窗,当前窗口直接销毁!");
  71. Utils_1.utils.SendEvent("结算前广告-创建快捷桌面-服务器配置直接创建桌面,不显示弹窗!");
  72. Utils_1.utils.cur_tool && Utils_1.utils.cur_tool.createShortcut && Utils_1.utils.cur_tool.createShortcut(function (res) {
  73. Utils_1.utils.SendEvent("结算前广告-直接创建快捷桌面-创建成功!");
  74. });
  75. this.node.destroy();
  76. return;
  77. }
  78. this.rewardValue = Utils_1.utils.rewardValue;
  79. this.rewardCallFunc = Utils_1.utils.rewardCallFunc;
  80. this.initUi();
  81. this.initListener();
  82. if (cc.winSize.height < cc.winSize.width) {
  83. Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Game);
  84. }
  85. else {
  86. this._showBanner = true;
  87. Utils_1.utils.adManager.ShowBanner(YZ_Constant_1.BannerLocation.Game);
  88. }
  89. };
  90. /**
  91. * 初始化UI
  92. */
  93. RewardShortCutPanel.prototype.initUi = function () {
  94. if (Utils_1.utils.otherConfig && Utils_1.utils.otherConfig.group) {
  95. this.node.group = Utils_1.utils.otherConfig.group;
  96. }
  97. this.bg = this.node.getChildByName("Panel").children[0];
  98. this.btnCancel = this.bg.getChildByName("btnClose");
  99. this.btnOk = this.bg.getChildByName("btnOk");
  100. this.glodNode = this.bg.getChildByName("rewardLabel");
  101. this.glodLabel = this.glodNode.getComponent(cc.Label);
  102. this.glodLabel.string = "奖励+" + this.rewardValue;
  103. if (this.rewardValue == 0) {
  104. this.glodNode.active = false;
  105. }
  106. Utils_1.utils.showSkipBtn(this.btnCancel);
  107. };
  108. RewardShortCutPanel.prototype.onDestroy = function () {
  109. this._showBanner && Utils_1.utils.adManager.HideBanner(YZ_Constant_1.BannerLocation.Game);
  110. if (Utils_1.utils.rewardShortCutPanelCloseFunc) {
  111. Utils_1.utils.rewardShortCutPanelCloseFunc();
  112. Utils_1.utils.rewardShortCutPanelCloseFunc = null;
  113. ;
  114. }
  115. else {
  116. Utils_1.utils.rewardCloseFunc && Utils_1.utils.rewardCloseFunc();
  117. Utils_1.utils.rewardCloseFunc = null;
  118. }
  119. Utils_1.utils.cur_tool && Utils_1.utils.cur_tool.checkHasShortCut && Utils_1.utils.cur_tool.checkHasShortCut();
  120. };
  121. RewardShortCutPanel.prototype.onClose = function () {
  122. var _this = this;
  123. this.bg.runAction(cc.sequence(cc.scaleTo(0.3, 0).easing(cc.easeBackIn()), cc.callFunc(function () {
  124. _this.node.destroy();
  125. })));
  126. };
  127. RewardShortCutPanel.prototype.onEnable = function () {
  128. var _this = this;
  129. this.bg.scale = 0;
  130. var ratio = 1;
  131. if (cc.winSize.height < cc.winSize.width) {
  132. // 横屏游戏
  133. ratio = cc.winSize.width / 1920 * 0.6;
  134. }
  135. else {
  136. ratio = cc.winSize.width / 1080;
  137. }
  138. this.bg.runAction(cc.sequence(cc.scaleTo(0.3, ratio).easing(cc.easeBackOut()), cc.callFunc(function () {
  139. _this.btnOk.runAction(cc.sequence(cc.scaleTo(0.5, 1.15), cc.scaleTo(0.5, 1)).repeatForever());
  140. })));
  141. };
  142. RewardShortCutPanel.prototype.onCreateShortCut = function () {
  143. var _this = this;
  144. if (PlatUtils_1.default.IsOPPO) {
  145. Utils_1.utils.oppoTool.createShortcut(function (res) {
  146. Utils_1.utils.SendEvent("结算前广告-创建快捷桌面-创建成功!");
  147. _this.rewardFunc(res);
  148. });
  149. }
  150. else if (PlatUtils_1.default.IsVIVO) {
  151. Utils_1.utils.Tool_Vivo.createShortcut(function (res) {
  152. Utils_1.utils.SendEvent("结算前广告-创建快捷桌面-创建成功!");
  153. _this.rewardFunc(res);
  154. });
  155. }
  156. };
  157. /**
  158. * 初始化监听事件
  159. */
  160. RewardShortCutPanel.prototype.initListener = function () {
  161. };
  162. /**
  163. * 分享回调
  164. * @param ret
  165. * @param msg
  166. */
  167. RewardShortCutPanel.prototype.rewardFunc = function (ret) {
  168. if (ret) {
  169. var result = new YZ_Constant_1.YZ_Reward();
  170. result.rewardValue = this.rewardValue;
  171. Utils_1.utils.showMsg("添加成功!奖励:+" + this.rewardValue);
  172. if (this.rewardCallFunc) {
  173. this.rewardCallFunc(result);
  174. }
  175. this.onClose();
  176. }
  177. else {
  178. Utils_1.utils.showMsg("添加失败!");
  179. this.onClose();
  180. }
  181. };
  182. /**
  183. * 初始化数据
  184. */
  185. RewardShortCutPanel.prototype.initData = function () {
  186. };
  187. RewardShortCutPanel = __decorate([
  188. ccclass
  189. ], RewardShortCutPanel);
  190. return RewardShortCutPanel;
  191. }(cc.Component));
  192. exports.default = RewardShortCutPanel;
  193. cc._RF.pop();