ATInterstitialJS.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. require("./AnyThinkAds/ATInterstitialJSSDK");
  2. require("./AnyThinkAds/ATJSSDK");
  3. var ATInterstitialJS = cc.Class({
  4. name: "ATInterstitialJS",
  5. /** 代理脚本(TS) */
  6. proxy: null,
  7. /** 插屏类型 */
  8. interType: 0,
  9. ctor: function () {
  10. // console.log("ATNativeJS created! ");
  11. },
  12. init: function () {
  13. ATBannerJSSDK.setAdListener(this);
  14. },
  15. /** 广告位id */
  16. placementID: function () {
  17. return this.proxy.placementID(this.interType);
  18. },
  19. /**
  20. * 插屏广告加载
  21. * @param {*} type 0 插屏 1 全屏
  22. */
  23. loadInter: function (type) {
  24. //v5.6.8新增,只针对Sigmob平台,Sigmob的激励视频广告源当做插屏使用
  25. var setting = {};
  26. setting[ATInterstitialJSSDK.UseRewardedVideoAsInterstitial] = false;
  27. this.interType = type
  28. ATInterstitialJSSDK.setAdListener(this);
  29. //setting[ATInterstitialJSSDK.UseRewardedVideoAsInterstitial] = true;
  30. if (this.interType == 0) {
  31. ATInterstitialJSSDK.loadInterstitial(this.placementID(), setting);
  32. // ATInterstitialJSSDK.showAd(this.interPlacementId);
  33. }
  34. else if (this.interType == 1) {
  35. ATInterstitialJSSDK.loadInterstitial(this.placementID(), setting);
  36. // ATInterstitialJSSDK.showAd(this.fullInterPlacementId);
  37. }
  38. },
  39. /**
  40. * 检查插屏是否加载成功
  41. * @param {*} type 0 插屏 1 全屏
  42. * @returns
  43. */
  44. checkInterReady: function (type) {
  45. if (this.proxy == null) return;
  46. if (type == 0) {
  47. return ATInterstitialJSSDK.hasAdReady(this.placementID()) ? true : false;
  48. }
  49. else if (type == 1) {
  50. return ATInterstitialJSSDK.hasAdReady(this.placementID()) ? true : false;
  51. }
  52. },
  53. /**
  54. * 显示插屏
  55. * @param {*} type 0 插屏 1 全屏
  56. */
  57. showInter: function (type) {
  58. if (type == 0) {
  59. ATInterstitialJSSDK.showAd(this.placementID());
  60. }
  61. else if (type == 1) {
  62. ATInterstitialJSSDK.showAd(this.placementID());
  63. }
  64. },
  65. /**
  66. * 插屏广告加载成功
  67. * @param {*} placementId 广告位Id
  68. * @returns
  69. */
  70. onInterstitialAdLoaded: function (placementId) {
  71. //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdLoaded(" + placementId + ")");
  72. if (this.proxy == null) return;
  73. this.proxy.onInterstitialAdLoaded(placementId);
  74. },
  75. /**
  76. * 插屏广告加载失败
  77. * @param {*} placementId 广告位Id
  78. * @param {*} errorInfo 错误信息
  79. * @returns
  80. */
  81. onInterstitialAdLoadFail: function (placementId, errorInfo) {
  82. //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdLoadFail(" + placementId + ", " + errorInfo + ")");
  83. if (this.proxy == null) return;
  84. this.proxy.onInterstitialAdLoadFail(placementId, errorInfo);
  85. },
  86. /**
  87. * 插屏广告显示成功
  88. * @param {*} placementId 广告位id
  89. * @param {*} callbackInfo 回调信息
  90. * @returns
  91. */
  92. onInterstitialAdShow: function (placementId, callbackInfo) {
  93. //ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdShow(" + placementId + ", " + callbackInfo + ")");
  94. if (this.proxy == null) return;
  95. this.proxy.onInterstitialAdShow(placementId, callbackInfo);
  96. },
  97. //广告视频开始播放,部分平台有此回调
  98. /**
  99. * 插屏广告开始播放视屏,部分广告平台有此回调
  100. * @param {*} placementId 广告位id
  101. * @param {*} callbackInfo 回调信息
  102. */
  103. onInterstitialAdStartPlayingVideo: function (placementId, callbackInfo) {
  104. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdStartPlayingVideo(" + placementId + ", " + callbackInfo + ")");
  105. },
  106. /**
  107. * 插屏广告视频播放结束,部分广告平台有此回调
  108. * @param {*} placementId 广告位id
  109. * @param {*} callbackInfo 回调信息
  110. */
  111. onInterstitialAdEndPlayingVideo: function (placementId, callbackInfo) {
  112. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdEndPlayingVideo(" + placementId + ", " + callbackInfo + ")");
  113. },
  114. /**
  115. * 插屏广告视频播放失败,部分广告平台有此回调
  116. * @param {*} placementId 广告位id
  117. * @param {*} errorInfo 错误回调
  118. */
  119. onInterstitialAdFailedToPlayVideo: function (placementId, errorInfo) {
  120. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToPlayVideo(" + placementId + ", " + errorInfo + ")");
  121. },
  122. /**
  123. * 插屏广告显示失败
  124. * @param {*} placementId 广告位id
  125. */
  126. onInterstitialAdFailedToShow: function (placementId) {
  127. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdFailedToShow(" + placementId + ")");
  128. },
  129. /**
  130. * 广告被关闭
  131. * @param {*} placementId 广告位id
  132. * @param {*} callbackInfo 回调信息
  133. * @returns
  134. */
  135. onInterstitialAdClose: function (placementId, callbackInfo) {
  136. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdClose(" + placementId + ", " + callbackInfo + ")");
  137. if (this.proxy == null) return;
  138. this.proxy.onInterstitialAdClose(placementId, callbackInfo);
  139. },
  140. /**
  141. * 广告被点击
  142. * @param {*} placementId 广告位id
  143. * @param {*} callbackInfo 回调信息
  144. * @returns
  145. */
  146. onInterstitialAdClick: function (placementId, callbackInfo) {
  147. // ATJSSDK.printLog("AnyThinkInterstitialDemo::onInterstitialAdClick(" + placementId + ", " + callbackInfo + ")");
  148. if (this.proxy == null) return;
  149. this.proxy.onInterstitialAdClick(placementId, callbackInfo);
  150. }
  151. });
  152. module.exports = ATInterstitialJS;
  153. if (!cc["ATInterstitialJS"]) {
  154. cc["ATInterstitialJS"] = new ATInterstitialJS();
  155. }