123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- "use strict";
- cc._RF.push(module, '5acc17BgL5BEZEAC8rqVjks', 'NavtiveData');
- // Script/sdk/vivo/NavtiveData.ts
- "use strict";
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- 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;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var Utils_1 = require("../tools/Utils");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var NavtiveData = /** @class */ (function (_super) {
- __extends(NavtiveData, _super);
- function NavtiveData() {
- var _this = _super.call(this) || this;
- _this._nativeCurrentAd = null;
- _this._nativeAd = null;
- _this._ready = false;
- _this.enterGmae = false;
- _this._utils = Utils_1.default.instance;
- return _this;
- }
- NavtiveData.prototype.start = function () {
- };
- /**
- * 创建广告
- */
- NavtiveData.prototype.initAd = function (config, callbacks) {
- this._utils.log("------创建native广告-----");
- var posId = config.insertAdCode;
- this._nativeAd = qg.createNativeAd({
- posId: posId,
- });
- this.enterGmae = false;
- var self = this;
- if (this._nativeAd) {
- this._nativeAd.load();
- this._utils.log("------创建native广告-this.nativeAd.load(): " + this._nativeAd);
- this._nativeAd.onLoad(function (res) {
- self.enterGmae = true;
- self._utils.log('原生广告加载完成-onload触发 ' + JSON.stringify(res));
- if (res && res.adList) {
- self._nativeCurrentAd = res.adList.pop();
- self._ready = true;
- if (callbacks) {
- callbacks(true);
- }
- }
- });
- this._nativeAd.onError(function (err) {
- self._utils.log("原生广告加载异常" + JSON.stringify(err));
- self.enterGmae = true;
- if (err) {
- if (err.errCode == 30009) {
- if (callbacks) {
- callbacks(false);
- }
- }
- else {
- if (callbacks) {
- callbacks(false);
- }
- }
- }
- });
- }
- else {
- self.enterGmae = true;
- if (callbacks) {
- callbacks(false);
- }
- }
- //5秒没反应,直接进入游戏
- this.scheduleOnce(function () {
- if (self.enterGmae) {
- return;
- }
- if (callbacks) {
- callbacks(false);
- }
- }, 5);
- };
- /**
- * 广告展示上报
- */
- NavtiveData.prototype.reportAdShow = function () {
- if (this._nativeAd && this._nativeCurrentAd) {
- this._nativeAd.reportAdShow({ adId: this._nativeCurrentAd.adId.toString() });
- }
- };
- /**
- * 广告点击上报
- */
- NavtiveData.prototype.reportAdClick = function () {
- if (this._nativeAd && this._nativeCurrentAd) {
- this._nativeAd.reportAdClick({ adId: this._nativeCurrentAd.adId.toString() });
- }
- };
- /**
- * 获取广告数据
- * @returns
- */
- NavtiveData.prototype.getNativeDate = function () {
- return this._nativeCurrentAd;
- };
- NavtiveData.prototype.isReady = function () {
- return this._ready;
- };
- NavtiveData = __decorate([
- ccclass
- ], NavtiveData);
- return NavtiveData;
- }(cc.Component));
- exports.default = NavtiveData;
- cc._RF.pop();
|