767ed1f2-fe26-42bb-9717-cee292894cd2.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. "use strict";
  2. cc._RF.push(module, '767edHy/iZCu5cXzuKSiUzS', 'AdAgentKwai');
  3. // common-plugin/Scripts/AdAgentKwai.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. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  30. var AdAgentKwai = /** @class */ (function (_super) {
  31. __extends(AdAgentKwai, _super);
  32. function AdAgentKwai() {
  33. var _this = _super !== null && _super.apply(this, arguments) || this;
  34. _this._sysData = null;
  35. _this._bannerAd = null;
  36. _this._videoAd = null;
  37. _this._videoCallback = null;
  38. _this._isVideoShow = false;
  39. _this._isVideoLoaded = false;
  40. //@ts-ignore
  41. _this.kwaigame = window.kwaigame;
  42. _this.canShowVideo = false;
  43. _this._interstitialAd = null;
  44. return _this;
  45. }
  46. AdAgentKwai.prototype.Init = function () {
  47. var _this = this;
  48. if (PlatUtils_1.default.IsKwai) {
  49. // this.kwaigame.getSystemInfo({
  50. // response: (result) => {
  51. // this._sysData = result;
  52. // utils.showLog("快手>>>获取系统信息:" + JSON.stringify(result));
  53. // }
  54. // });
  55. // utils.showLog(this.kwaigame.isSupport({ feature: this.kwaigame.Support.features.RewardVideo }) + "<<<<<");
  56. // this.canShowVideo = this.kwaigame.isSupport({ feature: this.kwaigame.Support.features.RewardVideo });
  57. // utils.showLog(`当前平台:${this.canShowVideo == true ? "支持" : "不支持"}视频广告!`);
  58. // if (this.canShowVideo) {
  59. Utils_1.utils.registerServerInitEvent(function () {
  60. _this._initVideoAd();
  61. }, this);
  62. // }
  63. }
  64. };
  65. AdAgentKwai.prototype.ShowBanner = function (location, args) {
  66. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  67. if (args === void 0) { args = null; }
  68. Utils_1.utils.showLog("快手平台没有banner广告!");
  69. };
  70. /**
  71. * 显示结算广告
  72. * @param data 参数: closeBtn:
  73. * statement_type
  74. * 1:只显示小游戏插屏广告
  75. * 2:只显示6个互推广告
  76. * 3:显示插屏广告+6个互推
  77. */
  78. AdAgentKwai.prototype.showStatementAds = function () {
  79. var result = { "type": 0, "node": null };
  80. var node = null;
  81. var resType = 0;
  82. Utils_1.utils.showLog("结算广告 >> 显示插屏广告+6个互推");
  83. this.ShowInterstitial();
  84. node = Utils_1.utils.showCrossWidget6();
  85. resType = 1;
  86. result.type = resType;
  87. result.node = node;
  88. return result;
  89. };
  90. AdAgentKwai.prototype.HideBanner = function (location) {
  91. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  92. };
  93. AdAgentKwai.prototype.ShowInterstitial = function (location) {
  94. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  95. Utils_1.utils.showLog("显示快手插屏");
  96. if (Utils_1.utils.config.kwaiConfig.insertId) {
  97. if (!this._interstitialAd) {
  98. this._interstitialAd = this.kwaigame.createInterstitialAd({ adUnitId: Utils_1.utils.config.kwaiConfig.insertId });
  99. this._interstitialAd.onError(function (err) {
  100. Utils_1.utils.showLog("插屏广告显示异常:" + JSON.stringify(err));
  101. });
  102. this._interstitialAd.onClose(function (res) {
  103. Utils_1.utils.showLog("用户点击了【关闭广告】按钮");
  104. });
  105. }
  106. this._interstitialAd && this._interstitialAd.show()
  107. .then(function () { return Utils_1.utils.showLog('插屏 广告显示成功!'); }).catch(function (err) {
  108. Utils_1.utils.showLog("插屏 广告显示失败 >>" + JSON.stringify(err));
  109. });
  110. }
  111. else {
  112. Utils_1.utils.showLog("未配置插屏广告ID");
  113. }
  114. };
  115. AdAgentKwai.prototype.ShowVideo = function (callback) {
  116. var _this = this;
  117. if (PlatUtils_1.default.IsKwai) {
  118. // 视频广告
  119. if (this._videoCallback) {
  120. return;
  121. }
  122. else {
  123. this._videoCallback = callback;
  124. }
  125. this._isVideoShow = true;
  126. if (!this._videoAd) {
  127. this._initVideoAd();
  128. if (this._videoCallback) {
  129. this._videoCallback(false, "激励视频加载失败!");
  130. this._videoCallback = null;
  131. }
  132. }
  133. else {
  134. this._videoAd.show({
  135. success: function () {
  136. Utils_1.utils.showLog("激励视频播放成功");
  137. },
  138. fail: function (error) {
  139. Utils_1.utils.showLog("激励视频播放失败: " + JSON.stringify(error));
  140. if (_this._videoCallback) {
  141. _this._videoCallback(false, "激励视频加载失败!");
  142. _this._videoCallback = null;
  143. }
  144. }
  145. });
  146. }
  147. }
  148. };
  149. AdAgentKwai.prototype._initVideoAd = function () {
  150. var _this = this;
  151. if (!this._videoAd) {
  152. var param = {};
  153. param.adUnitId = Utils_1.utils.config.kwaiConfig.videoId;
  154. this._videoAd = this.kwaigame.createRewardedVideoAd(param);
  155. if (this._videoAd) {
  156. Utils_1.utils.showLog("激励广告组件获取成功!");
  157. this._videoAd.onClose(function (result) {
  158. Utils_1.utils.showLog("激励视频关闭回调: " + JSON.stringify(result));
  159. if (_this._videoCallback) {
  160. _this._videoCallback(false, "视频播放完毕才能够获取奖励!");
  161. _this._videoCallback = null;
  162. }
  163. });
  164. this._videoAd.onReward(function (result) {
  165. Utils_1.utils.showLog("激励视频奖励回调: " + JSON.stringify(result));
  166. if (_this._videoCallback) {
  167. _this._videoCallback(true, "");
  168. _this._videoCallback = null;
  169. }
  170. });
  171. }
  172. else {
  173. Utils_1.utils.showLog("激励广告组件获取失败");
  174. }
  175. }
  176. };
  177. AdAgentKwai = __decorate([
  178. ccclass
  179. ], AdAgentKwai);
  180. return AdAgentKwai;
  181. }(AdAgent_1.default));
  182. exports.default = AdAgentKwai;
  183. cc._RF.pop();