123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623 |
- "use strict";
- cc._RF.push(module, 'a2a680a5EJDfKlZKlM8P3Vv', 'YZ_NativeBanner');
- // common-plugin/Scripts/YZ_NativeBanner.ts
- "use strict";
- 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 (b.hasOwnProperty(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 PlatUtils_1 = require("./PlatUtils");
- var Utils_1 = require("./Utils");
- var YZ_Constant_1 = require("./YZ_Constant");
- var CompatibleTool_1 = require("./CompatibleTool");
- var EventAdInfo_1 = require("./YouWanSDK/EventAdInfo");
- var YouWanAnalytics_1 = require("./YouWanSDK/YouWanAnalytics");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var YZ_NativeBanner = /** @class */ (function (_super) {
- __extends(YZ_NativeBanner, _super);
- function YZ_NativeBanner() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this._panel = null;
- _this._icon = null;
- _this._hW_icon = null;
- _this._sourceLable = null;
- _this._titleLabel = null;
- _this._desLabel = null;
- _this._btnLabel = null;
- _this._widget = null;
- _this._closeBtn = null;
- _this._nativeAd = null;
- _this._data = null;
- _this._dataDirty = false;
- _this._panel_widget = null;
- _this._closeBtn_widget = null;
- _this._mask_widget = null;
- _this._st_Panel = null;
- _this._st_Icon = null;
- _this._st_TitleLabel = null;
- _this._st_DesLabel = null;
- _this._st_BtnLabel = null;
- _this._st_Widget = null;
- _this._st_Img = null;
- _this._st_CloseBtn = null;
- _this._st_BtnDown = null;
- _this._st_adMask = null;
- _this._st_down_btn_default_img = null;
- _this.nativeBannerInfo = null;
- _this._st_TitleLabel_Widget = null;
- _this._st_DesLabel_Widget = null;
- _this._st_Img_Widget = null;
- _this._st_CloseBtn_Widget = null;
- _this._st_BtnDown_Widget = null;
- _this._st_adMask_Widget = null;
- _this._st_Icon_widget = null;
- _this._bg_mask = null;
- _this._alignType = "";
- _this._xmMask = null;
- return _this;
- }
- Object.defineProperty(YZ_NativeBanner.prototype, "ServerConfig", {
- get: function () {
- return Utils_1.utils.ServerConfig;
- },
- enumerable: false,
- configurable: true
- });
- YZ_NativeBanner.prototype.onLoad = function () {
- if (Utils_1.utils.otherConfig && Utils_1.utils.otherConfig.group) {
- this.node.group = Utils_1.utils.otherConfig.group;
- }
- cc.game.addPersistRootNode(this.node);
- this._panel = this.node.getChildByName("Panel");
- this._icon = this._panel.getChildByName("Icon").getComponent(cc.Sprite);
- this._hW_icon = this._panel.getChildByName("HuaweiIcon").getComponent(cc.Sprite);
- this._titleLabel = this._panel.getChildByName("TitleLabel").getComponent(cc.Label);
- this._desLabel = this._panel.getChildByName("DesLabel").getComponent(cc.Label);
- this._sourceLable = this._panel.getChildByName("source").getComponent(cc.Label);
- var btnDown = this._panel.getChildByName("Btn_Download");
- this._btnLabel = btnDown.getComponentInChildren(cc.Label);
- this._widget = this.getComponent(cc.Widget);
- this._panel_widget = this._panel.getComponent(cc.Widget);
- this._closeBtn = this._panel.getChildByName("Btn_Close");
- this._closeBtn_widget = this._closeBtn.getComponent(cc.Widget);
- this._mask_widget = this._panel.getChildByName("Mask").getComponent(cc.Widget);
- this._widget.left = 0;
- this._widget.right = 0;
- this._widget.bottom = 0;
- this._st_Panel = this.node.getChildByName("Panel_Statement");
- this._st_Widget = this._st_Panel.getComponent(cc.Widget);
- this._bg_mask = this.node.getChildByName("bgMask");
- this._st_Icon = this._st_Panel.getChildByName("IconMask").getChildByName("Icon").getComponent(cc.Sprite);
- this._st_TitleLabel = this._st_Panel.getChildByName("TitleLabel").getComponent(cc.Label);
- this._st_DesLabel = this._st_Panel.getChildByName("DesLabel").getComponent(cc.Label);
- this._st_BtnDown = this._st_Panel.getChildByName("Btn_Download");
- // this._st_BtnLabel = stBtnDown.getComponentInChildren(cc.Label);
- this._st_Img = this._st_Panel.getChildByName("adImage").getComponent(cc.Sprite);
- this._st_CloseBtn = this._st_Panel.getChildByName("Btn_Close");
- this._st_adMask = this._st_Panel.getChildByName("Mask");
- this._st_down_btn_default_img = this._st_BtnDown.getComponent(cc.Sprite).spriteFrame;
- this._st_TitleLabel_Widget = this._st_TitleLabel.getComponent(cc.Widget);
- this._st_DesLabel_Widget = this._st_DesLabel.getComponent(cc.Widget);
- this._st_Img_Widget = this._st_Img.getComponent(cc.Widget);
- this._st_CloseBtn_Widget = this._st_CloseBtn.getComponent(cc.Widget);
- this._st_BtnDown_Widget = this._st_BtnDown.getComponent(cc.Widget);
- this._st_adMask_Widget = this._st_adMask.getComponent(cc.Widget);
- this._st_Icon_widget = this._st_Panel.getChildByName("IconMask").getComponent(cc.Widget);
- if (PlatUtils_1.default.IsXiaoMi || CC_DEBUG) {
- this._panel.getChildByName("Xm_Mark").active = true;
- this._mask_widget.node.active = false;
- }
- var ratio = 1;
- if (cc.winSize.height < cc.winSize.width) {
- // 横屏游戏
- this._widget.left = cc.winSize.width * 0.25;
- this._widget.right = cc.winSize.width * 0.25;
- this._titleLabel.node.width = 400;
- ratio = cc.winSize.width / 1920;
- }
- else {
- ratio = cc.winSize.width / 1080;
- }
- this.node.scale = ratio;
- };
- YZ_NativeBanner.prototype.onShow = function () {
- cc.game.emit("HuaWeiOnShow");
- };
- YZ_NativeBanner.prototype.onEnable = function () {
- var _this = this;
- this._st_Panel.targetOff(this);
- this._panel.targetOff(this);
- cc.game.targetOff(this);
- if (PlatUtils_1.default.IsHuaWei) {
- console.log("注册监听事件 >>>>>.");
- cc.game.on(cc.game.EVENT_SHOW, function () {
- console.log("HuaWeiOnShow >>>>>>");
- _this._reportAdShow();
- }, this);
- }
- if (PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsHuaWei || PlatUtils_1.default.IsXiaoMi) {
- this._st_Panel.on(cc.Node.EventType.TOUCH_START, function (event) {
- _this._reportAdClick();
- }, this);
- this._panel.on(cc.Node.EventType.TOUCH_START, function (event) {
- _this._reportAdClick();
- }, this);
- cc.game.on(YZ_Constant_1.default.YZ_NativeAdClick, function () {
- _this._reportAdClick();
- }, this);
- }
- };
- YZ_NativeBanner.prototype.onDisable = function () {
- if (PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsHuaWei || PlatUtils_1.default.IsXiaoMi) {
- this._st_Panel.targetOff(this);
- this._panel.targetOff(this);
- }
- cc.game.targetOff(this);
- };
- YZ_NativeBanner.prototype.init = function (nativeAd, data, nativeBannerInfo) {
- this._nativeAd = nativeAd;
- this._data = data;
- this._dataDirty = true;
- this.nativeBannerInfo = nativeBannerInfo;
- // this.nativeBannerInfo.banner_show_height = 500;
- // this.nativeBannerInfo.st_banner_style = 1;
- // this.nativeBannerInfo.st_banner_down_but_show = 2;
- // this.nativeBannerInfo.show_st_banner = "true";
- // this.nativeBannerInfo.st_banner_width = 800;
- // this.nativeBannerInfo.st_banner_height = 300;
- if (this.nativeBannerInfo.show_st_banner == "true") {
- if (this.nativeBannerInfo.st_banner_style > -1) {
- if (this._data.imgUrlList && this._data.imgUrlList.length > 0) {
- this._panel.active = false;
- this._st_Panel.active = true;
- }
- else {
- this._panel.active = false;
- this._st_Panel.active = false;
- }
- }
- else {
- this._panel.active = false;
- this._st_Panel.active = true;
- }
- }
- else {
- this._panel.active = true;
- this._st_Panel.active = false;
- }
- // if(this.nativeBannerInfo._alignType === "top")
- // {
- // this._widget.top = 0;
- // this._widget.isAlignTop = true;
- // this._widget.isAlignBottom = false;
- // this._widget.updateAlignment();
- // }
- // utils.showLog("当前显示位置为:", this.nativeBannerInfo.location, ">>显示参数为:", this.nativeBannerInfo.toStrong());
- };
- YZ_NativeBanner.prototype.update = function (dt) {
- if (this._data && this._dataDirty) {
- this._dataDirty = false;
- this._updateContent();
- }
- if (!this._data) {
- this._st_Panel.active = false;
- this._panel.active = false;
- }
- };
- YZ_NativeBanner.prototype._updateContent = function () {
- var _this = this;
- if (this._data) {
- // 上报展示
- this._reportAdShow();
- if (PlatUtils_1.default.IsHuaWei) {
- this._data.icon = "";
- }
- Utils_1.utils.nativeBannerShowCount++;
- if (this.nativeBannerInfo.show_st_banner == "true" && this.nativeBannerInfo.st_banner_style > -1) {
- if (this.nativeBannerInfo.st_banner_style == 1 || this.nativeBannerInfo.st_banner_style == 2) {
- if (this.nativeBannerInfo.st_banner_width > -1) {
- this._st_Panel.width = this.nativeBannerInfo.st_banner_width;
- }
- else {
- this._st_Panel.width = 821.4;
- }
- if (this.nativeBannerInfo.st_banner_height > -1) {
- this._st_Panel.height = this.nativeBannerInfo.st_banner_height;
- }
- else {
- this._st_Panel.height = 589;
- }
- this._st_Widget.updateAlignment();
- this._st_adMask_Widget.updateAlignment();
- this._st_CloseBtn_Widget.updateAlignment();
- this._st_BtnDown_Widget.updateAlignment();
- this._st_Icon_widget.updateAlignment();
- }
- else {
- this._st_Panel.width = 821.4;
- this._st_Panel.height = 589;
- this._st_Widget.updateAlignment();
- this._st_adMask_Widget.updateAlignment();
- this._st_CloseBtn_Widget.updateAlignment();
- this._st_BtnDown_Widget.updateAlignment();
- this._st_Icon_widget.updateAlignment();
- }
- if (this.nativeBannerInfo.st_banner_style == 0 || this.nativeBannerInfo.st_banner_style == 1) {
- Utils_1.utils.showLog("//单图片样式,拉伸图片,并且隐藏标题和描述");
- this._st_Img_Widget.top = 0;
- this._st_Img_Widget.bottom = 0;
- this._st_Img_Widget.isAlignTop = true;
- this._st_Img_Widget.isAlignBottom = true;
- this._st_Img_Widget.updateAlignment();
- this._st_DesLabel.node.active = false;
- this._st_TitleLabel.node.active = false;
- this._st_Icon_widget.updateAlignment();
- }
- else if (this.nativeBannerInfo.st_banner_style == 2) {
- Utils_1.utils.showLog("默认样式自定义宽高:展示标题和描述");
- this._st_DesLabel.node.active = true;
- this._st_TitleLabel.node.active = true;
- this._st_DesLabel_Widget.updateAlignment();
- this._st_TitleLabel_Widget.updateAlignment();
- this._st_Img_Widget.isAlignTop = true;
- this._st_Img_Widget.isAlignBottom = true;
- this._st_Img_Widget.top = this._st_TitleLabel.node.height + this._st_TitleLabel_Widget.top;
- this._st_Img_Widget.bottom = this._st_DesLabel_Widget.node.height + this._st_DesLabel_Widget.bottom;
- this._st_Img_Widget.updateAlignment();
- this._st_Icon_widget.updateAlignment();
- }
- else {
- this._st_Img_Widget.isAlignTop = true;
- this._st_Img_Widget.isAlignBottom = true;
- this._st_Img_Widget.updateAlignment();
- this._st_DesLabel.node.active = true;
- this._st_TitleLabel.node.active = true;
- this._st_Icon_widget.updateAlignment();
- }
- }
- else if (this.nativeBannerInfo.show_st_banner == "true") {
- Utils_1.utils.showLog("结算banner使用默认样式!");
- this._st_Panel.width = 821.4;
- this._st_Panel.height = 589;
- this._st_Img_Widget.isAlignTop = false;
- this._st_Img_Widget.isAlignBottom = false;
- this._st_Img_Widget.updateAlignment();
- this._st_DesLabel.node.active = true;
- this._st_TitleLabel.node.active = true;
- this._st_Widget.updateAlignment();
- this._st_adMask_Widget.updateAlignment();
- this._st_CloseBtn_Widget.updateAlignment();
- this._st_BtnDown_Widget.updateAlignment();
- this._st_Icon_widget.updateAlignment();
- }
- this._st_CloseBtn.scale = this.nativeBannerInfo.st_banner_scale < 1 ? this._st_CloseBtn.scale * this.nativeBannerInfo.st_banner_scale : 1;
- this._st_adMask.scale = this.nativeBannerInfo.st_banner_scale < 1 ? this._st_adMask.scale * this.nativeBannerInfo.st_banner_scale : 1;
- this._st_CloseBtn.active = this.nativeBannerInfo.st_banner_close_but_show == "true";
- this._st_CloseBtn.opacity = this.nativeBannerInfo.st_banner_close_but_alpha;
- if (this.ServerConfig.first_native_banner_delayed_count_close) {
- if (Utils_1.utils.nativeBannerShowCount > 3 && this.ServerConfig.first_native_banner_delayed_count_close) {
- Utils_1.utils.nativeBannerResizeCloseBtnShowCount++;
- if (Utils_1.utils.nativeBannerResizeCloseBtnShowCount % this.ServerConfig.native_banner_delayed_count_close == 0) {
- Utils_1.utils.showLog("\u539F\u751Fbanner\u5173\u95ED\u6309\u94AE\u8BBE\u7F6E\u670D\u52A1\u5668\u914D\u7F6E\u5927\u5C0F" + this.ServerConfig.intersititia_close_but_size);
- if (this.nativeBannerInfo.st_banner_close_but_range) {
- this._st_CloseBtn.setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_range, this.nativeBannerInfo.st_banner_close_but_range));
- this._st_CloseBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_size, this.nativeBannerInfo.st_banner_close_but_size));
- }
- }
- }
- }
- else {
- if (this.nativeBannerInfo.st_banner_close_but_range) {
- this._st_CloseBtn.setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_range, this.nativeBannerInfo.st_banner_close_but_range));
- this._st_CloseBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_size, this.nativeBannerInfo.st_banner_close_but_size));
- }
- }
- if (this.nativeBannerInfo.st_banner_down_but_show) {
- this._st_BtnDown.active = true;
- if (this.nativeBannerInfo.st_banner_down_btn_image) {
- Utils_1.utils.showLog("this.nativeBannerInfo.st_banner_down_btn_image", this.nativeBannerInfo.st_banner_down_btn_image);
- CompatibleTool_1.default.LoadRes(this.nativeBannerInfo.st_banner_down_btn_image, function (err, res) {
- if (!err && cc.isValid(_this) && _this._st_BtnDown) {
- _this._st_BtnDown.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(res);
- if (_this.nativeBannerInfo.st_banner_down_but_margin_top) {
- _this._st_BtnDown_Widget.top = -(_this._st_BtnDown.getContentSize().height + _this.nativeBannerInfo.st_banner_down_but_margin_top);
- _this._st_BtnDown_Widget.updateAlignment();
- }
- else {
- _this._st_BtnDown_Widget.top = -_this._st_BtnDown.getContentSize().height;
- _this._st_BtnDown_Widget.updateAlignment();
- }
- }
- });
- }
- else {
- this._st_BtnDown.getComponent(cc.Sprite).spriteFrame = this._st_down_btn_default_img;
- if (this.nativeBannerInfo.st_banner_down_but_margin_top) {
- this._st_BtnDown_Widget.top -= this.nativeBannerInfo.st_banner_down_but_margin_top;
- this._st_BtnDown_Widget.updateAlignment();
- }
- }
- if (this.nativeBannerInfo.st_banner_down_but_show == 2) {
- this._st_BtnDown.runAction(cc.sequence(cc.scaleTo(0.3, 1.2), cc.scaleTo(0.3, 1)).repeatForever());
- }
- else {
- this._st_BtnDown.stopAllActions();
- }
- this._st_BtnDown.scale = this.node.scale;
- }
- else {
- this._st_BtnDown.active = false;
- this._st_BtnDown.stopAllActions();
- }
- this._closeBtn.active = this.nativeBannerInfo.banner_close_but_show == "true";
- this._closeBtn.opacity = this.nativeBannerInfo.banner_close_but_alpha;
- if (this.ServerConfig.first_native_banner_delayed_count_close) {
- if (Utils_1.utils.nativeBannerShowCount > 3 && this.ServerConfig.first_native_banner_delayed_count_close) {
- if (Utils_1.utils.nativeBannerResizeCloseBtnShowCount % this.ServerConfig.native_banner_delayed_count_close == 0) {
- Utils_1.utils.showLog("\u539F\u751Fbanner\u5173\u95ED\u6309\u94AE\u8BBE\u7F6E\u670D\u52A1\u5668\u914D\u7F6E\u5927\u5C0F" + this.ServerConfig.intersititia_close_but_size);
- this._closeBtn.setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_range, this.nativeBannerInfo.banner_close_but_range));
- this._closeBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_size, this.nativeBannerInfo.banner_close_but_size));
- }
- }
- }
- else {
- this._closeBtn.setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_range, this.nativeBannerInfo.banner_close_but_range));
- this._closeBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_size, this.nativeBannerInfo.banner_close_but_size));
- }
- if (this.nativeBannerInfo.show_st_banner == "false") {
- // this.node.setContentSize(cc.size(this.node.getContentSize().width,));
- this._panel_widget.isAlignTop = false;
- this._panel_widget.bottom = 0;
- this._panel.setContentSize(cc.size(this.node.getContentSize().width, this.nativeBannerInfo.banner_show_height < 160 ? 160 : this.nativeBannerInfo.banner_show_height));
- this._panel_widget.updateAlignment();
- this._closeBtn_widget.updateAlignment();
- this._mask_widget.updateAlignment();
- }
- else {
- //缩放
- this._st_Panel.scale = this.nativeBannerInfo.st_banner_scale ? this.nativeBannerInfo.st_banner_scale : 1;
- this._st_Widget.bottom = this.nativeBannerInfo.st_banner_bottom ? this.nativeBannerInfo.st_banner_bottom : 0;
- this._st_Widget.updateAlignment();
- }
- if (this.nativeBannerInfo._alignType === "top") {
- if (this.nativeBannerInfo.show_st_banner == "true") {
- this.node.height = this._st_Panel.height;
- this.node.width = this._st_Panel.width;
- this._st_CloseBtn_Widget.updateAlignment();
- this._st_adMask_Widget.updateAlignment();
- }
- else {
- this.node.height = this.nativeBannerInfo.banner_show_height < 160 ? 160 : this.nativeBannerInfo.banner_show_height;
- this._panel_widget.updateAlignment();
- this._closeBtn_widget.updateAlignment();
- this._mask_widget.updateAlignment();
- }
- this._widget.isAlignTop = true;
- // this._widget.top = 0;
- this._widget.isAlignBottom = false;
- this._widget.updateAlignment();
- }
- if (this.nativeBannerInfo.show_st_banner == "true") {
- Utils_1.utils.showLog("服务器配置显示为结算banner >>>>>");
- if (this.nativeBannerInfo.st_banner_bg_mask_opacity > 0) {
- this._bg_mask.opacity = this.nativeBannerInfo.st_banner_bg_mask_opacity;
- this._bg_mask.setContentSize(cc.size(this.node.getContentSize().width, this._st_Panel.height));
- this._st_adMask.active = false;
- }
- else {
- this._bg_mask.active = false;
- }
- // 居底部距离
- this._st_TitleLabel.string = this._data.title ? this._data.title : "";
- this._st_DesLabel.string = this._data.desc ? this._data.desc : "";
- // this._data.imgUrlList = null;
- // this._st_BtnLabel.string = this._data.clickBtnTxt ? this._data.clickBtnTxt : "查看详情";
- if (this._data.imgUrlList && this._data.imgUrlList.length > 0) {
- // 有图片,优先显示图片
- this._st_Icon.node.active = false;
- this._st_Img.node.active = true;
- CompatibleTool_1.default.LoadRes(this._data.imgUrlList[0], function (err, res) {
- if (!err && cc.isValid(_this) && _this._st_Img) {
- _this._st_Img.spriteFrame = new cc.SpriteFrame(res);
- }
- });
- }
- else if (PlatUtils_1.default.IsOPPO && this._data.iconUrlList && this._data.iconUrlList.length > 0) {
- // 有icon
- this._st_Icon.node.active = true;
- this._st_Img.node.active = false;
- if (this.nativeBannerInfo.st_banner_style == 0 || this.nativeBannerInfo.st_banner_style == 1) {
- Utils_1.utils.showLog("单图片样式-没有大图,显示默认原生样式banner");
- this._titleLabel.string = this._data.title;
- this._desLabel.string = this._data.desc;
- this._btnLabel.string = this._data.clickBtnTxt ? this._data.clickBtnTxt : "查看详情";
- var iconUrl = PlatUtils_1.default.IsOPPO ? this._data.iconUrlList[0] : this._data.icon;
- CompatibleTool_1.default.LoadRes(iconUrl, function (err, res) {
- if (!err && cc.isValid(_this) && _this._icon) {
- _this._icon.spriteFrame = new cc.SpriteFrame(res);
- }
- });
- this._st_Panel.active = false;
- this._panel.active = true;
- }
- else {
- CompatibleTool_1.default.LoadRes(this._data.iconUrlList[0], function (err, res) {
- if (!err && cc.isValid(_this) && _this._st_Icon) {
- _this._st_Icon.spriteFrame = new cc.SpriteFrame(res);
- }
- });
- }
- }
- else if ((PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsHuaWei) && this._data.icon) {
- // 有icon
- this._st_Icon.node.active = true;
- this._st_Img.node.active = false;
- CompatibleTool_1.default.LoadRes(this._data.icon, function (err, res) {
- if (!err && cc.isValid(_this) && _this._st_Icon) {
- _this._st_Icon.spriteFrame = new cc.SpriteFrame(res);
- }
- });
- }
- }
- else {
- this._titleLabel.string = this._data.title ? this._data.title : "";
- this._desLabel.string = this._data.desc ? this._data.desc : "";
- this._btnLabel.string = this._data.clickBtnTxt ? this._data.clickBtnTxt : "查看详情";
- if (PlatUtils_1.default.IsHuaWei) {
- this._sourceLable.string = this._data.source ? this._data.source : "";
- this._panel.getChildByName("Hw_Mark").active = true;
- this._mask_widget.node.active = false;
- }
- var iconUrl = "";
- if (PlatUtils_1.default.IsOPPO) {
- iconUrl = this._data.iconUrlList[0];
- }
- else {
- iconUrl = this._data.icon;
- }
- if (iconUrl) {
- CompatibleTool_1.default.LoadRes(iconUrl, function (err, res) {
- if (!err && cc.isValid(_this) && _this._icon) {
- _this._icon.spriteFrame = new cc.SpriteFrame(res);
- }
- });
- }
- else {
- if (this._data.imgUrlList && this._data.imgUrlList.length > 0) {
- CompatibleTool_1.default.LoadRes(this._data.imgUrlList[0], function (err, res) {
- if (!err && cc.isValid(_this) && _this._icon) {
- if (PlatUtils_1.default.IsHuaWei) {
- _this._icon.node.active = false;
- _this._hW_icon.node.active = true;
- _this._hW_icon.spriteFrame = new cc.SpriteFrame(res);
- }
- else {
- _this._icon.spriteFrame = new cc.SpriteFrame(res);
- }
- }
- });
- }
- }
- }
- // this.nativeBannerInfo.banner_close_but_range = 20;
- // this.nativeBannerInfo.banner_close_but_size = 50;
- if (PlatUtils_1.default.IsHuaWei) {
- this._closeBtn.setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_range, this.nativeBannerInfo.banner_close_but_range));
- this._closeBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_size, this.nativeBannerInfo.banner_close_but_size));
- }
- // this.nativeBannerInfo.st_banner_down_but_margin_top = -500;
- if (this.nativeBannerInfo.st_banner_down_but_margin_top != 0) {
- this._st_BtnDown_Widget.top = this.nativeBannerInfo.st_banner_down_but_margin_top;
- this._st_BtnDown_Widget.updateAlignment();
- }
- if (this.nativeBannerInfo.st_banner_down_but_show > 0) {
- this._st_BtnDown.active = true;
- if (this.nativeBannerInfo.st_banner_down_but_show === 2) {
- this._st_BtnDown.runAction(cc.sequence(cc.scaleTo(0.3, 1.3), cc.scaleTo(0.3, 1)).repeatForever());
- }
- else {
- this._st_BtnDown.stopAllActions();
- }
- }
- else {
- this._st_BtnDown.active = false;
- this._st_BtnDown.stopAllActions();
- }
- }
- };
- YZ_NativeBanner.prototype.onBtnClickHandler = function (event, data) {
- switch (event.target.name) {
- case "Btn_Close": {
- this.node.active = false;
- if (PlatUtils_1.default.IsOPPO) {
- Utils_1.utils.oppoTool.countBannerCloseCount();
- }
- Utils_1.utils._bannerCloseTime = new Date().getTime();
- break;
- }
- case "Btn_Download":
- case "bgMask": {
- this._reportAdClick();
- break;
- }
- }
- };
- YZ_NativeBanner.prototype._reportAdShow = function () {
- if (this._data) {
- if (this._nativeAd) {
- if (!this._data.isReportShow || PlatUtils_1.default.IsHuaWei) {
- YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(this._data.adId));
- this._data.isReportShow = true;
- Utils_1.utils.showLog("上报原生广告条展示!adId:" + this._data.adId);
- this._nativeAd.reportAdShow({
- adId: this._data.adId
- });
- Utils_1.utils.SendEvent("上报原生Banner广告展示,位置:" + this.nativeBannerInfo.location);
- }
- else {
- Utils_1.utils.showLog("当前广告已经过上报展示!adId:" + this._data.adId, ",当前不做上报");
- }
- }
- }
- };
- YZ_NativeBanner.prototype._reportAdClick = function () {
- if (this._data) {
- Utils_1.utils.showLog("上报原生广告条点击! adId:" + this._data.adId);
- if (this._nativeAd) {
- if (!this._data.isReportClick || PlatUtils_1.default.IsHuaWei) {
- YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.CLICK, new EventAdInfo_1.AdEventParameter(this._data.adId));
- this._data.isReportClick = true;
- this._nativeAd.reportAdClick({
- adId: this._data.adId,
- isAutoDownload: true
- });
- if (PlatUtils_1.default.IsHuaWei) {
- this.downLoadAd();
- }
- }
- this._data = null;
- if (this.nativeBannerInfo.banner_click_refresh == "true" && !PlatUtils_1.default.IsHuaWei) {
- Utils_1.utils.showLog("点击之后-先隐藏广告-再刷新广告条!");
- Utils_1.utils.adManager.HideBanner(this.nativeBannerInfo.location);
- // 刷新banner
- Utils_1.utils.adManager.ShowBanner(this.nativeBannerInfo.location, { isRefresh: true });
- }
- else {
- cc.game.targetOff(this);
- this.node.active = false;
- }
- }
- }
- };
- YZ_NativeBanner.prototype.downLoadAd = function () {
- return;
- var resultCode = this._nativeAd.startDownload({
- adId: this._data.adId
- });
- Utils_1.utils.showLog('原生广告主动下载 resumeDownloadresultCode = ' + resultCode);
- };
- YZ_NativeBanner = __decorate([
- ccclass
- ], YZ_NativeBanner);
- return YZ_NativeBanner;
- }(cc.Component));
- exports.default = YZ_NativeBanner;
- cc._RF.pop();
|