a2a68d1a-e442-437c-a959-2a533c3f756f.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. "use strict";
  2. cc._RF.push(module, 'a2a680a5EJDfKlZKlM8P3Vv', 'YZ_NativeBanner');
  3. // common-plugin/Scripts/YZ_NativeBanner.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 PlatUtils_1 = require("./PlatUtils");
  26. var Utils_1 = require("./Utils");
  27. var YZ_Constant_1 = require("./YZ_Constant");
  28. var CompatibleTool_1 = require("./CompatibleTool");
  29. var EventAdInfo_1 = require("./YouWanSDK/EventAdInfo");
  30. var YouWanAnalytics_1 = require("./YouWanSDK/YouWanAnalytics");
  31. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  32. var YZ_NativeBanner = /** @class */ (function (_super) {
  33. __extends(YZ_NativeBanner, _super);
  34. function YZ_NativeBanner() {
  35. var _this = _super !== null && _super.apply(this, arguments) || this;
  36. _this._panel = null;
  37. _this._icon = null;
  38. _this._hW_icon = null;
  39. _this._sourceLable = null;
  40. _this._titleLabel = null;
  41. _this._desLabel = null;
  42. _this._btnLabel = null;
  43. _this._widget = null;
  44. _this._closeBtn = null;
  45. _this._nativeAd = null;
  46. _this._data = null;
  47. _this._dataDirty = false;
  48. _this._panel_widget = null;
  49. _this._closeBtn_widget = null;
  50. _this._mask_widget = null;
  51. _this._st_Panel = null;
  52. _this._st_Icon = null;
  53. _this._st_TitleLabel = null;
  54. _this._st_DesLabel = null;
  55. _this._st_BtnLabel = null;
  56. _this._st_Widget = null;
  57. _this._st_Img = null;
  58. _this._st_CloseBtn = null;
  59. _this._st_BtnDown = null;
  60. _this._st_adMask = null;
  61. _this._st_down_btn_default_img = null;
  62. _this.nativeBannerInfo = null;
  63. _this._st_TitleLabel_Widget = null;
  64. _this._st_DesLabel_Widget = null;
  65. _this._st_Img_Widget = null;
  66. _this._st_CloseBtn_Widget = null;
  67. _this._st_BtnDown_Widget = null;
  68. _this._st_adMask_Widget = null;
  69. _this._st_Icon_widget = null;
  70. _this._bg_mask = null;
  71. _this._alignType = "";
  72. _this._xmMask = null;
  73. return _this;
  74. }
  75. Object.defineProperty(YZ_NativeBanner.prototype, "ServerConfig", {
  76. get: function () {
  77. return Utils_1.utils.ServerConfig;
  78. },
  79. enumerable: false,
  80. configurable: true
  81. });
  82. YZ_NativeBanner.prototype.onLoad = function () {
  83. if (Utils_1.utils.otherConfig && Utils_1.utils.otherConfig.group) {
  84. this.node.group = Utils_1.utils.otherConfig.group;
  85. }
  86. cc.game.addPersistRootNode(this.node);
  87. this._panel = this.node.getChildByName("Panel");
  88. this._icon = this._panel.getChildByName("Icon").getComponent(cc.Sprite);
  89. this._hW_icon = this._panel.getChildByName("HuaweiIcon").getComponent(cc.Sprite);
  90. this._titleLabel = this._panel.getChildByName("TitleLabel").getComponent(cc.Label);
  91. this._desLabel = this._panel.getChildByName("DesLabel").getComponent(cc.Label);
  92. this._sourceLable = this._panel.getChildByName("source").getComponent(cc.Label);
  93. var btnDown = this._panel.getChildByName("Btn_Download");
  94. this._btnLabel = btnDown.getComponentInChildren(cc.Label);
  95. this._widget = this.getComponent(cc.Widget);
  96. this._panel_widget = this._panel.getComponent(cc.Widget);
  97. this._closeBtn = this._panel.getChildByName("Btn_Close");
  98. this._closeBtn_widget = this._closeBtn.getComponent(cc.Widget);
  99. this._mask_widget = this._panel.getChildByName("Mask").getComponent(cc.Widget);
  100. this._widget.left = 0;
  101. this._widget.right = 0;
  102. this._widget.bottom = 0;
  103. this._st_Panel = this.node.getChildByName("Panel_Statement");
  104. this._st_Widget = this._st_Panel.getComponent(cc.Widget);
  105. this._bg_mask = this.node.getChildByName("bgMask");
  106. this._st_Icon = this._st_Panel.getChildByName("IconMask").getChildByName("Icon").getComponent(cc.Sprite);
  107. this._st_TitleLabel = this._st_Panel.getChildByName("TitleLabel").getComponent(cc.Label);
  108. this._st_DesLabel = this._st_Panel.getChildByName("DesLabel").getComponent(cc.Label);
  109. this._st_BtnDown = this._st_Panel.getChildByName("Btn_Download");
  110. // this._st_BtnLabel = stBtnDown.getComponentInChildren(cc.Label);
  111. this._st_Img = this._st_Panel.getChildByName("adImage").getComponent(cc.Sprite);
  112. this._st_CloseBtn = this._st_Panel.getChildByName("Btn_Close");
  113. this._st_adMask = this._st_Panel.getChildByName("Mask");
  114. this._st_down_btn_default_img = this._st_BtnDown.getComponent(cc.Sprite).spriteFrame;
  115. this._st_TitleLabel_Widget = this._st_TitleLabel.getComponent(cc.Widget);
  116. this._st_DesLabel_Widget = this._st_DesLabel.getComponent(cc.Widget);
  117. this._st_Img_Widget = this._st_Img.getComponent(cc.Widget);
  118. this._st_CloseBtn_Widget = this._st_CloseBtn.getComponent(cc.Widget);
  119. this._st_BtnDown_Widget = this._st_BtnDown.getComponent(cc.Widget);
  120. this._st_adMask_Widget = this._st_adMask.getComponent(cc.Widget);
  121. this._st_Icon_widget = this._st_Panel.getChildByName("IconMask").getComponent(cc.Widget);
  122. if (PlatUtils_1.default.IsXiaoMi || CC_DEBUG) {
  123. this._panel.getChildByName("Xm_Mark").active = true;
  124. this._mask_widget.node.active = false;
  125. }
  126. var ratio = 1;
  127. if (cc.winSize.height < cc.winSize.width) {
  128. // 横屏游戏
  129. this._widget.left = cc.winSize.width * 0.25;
  130. this._widget.right = cc.winSize.width * 0.25;
  131. this._titleLabel.node.width = 400;
  132. ratio = cc.winSize.width / 1920;
  133. }
  134. else {
  135. ratio = cc.winSize.width / 1080;
  136. }
  137. this.node.scale = ratio;
  138. };
  139. YZ_NativeBanner.prototype.onShow = function () {
  140. cc.game.emit("HuaWeiOnShow");
  141. };
  142. YZ_NativeBanner.prototype.onEnable = function () {
  143. var _this = this;
  144. this._st_Panel.targetOff(this);
  145. this._panel.targetOff(this);
  146. cc.game.targetOff(this);
  147. if (PlatUtils_1.default.IsHuaWei) {
  148. console.log("注册监听事件 >>>>>.");
  149. cc.game.on(cc.game.EVENT_SHOW, function () {
  150. console.log("HuaWeiOnShow >>>>>>");
  151. _this._reportAdShow();
  152. }, this);
  153. }
  154. if (PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsHuaWei || PlatUtils_1.default.IsXiaoMi) {
  155. this._st_Panel.on(cc.Node.EventType.TOUCH_START, function (event) {
  156. _this._reportAdClick();
  157. }, this);
  158. this._panel.on(cc.Node.EventType.TOUCH_START, function (event) {
  159. _this._reportAdClick();
  160. }, this);
  161. cc.game.on(YZ_Constant_1.default.YZ_NativeAdClick, function () {
  162. _this._reportAdClick();
  163. }, this);
  164. }
  165. };
  166. YZ_NativeBanner.prototype.onDisable = function () {
  167. if (PlatUtils_1.default.IsOPPO || PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsHuaWei || PlatUtils_1.default.IsXiaoMi) {
  168. this._st_Panel.targetOff(this);
  169. this._panel.targetOff(this);
  170. }
  171. cc.game.targetOff(this);
  172. };
  173. YZ_NativeBanner.prototype.init = function (nativeAd, data, nativeBannerInfo) {
  174. this._nativeAd = nativeAd;
  175. this._data = data;
  176. this._dataDirty = true;
  177. this.nativeBannerInfo = nativeBannerInfo;
  178. // this.nativeBannerInfo.banner_show_height = 500;
  179. // this.nativeBannerInfo.st_banner_style = 1;
  180. // this.nativeBannerInfo.st_banner_down_but_show = 2;
  181. // this.nativeBannerInfo.show_st_banner = "true";
  182. // this.nativeBannerInfo.st_banner_width = 800;
  183. // this.nativeBannerInfo.st_banner_height = 300;
  184. if (this.nativeBannerInfo.show_st_banner == "true") {
  185. if (this.nativeBannerInfo.st_banner_style > -1) {
  186. if (this._data.imgUrlList && this._data.imgUrlList.length > 0) {
  187. this._panel.active = false;
  188. this._st_Panel.active = true;
  189. }
  190. else {
  191. this._panel.active = false;
  192. this._st_Panel.active = false;
  193. }
  194. }
  195. else {
  196. this._panel.active = false;
  197. this._st_Panel.active = true;
  198. }
  199. }
  200. else {
  201. this._panel.active = true;
  202. this._st_Panel.active = false;
  203. }
  204. // if(this.nativeBannerInfo._alignType === "top")
  205. // {
  206. // this._widget.top = 0;
  207. // this._widget.isAlignTop = true;
  208. // this._widget.isAlignBottom = false;
  209. // this._widget.updateAlignment();
  210. // }
  211. // utils.showLog("当前显示位置为:", this.nativeBannerInfo.location, ">>显示参数为:", this.nativeBannerInfo.toStrong());
  212. };
  213. YZ_NativeBanner.prototype.update = function (dt) {
  214. if (this._data && this._dataDirty) {
  215. this._dataDirty = false;
  216. this._updateContent();
  217. }
  218. if (!this._data) {
  219. this._st_Panel.active = false;
  220. this._panel.active = false;
  221. }
  222. };
  223. YZ_NativeBanner.prototype._updateContent = function () {
  224. var _this = this;
  225. if (this._data) {
  226. // 上报展示
  227. this._reportAdShow();
  228. if (PlatUtils_1.default.IsHuaWei) {
  229. this._data.icon = "";
  230. }
  231. Utils_1.utils.nativeBannerShowCount++;
  232. if (this.nativeBannerInfo.show_st_banner == "true" && this.nativeBannerInfo.st_banner_style > -1) {
  233. if (this.nativeBannerInfo.st_banner_style == 1 || this.nativeBannerInfo.st_banner_style == 2) {
  234. if (this.nativeBannerInfo.st_banner_width > -1) {
  235. this._st_Panel.width = this.nativeBannerInfo.st_banner_width;
  236. }
  237. else {
  238. this._st_Panel.width = 821.4;
  239. }
  240. if (this.nativeBannerInfo.st_banner_height > -1) {
  241. this._st_Panel.height = this.nativeBannerInfo.st_banner_height;
  242. }
  243. else {
  244. this._st_Panel.height = 589;
  245. }
  246. this._st_Widget.updateAlignment();
  247. this._st_adMask_Widget.updateAlignment();
  248. this._st_CloseBtn_Widget.updateAlignment();
  249. this._st_BtnDown_Widget.updateAlignment();
  250. this._st_Icon_widget.updateAlignment();
  251. }
  252. else {
  253. this._st_Panel.width = 821.4;
  254. this._st_Panel.height = 589;
  255. this._st_Widget.updateAlignment();
  256. this._st_adMask_Widget.updateAlignment();
  257. this._st_CloseBtn_Widget.updateAlignment();
  258. this._st_BtnDown_Widget.updateAlignment();
  259. this._st_Icon_widget.updateAlignment();
  260. }
  261. if (this.nativeBannerInfo.st_banner_style == 0 || this.nativeBannerInfo.st_banner_style == 1) {
  262. Utils_1.utils.showLog("//单图片样式,拉伸图片,并且隐藏标题和描述");
  263. this._st_Img_Widget.top = 0;
  264. this._st_Img_Widget.bottom = 0;
  265. this._st_Img_Widget.isAlignTop = true;
  266. this._st_Img_Widget.isAlignBottom = true;
  267. this._st_Img_Widget.updateAlignment();
  268. this._st_DesLabel.node.active = false;
  269. this._st_TitleLabel.node.active = false;
  270. this._st_Icon_widget.updateAlignment();
  271. }
  272. else if (this.nativeBannerInfo.st_banner_style == 2) {
  273. Utils_1.utils.showLog("默认样式自定义宽高:展示标题和描述");
  274. this._st_DesLabel.node.active = true;
  275. this._st_TitleLabel.node.active = true;
  276. this._st_DesLabel_Widget.updateAlignment();
  277. this._st_TitleLabel_Widget.updateAlignment();
  278. this._st_Img_Widget.isAlignTop = true;
  279. this._st_Img_Widget.isAlignBottom = true;
  280. this._st_Img_Widget.top = this._st_TitleLabel.node.height + this._st_TitleLabel_Widget.top;
  281. this._st_Img_Widget.bottom = this._st_DesLabel_Widget.node.height + this._st_DesLabel_Widget.bottom;
  282. this._st_Img_Widget.updateAlignment();
  283. this._st_Icon_widget.updateAlignment();
  284. }
  285. else {
  286. this._st_Img_Widget.isAlignTop = true;
  287. this._st_Img_Widget.isAlignBottom = true;
  288. this._st_Img_Widget.updateAlignment();
  289. this._st_DesLabel.node.active = true;
  290. this._st_TitleLabel.node.active = true;
  291. this._st_Icon_widget.updateAlignment();
  292. }
  293. }
  294. else if (this.nativeBannerInfo.show_st_banner == "true") {
  295. Utils_1.utils.showLog("结算banner使用默认样式!");
  296. this._st_Panel.width = 821.4;
  297. this._st_Panel.height = 589;
  298. this._st_Img_Widget.isAlignTop = false;
  299. this._st_Img_Widget.isAlignBottom = false;
  300. this._st_Img_Widget.updateAlignment();
  301. this._st_DesLabel.node.active = true;
  302. this._st_TitleLabel.node.active = true;
  303. this._st_Widget.updateAlignment();
  304. this._st_adMask_Widget.updateAlignment();
  305. this._st_CloseBtn_Widget.updateAlignment();
  306. this._st_BtnDown_Widget.updateAlignment();
  307. this._st_Icon_widget.updateAlignment();
  308. }
  309. this._st_CloseBtn.scale = this.nativeBannerInfo.st_banner_scale < 1 ? this._st_CloseBtn.scale * this.nativeBannerInfo.st_banner_scale : 1;
  310. this._st_adMask.scale = this.nativeBannerInfo.st_banner_scale < 1 ? this._st_adMask.scale * this.nativeBannerInfo.st_banner_scale : 1;
  311. this._st_CloseBtn.active = this.nativeBannerInfo.st_banner_close_but_show == "true";
  312. this._st_CloseBtn.opacity = this.nativeBannerInfo.st_banner_close_but_alpha;
  313. if (this.ServerConfig.first_native_banner_delayed_count_close) {
  314. if (Utils_1.utils.nativeBannerShowCount > 3 && this.ServerConfig.first_native_banner_delayed_count_close) {
  315. Utils_1.utils.nativeBannerResizeCloseBtnShowCount++;
  316. if (Utils_1.utils.nativeBannerResizeCloseBtnShowCount % this.ServerConfig.native_banner_delayed_count_close == 0) {
  317. 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);
  318. if (this.nativeBannerInfo.st_banner_close_but_range) {
  319. this._st_CloseBtn.setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_range, this.nativeBannerInfo.st_banner_close_but_range));
  320. this._st_CloseBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_size, this.nativeBannerInfo.st_banner_close_but_size));
  321. }
  322. }
  323. }
  324. }
  325. else {
  326. if (this.nativeBannerInfo.st_banner_close_but_range) {
  327. this._st_CloseBtn.setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_range, this.nativeBannerInfo.st_banner_close_but_range));
  328. this._st_CloseBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.st_banner_close_but_size, this.nativeBannerInfo.st_banner_close_but_size));
  329. }
  330. }
  331. if (this.nativeBannerInfo.st_banner_down_but_show) {
  332. this._st_BtnDown.active = true;
  333. if (this.nativeBannerInfo.st_banner_down_btn_image) {
  334. Utils_1.utils.showLog("this.nativeBannerInfo.st_banner_down_btn_image", this.nativeBannerInfo.st_banner_down_btn_image);
  335. CompatibleTool_1.default.LoadRes(this.nativeBannerInfo.st_banner_down_btn_image, function (err, res) {
  336. if (!err && cc.isValid(_this) && _this._st_BtnDown) {
  337. _this._st_BtnDown.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(res);
  338. if (_this.nativeBannerInfo.st_banner_down_but_margin_top) {
  339. _this._st_BtnDown_Widget.top = -(_this._st_BtnDown.getContentSize().height + _this.nativeBannerInfo.st_banner_down_but_margin_top);
  340. _this._st_BtnDown_Widget.updateAlignment();
  341. }
  342. else {
  343. _this._st_BtnDown_Widget.top = -_this._st_BtnDown.getContentSize().height;
  344. _this._st_BtnDown_Widget.updateAlignment();
  345. }
  346. }
  347. });
  348. }
  349. else {
  350. this._st_BtnDown.getComponent(cc.Sprite).spriteFrame = this._st_down_btn_default_img;
  351. if (this.nativeBannerInfo.st_banner_down_but_margin_top) {
  352. this._st_BtnDown_Widget.top -= this.nativeBannerInfo.st_banner_down_but_margin_top;
  353. this._st_BtnDown_Widget.updateAlignment();
  354. }
  355. }
  356. if (this.nativeBannerInfo.st_banner_down_but_show == 2) {
  357. this._st_BtnDown.runAction(cc.sequence(cc.scaleTo(0.3, 1.2), cc.scaleTo(0.3, 1)).repeatForever());
  358. }
  359. else {
  360. this._st_BtnDown.stopAllActions();
  361. }
  362. this._st_BtnDown.scale = this.node.scale;
  363. }
  364. else {
  365. this._st_BtnDown.active = false;
  366. this._st_BtnDown.stopAllActions();
  367. }
  368. this._closeBtn.active = this.nativeBannerInfo.banner_close_but_show == "true";
  369. this._closeBtn.opacity = this.nativeBannerInfo.banner_close_but_alpha;
  370. if (this.ServerConfig.first_native_banner_delayed_count_close) {
  371. if (Utils_1.utils.nativeBannerShowCount > 3 && this.ServerConfig.first_native_banner_delayed_count_close) {
  372. if (Utils_1.utils.nativeBannerResizeCloseBtnShowCount % this.ServerConfig.native_banner_delayed_count_close == 0) {
  373. 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);
  374. this._closeBtn.setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_range, this.nativeBannerInfo.banner_close_but_range));
  375. this._closeBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_size, this.nativeBannerInfo.banner_close_but_size));
  376. }
  377. }
  378. }
  379. else {
  380. this._closeBtn.setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_range, this.nativeBannerInfo.banner_close_but_range));
  381. this._closeBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_size, this.nativeBannerInfo.banner_close_but_size));
  382. }
  383. if (this.nativeBannerInfo.show_st_banner == "false") {
  384. // this.node.setContentSize(cc.size(this.node.getContentSize().width,));
  385. this._panel_widget.isAlignTop = false;
  386. this._panel_widget.bottom = 0;
  387. this._panel.setContentSize(cc.size(this.node.getContentSize().width, this.nativeBannerInfo.banner_show_height < 160 ? 160 : this.nativeBannerInfo.banner_show_height));
  388. this._panel_widget.updateAlignment();
  389. this._closeBtn_widget.updateAlignment();
  390. this._mask_widget.updateAlignment();
  391. }
  392. else {
  393. //缩放
  394. this._st_Panel.scale = this.nativeBannerInfo.st_banner_scale ? this.nativeBannerInfo.st_banner_scale : 1;
  395. this._st_Widget.bottom = this.nativeBannerInfo.st_banner_bottom ? this.nativeBannerInfo.st_banner_bottom : 0;
  396. this._st_Widget.updateAlignment();
  397. }
  398. if (this.nativeBannerInfo._alignType === "top") {
  399. if (this.nativeBannerInfo.show_st_banner == "true") {
  400. this.node.height = this._st_Panel.height;
  401. this.node.width = this._st_Panel.width;
  402. this._st_CloseBtn_Widget.updateAlignment();
  403. this._st_adMask_Widget.updateAlignment();
  404. }
  405. else {
  406. this.node.height = this.nativeBannerInfo.banner_show_height < 160 ? 160 : this.nativeBannerInfo.banner_show_height;
  407. this._panel_widget.updateAlignment();
  408. this._closeBtn_widget.updateAlignment();
  409. this._mask_widget.updateAlignment();
  410. }
  411. this._widget.isAlignTop = true;
  412. // this._widget.top = 0;
  413. this._widget.isAlignBottom = false;
  414. this._widget.updateAlignment();
  415. }
  416. if (this.nativeBannerInfo.show_st_banner == "true") {
  417. Utils_1.utils.showLog("服务器配置显示为结算banner >>>>>");
  418. if (this.nativeBannerInfo.st_banner_bg_mask_opacity > 0) {
  419. this._bg_mask.opacity = this.nativeBannerInfo.st_banner_bg_mask_opacity;
  420. this._bg_mask.setContentSize(cc.size(this.node.getContentSize().width, this._st_Panel.height));
  421. this._st_adMask.active = false;
  422. }
  423. else {
  424. this._bg_mask.active = false;
  425. }
  426. // 居底部距离
  427. this._st_TitleLabel.string = this._data.title ? this._data.title : "";
  428. this._st_DesLabel.string = this._data.desc ? this._data.desc : "";
  429. // this._data.imgUrlList = null;
  430. // this._st_BtnLabel.string = this._data.clickBtnTxt ? this._data.clickBtnTxt : "查看详情";
  431. if (this._data.imgUrlList && this._data.imgUrlList.length > 0) {
  432. // 有图片,优先显示图片
  433. this._st_Icon.node.active = false;
  434. this._st_Img.node.active = true;
  435. CompatibleTool_1.default.LoadRes(this._data.imgUrlList[0], function (err, res) {
  436. if (!err && cc.isValid(_this) && _this._st_Img) {
  437. _this._st_Img.spriteFrame = new cc.SpriteFrame(res);
  438. }
  439. });
  440. }
  441. else if (PlatUtils_1.default.IsOPPO && this._data.iconUrlList && this._data.iconUrlList.length > 0) {
  442. // 有icon
  443. this._st_Icon.node.active = true;
  444. this._st_Img.node.active = false;
  445. if (this.nativeBannerInfo.st_banner_style == 0 || this.nativeBannerInfo.st_banner_style == 1) {
  446. Utils_1.utils.showLog("单图片样式-没有大图,显示默认原生样式banner");
  447. this._titleLabel.string = this._data.title;
  448. this._desLabel.string = this._data.desc;
  449. this._btnLabel.string = this._data.clickBtnTxt ? this._data.clickBtnTxt : "查看详情";
  450. var iconUrl = PlatUtils_1.default.IsOPPO ? this._data.iconUrlList[0] : this._data.icon;
  451. CompatibleTool_1.default.LoadRes(iconUrl, function (err, res) {
  452. if (!err && cc.isValid(_this) && _this._icon) {
  453. _this._icon.spriteFrame = new cc.SpriteFrame(res);
  454. }
  455. });
  456. this._st_Panel.active = false;
  457. this._panel.active = true;
  458. }
  459. else {
  460. CompatibleTool_1.default.LoadRes(this._data.iconUrlList[0], function (err, res) {
  461. if (!err && cc.isValid(_this) && _this._st_Icon) {
  462. _this._st_Icon.spriteFrame = new cc.SpriteFrame(res);
  463. }
  464. });
  465. }
  466. }
  467. else if ((PlatUtils_1.default.IsVIVO || PlatUtils_1.default.IsHuaWei) && this._data.icon) {
  468. // 有icon
  469. this._st_Icon.node.active = true;
  470. this._st_Img.node.active = false;
  471. CompatibleTool_1.default.LoadRes(this._data.icon, function (err, res) {
  472. if (!err && cc.isValid(_this) && _this._st_Icon) {
  473. _this._st_Icon.spriteFrame = new cc.SpriteFrame(res);
  474. }
  475. });
  476. }
  477. }
  478. else {
  479. this._titleLabel.string = this._data.title ? this._data.title : "";
  480. this._desLabel.string = this._data.desc ? this._data.desc : "";
  481. this._btnLabel.string = this._data.clickBtnTxt ? this._data.clickBtnTxt : "查看详情";
  482. if (PlatUtils_1.default.IsHuaWei) {
  483. this._sourceLable.string = this._data.source ? this._data.source : "";
  484. this._panel.getChildByName("Hw_Mark").active = true;
  485. this._mask_widget.node.active = false;
  486. }
  487. var iconUrl = "";
  488. if (PlatUtils_1.default.IsOPPO) {
  489. iconUrl = this._data.iconUrlList[0];
  490. }
  491. else {
  492. iconUrl = this._data.icon;
  493. }
  494. if (iconUrl) {
  495. CompatibleTool_1.default.LoadRes(iconUrl, function (err, res) {
  496. if (!err && cc.isValid(_this) && _this._icon) {
  497. _this._icon.spriteFrame = new cc.SpriteFrame(res);
  498. }
  499. });
  500. }
  501. else {
  502. if (this._data.imgUrlList && this._data.imgUrlList.length > 0) {
  503. CompatibleTool_1.default.LoadRes(this._data.imgUrlList[0], function (err, res) {
  504. if (!err && cc.isValid(_this) && _this._icon) {
  505. if (PlatUtils_1.default.IsHuaWei) {
  506. _this._icon.node.active = false;
  507. _this._hW_icon.node.active = true;
  508. _this._hW_icon.spriteFrame = new cc.SpriteFrame(res);
  509. }
  510. else {
  511. _this._icon.spriteFrame = new cc.SpriteFrame(res);
  512. }
  513. }
  514. });
  515. }
  516. }
  517. }
  518. // this.nativeBannerInfo.banner_close_but_range = 20;
  519. // this.nativeBannerInfo.banner_close_but_size = 50;
  520. if (PlatUtils_1.default.IsHuaWei) {
  521. this._closeBtn.setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_range, this.nativeBannerInfo.banner_close_but_range));
  522. this._closeBtn.getChildByName("Background").setContentSize(cc.size(this.nativeBannerInfo.banner_close_but_size, this.nativeBannerInfo.banner_close_but_size));
  523. }
  524. // this.nativeBannerInfo.st_banner_down_but_margin_top = -500;
  525. if (this.nativeBannerInfo.st_banner_down_but_margin_top != 0) {
  526. this._st_BtnDown_Widget.top = this.nativeBannerInfo.st_banner_down_but_margin_top;
  527. this._st_BtnDown_Widget.updateAlignment();
  528. }
  529. if (this.nativeBannerInfo.st_banner_down_but_show > 0) {
  530. this._st_BtnDown.active = true;
  531. if (this.nativeBannerInfo.st_banner_down_but_show === 2) {
  532. this._st_BtnDown.runAction(cc.sequence(cc.scaleTo(0.3, 1.3), cc.scaleTo(0.3, 1)).repeatForever());
  533. }
  534. else {
  535. this._st_BtnDown.stopAllActions();
  536. }
  537. }
  538. else {
  539. this._st_BtnDown.active = false;
  540. this._st_BtnDown.stopAllActions();
  541. }
  542. }
  543. };
  544. YZ_NativeBanner.prototype.onBtnClickHandler = function (event, data) {
  545. switch (event.target.name) {
  546. case "Btn_Close": {
  547. this.node.active = false;
  548. if (PlatUtils_1.default.IsOPPO) {
  549. Utils_1.utils.oppoTool.countBannerCloseCount();
  550. }
  551. Utils_1.utils._bannerCloseTime = new Date().getTime();
  552. break;
  553. }
  554. case "Btn_Download":
  555. case "bgMask": {
  556. this._reportAdClick();
  557. break;
  558. }
  559. }
  560. };
  561. YZ_NativeBanner.prototype._reportAdShow = function () {
  562. if (this._data) {
  563. if (this._nativeAd) {
  564. if (!this._data.isReportShow || PlatUtils_1.default.IsHuaWei) {
  565. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.SHOW_SUCCESS, new EventAdInfo_1.AdEventParameter(this._data.adId));
  566. this._data.isReportShow = true;
  567. Utils_1.utils.showLog("上报原生广告条展示!adId:" + this._data.adId);
  568. this._nativeAd.reportAdShow({
  569. adId: this._data.adId
  570. });
  571. Utils_1.utils.SendEvent("上报原生Banner广告展示,位置:" + this.nativeBannerInfo.location);
  572. }
  573. else {
  574. Utils_1.utils.showLog("当前广告已经过上报展示!adId:" + this._data.adId, ",当前不做上报");
  575. }
  576. }
  577. }
  578. };
  579. YZ_NativeBanner.prototype._reportAdClick = function () {
  580. if (this._data) {
  581. Utils_1.utils.showLog("上报原生广告条点击! adId:" + this._data.adId);
  582. if (this._nativeAd) {
  583. if (!this._data.isReportClick || PlatUtils_1.default.IsHuaWei) {
  584. YouWanAnalytics_1.default.EventAdWithObj(EventAdInfo_1.YwAdType.NATIVE_BANNER, EventAdInfo_1.YwAdStatus.CLICK, new EventAdInfo_1.AdEventParameter(this._data.adId));
  585. this._data.isReportClick = true;
  586. this._nativeAd.reportAdClick({
  587. adId: this._data.adId,
  588. isAutoDownload: true
  589. });
  590. if (PlatUtils_1.default.IsHuaWei) {
  591. this.downLoadAd();
  592. }
  593. }
  594. this._data = null;
  595. if (this.nativeBannerInfo.banner_click_refresh == "true" && !PlatUtils_1.default.IsHuaWei) {
  596. Utils_1.utils.showLog("点击之后-先隐藏广告-再刷新广告条!");
  597. Utils_1.utils.adManager.HideBanner(this.nativeBannerInfo.location);
  598. // 刷新banner
  599. Utils_1.utils.adManager.ShowBanner(this.nativeBannerInfo.location, { isRefresh: true });
  600. }
  601. else {
  602. cc.game.targetOff(this);
  603. this.node.active = false;
  604. }
  605. }
  606. }
  607. };
  608. YZ_NativeBanner.prototype.downLoadAd = function () {
  609. return;
  610. var resultCode = this._nativeAd.startDownload({
  611. adId: this._data.adId
  612. });
  613. Utils_1.utils.showLog('原生广告主动下载 resumeDownloadresultCode = ' + resultCode);
  614. };
  615. YZ_NativeBanner = __decorate([
  616. ccclass
  617. ], YZ_NativeBanner);
  618. return YZ_NativeBanner;
  619. }(cc.Component));
  620. exports.default = YZ_NativeBanner;
  621. cc._RF.pop();