614839fd-36e0-4f45-a79d-6188a6e4bedf.js 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212
  1. "use strict";
  2. cc._RF.push(module, '61483n9NuBPRaedYYim5L7f', 'AdAgentOPPO');
  3. // common-plugin/Scripts/AdAgentOPPO.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 YZ_NativeAdObject_1 = require("./YZ_NativeAdObject");
  30. var NativeTryGamesWidget_1 = require("./NativeTryGamesWidget");
  31. var CompatibleTool_1 = require("./CompatibleTool");
  32. var YouWanAnalytics_1 = require("./YouWanSDK/YouWanAnalytics");
  33. var EventAdInfo_1 = require("./YouWanSDK/EventAdInfo");
  34. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  35. var AdAgentOPPO = /** @class */ (function (_super) {
  36. __extends(AdAgentOPPO, _super);
  37. function AdAgentOPPO() {
  38. var _this = _super !== null && _super.apply(this, arguments) || this;
  39. _this._bannerAd = null;
  40. _this._insertAd = null;
  41. _this._videoAd = null;
  42. _this._nativeBannerAd = [];
  43. _this._nativeInsertAd = [];
  44. _this._nativeSingleAd = [];
  45. _this._nativeAd = null;
  46. // 广告组件是否初始化成功
  47. _this._isAdInit = false;
  48. _this._isBannerShow = false;
  49. _this._isInsertShow = false;
  50. // 当前位置id的索引
  51. _this._curPosIdIndexNativeBanner = 0;
  52. _this._curPosIdIndexNativeInser = 0;
  53. _this._curPosIdIndexSingleNative = 0;
  54. _this._nativeData = null;
  55. _this._nativeInsertData = null;
  56. _this._nativeBannerNode = null;
  57. _this._nativeInsertNode = null;
  58. _this._videoCallback = null;
  59. _this._videoLoaded = null;
  60. _this._miniBannerHeight = 0;
  61. _this._showBannerCallBack = null;
  62. _this._nativeAdObject = null;
  63. //插屏显示次数
  64. _this._insertShowCount = 0;
  65. _this._insertLastShowTime = 0;
  66. _this._curNativeItem = null;
  67. _this._isNativeBannerShow = false; //原生广告展示,调用的隐藏
  68. _this.lastLastShowVideoTime = 0; //最后一次显示视频时间
  69. _this._bannerHideCount = 0;
  70. _this.canShowNativeBanner = true; //原生banner是否展示
  71. _this._nativeBannerInfo = null;
  72. _this.show_ad_by_config = true;
  73. _this._nativeIsClose = false;
  74. _this._showBannerTimerId = 0;
  75. _this._delayShowBannerId = 0;
  76. // nbclr:是否开启强制刷新
  77. //当前显示Banner的位置
  78. _this._curLocation = YZ_Constant_1.BannerLocation.None;
  79. _this._isTimeRefresh = false;
  80. //启动定时器的时间
  81. _this._startBannerTimerTask = 0;
  82. _this._showBannerCount = 0;
  83. _this.tryGameAdArr = [];
  84. _this._nativeInsertAdShowCount = 0;
  85. /**
  86. * 验证是否第一次创建插屏
  87. */
  88. _this.miniInserAdIsCreate = false;
  89. _this._curNativeBannerInfo = {};
  90. _this._singleAdCreateTime = 0;
  91. _this._rewardInsertNode = null;
  92. _this.signleNativeAd = null;
  93. _this._nativeTryGameNode = null;
  94. _this.nativeTemplateBannerAd = null;
  95. return _this;
  96. }
  97. Object.defineProperty(AdAgentOPPO.prototype, "ServerConfig", {
  98. get: function () {
  99. if (Utils_1.utils.oppoTool && Utils_1.utils.oppoTool.ServerConfig)
  100. return Utils_1.utils.oppoTool.ServerConfig;
  101. return {};
  102. },
  103. enumerable: false,
  104. configurable: true
  105. });
  106. /**
  107. * 获取当前banner配置
  108. */
  109. AdAgentOPPO.prototype.getNativeBannerInfo = function () {
  110. if (this._nativeBannerInfo && this._nativeBannerInfo.location == this._curLocation) {
  111. return this._nativeBannerInfo;
  112. }
  113. return Utils_1.utils.config.oppoconfig.getNativeBannerInfo(this._curLocation);
  114. };
  115. AdAgentOPPO.prototype.Init = function () {
  116. var _this = this;
  117. if (PlatUtils_1.default.IsOPPO && Utils_1.utils.oppoTool && Utils_1.utils.oppoTool.isOverMiniVersion("1031")) {
  118. Utils_1.utils.registerServerInitEvent(function () {
  119. Utils_1.utils.showLog("OPPO 广告代理组件初始化!");
  120. var self = _this;
  121. //@ts-ignore
  122. qg.initAdService({
  123. appId: Utils_1.utils.config.oppoconfig.appID,
  124. isDebug: true,
  125. success: function (res) {
  126. Utils_1.utils.showLog("OPPO 小游戏广告组件初始化成功!");
  127. self._isAdInit = true;
  128. self._initVideoAd();
  129. },
  130. fail: function (res) {
  131. Utils_1.utils.showLog("OPPO 小游戏广告组件初始化失败 :" + res.code + res.msg);
  132. },
  133. complete: function (res) {
  134. }
  135. });
  136. }, this);
  137. }
  138. };
  139. AdAgentOPPO.prototype.ShowBanner = function (location, args, isTimeRefresh) {
  140. var _this = this;
  141. if (location === void 0) { location = null; }
  142. if (args === void 0) { args = null; }
  143. if (isTimeRefresh === void 0) { isTimeRefresh = false; }
  144. if (PlatUtils_1.default.IsOPPO) {
  145. if (!this.ServerConfig) {
  146. Utils_1.utils.showLog("未请求到配置文件!");
  147. return;
  148. }
  149. this._showBannerCount++;
  150. var oldLocation = this._curLocation;
  151. this._curLocation = location;
  152. this._isTimeRefresh = isTimeRefresh;
  153. //如果跳用位置切换之后,验证是不是通过定时器强制刷新数据,不是则先隐藏banner
  154. if (oldLocation != location) {
  155. this.HideBanner(location);
  156. }
  157. var curTime = new Date().getTime();
  158. var refresh_ad_time = (curTime - this._startBannerTimerTask) / 1000;
  159. var interval_1 = this.ServerConfig.refresh_ad_time;
  160. // utils.showLog("isTimeRefresh=" + isTimeRefresh);
  161. if (args && args.isRefresh) {
  162. isTimeRefresh = true;
  163. }
  164. else if (interval_1 && interval_1 > 0) {
  165. if (refresh_ad_time > interval_1) {
  166. isTimeRefresh = true;
  167. }
  168. }
  169. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST);
  170. // utils.showLog("isTimeRefresh=" + isTimeRefresh);
  171. // 判断当前位置是不是显示banner
  172. if (this.getNativeBannerInfo().is_show_banner == -1) {
  173. Utils_1.utils.showLog("当前位置配置为不展示banner!");
  174. this.HideBanner(location);
  175. return;
  176. }
  177. else if (this.getNativeBannerInfo().is_show_rec > -1) {
  178. this.HideBanner(location);
  179. Utils_1.utils.showLog("当前位置显示互推banner");
  180. if (Utils_1.utils.oppoTool.canShowRecommend()) {
  181. Utils_1.utils.oppoTool.showOppoRecBanner();
  182. return;
  183. }
  184. Utils_1.utils.showLog("当前平台不支持互推banner");
  185. }
  186. else {
  187. if (!isTimeRefresh && !this.show_ad_by_config) {
  188. if (this.ServerConfig.nbclr && this.ServerConfig.nbclr == "true" && this._curNativeBannerInfo.nativeBannerAd) {
  189. Utils_1.utils.showLog("服务器配置定时器刷新数据 ");
  190. Utils_1.utils.showLog("\u539F\u751Fbanner\u5EF6\u8FDF\u663E\u793A" + this.getNativeBannerInfo().delay_show_time + "\u79D2");
  191. clearTimeout(this._showBannerTimerId);
  192. clearTimeout(this._delayShowBannerId);
  193. //@ts-ignore
  194. this._delayShowBannerId = setTimeout(function () {
  195. _this._showNativeBanner(_this._curNativeBannerInfo.nativeBannerAd, _this._curNativeBannerInfo.data);
  196. }, this.getNativeBannerInfo().delay_show_time * 1000);
  197. Utils_1.utils.showLog("开启定时刷新 >>>>>>>>>" + (interval_1 - refresh_ad_time));
  198. //@ts-ignore
  199. this._showBannerTimerId = setTimeout(function () {
  200. Utils_1.utils.showLog("\u5B9A\u65F6" + interval_1 + "\u79D2\u8C03\u7528showbanner");
  201. _this.ShowBanner(_this._curLocation, {}, true);
  202. }, (interval_1 - refresh_ad_time) * 1000);
  203. return;
  204. }
  205. }
  206. }
  207. this.canShowNativeBanner = true;
  208. this._nativeIsClose = false;
  209. clearTimeout(this._showBannerTimerId);
  210. clearTimeout(this._delayShowBannerId);
  211. Utils_1.utils.showLog("清理定时器");
  212. if (this.ServerConfig) {
  213. if (interval_1 && interval_1 > 0) {
  214. Utils_1.utils.showLog("开启定时刷新 >>>>>>>>>" + interval_1);
  215. //@ts-ignore
  216. this._showBannerTimerId = setTimeout(function () {
  217. Utils_1.utils.showLog("\u5B9A\u65F6" + interval_1 + "\u79D2\u8C03\u7528showbanner");
  218. _this.ShowBanner(_this._curLocation, {}, true);
  219. }, interval_1 * 1000);
  220. }
  221. if (this.show_ad_by_config) {
  222. this.ShowBannerByConfigs(0);
  223. return;
  224. }
  225. if (this.ServerConfig.banner_first_ad) {
  226. if (this.ServerConfig.banner_first_ad.indexOf("native") > -1) {
  227. Utils_1.utils.showLog("优先展示原生Banner广告!" + isTimeRefresh + " <<<<");
  228. if (!this._isTimeRefresh) {
  229. Utils_1.utils.showLog("\u539F\u751Fbanner\u5EF6\u8FDF\u663E\u793A" + this.getNativeBannerInfo().delay_show_time + "\u79D2");
  230. //@ts-ignore
  231. this._delayShowBannerId = setTimeout(function () {
  232. _this._createNativeBannerAd(_this._showNativeBanner);
  233. }, this.getNativeBannerInfo().delay_show_time * 1000);
  234. }
  235. else {
  236. this._createNativeBannerAd(this._showNativeBanner);
  237. }
  238. }
  239. else {
  240. Utils_1.utils.showLog("优先展示小游戏Banner广告!");
  241. this._createMiniGameBannerAd(location);
  242. }
  243. }
  244. else {
  245. Utils_1.utils.showLog("配置数据中没有 banner_first_ad 字段, banner广告不显示!");
  246. }
  247. }
  248. else {
  249. Utils_1.utils.showLog("服务器配置数据未初始化!");
  250. }
  251. }
  252. };
  253. AdAgentOPPO.prototype.hideMiniGameBanner = function () {
  254. if (this._bannerAd) {
  255. if (Utils_1.utils.oppoTool.isOverMiniVersion("1050")) {
  256. Utils_1.utils.showLog("销毁小游戏Banner");
  257. this._bannerAd.destroy();
  258. this._bannerAd = null;
  259. }
  260. else {
  261. Utils_1.utils.showLog("当前小游戏平台小于1051,只能隐藏小游戏Banner");
  262. this._bannerAd.hide();
  263. }
  264. }
  265. };
  266. AdAgentOPPO.prototype.hideNativeBanner = function () {
  267. if (this._nativeBannerNode) {
  268. Utils_1.utils.showLog("隐藏原生Banner");
  269. this._nativeBannerNode.active = false;
  270. }
  271. };
  272. AdAgentOPPO.prototype.hideBanner = function (type) {
  273. switch (type) {
  274. case "default":
  275. this.hideNativeBanner();
  276. //隐藏自定义banner
  277. Utils_1.utils.hideRecommendGamesBanner();
  278. this.hideNativeTemplateBannerAd();
  279. //隐藏互推banner
  280. Utils_1.utils.oppoTool && Utils_1.utils.oppoTool._rec_is_banner && Utils_1.utils.oppoTool.hideOppoRecBanner();
  281. break;
  282. case "native":
  283. this.hideMiniGameBanner();
  284. //隐藏自定义banner
  285. Utils_1.utils.hideRecommendGamesBanner();
  286. this.hideNativeTemplateBannerAd();
  287. //隐藏互推banner
  288. Utils_1.utils.oppoTool && Utils_1.utils.oppoTool._rec_is_banner && Utils_1.utils.oppoTool.hideOppoRecBanner();
  289. break;
  290. case "template":
  291. this.hideMiniGameBanner();
  292. this.hideNativeBanner();
  293. //隐藏自定义banner
  294. Utils_1.utils.hideRecommendGamesBanner();
  295. //隐藏互推banner
  296. Utils_1.utils.oppoTool && Utils_1.utils.oppoTool._rec_is_banner && Utils_1.utils.oppoTool.hideOppoRecBanner();
  297. break;
  298. case "rec":
  299. this.hideMiniGameBanner();
  300. this.hideNativeBanner();
  301. //隐藏自定义banner
  302. Utils_1.utils.hideRecommendGamesBanner();
  303. this.hideNativeTemplateBannerAd();
  304. break;
  305. default:
  306. this.hideMiniGameBanner();
  307. this.hideNativeBanner();
  308. //隐藏自定义banner
  309. Utils_1.utils.hideRecommendGamesBanner();
  310. this.hideNativeTemplateBannerAd();
  311. Utils_1.utils.oppoTool && Utils_1.utils.oppoTool._rec_is_banner && Utils_1.utils.oppoTool.hideOppoRecBanner();
  312. break;
  313. }
  314. };
  315. AdAgentOPPO.prototype.HideBanner = function (location) {
  316. if (location === void 0) { location = null; }
  317. if (PlatUtils_1.default.IsOPPO) {
  318. clearTimeout(this._showBannerTimerId);
  319. clearTimeout(this._delayShowBannerId);
  320. this._isBannerShow = false;
  321. this._nativeIsClose = true;
  322. this.canShowNativeBanner = false;
  323. this.hideBanner("");
  324. }
  325. };
  326. /**
  327. * 隐藏快游戏的banner
  328. */
  329. AdAgentOPPO.prototype.hideKyxBanner = function () {
  330. this.hideBanner("rec");
  331. };
  332. AdAgentOPPO.prototype.showNativeTryGameWidget = function (params) {
  333. if (params === void 0) { params = null; }
  334. if (PlatUtils_1.default.IsOPPO) {
  335. Utils_1.utils.showLog("显示原生抖动试玩 nativeNeedChange=", Utils_1.utils.nativeNeedChange, " utils.tryGameDate", Utils_1.utils.tryGameDate, "utils.config.oppoconfig.nativeTryGameIds", Utils_1.utils.config.oppoconfig.nativeTryGameIds);
  336. if (Utils_1.utils.nativeNeedChange || !Utils_1.utils.tryGameDate) {
  337. if (Utils_1.utils.config.oppoconfig.nativeTryGameIds) {
  338. var len = Utils_1.utils.config.oppoconfig.nativeTryGameIds.length;
  339. Utils_1.utils.showLog("len:" + len);
  340. var _loop_1 = function (i) {
  341. if (!this_1.tryGameAdArr[i]) {
  342. var posId = Utils_1.utils.config.oppoconfig.nativeTryGameIds[i];
  343. Utils_1.utils.showLog("创建原生抖动试玩广告, posId:" + posId);
  344. //@ts-ignore
  345. var tryGameAd_1 = qg.createNativeAd({
  346. posId: posId
  347. });
  348. if (tryGameAd_1) {
  349. tryGameAd_1.onLoad(function (res) {
  350. Utils_1.utils.nativeNeedChange = false;
  351. if (res && res.adList && res.adList.length > 0) {
  352. res = JSON.parse(JSON.stringify(res));
  353. var adId_1 = res.adList[0].adId;
  354. Utils_1.utils.showLog("adId:" + adId_1);
  355. var canAdd_1 = true;
  356. Utils_1.utils.tryGameDate.forEach(function (element) {
  357. if (adId_1 == element.date[0].adId) {
  358. canAdd_1 = false;
  359. }
  360. });
  361. if (canAdd_1) {
  362. Utils_1.utils.tryGameDate.push({ "tryGameAd": tryGameAd_1, "date": res.adList });
  363. if (Utils_1.utils._nativeTryGameNode) {
  364. Utils_1.utils._nativeTryGameNode.getComponent(NativeTryGamesWidget_1.default).init();
  365. }
  366. }
  367. Utils_1.utils.showLog("原生抖动试完广告资源拉取成功,是否可以添加广告" + canAdd_1);
  368. Utils_1.utils.showLog(JSON.stringify(res));
  369. }
  370. });
  371. tryGameAd_1.onError(function (err) {
  372. Utils_1.utils.showLog("原生抖动广告资源拉取失败!" + err.code + err.msg);
  373. Utils_1.utils.nativeNeedChange = true;
  374. });
  375. tryGameAd_1.load();
  376. this_1.tryGameAdArr[i] = tryGameAd_1;
  377. }
  378. }
  379. else {
  380. this_1.tryGameAdArr[i].load();
  381. }
  382. };
  383. var this_1 = this;
  384. for (var i = 0; i < len; i++) {
  385. _loop_1(i);
  386. }
  387. }
  388. }
  389. this.createNativeTryGameWidget(params);
  390. }
  391. };
  392. /**
  393. * 通过配置展示插屏
  394. * @param index 索引
  395. */
  396. AdAgentOPPO.prototype.ShowInterstitialByConfigs = function (index) {
  397. Utils_1.utils.showLog("ShowInterstitialByConfigs index=" + index + " #configsLength=" + Utils_1.utils.config.oppoconfig.intersitialAdConfigs.length);
  398. if (index < Utils_1.utils.config.oppoconfig.intersitialAdConfigs.length) {
  399. var adInfo = Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index];
  400. Utils_1.utils.showLog("ShowInterstitialByConfigs adInfo:" + JSON.stringify(adInfo));
  401. switch (adInfo.type) {
  402. case "default":
  403. this._createMiniGameInsertAdByConfig(index);
  404. break;
  405. case "native":
  406. this._createNativeInsertAdByConfig(index);
  407. break;
  408. case "template":
  409. this._createNativeTemplateIntersitialAd(index);
  410. break;
  411. }
  412. }
  413. else {
  414. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  415. Utils_1.utils.showLog("插屏展示失败,所有广告类型都未请求到广告!");
  416. }
  417. };
  418. /**
  419. * 通过索引展示Banner
  420. * @param index 索引
  421. */
  422. AdAgentOPPO.prototype.ShowBannerByConfigs = function (index) {
  423. Utils_1.utils.showLog("ShowBannerByConfigs index=" + index + " #configsLength=" + Utils_1.utils.config.oppoconfig.bannerAdConfigs.length);
  424. if (index < Utils_1.utils.config.oppoconfig.bannerAdConfigs.length) {
  425. var adInfo = Utils_1.utils.config.oppoconfig.bannerAdConfigs[index];
  426. Utils_1.utils.showLog("ShowBannerByConfigs adInfo:" + JSON.stringify(adInfo));
  427. switch (adInfo.type) {
  428. case "default":
  429. this._createMiniGameBannerAdByConfigs(index);
  430. break;
  431. case "native":
  432. this._createNativeBannerAdByConfigs(index);
  433. break;
  434. case "template":
  435. this._createNativeTemplateBannerAd(index);
  436. break;
  437. }
  438. }
  439. else {
  440. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  441. Utils_1.utils.showLog("Banner展示失败,所有广告类型都未请求到广告!");
  442. }
  443. };
  444. AdAgentOPPO.prototype.ShowInterstitial = function (location) {
  445. if (location === void 0) { location = null; }
  446. if (PlatUtils_1.default.IsOPPO) {
  447. if (this.ServerConfig) {
  448. if (!this.checkInsertAdShow())
  449. return;
  450. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST);
  451. if (this.show_ad_by_config) {
  452. this.ShowInterstitialByConfigs(0);
  453. return;
  454. }
  455. if (location && location == YZ_Constant_1.BannerLocation.Pause) {
  456. if (this.ServerConfig.intersititial_first_ad == "native") {
  457. Utils_1.utils.showLog("暂停界面不延时展示!");
  458. Utils_1.utils.showLog("优先展示原生插屏广告!");
  459. this.nativeInserAdDelayCall();
  460. }
  461. else {
  462. Utils_1.utils.showLog("优先展示小游戏插屏广告!");
  463. this._createMiniGameInsertAd();
  464. }
  465. }
  466. else {
  467. if (this.ServerConfig.intersititial_first_ad == "native") {
  468. Utils_1.utils.showLog("优先展示原生插屏广告!");
  469. Utils_1.utils.delayCall(this.nativeInserAdDelayCall.bind(this), this.ServerConfig.intersititia_delay_show_time || 0);
  470. }
  471. else {
  472. Utils_1.utils.showLog("优先展示小游戏插屏广告!");
  473. this._createMiniGameInsertAd();
  474. // utils.delayCall(this._createMiniGameInsertAd.bind(this), this.ServerConfig.intersititia_delay_show_time || 0);
  475. }
  476. }
  477. }
  478. else {
  479. Utils_1.utils.showLog("服务器配置数据未初始化!");
  480. }
  481. }
  482. };
  483. AdAgentOPPO.prototype.nativeInserAdDelayCall = function () {
  484. Utils_1.utils.showLog("原生插屏广告: 当前点击次数=" + Utils_1.utils.oppoTool.NativeInsertAdClickTimes + "; 点击次数限制=" + this.ServerConfig.intersititia_click_count + "; 展示次数间隔=" + this.ServerConfig.intersititia_show_interval + "; 展示累计=" + this._nativeInsertAdShowCount);
  485. if (Utils_1.utils.oppoTool.NativeInsertAdClickTimes >= (this.ServerConfig.intersititia_click_count || 0)) {
  486. // 每日点击次数到达上限,限制展示次数
  487. if (this._nativeInsertAdShowCount >= (this.ServerConfig.intersititia_show_interval || 0)) {
  488. // 可以展示
  489. this._createNativeInsertAd(this._showNativeInsert);
  490. }
  491. else {
  492. // 不能展示
  493. this._nativeInsertAdShowCount++;
  494. }
  495. }
  496. else {
  497. this._createNativeInsertAd(this._showNativeInsert);
  498. }
  499. };
  500. AdAgentOPPO.prototype.ShowVideo = function (callback) {
  501. if (PlatUtils_1.default.IsOPPO) {
  502. this._videoCallback = callback;
  503. var curTime = new Date().getTime();
  504. var interval = (curTime - this.lastLastShowVideoTime) / 1000;
  505. if (interval < 4) {
  506. Utils_1.utils.showLog("视频广告请求间隔小于4秒,直接返回false");
  507. if (this._videoCallback) {
  508. this._videoCallback(false, "暂无视频广告!");
  509. this._videoCallback = null;
  510. }
  511. return;
  512. }
  513. if (this.ServerConfig) {
  514. if (this.checkRewardInsertIsShow() && Utils_1.utils.oppoTool
  515. && Utils_1.utils.oppoTool.ServerConfig
  516. && Utils_1.utils.oppoTool.ServerConfig.reward_first_ad && Utils_1.utils.oppoTool.ServerConfig.reward_first_ad != "video") {
  517. Utils_1.utils.showLog("<<<服务器默认优先展示激励插屏>>>");
  518. this.showRewardInsert();
  519. return;
  520. }
  521. if (Utils_1.utils.oppoTool.isOverMiniVersion("1040")) {
  522. if (!this._videoAd) {
  523. this._initVideoAd();
  524. }
  525. if (this._videoAd && this._videoLoaded) {
  526. this._videoAd.show();
  527. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  528. return;
  529. }
  530. }
  531. }
  532. Utils_1.utils.showLog("暂无视频广告!");
  533. if (this._videoCallback) {
  534. this._videoAd.load();
  535. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  536. // this.showRewardInsert();
  537. this._videoCallback(false, "暂无视频广告!");
  538. this._videoCallback = null;
  539. }
  540. }
  541. };
  542. AdAgentOPPO.prototype._initVideoAd = function () {
  543. var _this = this;
  544. if (!this._videoAd) {
  545. if (Utils_1.utils.config.oppoconfig.videoId) {
  546. //@ts-ignore
  547. this._videoAd = qg.createRewardedVideoAd({
  548. posId: Utils_1.utils.config.oppoconfig.videoId
  549. });
  550. var self_1 = this;
  551. if (this._videoAd) {
  552. Utils_1.utils.showLog("初始化注册视频回调!");
  553. this._videoAd.load();
  554. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  555. this._videoAd.onLoad(function () {
  556. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REQUEST_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  557. Utils_1.utils.showLog("激励视频加载成功");
  558. self_1._videoLoaded = true;
  559. });
  560. this._videoAd.onError(function (err) {
  561. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  562. Utils_1.utils.showLog("激励视频出错: " + err.code + err.msg);
  563. self_1._videoLoaded = false;
  564. if (self_1._videoCallback) {
  565. self_1._videoCallback(false, "暂无视频广告!");
  566. self_1._videoCallback = null;
  567. }
  568. });
  569. this._videoAd.onClose(function (res) {
  570. setTimeout(function () {
  571. self_1._videoAd.load();
  572. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  573. Utils_1.utils.showLog("延迟3秒重新加载视频广告");
  574. }, 3000);
  575. if (res.isEnded) {
  576. _this.lastLastShowVideoTime = new Date().getTime();
  577. Utils_1.utils.showLog('激励视频广告完成,发放奖励');
  578. if (self_1._videoCallback) {
  579. self_1._videoCallback(true, "");
  580. self_1._videoCallback = null;
  581. }
  582. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REWARD_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  583. }
  584. else {
  585. Utils_1.utils.showLog('激励视频广告取消关闭,不发放奖励');
  586. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.REWARD_VIDEO, EventAdInfo_1.YwAdStatus.REWARD_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.videoId));
  587. if (self_1._videoCallback) {
  588. self_1._videoCallback(false, "观看完视频才能获得奖励!");
  589. self_1._videoCallback = null;
  590. }
  591. }
  592. });
  593. }
  594. }
  595. else {
  596. Utils_1.utils.showLog("视频广告Id配置错误!");
  597. }
  598. }
  599. };
  600. /**
  601. * 验证插屏是否能展示
  602. * 1、次数限制 默认每日8次
  603. * 2、时间限制 默认60秒
  604. */
  605. AdAgentOPPO.prototype.checkInsertAdShow = function () {
  606. var maxShowCount = this.ServerConfig.intersititial_max_show_count;
  607. var intervalTime = this.ServerConfig.intersititial_interval_time;
  608. var curTime = new Date().getTime();
  609. var interval = (curTime - this._insertLastShowTime) / 1000;
  610. Utils_1.utils.showLog("OPPO服务器插屏最大显示次数为:" + maxShowCount + ",间隔显示时间为:" + intervalTime + "秒!");
  611. Utils_1.utils.showLog("OPPO插屏当前广告显示次数:" + Utils_1.utils.oppoTool.insertAdShowCounts + "次,间隔时间:" + interval + "秒!");
  612. if (maxShowCount > 0 && Utils_1.utils.oppoTool.insertAdShowCounts >= maxShowCount) {
  613. Utils_1.utils.showLog("OPPO插屏广告显示的次数达到" + maxShowCount + "次。插屏不显示");
  614. return false;
  615. }
  616. if (intervalTime > 0 && interval < intervalTime) {
  617. Utils_1.utils.showLog("OPPO插屏广告显示的间隔少于" + intervalTime + "秒。插屏不显示");
  618. return false;
  619. }
  620. return true;
  621. };
  622. // /**
  623. // * 创建小程序插屏广告
  624. // * @param isUnique 是否唯一展示 不轮询显示原生
  625. // */
  626. AdAgentOPPO.prototype._createMiniGameInsertAd = function (isUnique) {
  627. var _this = this;
  628. if (isUnique === void 0) { isUnique = false; }
  629. if (PlatUtils_1.default.IsOPPO) {
  630. this._isInsertShow = true;
  631. if (this._isAdInit
  632. && Utils_1.utils.config.oppoconfig
  633. && Utils_1.utils.config.oppoconfig.insertId) {
  634. //@ts-ignore
  635. var _insertAd_1 = qg.createInsertAd({
  636. adUnitId: Utils_1.utils.config.oppoconfig.insertId
  637. });
  638. if (_insertAd_1) {
  639. Utils_1.utils.showLog("注册小游戏插屏广告回调!");
  640. var clearCallBack_1 = function () {
  641. _insertAd_1.offShow();
  642. _insertAd_1.offError();
  643. _insertAd_1.offLoad();
  644. };
  645. _insertAd_1.onError((function (err) {
  646. Utils_1.utils.showLog("OPPO 小游戏插屏广告出错:" + err.code + err.msg);
  647. if (_this._isInsertShow && !isUnique) {
  648. if (_this.ServerConfig.intersititial_first_ad == "default") {
  649. _this._isInsertShow = false;
  650. Utils_1.utils.showLog("开始显示原生插屏广告!");
  651. _this._curPosIdIndexNativeInser = 0;
  652. Utils_1.utils.delayCall(_this.nativeInserAdDelayCall.bind(_this), _this.ServerConfig.intersititia_delay_show_time || 0);
  653. }
  654. }
  655. _insertAd_1.offError();
  656. clearCallBack_1();
  657. }).bind(this));
  658. _insertAd_1.onLoad((function () {
  659. Utils_1.utils.showLog("OPPO 小程序插屏广告加载成功!");
  660. if (_this._isInsertShow) {
  661. _this._isInsertShow = false;
  662. _insertAd_1.show();
  663. //onShow
  664. _this._isInsertShow = false;
  665. Utils_1.utils.oppoTool.countInserShowCount();
  666. _this._insertLastShowTime = new Date().getTime();
  667. var closeType = _this.ServerConfig.intersititial_open_close_banner;
  668. if (closeType && closeType > 0) {
  669. Utils_1.utils.showLog("OPPO 配置当前插屏显示成功后" + (closeType == 1 ? "销毁" : "隐藏") + "banner!");
  670. _this.HideBanner();
  671. }
  672. }
  673. // _insertAd.offLoad();
  674. // clearCallBack();
  675. }).bind(this));
  676. _insertAd_1.onShow((function () {
  677. Utils_1.utils.showLog("OPPO 小游戏插屏广告显示成功! ");
  678. // _insertAd.offShow();
  679. clearCallBack_1();
  680. }).bind(this));
  681. /**
  682. * 第一次调用不需要手动load
  683. */
  684. if (!this.miniInserAdIsCreate) {
  685. this.miniInserAdIsCreate = true;
  686. }
  687. else {
  688. _insertAd_1.load();
  689. }
  690. }
  691. if (!_insertAd_1) {
  692. Utils_1.utils.showLog("OPPO小游戏插屏广告创建失败!");
  693. if (this.ServerConfig.intersititial_first_ad == "default" && !isUnique) {
  694. Utils_1.utils.showLog("开始显示原生插屏广告!");
  695. this._curPosIdIndexNativeInser = 0;
  696. Utils_1.utils.delayCall(this.nativeInserAdDelayCall.bind(this), this.ServerConfig.intersititia_delay_show_time || 0);
  697. }
  698. }
  699. }
  700. else {
  701. Utils_1.utils.showLog("OPPO 小游戏插屏广告配置信息错误!");
  702. if (this.ServerConfig.intersititial_first_ad == "default" && !isUnique) {
  703. Utils_1.utils.showLog("开始显示原生插屏广告!");
  704. this._curPosIdIndexNativeInser = 0;
  705. Utils_1.utils.delayCall(this.nativeInserAdDelayCall.bind(this), this.ServerConfig.intersititia_delay_show_time || 0);
  706. }
  707. }
  708. }
  709. };
  710. // /**
  711. // * 创建小程序插屏广告
  712. // * @param isUnique 是否唯一展示 不轮询显示原生
  713. // */
  714. AdAgentOPPO.prototype._createMiniGameInsertAdByConfig = function (index) {
  715. var _this = this;
  716. if (PlatUtils_1.default.IsOPPO) {
  717. this._isInsertShow = true;
  718. Utils_1.utils.showLog("_createMiniGameInsertAdByIndex: index=" + index);
  719. if (this._isAdInit
  720. && Utils_1.utils.config.oppoconfig
  721. && index < Utils_1.utils.config.oppoconfig.intersitialAdConfigs.length) {
  722. //@ts-ignore
  723. var _insertAd_2 = qg.createInsertAd({
  724. adUnitId: Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id
  725. });
  726. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  727. if (_insertAd_2) {
  728. Utils_1.utils.showLog("注册小游戏插屏广告回调!");
  729. var clearCallBack_2 = function () {
  730. _insertAd_2.offShow();
  731. _insertAd_2.offError();
  732. _insertAd_2.offLoad();
  733. };
  734. _insertAd_2.onError((function (err) {
  735. Utils_1.utils.showLog("OPPO 小游戏插屏广告出错:" + err.code + err.msg);
  736. if (_this._isInsertShow) {
  737. _this.ShowInterstitialByConfigs(index + 1);
  738. }
  739. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id, err.code, err.msg));
  740. _insertAd_2.offError();
  741. clearCallBack_2();
  742. }).bind(this));
  743. _insertAd_2.onLoad((function () {
  744. Utils_1.utils.showLog("OPPO 小程序插屏广告加载成功!");
  745. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  746. if (_this._isInsertShow) {
  747. _this._isInsertShow = false;
  748. _insertAd_2.show();
  749. //onShow
  750. _this._isInsertShow = false;
  751. Utils_1.utils.oppoTool.countInserShowCount();
  752. _this._insertLastShowTime = new Date().getTime();
  753. var closeType = _this.ServerConfig.intersititial_open_close_banner;
  754. if (closeType && closeType > 0) {
  755. Utils_1.utils.showLog("OPPO 配置当前插屏显示成功后" + (closeType == 1 ? "销毁" : "隐藏") + "banner!");
  756. _this.HideBanner();
  757. }
  758. }
  759. // _insertAd.offLoad();
  760. // clearCallBack();
  761. }).bind(this));
  762. _insertAd_2.onShow((function () {
  763. Utils_1.utils.showLog("OPPO 小游戏插屏广告显示成功! ");
  764. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_SUCCESS);
  765. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  766. // _insertAd.offShow();
  767. clearCallBack_2();
  768. }).bind(this));
  769. /**
  770. * 第一次调用不需要手动load
  771. */
  772. if (!this.miniInserAdIsCreate) {
  773. this.miniInserAdIsCreate = true;
  774. }
  775. else {
  776. _insertAd_2.load();
  777. }
  778. }
  779. if (!_insertAd_2) {
  780. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  781. Utils_1.utils.showLog("OPPO小游戏插屏广告创建失败!");
  782. this.ShowInterstitialByConfigs(index + 1);
  783. }
  784. }
  785. else {
  786. Utils_1.utils.showLog("OPPO 小游戏插屏广告配置信息错误!");
  787. // if (this.ServerConfig.intersititial_first_ad == "default" && !isUnique) {
  788. // utils.showLog("开始显示原生插屏广告!");
  789. // this._curPosIdIndexNativeInser = 0;
  790. // utils.delayCall(this.nativeInserAdDelayCall.bind(this), this.ServerConfig.intersititia_delay_show_time || 0);
  791. // }
  792. }
  793. }
  794. };
  795. AdAgentOPPO.prototype._createMiniGameBannerAd = function (location) {
  796. var _this = this;
  797. if (location === void 0) { location = null; }
  798. if (PlatUtils_1.default.IsOPPO) {
  799. this._isBannerShow = true;
  800. if (this._isAdInit
  801. && Utils_1.utils.config.oppoconfig
  802. && Utils_1.utils.config.oppoconfig.bannerId) {
  803. var style = {
  804. top: 0
  805. };
  806. if (this.getNativeBannerInfo()._alignType === "top") {
  807. style.top = 0;
  808. }
  809. else {
  810. style = null;
  811. }
  812. if (!this._bannerAd || true) {
  813. //@ts-ignore
  814. this._bannerAd = qg.createBannerAd({
  815. posId: Utils_1.utils.config.oppoconfig.bannerId,
  816. style: style
  817. });
  818. if (this._bannerAd) {
  819. Utils_1.utils.showLog("注册小游戏banner回调!");
  820. this._bannerAd.onError((function (err) {
  821. Utils_1.utils.showLog("OPPO 小游戏Banner广告出错: " + err.code + err.msg);
  822. var bannerInfo = _this.getNativeBannerInfo();
  823. if (bannerInfo.st_banner_show_back_up == -1) {
  824. Utils_1.utils.showLog("服务器配置不显示备用广告");
  825. return;
  826. }
  827. if (_this._isBannerShow) {
  828. _this._isBannerShow = false;
  829. if (_this.ServerConfig.banner_first_ad.indexOf("default") > -1) {
  830. _this._curPosIdIndexNativeBanner = 0;
  831. _this._createNativeBannerAd(_this._showNativeBanner.bind(_this));
  832. }
  833. else {
  834. //显示自定义banner
  835. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  836. clearTimeout(_this._showBannerTimerId);
  837. Utils_1.utils.showRecommendGamesBanner();
  838. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  839. return;
  840. }
  841. }
  842. }
  843. }).bind(this));
  844. this._bannerAd.onShow((function () {
  845. Utils_1.utils.showLog("OPPO 小游戏Banner显示成功!");
  846. if (_this._nativeBannerNode) {
  847. _this._nativeBannerNode.active = false;
  848. }
  849. Utils_1.utils.hideRecommendGamesBanner();
  850. // if (this._bannerIsHide) {
  851. // this._bannerAd.hide();
  852. // utils.showLog("当前Banner广告为隐藏状态。调用隐藏!");
  853. // }
  854. _this._showBannerCallBack && _this._showBannerCallBack();
  855. _this._showBannerCallBack = null;
  856. }).bind(this));
  857. // this._bannerAd.onResize((obj) => {
  858. // utils.showLog("on resize >>>>" + JSON.stringify(obj));
  859. // utils.showLog('banner 宽度:' + obj.width + ', banner 高度:' + obj.height + " ,top" + obj.top)
  860. // })
  861. this._bannerAd.onHide(function () {
  862. if (!this._isNativeBannerShow) {
  863. Utils_1.utils.oppoTool.countBannerCloseCount();
  864. Utils_1.utils.showLog("OPPO 小游戏Banner 广告隐藏,当前隐藏次数>" + Utils_1.utils.oppoTool.bannerAdCloseCounts);
  865. }
  866. else {
  867. this._isNativeBannerShow = false;
  868. Utils_1.utils.showLog("OPPO 小游戏Banner 广告隐藏,来自原生的显示,不增加隐藏次数,当前隐藏次数>" + Utils_1.utils.oppoTool.bannerAdCloseCounts);
  869. }
  870. });
  871. // _miniBannerHeight
  872. }
  873. else {
  874. if (this.ServerConfig.banner_first_ad.indexOf("default") > -1) {
  875. this._curPosIdIndexNativeBanner = 0;
  876. this._createNativeBannerAd(this._showNativeBanner.bind(this));
  877. }
  878. else {
  879. //显示自定义banner
  880. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  881. clearTimeout(this._showBannerTimerId);
  882. Utils_1.utils.showRecommendGamesBanner();
  883. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  884. return;
  885. }
  886. }
  887. }
  888. }
  889. if (this._bannerAd) {
  890. if (this.getNativeBannerInfo()._alignType !== "top") {
  891. this._bannerAd.style.top = Utils_1.utils.oppoTool.SysInfo.screenHeight;
  892. }
  893. this._bannerAd.show();
  894. }
  895. else {
  896. Utils_1.utils.showLog("OPPO 小游戏Banner广告创建失败!");
  897. if (this.ServerConfig.indexOf("default") > -1) {
  898. this._curPosIdIndexNativeBanner = 0;
  899. this._createNativeBannerAd(this._showNativeBanner.bind(this));
  900. }
  901. else {
  902. //显示自定义banner
  903. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  904. clearTimeout(this._showBannerTimerId);
  905. Utils_1.utils.showRecommendGamesBanner();
  906. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  907. return;
  908. }
  909. }
  910. }
  911. }
  912. else {
  913. Utils_1.utils.showLog("OPPO 小游戏Banner广告配置信息错误!");
  914. var bannerInfo = this.getNativeBannerInfo();
  915. if (bannerInfo.st_banner_show_back_up == -1) {
  916. Utils_1.utils.showLog("服务器配置不显示备用广告");
  917. return;
  918. }
  919. if (this.ServerConfig.banner_first_ad.indexOf("default") > -1) {
  920. this._curPosIdIndexNativeBanner = 0;
  921. this._createNativeBannerAd(this._showNativeBanner.bind(this));
  922. }
  923. else {
  924. //显示自定义banner
  925. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  926. clearTimeout(this._showBannerTimerId);
  927. Utils_1.utils.showRecommendGamesBanner();
  928. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  929. return;
  930. }
  931. }
  932. }
  933. }
  934. };
  935. AdAgentOPPO.prototype._createMiniGameBannerAdByConfigs = function (index) {
  936. var _this = this;
  937. Utils_1.utils.showLog("_createMiniGameBannerAdByConfigs: #index=" + index);
  938. if (PlatUtils_1.default.IsOPPO) {
  939. this._isBannerShow = true;
  940. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  941. if (this._isAdInit
  942. && Utils_1.utils.config.oppoconfig
  943. && index < Utils_1.utils.config.oppoconfig.bannerAdConfigs.length) {
  944. var style = {
  945. top: 0
  946. };
  947. if (this.getNativeBannerInfo()._alignType === "top") {
  948. style.top = 0;
  949. }
  950. else {
  951. style = null;
  952. }
  953. //@ts-ignore
  954. this._bannerAd = qg.createBannerAd({
  955. posId: Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id,
  956. style: style
  957. });
  958. if (this._bannerAd) {
  959. Utils_1.utils.showLog("注册小游戏banner回调!");
  960. this._bannerAd.onError(function (err) {
  961. _this._bannerAd.offError();
  962. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  963. Utils_1.utils.showLog("OPPO 小游戏 Configs Banner广告出错: " + err.code + err.msg);
  964. var bannerInfo = _this.getNativeBannerInfo();
  965. if (bannerInfo.st_banner_show_back_up == -1) {
  966. Utils_1.utils.showLog("服务器配置不显示备用广告");
  967. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  968. return;
  969. }
  970. if (_this._isBannerShow) {
  971. _this._isBannerShow = false;
  972. _this.ShowBannerByConfigs(index + 1);
  973. }
  974. });
  975. // this._bannerAd.onShow((() => {
  976. // this._bannerAd.offShow();
  977. // utils.showLog("OPPO 小游戏Banner显示成功!");
  978. // this.hideBanner("default");
  979. // this._showBannerCallBack && this._showBannerCallBack();
  980. // this._showBannerCallBack = null;
  981. // }).bind(this));
  982. // this._bannerAd.onResize((obj) => {
  983. // utils.showLog("on resize >>>>" + JSON.stringify(obj));
  984. // utils.showLog('banner 宽度:' + obj.width + ', banner 高度:' + obj.height + " ,top" + obj.top)
  985. // })
  986. this._bannerAd.onHide(function () {
  987. _this._bannerAd.offHide();
  988. if (!_this._isNativeBannerShow) {
  989. Utils_1.utils.oppoTool.countBannerCloseCount();
  990. Utils_1.utils.showLog("OPPO 小游戏Banner 广告隐藏,当前隐藏次数>" + Utils_1.utils.oppoTool.bannerAdCloseCounts);
  991. }
  992. else {
  993. _this._isNativeBannerShow = false;
  994. Utils_1.utils.showLog("OPPO 小游戏Banner 广告隐藏,来自原生的显示,不增加隐藏次数,当前隐藏次数>" + Utils_1.utils.oppoTool.bannerAdCloseCounts);
  995. }
  996. });
  997. if (this.getNativeBannerInfo()._alignType !== "top") {
  998. this._bannerAd.style.top = Utils_1.utils.oppoTool.SysInfo.screenHeight;
  999. }
  1000. this._bannerAd.show().then(function () {
  1001. _this._bannerAd.offShow();
  1002. Utils_1.utils.showLog("OPPO 小游戏Banner显示成功!");
  1003. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1004. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_SUCCESS);
  1005. _this.hideBanner("default");
  1006. _this._showBannerCallBack && _this._showBannerCallBack();
  1007. _this._showBannerCallBack = null;
  1008. });
  1009. }
  1010. else {
  1011. this.ShowBannerByConfigs(index + 1);
  1012. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1013. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  1014. }
  1015. }
  1016. else {
  1017. Utils_1.utils.showLog("OPPO 小游戏Banner广告配置信息错误!");
  1018. var bannerInfo = this.getNativeBannerInfo();
  1019. if (bannerInfo.st_banner_show_back_up == -1) {
  1020. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  1021. Utils_1.utils.showLog("服务器配置不显示备用广告");
  1022. return;
  1023. }
  1024. this.ShowBannerByConfigs(index + 1);
  1025. }
  1026. }
  1027. };
  1028. AdAgentOPPO.prototype._createNativeBannerAdByConfigs = function (index) {
  1029. var _this = this;
  1030. if (PlatUtils_1.default.IsOPPO) {
  1031. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1032. Utils_1.utils.showLog("_createNativeBannerAdByConfigs: #index=" + index);
  1033. if (this._isAdInit
  1034. && Utils_1.utils.config.oppoconfig
  1035. && index < Utils_1.utils.config.oppoconfig.bannerAdConfigs.length) {
  1036. var nativeBannerAd_1 = Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].nativeBannerAd;
  1037. if (!nativeBannerAd_1) {
  1038. Utils_1.utils.showLog("创建原生广告Banner。 posId:" + Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id);
  1039. //@ts-ignore
  1040. nativeBannerAd_1 = qg.createNativeAd({
  1041. posId: Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id
  1042. });
  1043. if (nativeBannerAd_1) {
  1044. Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].nativeBannerAd = nativeBannerAd_1;
  1045. nativeBannerAd_1.onLoad(function (res) {
  1046. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1047. if (_this._nativeIsClose) {
  1048. Utils_1.utils.showLog("隐藏了BANNER,不做任何处理!");
  1049. return;
  1050. }
  1051. if (res && res.adList && res.adList.length > 0) {
  1052. _this._startBannerTimerTask = new Date().getTime();
  1053. Utils_1.utils.showLog("原生Banner广告资源拉取成功!");
  1054. Utils_1.utils.showLog(JSON.stringify(res));
  1055. res = JSON.parse(JSON.stringify(res));
  1056. var data = res.adList[0];
  1057. //如果当前显示为结算banner,则不做数据验证
  1058. if (_this._checkNativeDataValid(data) || _this.getNativeBannerInfo().show_st_banner == "true") {
  1059. if (_this.canShowNativeBanner) {
  1060. _this._curPosIdIndexNativeBanner = 0;
  1061. _this._showNativeBanner(nativeBannerAd_1, data);
  1062. _this._curNativeBannerInfo.nativeBannerAd = nativeBannerAd_1;
  1063. _this._curNativeBannerInfo.data = data;
  1064. _this.hideBanner("native");
  1065. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1066. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_SUCCESS);
  1067. }
  1068. else {
  1069. Utils_1.utils.showLog("已经隐藏banner不可重复展示");
  1070. }
  1071. return;
  1072. }
  1073. }
  1074. Utils_1.utils.showLog("原生Banner广告资源出错!");
  1075. var bannerInfo = _this.getNativeBannerInfo();
  1076. if (bannerInfo.st_banner_show_back_up == -1) {
  1077. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  1078. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1079. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  1080. return;
  1081. }
  1082. _this.ShowBannerByConfigs(index + 1);
  1083. });
  1084. nativeBannerAd_1.onError(function (err) {
  1085. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  1086. if (_this._nativeIsClose) {
  1087. Utils_1.utils.showLog("隐藏了BANNER,不做任何处理!");
  1088. return;
  1089. }
  1090. Utils_1.utils.showLog("原生Banner广告资源拉取失败!" + err.code + err.msg);
  1091. // 原生广告遍历完毕
  1092. var bannerInfo = _this.getNativeBannerInfo();
  1093. if (bannerInfo.st_banner_show_back_up == -1) {
  1094. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  1095. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  1096. return;
  1097. }
  1098. _this.ShowBannerByConfigs(index + 1);
  1099. });
  1100. }
  1101. }
  1102. if (nativeBannerAd_1) {
  1103. Utils_1.utils.showLog("nativeBannerAd reLoad>>");
  1104. nativeBannerAd_1.load();
  1105. }
  1106. else {
  1107. var bannerInfo = this.getNativeBannerInfo();
  1108. if (bannerInfo.st_banner_show_back_up == -1) {
  1109. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  1110. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  1111. return;
  1112. }
  1113. this.ShowBannerByConfigs(index + 1);
  1114. }
  1115. }
  1116. }
  1117. };
  1118. AdAgentOPPO.prototype._createNativeBannerAd = function (completeCallback) {
  1119. var _this = this;
  1120. if (PlatUtils_1.default.IsOPPO) {
  1121. var callback_1 = completeCallback;
  1122. Utils_1.utils.showLog("curPosIdIndexNativeBanner:" + this._curPosIdIndexNativeBanner);
  1123. var nativeBannerAd_2 = this._nativeBannerAd[this._curPosIdIndexNativeBanner];
  1124. if (!nativeBannerAd_2) {
  1125. if (Utils_1.utils.config.oppoconfig.nativeBannerIds
  1126. && Utils_1.utils.config.oppoconfig.nativeBannerIds[this._curPosIdIndexNativeBanner]) {
  1127. Utils_1.utils.showLog("创建原生广告Banner。 posId:" + Utils_1.utils.config.oppoconfig.nativeBannerIds[this._curPosIdIndexNativeBanner]);
  1128. //@ts-ignore
  1129. nativeBannerAd_2 = qg.createNativeAd({
  1130. posId: Utils_1.utils.config.oppoconfig.nativeBannerIds[this._curPosIdIndexNativeBanner]
  1131. });
  1132. if (nativeBannerAd_2) {
  1133. this._nativeBannerAd.push(nativeBannerAd_2);
  1134. nativeBannerAd_2.onLoad(function (res) {
  1135. if (_this._nativeIsClose) {
  1136. Utils_1.utils.showLog("隐藏了BANNER,不做任何处理!");
  1137. return;
  1138. }
  1139. if (res && res.adList && res.adList.length > 0) {
  1140. _this._startBannerTimerTask = new Date().getTime();
  1141. Utils_1.utils.showLog("原生Banner广告资源拉取成功!");
  1142. Utils_1.utils.showLog(JSON.stringify(res));
  1143. res = JSON.parse(JSON.stringify(res));
  1144. var data = res.adList[0];
  1145. //如果当前显示为结算banner,则不做数据验证
  1146. if (_this._checkNativeDataValid(data) || _this.getNativeBannerInfo().show_st_banner == "true") {
  1147. if (_this.canShowNativeBanner) {
  1148. _this._curPosIdIndexNativeBanner = 0;
  1149. _this._showNativeBanner(nativeBannerAd_2, data);
  1150. _this._curNativeBannerInfo.nativeBannerAd = nativeBannerAd_2;
  1151. _this._curNativeBannerInfo.data = data;
  1152. // 删除当前广告
  1153. if (_this._bannerAd) {
  1154. _this._isNativeBannerShow = true;
  1155. if (Utils_1.utils.oppoTool.isOverMiniVersion("1050")) {
  1156. Utils_1.utils.showLog("销毁小游戏Banner");
  1157. _this._bannerAd.destroy();
  1158. _this._bannerAd = null;
  1159. }
  1160. else {
  1161. Utils_1.utils.showLog("当前小游戏平台小于1051,只能隐藏小游戏Banner");
  1162. _this._bannerAd.hide();
  1163. }
  1164. }
  1165. Utils_1.utils.hideRecommendGamesBanner();
  1166. }
  1167. else {
  1168. cc.warn("已经隐藏banner不可重复展示");
  1169. }
  1170. return;
  1171. }
  1172. }
  1173. Utils_1.utils.showLog("原生Banner广告资源出错!");
  1174. _this._curPosIdIndexNativeBanner++;
  1175. if (_this._curPosIdIndexNativeBanner < Utils_1.utils.config.oppoconfig.nativeBannerIds.length) {
  1176. _this._createNativeBannerAd(callback_1);
  1177. }
  1178. else {
  1179. _this._curPosIdIndexNativeBanner = 0;
  1180. // 原生广告遍历完毕
  1181. Utils_1.utils.showLog("原生广告条遍历完毕,无法展示!");
  1182. var bannerInfo = _this.getNativeBannerInfo();
  1183. if (bannerInfo.st_banner_show_back_up == -1) {
  1184. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  1185. return;
  1186. }
  1187. if (_this.ServerConfig.banner_first_ad.indexOf("native") > -1) {
  1188. Utils_1.utils.showLog("开始展示小游戏广告条!");
  1189. _this._createMiniGameBannerAd();
  1190. }
  1191. else {
  1192. //显示自定义banner
  1193. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  1194. clearTimeout(_this._showBannerTimerId);
  1195. Utils_1.utils.showRecommendGamesBanner();
  1196. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  1197. return;
  1198. }
  1199. }
  1200. }
  1201. });
  1202. nativeBannerAd_2.onError(function (err) {
  1203. if (_this._nativeIsClose) {
  1204. Utils_1.utils.showLog("隐藏了BANNER,不做任何处理!");
  1205. return;
  1206. }
  1207. Utils_1.utils.showLog("原生Banner广告资源拉取失败!" + err.code + err.msg);
  1208. _this._curPosIdIndexNativeBanner++;
  1209. if (_this._curPosIdIndexNativeBanner < Utils_1.utils.config.oppoconfig.nativeBannerIds.length) {
  1210. _this._createNativeBannerAd(callback_1);
  1211. }
  1212. else {
  1213. _this._curPosIdIndexNativeBanner = 0;
  1214. // 原生广告遍历完毕
  1215. Utils_1.utils.showLog("原生广告条遍历完毕,无法展示!");
  1216. var bannerInfo = _this.getNativeBannerInfo();
  1217. if (bannerInfo.st_banner_show_back_up == -1) {
  1218. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  1219. return;
  1220. }
  1221. if (_this.ServerConfig.banner_first_ad.indexOf("native") > -1) {
  1222. Utils_1.utils.showLog("开始展示小游戏广告条!");
  1223. _this._createMiniGameBannerAd();
  1224. }
  1225. else {
  1226. //显示自定义banner
  1227. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  1228. clearTimeout(_this._showBannerTimerId);
  1229. Utils_1.utils.showRecommendGamesBanner();
  1230. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  1231. return;
  1232. }
  1233. }
  1234. }
  1235. });
  1236. }
  1237. }
  1238. }
  1239. if (nativeBannerAd_2) {
  1240. Utils_1.utils.showLog("nativeBannerAd reLoad>>");
  1241. nativeBannerAd_2.load();
  1242. }
  1243. else {
  1244. this._curPosIdIndexNativeBanner++;
  1245. if (Utils_1.utils.config.oppoconfig.nativeBannerIds && this._curPosIdIndexNativeBanner < Utils_1.utils.config.oppoconfig.nativeBannerIds.length) {
  1246. this._createNativeBannerAd(callback_1);
  1247. }
  1248. else {
  1249. this._curPosIdIndexNativeBanner = 0;
  1250. // 原生广告遍历完毕
  1251. Utils_1.utils.showLog("原生广告条遍历完毕,无法展示!");
  1252. var bannerInfo = this.getNativeBannerInfo();
  1253. if (bannerInfo.st_banner_show_back_up == -1) {
  1254. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  1255. return;
  1256. }
  1257. if (this.ServerConfig.banner_first_ad.indexOf("native") > -1) {
  1258. Utils_1.utils.showLog("开始展示小游戏广告条!");
  1259. this._createMiniGameBannerAd();
  1260. }
  1261. else {
  1262. //显示自定义banner
  1263. if (Utils_1.utils.isShowRecommondGamesBanner()) {
  1264. clearTimeout(this._showBannerTimerId);
  1265. Utils_1.utils.showRecommendGamesBanner();
  1266. Utils_1.utils.showLog("\u5C0F\u6E38\u620F\u3001\u539F\u751F\u5E7F\u544A\u6761\u90FD\u65E0\u6CD5\u5C55\u793A\uFF0C\u5C55\u793A\u81EA\u5B9A\u4E49banner");
  1267. return;
  1268. }
  1269. }
  1270. }
  1271. }
  1272. }
  1273. };
  1274. AdAgentOPPO.prototype._createNativeInsertAd = function (completeCallback) {
  1275. var _this = this;
  1276. if (PlatUtils_1.default.IsOPPO) {
  1277. var callback_2 = completeCallback;
  1278. Utils_1.utils.showLog("curPosIdIndexNativeInsert:" + this._curPosIdIndexNativeInser);
  1279. var nativeInsertAd_1 = this._nativeInsertAd[this._curPosIdIndexNativeInser];
  1280. if (!nativeInsertAd_1) {
  1281. if (Utils_1.utils.config.oppoconfig.nativeInsertIds
  1282. && Utils_1.utils.config.oppoconfig.nativeInsertIds[this._curPosIdIndexNativeInser]) {
  1283. Utils_1.utils.showLog("创建原生插屏广告。 posId:" + Utils_1.utils.config.oppoconfig.nativeInsertIds[this._curPosIdIndexNativeInser]);
  1284. //@ts-ignore
  1285. nativeInsertAd_1 = qg.createNativeAd({
  1286. posId: Utils_1.utils.config.oppoconfig.nativeInsertIds[this._curPosIdIndexNativeInser]
  1287. });
  1288. if (nativeInsertAd_1) {
  1289. this._nativeInsertAd.push(nativeInsertAd_1);
  1290. nativeInsertAd_1.onLoad(function (res) {
  1291. if (res && res.adList && res.adList.length > 0) {
  1292. Utils_1.utils.showLog("原生插屏广告资源拉取成功!");
  1293. Utils_1.utils.showLog(JSON.stringify(res));
  1294. res = JSON.parse(JSON.stringify(res));
  1295. var data = res.adList[0];
  1296. if (_this._checkNativeInsertDataValid(data)) {
  1297. _this._curPosIdIndexNativeInser = 0;
  1298. _this._showNativeInsert(nativeInsertAd_1, data);
  1299. return;
  1300. }
  1301. else {
  1302. Utils_1.utils.showLog("原生插屏广告资源不合法!");
  1303. }
  1304. }
  1305. Utils_1.utils.showLog("原生插屏广告资源出错!");
  1306. _this._curPosIdIndexNativeInser++;
  1307. if (_this._curPosIdIndexNativeInser < Utils_1.utils.config.oppoconfig.nativeInsertIds.length) {
  1308. _this._createNativeInsertAd(callback_2);
  1309. }
  1310. else {
  1311. _this._curPosIdIndexNativeInser = 0;
  1312. // 原生广告遍历完毕
  1313. Utils_1.utils.showLog("原生插屏广告遍历完毕,无法展示!");
  1314. if (_this.ServerConfig.intersititial_first_ad == "native") {
  1315. Utils_1.utils.showLog("开始展示小游戏插屏广告!");
  1316. _this._createMiniGameInsertAd();
  1317. }
  1318. }
  1319. });
  1320. nativeInsertAd_1.onError(function (err) {
  1321. Utils_1.utils.showLog("原生插屏广告资源拉取失败!" + err.code + err.msg);
  1322. _this._curPosIdIndexNativeInser++;
  1323. if (_this._curPosIdIndexNativeInser < Utils_1.utils.config.oppoconfig.nativeInsertIds.length) {
  1324. _this._createNativeInsertAd(callback_2);
  1325. }
  1326. else {
  1327. _this._curPosIdIndexNativeInser = 0;
  1328. // 原生广告遍历完毕
  1329. Utils_1.utils.showLog("原生插屏广告遍历完毕,无法展示!");
  1330. if (_this.ServerConfig.intersititial_first_ad == "native") {
  1331. Utils_1.utils.showLog("开始展示小游戏插屏广告!");
  1332. _this._createMiniGameInsertAd();
  1333. }
  1334. }
  1335. });
  1336. }
  1337. }
  1338. }
  1339. if (nativeInsertAd_1) {
  1340. nativeInsertAd_1.load();
  1341. }
  1342. else {
  1343. this._curPosIdIndexNativeInser++;
  1344. if (Utils_1.utils.config.oppoconfig.nativeInsertIds && this._curPosIdIndexNativeInser < Utils_1.utils.config.oppoconfig.nativeInsertIds.length) {
  1345. this._createNativeInsertAd(callback_2);
  1346. }
  1347. else {
  1348. this._curPosIdIndexNativeInser = 0;
  1349. // 原生广告遍历完毕
  1350. Utils_1.utils.showLog("原生插屏广告遍历完毕,无法展示!");
  1351. if (this.ServerConfig.intersititial_first_ad == "native") {
  1352. Utils_1.utils.showLog("开始展示小游戏插屏广告!");
  1353. this._createMiniGameInsertAd();
  1354. }
  1355. }
  1356. }
  1357. }
  1358. };
  1359. AdAgentOPPO.prototype._createNativeInsertAdByConfig = function (index) {
  1360. var _this = this;
  1361. if (PlatUtils_1.default.IsOPPO) {
  1362. Utils_1.utils.showLog("_createNativeInsertAdByConfig: #index=" + index);
  1363. if (this._isAdInit
  1364. && Utils_1.utils.config.oppoconfig
  1365. && index < Utils_1.utils.config.oppoconfig.intersitialAdConfigs.length) {
  1366. var nativeInsertAd_2 = Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].nativeInsertAd;
  1367. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  1368. if (!nativeInsertAd_2) {
  1369. if (Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id) {
  1370. Utils_1.utils.showLog("创建原生插屏广告。 posId:" + Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id);
  1371. //@ts-ignore
  1372. nativeInsertAd_2 = qg.createNativeAd({
  1373. posId: Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id
  1374. });
  1375. if (nativeInsertAd_2) {
  1376. Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].nativeInsertAd = nativeInsertAd_2;
  1377. nativeInsertAd_2.onLoad(function (res) {
  1378. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  1379. if (res && res.adList && res.adList.length > 0) {
  1380. Utils_1.utils.showLog("原生插屏广告资源拉取成功!");
  1381. Utils_1.utils.showLog(JSON.stringify(res));
  1382. res = JSON.parse(JSON.stringify(res));
  1383. var data = res.adList[0];
  1384. if (_this._checkNativeInsertDataValid(data)) {
  1385. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_SUCCESS);
  1386. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_INTERSITITIAL, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  1387. _this._showNativeInsert(nativeInsertAd_2, data);
  1388. return;
  1389. }
  1390. else {
  1391. Utils_1.utils.showLog("原生插屏广告资源不合法!");
  1392. }
  1393. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  1394. }
  1395. Utils_1.utils.showLog("原生插屏广告资源出错!");
  1396. _this.ShowInterstitialByConfigs(index + 1);
  1397. });
  1398. nativeInsertAd_2.onError(function (err) {
  1399. Utils_1.utils.showLog("原生插屏广告资源拉取失败!" + err.code + err.msg);
  1400. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id, err.code, err.msg));
  1401. _this.ShowInterstitialByConfigs(index + 1);
  1402. });
  1403. }
  1404. }
  1405. }
  1406. if (nativeInsertAd_2) {
  1407. nativeInsertAd_2.load();
  1408. }
  1409. else {
  1410. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  1411. Utils_1.utils.showLog("创建原生插屏失败:#index=" + index);
  1412. this.ShowInterstitialByConfigs(index + 1);
  1413. }
  1414. }
  1415. }
  1416. };
  1417. /**
  1418. * 获取原生广告数据
  1419. * @param args
  1420. */
  1421. AdAgentOPPO.prototype.getNativeAdData = function () {
  1422. if (!this._nativeAdObject) {
  1423. this._nativeAdObject = new YZ_NativeAdObject_1.default();
  1424. }
  1425. this._nativeAdObject._nativeObj = this._nativeAd;
  1426. if (this._nativeAdObject.data) {
  1427. if (this._nativeAdObject.data.adId != this._nativeData.adId) {
  1428. this._nativeAdObject.is_reportClick = false;
  1429. this._nativeAdObject.is_reportShow = false;
  1430. }
  1431. }
  1432. this._nativeAdObject.data = this._nativeData;
  1433. // setTimeout(() => {
  1434. // utils.showLog("延迟两秒重新请求原生广告数据");
  1435. // this._createNativeAd(args);
  1436. // }, 2000);
  1437. if (this._nativeData && this._nativeAd) {
  1438. // this._nativeData = null;
  1439. Utils_1.utils.showLog("获取原生数据 >>>", this._nativeData, "...", this._nativeAdObject);
  1440. return this._nativeAdObject;
  1441. }
  1442. return null;
  1443. };
  1444. /**
  1445. * 创建单个原生广告
  1446. * @param completeCallback
  1447. */
  1448. AdAgentOPPO.prototype.createNativeAd = function (params, nativeItem) {
  1449. var _this = this;
  1450. if (params === void 0) { params = null; }
  1451. Utils_1.utils.showLog("_createNativeAd >>>>>");
  1452. if (PlatUtils_1.default.IsOPPO) {
  1453. if (nativeItem) {
  1454. this._curNativeItem = nativeItem;
  1455. }
  1456. var refreshTime = this.ServerConfig.st_native_ad_refresh_time ? this.ServerConfig.st_native_ad_refresh_time : 0;
  1457. if (this._nativeAdObject && this._nativeAdObject.data && !this._nativeAdObject.is_reportClick && (new Date().getTime() - this._singleAdCreateTime) / 1000 < refreshTime) {
  1458. Utils_1.utils.showLog("\u5F53\u524D\u539F\u751F\u5E7F\u544A\u7684\u5C55\u793A\u65F6\u95F4" + (new Date().getTime() - this._singleAdCreateTime) / 1000 + "\u79D2\uFF0C\u672A\u8FBE\u5237\u65B0\u65F6\u95F4" + refreshTime + "\u79D2\u9650\u5236\uFF0C\u76F4\u63A5\u4F7F\u7528\u4E0A\u4E00\u6B21\u6570\u636E\uFF01");
  1459. this._showNativeAd();
  1460. return;
  1461. }
  1462. Utils_1.utils.showLog("_curPosIdIndexSingleNative:" + this._curPosIdIndexSingleNative + " #this._nativeSingleAd.length" + this._nativeSingleAd.length);
  1463. var nativeSingleAd_1 = this._nativeSingleAd[this._curPosIdIndexSingleNative];
  1464. if (!nativeSingleAd_1) {
  1465. if (Utils_1.utils.config.oppoconfig.nativeSingleAdIds
  1466. && Utils_1.utils.config.oppoconfig.nativeSingleAdIds[this._curPosIdIndexSingleNative]) {
  1467. Utils_1.utils.showLog("创建原生广告。 posId:" + Utils_1.utils.config.oppoconfig.nativeSingleAdIds[this._curPosIdIndexSingleNative]);
  1468. //@ts-ignore
  1469. nativeSingleAd_1 = qg.createNativeAd({
  1470. posId: Utils_1.utils.config.oppoconfig.nativeSingleAdIds[this._curPosIdIndexSingleNative]
  1471. });
  1472. if (nativeSingleAd_1) {
  1473. this._nativeSingleAd.push(nativeSingleAd_1);
  1474. nativeSingleAd_1.onLoad(function (res) {
  1475. if (res && res.adList && res.adList.length > 0) {
  1476. Utils_1.utils.showLog("原生广告资源拉取成功!");
  1477. Utils_1.utils.showLog(JSON.stringify(res));
  1478. res = JSON.parse(JSON.stringify(res));
  1479. var data = res.adList[0];
  1480. if (_this._checkNativeDataValid(data)) {
  1481. _this._singleAdCreateTime = new Date().getTime();
  1482. _this._curPosIdIndexSingleNative = 0;
  1483. _this._nativeData = data;
  1484. _this._nativeAd = nativeSingleAd_1;
  1485. // utils.showLog("callback >>>", callback);
  1486. // callback(this.getNativeAdData());
  1487. _this._showNativeAd();
  1488. return;
  1489. }
  1490. else {
  1491. Utils_1.utils.showLog("原生广告资源不合法!");
  1492. }
  1493. }
  1494. Utils_1.utils.showLog("原生广告资源出错!");
  1495. _this._curPosIdIndexSingleNative++;
  1496. if (_this._curPosIdIndexSingleNative < Utils_1.utils.config.oppoconfig.nativeSingleAdIds.length) {
  1497. _this.createNativeAd();
  1498. }
  1499. else {
  1500. _this._curPosIdIndexSingleNative = 0;
  1501. // 原生广告遍历完毕
  1502. Utils_1.utils.showLog("单个原生广告ID遍历完毕,无法展示!");
  1503. }
  1504. });
  1505. nativeSingleAd_1.onError(function (err) {
  1506. Utils_1.utils.showLog("原生单个广告资源拉取失败!" + err.code + err.msg);
  1507. _this._curPosIdIndexSingleNative++;
  1508. if (_this._curPosIdIndexSingleNative < Utils_1.utils.config.oppoconfig.nativeSingleAdIds.length) {
  1509. _this.createNativeAd();
  1510. }
  1511. else {
  1512. _this._curPosIdIndexSingleNative = 0;
  1513. // 原生广告遍历完毕
  1514. Utils_1.utils.showLog("单个原生广告ID遍历完毕,无法展示!");
  1515. }
  1516. });
  1517. }
  1518. }
  1519. }
  1520. if (nativeSingleAd_1) {
  1521. Utils_1.utils.showLog("nativeSingleAd reload");
  1522. nativeSingleAd_1.load();
  1523. }
  1524. else {
  1525. this._curPosIdIndexSingleNative++;
  1526. if (Utils_1.utils.config.oppoconfig.nativeSingleAdIds && this._curPosIdIndexSingleNative < Utils_1.utils.config.oppoconfig.nativeSingleAdIds.length) {
  1527. this.createNativeAd();
  1528. }
  1529. else {
  1530. this._curPosIdIndexSingleNative = 0;
  1531. // 原生广告遍历完毕
  1532. Utils_1.utils.showLog("单个原生广告ID 遍历完毕,无法展示!");
  1533. }
  1534. }
  1535. }
  1536. };
  1537. /**
  1538. * 显示原生banner组件
  1539. */
  1540. AdAgentOPPO.prototype._showNativeBanner = function (nativeBannerAd, data) {
  1541. if (PlatUtils_1.default.IsOPPO) {
  1542. if (data) {
  1543. if (cc.isValid(this._nativeBannerNode) && this._nativeBannerNode) {
  1544. this._nativeBannerNode.destroy();
  1545. }
  1546. // if (!cc.isValid(this._nativeBannerNode) || (!this._nativeBannerNode && utils.config.otherconfig.nativeBanner)) {
  1547. this._nativeBannerNode = cc.instantiate(Utils_1.utils.config.otherconfig.nativeBanner);
  1548. this._nativeBannerNode.position = CompatibleTool_1.default.position(cc.winSize.width / 2, this._nativeBannerNode.height * this._nativeBannerNode.scaleY / 2);
  1549. cc.director.getScene().addChild(this._nativeBannerNode, 1000);
  1550. // }
  1551. if (this._nativeBannerNode) {
  1552. this._nativeBannerNode.active = true;
  1553. var nativeBanner = this._nativeBannerNode.getComponent("YZ_NativeBanner");
  1554. if (nativeBanner) {
  1555. nativeBanner.init(nativeBannerAd, data, this.getNativeBannerInfo());
  1556. }
  1557. else {
  1558. Utils_1.utils.showLog("NativeBanner组件不存在!");
  1559. }
  1560. this._showBannerCallBack && this._showBannerCallBack();
  1561. this._showBannerCallBack = null;
  1562. }
  1563. else {
  1564. Utils_1.utils.showLog("原生广告banner位没有创建!");
  1565. }
  1566. }
  1567. }
  1568. };
  1569. /**
  1570. * 显示原生插屏组件
  1571. */
  1572. AdAgentOPPO.prototype._showNativeInsert = function (nativeInsertAd, data) {
  1573. if (PlatUtils_1.default.IsOPPO) {
  1574. if (data) {
  1575. if ((!cc.isValid(this._nativeInsertNode)) || !this._nativeInsertNode && Utils_1.utils.config.otherconfig.nativeInsert) {
  1576. Utils_1.utils.showLog("创建原生插屏广告位");
  1577. this._nativeInsertNode = cc.instantiate(Utils_1.utils.config.otherconfig.nativeInsert);
  1578. this._nativeInsertNode.position = CompatibleTool_1.default.position(cc.winSize.width / 2, cc.winSize.height / 2);
  1579. cc.director.getScene().addChild(this._nativeInsertNode, 999999);
  1580. }
  1581. if (this._nativeInsertNode) {
  1582. var nativeInsert = this._nativeInsertNode.getComponent("YZ_NativeInsert");
  1583. if (nativeInsert) {
  1584. this._nativeInsertAdShowCount = 0;
  1585. nativeInsert.init(nativeInsertAd, data);
  1586. this._insertLastShowTime = new Date().getTime();
  1587. Utils_1.utils.oppoTool.countInserShowCount();
  1588. Utils_1.utils.showLog("原生插屏显示成功,当前显示次数=" + Utils_1.utils.oppoTool.insertAdShowCounts);
  1589. var closeType = this.ServerConfig.intersititial_open_close_banner;
  1590. if (closeType && closeType > 0) {
  1591. Utils_1.utils.showLog("OPPO 配置当前插屏显示成功后" + (closeType == 1 ? "销毁" : "隐藏") + "banner!");
  1592. this.HideBanner();
  1593. }
  1594. }
  1595. else {
  1596. Utils_1.utils.showLog("NativeInsert组件不存在!");
  1597. }
  1598. }
  1599. else {
  1600. Utils_1.utils.showLog("原生广告插屏位没有创建!");
  1601. }
  1602. }
  1603. }
  1604. };
  1605. /**
  1606. * 隐藏banner
  1607. * @param args
  1608. */
  1609. AdAgentOPPO.prototype.HideSingleNativeAd = function (args) {
  1610. if (this.signleNativeAd && cc.isValid(this.signleNativeAd)) {
  1611. this.signleNativeAd.destroy();
  1612. }
  1613. };
  1614. AdAgentOPPO.prototype.ShowCloseBtnBanner = function (location, args) {
  1615. var _this = this;
  1616. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  1617. Utils_1.utils.showLog("ShowCloseBtnBanner >>>>>>>>>.");
  1618. var isMoveBtn = 0;
  1619. var fadeInTime = 0;
  1620. var btn = args.closeBtn;
  1621. var winHeight = cc.winSize.height;
  1622. btn.opacity = 0;
  1623. if (this.ServerConfig) {
  1624. if (this.ServerConfig.is_move_btn) {
  1625. isMoveBtn = this.ServerConfig.is_move_btn;
  1626. }
  1627. if (this.ServerConfig.close_btn_fade_in_time) {
  1628. fadeInTime = this.ServerConfig.close_btn_fade_in_time;
  1629. }
  1630. Utils_1.utils.showLog(isMoveBtn == 0 ? "显示banner,且按钮在上面" : "\u663E\u793ABanner,\u6309\u94AE\u5C45\u5E95\u90E8\u4E14" + isMoveBtn + "\u6BEB\u79D2\u540E\u79FB\u52A8");
  1631. setTimeout(function () {
  1632. Utils_1.utils.showLog("延迟调用关闭按钮的Banner >>>>");
  1633. _this.ShowBanner(location, args);
  1634. var adY = 240;
  1635. Utils_1.utils.showLog('utils - adY:' + adY);
  1636. if (adY > 0 && btn) {
  1637. btn.y = -(winHeight / 2 - adY) + btn.height;
  1638. Utils_1.utils.showLog("btnClose.y" + btn.y);
  1639. }
  1640. }, isMoveBtn);
  1641. setTimeout(function () {
  1642. btn.runAction(cc.fadeIn(0.3));
  1643. }, fadeInTime * 1000);
  1644. }
  1645. };
  1646. AdAgentOPPO.prototype._checkNativeInsertDataValid = function (data) {
  1647. if (!data) {
  1648. return false;
  1649. }
  1650. return data.title && ((data.iconUrlList && data.iconUrlList.length > 0) || (data.imgUrlList && data.imgUrlList.length > 0));
  1651. };
  1652. AdAgentOPPO.prototype._checkNativeDataValid = function (data) {
  1653. if (!data) {
  1654. return false;
  1655. }
  1656. return data.imgUrlList && data.imgUrlList.length;
  1657. };
  1658. /**
  1659. * 验证是否显示激励插屏
  1660. */
  1661. AdAgentOPPO.prototype.checkRewardInsertIsShow = function () {
  1662. var jumpList = Utils_1.utils.getRecommondGameList();
  1663. if (Utils_1.utils.isSupportnavigateToMiniGame()) {
  1664. if (Utils_1.utils.oppoTool
  1665. && Utils_1.utils.oppoTool.ServerConfig
  1666. && Utils_1.utils.oppoTool.ServerConfig.is_reward_intersititia) {
  1667. if (Utils_1.utils.oppoTool.ServerConfig.is_reward_intersititia == "true"
  1668. && jumpList && jumpList.length > 0) {
  1669. Utils_1.utils.showLog("激励插屏显示环境验证通过!");
  1670. return true;
  1671. }
  1672. else {
  1673. Utils_1.utils.showLog("is_reward_intersititia 参数为false,激励插屏组件不显示!");
  1674. return false;
  1675. }
  1676. }
  1677. else {
  1678. Utils_1.utils.showLog("配置中没有is_reward_intersititia参数,激励插屏组件组件不显示!");
  1679. return false;
  1680. }
  1681. }
  1682. Utils_1.utils.showLog("当前平台不支持小程序跳转!");
  1683. return false;
  1684. };
  1685. /**
  1686. * 显示激励插屏组件
  1687. */
  1688. AdAgentOPPO.prototype.showRewardInsert = function () {
  1689. Utils_1.utils.showLog("show reward");
  1690. var self = this;
  1691. if (!this.checkRewardInsertIsShow()) {
  1692. self._videoCallback && self._videoCallback(false, "暂无视频广告!");
  1693. Utils_1.utils.adManager.videoCallBack = null;
  1694. return;
  1695. }
  1696. if (((!cc.isValid(this._rewardInsertNode)) || !this._rewardInsertNode) && Utils_1.utils.config.otherconfig.rewardInsert) {
  1697. Utils_1.utils.showLog("创建激励插屏广告");
  1698. this._rewardInsertNode = cc.instantiate(Utils_1.utils.config.otherconfig.rewardInsert);
  1699. this._rewardInsertNode.position = CompatibleTool_1.default.position(cc.winSize.width / 2, cc.winSize.height / 2);
  1700. cc.director.getScene().addChild(this._rewardInsertNode, 9999);
  1701. }
  1702. if (this._rewardInsertNode) {
  1703. var rewardInsert = this._rewardInsertNode.getComponent("RewardInsert");
  1704. if (rewardInsert) {
  1705. rewardInsert.isShow = false;
  1706. Utils_1.utils.showLog("显示激励插屏组件!");
  1707. }
  1708. else {
  1709. Utils_1.utils.showLog("RewardInsert组件不存在!");
  1710. }
  1711. }
  1712. else {
  1713. Utils_1.utils.showLog("激励插屏没有创建!");
  1714. }
  1715. };
  1716. AdAgentOPPO.prototype.hideRewardInsert = function () {
  1717. if (this._rewardInsertNode) {
  1718. var rewardInsert = this._rewardInsertNode.getComponent("RewardInsert");
  1719. if (rewardInsert) {
  1720. rewardInsert.hide();
  1721. Utils_1.utils.showLog("隐藏激励插屏组件!");
  1722. }
  1723. else {
  1724. Utils_1.utils.showLog("RewardInsert组件不存在!");
  1725. }
  1726. }
  1727. else {
  1728. Utils_1.utils.showLog("激励插屏没有创建!");
  1729. }
  1730. };
  1731. // public ShowStatementRecomment(): cc.Node {
  1732. // if (PlatUtils.IsOPPO) {
  1733. // utils.showLog("curPosIdIndexNativeInsert:", this._curPosIdIndexNativeInser);
  1734. // let nativeInsertAd = this._nativeInsertAd[this._curPosIdIndexNativeInser];
  1735. // if (!nativeInsertAd) {
  1736. // if (utils.config.oppoconfig.nativeInsertIds
  1737. // && utils.config.oppoconfig.nativeInsertIds[this._curPosIdIndexNativeInser]) {
  1738. // utils.showLog("创建原生结算页面广告。 posId:", utils.config.oppoconfig.nativeInsertIds[this._curPosIdIndexNativeInser]);
  1739. // nativeInsertAd = qg.createNativeAd({
  1740. // posId: utils.config.oppoconfig.nativeInsertIds[this._curPosIdIndexNativeInser]
  1741. // });
  1742. // if (nativeInsertAd) {
  1743. // this._nativeInsertAd.push(nativeInsertAd);
  1744. // nativeInsertAd.onLoad((res) => {
  1745. // if (res && res.adList && res.adList.length > 0) {
  1746. // utils.showLog("原生原生结算页面资源拉取成功!");
  1747. // utils.showLog(JSON.stringify(res));
  1748. // res = JSON.parse(JSON.stringify(res));
  1749. // let data = res.adList[0];
  1750. // if (this._checkNativeDataValid(data)) {
  1751. // this._curPosIdIndexNativeInser = 0;
  1752. // // this._showNativeInsert(nativeInsertAd, data);
  1753. // // return this.cre;
  1754. // } else {
  1755. // utils.showLog("原生结算页面资源不合法!");
  1756. // }
  1757. // }
  1758. // utils.showLog("原生结算页面资源出错!");
  1759. // this._curPosIdIndexNativeInser++;
  1760. // if (this._curPosIdIndexNativeInser < utils.config.oppoconfig.nativeInsertIds.length) {
  1761. // this.ShowStatementRecomment();
  1762. // } else {
  1763. // this._curPosIdIndexNativeInser = 0;
  1764. // // 原生广告遍历完毕
  1765. // utils.showLog("原生结算页面遍历完毕,无法展示!");
  1766. // }
  1767. // });
  1768. // nativeInsertAd.onError((err) => {
  1769. // utils.showLog("原生结算页面资源拉取失败!", err.code, err.msg);
  1770. // this._curPosIdIndexNativeInser++;
  1771. // if (this._curPosIdIndexNativeInser < utils.config.oppoconfig.nativeInsertIds.length) {
  1772. // this.ShowStatementRecomment();
  1773. // } else {
  1774. // this._curPosIdIndexNativeInser = 0;
  1775. // // 原生广告遍历完毕
  1776. // utils.showLog("原生结算页面遍历完毕,无法展示!");
  1777. // }
  1778. // });
  1779. // }
  1780. // }
  1781. // }
  1782. // if (nativeInsertAd) {
  1783. // nativeInsertAd.load();
  1784. // } else {
  1785. // this._curPosIdIndexNativeInser++;
  1786. // if (utils.config.oppoconfig.nativeInsertIds && this._curPosIdIndexNativeInser < utils.config.oppoconfig.nativeInsertIds.length) {
  1787. // this.ShowStatementRecomment();
  1788. // } else {
  1789. // this._curPosIdIndexNativeInser = 0;
  1790. // // 原生广告遍历完毕
  1791. // utils.showLog("原生插屏广告遍历完毕,无法展示!");
  1792. // }
  1793. // }
  1794. // }
  1795. // return null;
  1796. // }
  1797. AdAgentOPPO.prototype.checkIsShowStatementAd = function () {
  1798. if (Utils_1.utils.isSupportnavigateToMiniGame() && this.ServerConfig) {
  1799. return true;
  1800. }
  1801. Utils_1.utils.showLog("当前平台不支持游戏内跳转,6元素交叉推广组件不显示!");
  1802. return false;
  1803. };
  1804. /**
  1805. * 创建结算页面推广组件
  1806. */
  1807. AdAgentOPPO.prototype.ShowStatementRecomment = function (showNativeAd) {
  1808. if (showNativeAd === void 0) { showNativeAd = true; }
  1809. if (this.checkIsShowStatementAd()) {
  1810. if (!showNativeAd) {
  1811. if (Utils_1.utils.config.otherconfig.crossWidget6) {
  1812. var node = cc.instantiate(Utils_1.utils.config.otherconfig.crossWidget6);
  1813. Utils_1.utils.showLog("只显示结算互推广告");
  1814. return node;
  1815. }
  1816. else {
  1817. Utils_1.utils.showLog("未找到预制体 crossWidget6, 请查看CommonUtils组件上是否赋值!");
  1818. return null;
  1819. }
  1820. }
  1821. else {
  1822. if (Utils_1.utils.config.otherconfig.statementRecomment) {
  1823. var node = cc.instantiate(Utils_1.utils.config.otherconfig.statementRecomment);
  1824. var statementRecomment = node.getComponent("YZ_StatementRecommentAd");
  1825. statementRecomment.showNativeAd = showNativeAd;
  1826. Utils_1.utils.showLog("显示结算互推和原生广告");
  1827. return node;
  1828. }
  1829. else {
  1830. Utils_1.utils.showLog("未找到预制体 StatementRecomment, 请查看CommonUtils组件上是否赋值!");
  1831. return null;
  1832. }
  1833. }
  1834. }
  1835. else {
  1836. return null;
  1837. }
  1838. };
  1839. AdAgentOPPO.prototype._showNativeAd = function () {
  1840. if (this._curNativeItem && cc.isValid(this._curNativeItem.node)) {
  1841. this._curNativeItem.init(this.getNativeAdData());
  1842. }
  1843. };
  1844. /**
  1845. * 创建结算页面推广组件
  1846. */
  1847. AdAgentOPPO.prototype.ShowSingleNativeAd = function (params) {
  1848. if (Utils_1.utils.config.otherconfig.singleNativeAd) {
  1849. if (this.signleNativeAd && cc.isValid(this.signleNativeAd)) {
  1850. this.signleNativeAd.destroy();
  1851. }
  1852. this.signleNativeAd = cc.instantiate(Utils_1.utils.config.otherconfig.singleNativeAd);
  1853. var nativeItem = this.signleNativeAd.getComponent("YZ_NativeItem");
  1854. nativeItem.showType = 2;
  1855. nativeItem.params = params;
  1856. this._curNativeItem = nativeItem;
  1857. if (params && params.parent) {
  1858. params.parent.addChild(this.signleNativeAd, cc.macro.MAX_ZINDEX);
  1859. }
  1860. this.createNativeAd();
  1861. Utils_1.utils.showLog("单个原生广告创建成功!");
  1862. return this.signleNativeAd;
  1863. }
  1864. else {
  1865. Utils_1.utils.showLog("未找到预制体 singleNativeAd, 请查看CommonUtils组件上是否赋值!");
  1866. return null;
  1867. }
  1868. };
  1869. /**
  1870. * 显示结算广告
  1871. * @param data
  1872. * @returns json{ type:(1:6元素互推,2:单个原生广告),node:节点}
  1873. */
  1874. AdAgentOPPO.prototype.showStatementAds = function (data) {
  1875. var result = { "type": 0, "node": null };
  1876. if (this.ServerConfig && this.ServerConfig.statement_type) {
  1877. if (this.ServerConfig.statement_type === 4) {
  1878. result.type = 2;
  1879. result.node = this.ShowSingleNativeAd();
  1880. Utils_1.utils.showLog("结算广告 >> 单个原生广告>>" + result.node.name);
  1881. }
  1882. else {
  1883. this.ShowInterstitial();
  1884. }
  1885. return result;
  1886. // let isSycn = this.ServerConfig.st_sync;
  1887. // let node: cc.Node = null;
  1888. // let resType: number = 0;
  1889. // switch (type) {
  1890. // case 1:
  1891. // utils.showLog("结算广告 >> 只显示小游戏插屏广告");
  1892. // if (!this.checkInsertAdShow()) {
  1893. // if (spareType && spareType > 0) {
  1894. // switch (spareType) {
  1895. // case 3:
  1896. // utils.showLog("结算广告 >> 小游戏插屏达到限制的次数 >> 显示备用组件 6个互推");
  1897. // node = this.ShowStatementRecomment(false);
  1898. // resType = 1;
  1899. // break;
  1900. // case 4:
  1901. // utils.showLog("结算广告 >> 小游戏插屏达到限制的次数 >> 显示备用组件 单个原生广告");
  1902. // node = this.ShowSingleNativeAd();
  1903. // resType = 2;
  1904. // break;
  1905. // case 5:
  1906. // utils.showLog("结算广告 >> 小游戏插屏达到限制的次数 >> 显示备用组件 3个互推+单个原生广告");
  1907. // node = this.ShowStatementRecomment();
  1908. // resType = 1;
  1909. // break;
  1910. // }
  1911. // }
  1912. // } else {
  1913. // this._createMiniGameInsertAd(true);
  1914. // }
  1915. // break;
  1916. // case 2:
  1917. // utils.showLog("结算广告 >> 显示插屏广告且判断优先级");
  1918. // if (!this.checkInsertAdShow()) {
  1919. // if (spareType) {
  1920. // switch (spareType) {
  1921. // case 3:
  1922. // utils.showLog("结算广告 >> 小游戏插屏达到限制的次数 >> 显示备用组件 6个互推");
  1923. // node = this.ShowStatementRecomment(false);
  1924. // resType = 1;
  1925. // break;
  1926. // case 4:
  1927. // utils.showLog("结算广告 >> 小游戏插屏达到限制的次数 >> 显示备用组件 单个原生广告");
  1928. // node = this.ShowSingleNativeAd();
  1929. // resType = 2;
  1930. // break;
  1931. // case 5:
  1932. // utils.showLog("结算广告 >> 小游戏插屏达到限制的次数 >> 显示备用组件 3个互推+单个原生广告");
  1933. // node = this.ShowStatementRecomment();
  1934. // resType = 1;
  1935. // break;
  1936. // }
  1937. // }
  1938. // } else {
  1939. // this.ShowInterstitial();
  1940. // }
  1941. // break;
  1942. // case 3:
  1943. // utils.showLog("结算广告 >> 显示插屏广告+6个互推");
  1944. // this.ShowInterstitial();
  1945. // node = this.ShowStatementRecomment(false);
  1946. // resType = 1;
  1947. // break;
  1948. // case 4:
  1949. // if (isSycn && isSycn == "true") {
  1950. // utils.showLog("结算广告 >> 显示插屏广告+单个原生广告");
  1951. // this.ShowInterstitial();
  1952. // node = this.ShowSingleNativeAd();
  1953. // } else {
  1954. // node = this.ShowSingleNativeAd();
  1955. // utils.showLog("结算广告 >> 只显示单个原生广告");
  1956. // }
  1957. // resType = 2;
  1958. // break;
  1959. // case 5:
  1960. // if (isSycn && isSycn == "true") {
  1961. // utils.showLog("结算广告 >> 显示插屏广告+ 3个互推+单个原生广告");
  1962. // this.ShowInterstitial();
  1963. // node = this.ShowStatementRecomment();
  1964. // } else {
  1965. // utils.showLog("结算广告 >> 只显示 3个互推+单个原生广告");
  1966. // node = this.ShowStatementRecomment();
  1967. // }
  1968. // resType = 1;
  1969. // break;
  1970. // case 6:
  1971. // if (isSycn && isSycn == "true") {
  1972. // utils.showLog("结算广告 >> 显示滚动互推+原生广告");
  1973. // node = this.ShowStatementRecomment(true);
  1974. // } else {
  1975. // utils.showLog("结算广告 >> 只显示滚动互推");
  1976. // node = this.ShowStatementRecomment();
  1977. // }
  1978. // resType = 1;
  1979. // break;
  1980. // default:
  1981. // utils.showLog("非法的结算广告类型,:" + type)
  1982. // break;
  1983. // }
  1984. // result.type = resType;
  1985. // result.node = node;
  1986. // return result;
  1987. }
  1988. else {
  1989. Utils_1.utils.showLog("没有配置结算广告!");
  1990. return result;
  1991. }
  1992. };
  1993. /**
  1994. * 显示浮窗广告挂件
  1995. * @param params
  1996. * ```
  1997. * {
  1998. * group:string
  1999. * left:number
  2000. * bottom:number
  2001. * scale:number
  2002. * parent:cc.Node
  2003. * }
  2004. * ```
  2005. * @returns 生成的组件
  2006. */
  2007. AdAgentOPPO.prototype.createNativeTryGameWidget = function (params) {
  2008. if (params === void 0) { params = null; }
  2009. if (this._nativeTryGameNode && cc.isValid(this._nativeTryGameNode)) {
  2010. this._nativeTryGameNode.destroy();
  2011. }
  2012. var node = cc.instantiate(Utils_1.utils.config.otherconfig.nativeTryGameWidget);
  2013. if (node) {
  2014. this._nativeTryGameNode = node;
  2015. this._nativeTryGameNode.zIndex = 9999;
  2016. }
  2017. node = this._nativeTryGameNode;
  2018. var widget = node.getComponent(cc.Widget);
  2019. if (params) {
  2020. if (params.group) {
  2021. node.group = params.group;
  2022. }
  2023. if (params.scale != null) {
  2024. node.scale = params.scale;
  2025. }
  2026. if (params.top != null) {
  2027. widget.isAlignTop = true;
  2028. widget.isAlignBottom = false;
  2029. widget.top = params.top;
  2030. }
  2031. else if (params.bottom != null) {
  2032. widget.isAlignTop = false;
  2033. widget.isAlignBottom = true;
  2034. widget.bottom = params.bottom;
  2035. }
  2036. if (params.left != null) {
  2037. widget.isAlignLeft = true;
  2038. widget.isAlignRight = false;
  2039. widget.left = params.left;
  2040. }
  2041. else if (params.right != null) {
  2042. widget.isAlignLeft = false;
  2043. widget.isAlignRight = true;
  2044. widget.right = params.right;
  2045. }
  2046. if (params.parent != null) {
  2047. node.parent = params.parent;
  2048. }
  2049. }
  2050. widget.updateAlignment();
  2051. node.active = true;
  2052. if (this._nativeTryGameNode) {
  2053. this._nativeTryGameNode.getComponent(NativeTryGamesWidget_1.default).init();
  2054. }
  2055. };
  2056. /**
  2057. * 隐藏浮动试玩挂件
  2058. */
  2059. AdAgentOPPO.prototype.hideNativeTryGameWidget = function () {
  2060. if (this._nativeTryGameNode && cc.isValid(this._nativeTryGameNode)) {
  2061. this._nativeTryGameNode.destroy();
  2062. }
  2063. };
  2064. /**
  2065. * 是否支持原生模版广告
  2066. * @returns
  2067. */
  2068. AdAgentOPPO.prototype.canShowNativeTemplateAd = function () {
  2069. //@ts-ignore
  2070. return qg.createCustomAd;
  2071. };
  2072. /**
  2073. * 获取原生模版广告对象
  2074. * @param type 广告类型:1:banner 2:插屏
  2075. * @param id 广告ID
  2076. */
  2077. AdAgentOPPO.prototype.getNativeTemplateAdStyle = function (type) {
  2078. var style = {};
  2079. var systemInfo = Utils_1.utils.oppoTool.SysInfo;
  2080. switch (type) {
  2081. case 1:
  2082. style.width = "";
  2083. style.top = "";
  2084. style.left = "";
  2085. break;
  2086. case 2:
  2087. style.width = "";
  2088. style.top = (systemInfo.screenHeight - 400) / 2;
  2089. style.left = "";
  2090. break;
  2091. }
  2092. return style;
  2093. };
  2094. /**
  2095. * 创建原生模版Banner广告
  2096. * @param index
  2097. * @returns
  2098. */
  2099. AdAgentOPPO.prototype._createNativeTemplateBannerAd = function (index) {
  2100. var _this = this;
  2101. Utils_1.utils.showLog("_createNativeTemplateBannerAd : #index=" + index);
  2102. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  2103. if (!this.canShowNativeTemplateAd()) {
  2104. Utils_1.utils.showLog("当前快应用版本不支持原生模版广告!");
  2105. return;
  2106. }
  2107. if (index < Utils_1.utils.config.oppoconfig.bannerAdConfigs.length) {
  2108. //@ts-ignore
  2109. this.nativeTemplateBannerAd = qg.createCustomAd({
  2110. adUnitId: Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id,
  2111. style: this.getNativeTemplateAdStyle(1)
  2112. });
  2113. this.nativeTemplateBannerAd.onLoad(function () {
  2114. _this.nativeTemplateBannerAd.offLoad();
  2115. Utils_1.utils.showLog("NativeTemplateBannerAd 广告加载成功");
  2116. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  2117. });
  2118. this.nativeTemplateBannerAd.onError(function (err) {
  2119. _this.nativeTemplateBannerAd.offError();
  2120. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.REQUEST_FAIL, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  2121. Utils_1.utils.showLog("NativeTemplateBannerAd 广告异常:#erro=" + JSON.stringify(err));
  2122. if (_this._nativeIsClose) {
  2123. Utils_1.utils.showLog("隐藏了BANNER,不做任何处理!");
  2124. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  2125. return;
  2126. }
  2127. var bannerInfo = _this.getNativeBannerInfo();
  2128. if (bannerInfo.st_banner_show_back_up == -1) {
  2129. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_FAIL);
  2130. Utils_1.utils.showLog(">>>>>服务器配置不显示备用广告!");
  2131. return;
  2132. }
  2133. _this.ShowBannerByConfigs(index + 1);
  2134. });
  2135. this.nativeTemplateBannerAd
  2136. .show()
  2137. .then(function () {
  2138. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.bannerAdConfigs[index].id));
  2139. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.NATIVE_TEMPLATE_BANNER, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_SUCCESS);
  2140. _this.nativeTemplateBannerAd.offShow();
  2141. Utils_1.utils.showLog("NativeTemplateBannerAd show success");
  2142. _this.hideBanner("template");
  2143. })
  2144. .catch(function (error) {
  2145. Utils_1.utils.showLog("NativeTemplateBannerAd show fail with:" + error.errCode + "," + error.errMsg);
  2146. });
  2147. }
  2148. };
  2149. /**
  2150. * 隐藏原生模版Banner
  2151. */
  2152. AdAgentOPPO.prototype.hideNativeTemplateBannerAd = function () {
  2153. Utils_1.utils.showLog("hideNativeTemplateBannerAd ");
  2154. this.nativeTemplateBannerAd && this.nativeTemplateBannerAd.destroy();
  2155. this.nativeTemplateBannerAd = null;
  2156. };
  2157. /**
  2158. * 创建原生模版插屏广告
  2159. * @param index
  2160. * @returns
  2161. */
  2162. AdAgentOPPO.prototype._createNativeTemplateIntersitialAd = function (index) {
  2163. var _this = this;
  2164. Utils_1.utils.showLog("_createNativeTemplateIntersitialAd : #index=" + index);
  2165. if (!this.canShowNativeTemplateAd()) {
  2166. Utils_1.utils.showLog("当前快应用版本不支持原生模版广告!");
  2167. return;
  2168. }
  2169. if (index < Utils_1.utils.config.oppoconfig.intersitialAdConfigs.length) {
  2170. Utils_1.utils.showLog("nativetemplate style=" + this.getNativeTemplateAdStyle(2));
  2171. //@ts-ignore
  2172. var customAd = qg.createCustomAd({
  2173. adUnitId: Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id,
  2174. style: this.getNativeTemplateAdStyle(2)
  2175. });
  2176. customAd.onLoad(function () {
  2177. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.REQUEST_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  2178. Utils_1.utils.showLog("NativeTemplateIntersitialAd 广告加载成功");
  2179. });
  2180. customAd.onError(function (err) {
  2181. Utils_1.utils.showLog("NativeTemplateIntersitialAd 广告异常:" + +JSON.stringify(err));
  2182. _this.ShowInterstitialByConfigs(index + 1);
  2183. });
  2184. customAd
  2185. .show()
  2186. .then(function () {
  2187. Utils_1.utils.showLog("NativeTemplateIntersitialAd show success");
  2188. _this._insertLastShowTime = new Date().getTime();
  2189. var closeType = _this.ServerConfig.intersititial_open_close_banner;
  2190. if (closeType && closeType > 0) {
  2191. Utils_1.utils.showLog("OPPO 配置当前插屏显示成功后" + (closeType == 1 ? "销毁" : "隐藏") + "banner!");
  2192. _this.HideBanner();
  2193. }
  2194. YouWanAnalytics_1.default.EventAd(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.AD_ID_REQUEST_SUCCESS);
  2195. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.INTERSITITIAL, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(Utils_1.utils.config.oppoconfig.intersitialAdConfigs[index].id));
  2196. })
  2197. .catch(function (error) {
  2198. Utils_1.utils.showLog("NativeTemplateIntersitialAd show fail with:" + error.errCode + "," + error.errMsg);
  2199. });
  2200. }
  2201. };
  2202. AdAgentOPPO.prototype.GameExit = function () { };
  2203. AdAgentOPPO.prototype.Share = function () { };
  2204. AdAgentOPPO = __decorate([
  2205. ccclass
  2206. ], AdAgentOPPO);
  2207. return AdAgentOPPO;
  2208. }(AdAgent_1.default));
  2209. exports.default = AdAgentOPPO;
  2210. cc._RF.pop();