123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- "use strict";
- cc._RF.push(module, 'cc3a7d5GfpIjLR4b2QEfuw+', 'Icon');
- // Script/sdk/vivo/Icon.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 NativeAdComponent_1 = require("./NativeAdComponent");
- var SDK_1 = require("../SDK");
- var Utils_1 = require("../tools/Utils");
- var VivoAd_1 = require("./VivoAd");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var Icon = /** @class */ (function (_super) {
- __extends(Icon, _super);
- function Icon() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this._iconList = [];
- return _this;
- }
- Icon.prototype.init = function (config) {
- this._config = config;
- Utils_1.default.instance.log('创建Icon广告');
- };
- Icon.prototype.showIconAd = function (id, x, y) {
- if (id === void 0) { id = 0; }
- var self = this;
- if (this._config == null) {
- return;
- }
- if (this._config.masterEnable != 1) { //插屏是否打开
- return;
- }
- if (this._config.iconAdEnable != 1) { //插屏是否打开
- return;
- }
- var adNodeList = JSON.parse(this._config.insertAdNodeList);
- //当前节点是否打开
- if (adNodeList[id].enable != 1) {
- return;
- }
- var nativeData = VivoAd_1.default.Instance.getVivoNativeData();
- if (nativeData == null || !nativeData.isReady()) {
- Utils_1.default.instance.log("---------showNativeIconAd 广告数据不存在-----");
- return;
- }
- var clickCallBack = function () {
- VivoAd_1.default.Instance.creatorNativeData();
- SDK_1.default.Instance.reportLog(SDK_1.NodeAction.NATIVE_CLICK, "原生icon点击");
- };
- var showCallBack = function () {
- //缓存下一条广告
- VivoAd_1.default.Instance.creatorNativeData();
- SDK_1.default.Instance.reportLog(SDK_1.NodeAction.NATIVE_SHOW, "原生icon展示");
- };
- var closeCallBack = function () {
- SDK_1.default.Instance.reportLog(SDK_1.NodeAction.NATIVE_CLOSE, "原生icon关闭");
- };
- var node = cc.director.getScene().children[0];
- var iconAd = node.getChildByName("iconAd");
- if (iconAd) {
- iconAd.removeFromParent();
- // return ;
- }
- Utils_1.default.instance.loadPrefabs("sdk/res/prefabs/NativeIconAd", function (prefabs) {
- var adNode = cc.instantiate(prefabs);
- self._nativeIconAd = adNode.addComponent(NativeAdComponent_1.default);
- self._nativeIconAd.initData(nativeData);
- self._nativeIconAd.listionCall(showCallBack, clickCallBack, closeCallBack);
- node.addChild(adNode, 1000, "icon"); //加节点名,防止重复加广告
- // adNode.active = false;
- self._nativeIconAd.showAd(NativeAdComponent_1.NativeType.ICON, self._config, x, y);
- });
- };
- Icon.prototype.hideIcon = function () {
- if (this._nativeIconAd) {
- this._nativeIconAd.hide();
- }
- };
- Icon = __decorate([
- ccclass
- ], Icon);
- return Icon;
- }(cc.Component));
- exports.default = Icon;
- cc._RF.pop();
|