cc3a7779-19fa-488c-b478-6f64047eec3e.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. "use strict";
  2. cc._RF.push(module, 'cc3a7d5GfpIjLR4b2QEfuw+', 'Icon');
  3. // Script/sdk/vivo/Icon.ts
  4. "use strict";
  5. // Learn TypeScript:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  7. // Learn Attribute:
  8. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  9. // Learn life-cycle callbacks:
  10. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  11. var __extends = (this && this.__extends) || (function () {
  12. var extendStatics = function (d, b) {
  13. extendStatics = Object.setPrototypeOf ||
  14. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  15. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  16. return extendStatics(d, b);
  17. };
  18. return function (d, b) {
  19. extendStatics(d, b);
  20. function __() { this.constructor = d; }
  21. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22. };
  23. })();
  24. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  25. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  27. 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;
  28. return c > 3 && r && Object.defineProperty(target, key, r), r;
  29. };
  30. Object.defineProperty(exports, "__esModule", { value: true });
  31. var NativeAdComponent_1 = require("./NativeAdComponent");
  32. var SDK_1 = require("../SDK");
  33. var Utils_1 = require("../tools/Utils");
  34. var VivoAd_1 = require("./VivoAd");
  35. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  36. var Icon = /** @class */ (function (_super) {
  37. __extends(Icon, _super);
  38. function Icon() {
  39. var _this = _super !== null && _super.apply(this, arguments) || this;
  40. _this._iconList = [];
  41. return _this;
  42. }
  43. Icon.prototype.init = function (config) {
  44. this._config = config;
  45. Utils_1.default.instance.log('创建Icon广告');
  46. };
  47. Icon.prototype.showIconAd = function (id, x, y) {
  48. if (id === void 0) { id = 0; }
  49. var self = this;
  50. if (this._config == null) {
  51. return;
  52. }
  53. if (this._config.masterEnable != 1) { //插屏是否打开
  54. return;
  55. }
  56. if (this._config.iconAdEnable != 1) { //插屏是否打开
  57. return;
  58. }
  59. var adNodeList = JSON.parse(this._config.insertAdNodeList);
  60. //当前节点是否打开
  61. if (adNodeList[id].enable != 1) {
  62. return;
  63. }
  64. var nativeData = VivoAd_1.default.Instance.getVivoNativeData();
  65. if (nativeData == null || !nativeData.isReady()) {
  66. Utils_1.default.instance.log("---------showNativeIconAd 广告数据不存在-----");
  67. return;
  68. }
  69. var clickCallBack = function () {
  70. VivoAd_1.default.Instance.creatorNativeData();
  71. SDK_1.default.Instance.reportLog(SDK_1.NodeAction.NATIVE_CLICK, "原生icon点击");
  72. };
  73. var showCallBack = function () {
  74. //缓存下一条广告
  75. VivoAd_1.default.Instance.creatorNativeData();
  76. SDK_1.default.Instance.reportLog(SDK_1.NodeAction.NATIVE_SHOW, "原生icon展示");
  77. };
  78. var closeCallBack = function () {
  79. SDK_1.default.Instance.reportLog(SDK_1.NodeAction.NATIVE_CLOSE, "原生icon关闭");
  80. };
  81. var node = cc.director.getScene().children[0];
  82. var iconAd = node.getChildByName("iconAd");
  83. if (iconAd) {
  84. iconAd.removeFromParent();
  85. // return ;
  86. }
  87. Utils_1.default.instance.loadPrefabs("sdk/res/prefabs/NativeIconAd", function (prefabs) {
  88. var adNode = cc.instantiate(prefabs);
  89. self._nativeIconAd = adNode.addComponent(NativeAdComponent_1.default);
  90. self._nativeIconAd.initData(nativeData);
  91. self._nativeIconAd.listionCall(showCallBack, clickCallBack, closeCallBack);
  92. node.addChild(adNode, 1000, "icon"); //加节点名,防止重复加广告
  93. // adNode.active = false;
  94. self._nativeIconAd.showAd(NativeAdComponent_1.NativeType.ICON, self._config, x, y);
  95. });
  96. };
  97. Icon.prototype.hideIcon = function () {
  98. if (this._nativeIconAd) {
  99. this._nativeIconAd.hide();
  100. }
  101. };
  102. Icon = __decorate([
  103. ccclass
  104. ], Icon);
  105. return Icon;
  106. }(cc.Component));
  107. exports.default = Icon;
  108. cc._RF.pop();