737dc49d-6936-4825-87a6-3caa80cda8d1.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. "use strict";
  2. cc._RF.push(module, '737dcSdaTZIJYemPKqAzajR', 'AdAgentHago');
  3. // common-plugin/Scripts/AdAgentHago.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 AdAgent_1 = require("./AdAgent");
  26. var YZ_Constant_1 = require("./YZ_Constant");
  27. var PlatUtils_1 = require("./PlatUtils");
  28. var Utils_1 = require("./Utils");
  29. // const i18n = require('LanguageData');
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var AdAgentHago = /** @class */ (function (_super) {
  32. __extends(AdAgentHago, _super);
  33. function AdAgentHago() {
  34. var _this = _super !== null && _super.apply(this, arguments) || this;
  35. _this._sysData = null;
  36. _this._bannerAd = null;
  37. _this._videoAd = null;
  38. _this._videoCallback = null;
  39. _this._isVideoShow = false;
  40. _this._isVideoLoaded = false;
  41. //@ts-ignore
  42. _this.hg = window.hg;
  43. _this.canShowVideo = false;
  44. return _this;
  45. }
  46. AdAgentHago.prototype.Init = function () {
  47. if (PlatUtils_1.default.IsHago) {
  48. this.initVideoAd();
  49. Utils_1.utils.showLog("hago 平台广告初始化成功!");
  50. }
  51. };
  52. AdAgentHago.prototype.ShowBanner = function (location, args) {
  53. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  54. if (args === void 0) { args = null; }
  55. Utils_1.utils.showLog("Hago平台没有banner广告!");
  56. };
  57. /**
  58. * 显示结算广告
  59. * @param data 参数: closeBtn:
  60. * statement_type
  61. * 1:只显示小游戏插屏广告
  62. * 2:只显示6个互推广告
  63. * 3:显示插屏广告+6个互推
  64. */
  65. AdAgentHago.prototype.showStatementAds = function () {
  66. var result = { "type": 0, "node": null };
  67. var node = null;
  68. var resType = 0;
  69. Utils_1.utils.showLog("结算广告 >> 显示插屏广告+6个互推");
  70. this.ShowInterstitial();
  71. node = Utils_1.utils.showCrossWidget6();
  72. resType = 1;
  73. result.type = resType;
  74. result.node = node;
  75. return result;
  76. };
  77. AdAgentHago.prototype.initVideoAd = function () {
  78. var _this = this;
  79. this._videoAd = this.hg.createRewardedVideoAd({
  80. adUnitId: parseInt(Utils_1.utils.config.hagoConfig.videoId) //测试使用9999,上线前必须申请独立的,否则无法分成! 注意:要下载最新的app测试版本9999才能生效。
  81. });
  82. this._videoAd.onClose = function (res) {
  83. if (res.isEnded) {
  84. _this._videoCallback(true);
  85. _this._videoCallback = null;
  86. }
  87. else {
  88. if (_this._videoCallback) {
  89. _this._videoCallback(false, i18n.t('ad.video_not_played_complete'));
  90. _this._videoCallback = null;
  91. }
  92. }
  93. };
  94. //中途关闭广告或者拉去广告失败。
  95. this._videoAd.onError = function () {
  96. if (_this._videoCallback) {
  97. _this._videoCallback(false, i18n.t('ad.video_load_fail'));
  98. _this._videoCallback = null;
  99. }
  100. };
  101. };
  102. AdAgentHago.prototype.HideBanner = function (location) {
  103. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  104. };
  105. AdAgentHago.prototype.ShowInterstitial = function (location) {
  106. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  107. console.warn("Hago没有插屏");
  108. };
  109. AdAgentHago.prototype.ShowVideo = function (callback) {
  110. if (PlatUtils_1.default.IsHago) {
  111. // 视频广告
  112. if (this._videoCallback) {
  113. return;
  114. }
  115. this._videoCallback = callback;
  116. if (!this._videoAd) {
  117. this.initVideoAd();
  118. }
  119. this._videoAd.show().then(function () {
  120. Utils_1.utils.showLog("video show success");
  121. });
  122. }
  123. };
  124. AdAgentHago = __decorate([
  125. ccclass
  126. ], AdAgentHago);
  127. return AdAgentHago;
  128. }(AdAgent_1.default));
  129. exports.default = AdAgentHago;
  130. cc._RF.pop();