50d79089-59a9-45d1-8680-2afb4ffb22ea.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. "use strict";
  2. cc._RF.push(module, '50d79CJWalF0YaAKvtP+yLq', 'AdAgent4399');
  3. // common-plugin/Scripts/AdAgent4399.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 PlatUtils_1 = require("./PlatUtils");
  27. var Utils_1 = require("./Utils");
  28. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  29. /**
  30. * uc广告组件
  31. */
  32. var AdAgent4399 = /** @class */ (function (_super) {
  33. __extends(AdAgent4399, _super);
  34. function AdAgent4399() {
  35. var _this = _super !== null && _super.apply(this, arguments) || this;
  36. _this._videoCallback = null;
  37. _this._isVideoLoaded = false;
  38. _this._videoAd = null;
  39. //@ts-ignore
  40. _this._4399 = window.h5api;
  41. _this._canPlayAd = true;
  42. _this._remain = 0;
  43. return _this;
  44. }
  45. AdAgent4399.prototype.Init = function () {
  46. this.checkPlayAd();
  47. };
  48. /**
  49. * 获得是否可以播放广告及剩余次数
  50. */
  51. AdAgent4399.prototype.checkPlayAd = function () {
  52. this._canPlayAd = true;
  53. return;
  54. // this._4399.canPlayAd((data: any) => {
  55. // if (data.canPlayAd) {
  56. // this._canPlayAd = data.canPlayAd;
  57. // } else {
  58. // this._canPlayAd = false;
  59. // }
  60. // if (data.remain) {
  61. // this._remain = data.remain;
  62. // }
  63. // utils.showLog("是否可播放广告", data.canPlayAd, "剩余次数", data.remain)
  64. // })
  65. };
  66. AdAgent4399.prototype.ShowBanner = function () {
  67. Utils_1.utils.showLog("4399平台暂无banner广告");
  68. };
  69. AdAgent4399.prototype.ShowInterstitial = function () {
  70. Utils_1.utils.showLog("4399平台暂时无插屏广告");
  71. };
  72. /**
  73. * 播放全屏广告
  74. * @param callback 播放广告时的广告状态回调函数
  75. */
  76. AdAgent4399.prototype.ShowVideo = function (callback) {
  77. var _this = this;
  78. if (PlatUtils_1.default.Is4399) {
  79. this._videoCallback = callback;
  80. if (this._canPlayAd) {
  81. this._4399.playAd(function (obj) {
  82. Utils_1.utils.showLog('代码:' + obj.code + ',消息:' + obj.message);
  83. if (obj.code === 10000) {
  84. Utils_1.utils.showLog('视频开始播放');
  85. }
  86. else if (obj.code === 10001) {
  87. Utils_1.utils.showLog('视频播放结束');
  88. if (_this._videoCallback) {
  89. _this._videoCallback(true, "");
  90. _this._videoCallback = null;
  91. }
  92. _this.checkPlayAd();
  93. }
  94. else {
  95. if (_this._videoCallback) {
  96. _this._videoCallback(false, "激励视频异常!");
  97. _this._videoCallback = null;
  98. }
  99. _this.checkPlayAd();
  100. Utils_1.utils.showLog('视频广告异常');
  101. }
  102. });
  103. }
  104. else {
  105. Utils_1.utils.showLog('4399获取到不能播放广告! #this._canPlayAd=', this._canPlayAd, "剩余次数", this._remain);
  106. if (this._videoCallback) {
  107. this._videoCallback(false, "今日次数用完,明天再来!");
  108. this._videoCallback = null;
  109. }
  110. this.checkPlayAd();
  111. }
  112. }
  113. };
  114. AdAgent4399 = __decorate([
  115. ccclass
  116. ], AdAgent4399);
  117. return AdAgent4399;
  118. }(AdAgent_1.default));
  119. exports.default = AdAgent4399;
  120. cc._RF.pop();