System.register(["cc"], function (_export, _context) { "use strict"; var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, sys, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _class3, _crd, ccclass, property, DYSdk; function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); } return { setters: [function (_cc) { _cclegacy = _cc.cclegacy; __checkObsolete__ = _cc.__checkObsolete__; __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__; _decorator = _cc._decorator; Component = _cc.Component; sys = _cc.sys; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "e50a2TVh1RIKYep854CE/5e", "DYSdk", undefined); __checkObsolete__(['_decorator', 'Component', 'director', 'game', 'Node', 'sys']); ({ ccclass, property } = _decorator); _export("DYSdk", DYSdk = (_dec = ccclass('DYSdk'), _dec2 = property({ displayName: "bannner广告uid" }), _dec3 = property({ displayName: "视频奖励广告uid" }), _dec4 = property({ displayName: "插屏广告uid" }), _dec5 = property({ displayName: "分享图url" }), _dec6 = property({ displayName: "分享tile文本" }), _dec(_class = (_class2 = (_class3 = class DYSdk extends Component { constructor() { super(...arguments); _initializerDefineProperty(this, "bannerId", _descriptor, this); _initializerDefineProperty(this, "videoUid", _descriptor2, this); _initializerDefineProperty(this, "interstitialUid", _descriptor3, this); _initializerDefineProperty(this, "shareImageUrl", _descriptor4, this); _initializerDefineProperty(this, "shareTilt", _descriptor5, this); this.bannerAdv = null; this.videoAdv = null; this.interstitialAd = null; this.successCallback = null; this.failedCallback = null; } onLoad() { DYSdk.instance = this; } initBanner() { var winSize = window["tt"].getSystemInfoSync(); //获取像素size // 创建 Banner 广告实例,提前初始化 var bannerWidth = 300; var bannerHeight = 80; console.error("bannerId:", this.bannerId); this.bannerAdv = window["tt"].createBannerAd({ adUnitId: this.bannerId, //传入自己的id,此处为banner广告位ID adIntervals: 30, //定时刷新,最低30S style: { left: (winSize.windowWidth - bannerWidth) / 2, top: winSize.windowHeight - bannerHeight, width: bannerWidth } }); //重新定banner位置 this.bannerAdv.onResize(res => { this.bannerAdv.style.top = winSize.windowHeight - this.bannerAdv.style.realHeight - 1; }); this.bannerAdv.onError(err => { console.log("banner", err); }); } navigateToScene() { window["tt"].navigateToScene({ scene: 'sidebar', fail: console.log, success: console.log }); } initVideo() { var self = this; // 创建激励视频广告实例,提前初始化 console.log("激励视频广告id:", this.videoUid); this.videoAdv = window["tt"].createRewardedVideoAd({ adUnitId: this.videoUid //传入自己的id,此处为视频广告位ID }); this.videoAdv.onLoad(() => { console.log("广告加载完成"); }); this.videoAdv.onError(() => { console.log("广告错误"); if (self.failedCallback) { self.failedCallback(); } }); function listener(res) { if (res && res.isEnded) { if (self.successCallback) { self.successCallback(); self.successCallback = null; } } else { if (self.failedCallback) { self.failedCallback(); self.failedCallback = null; } } } this.videoAdv.onClose(listener); //这里监听广告的close 事件 } initInterstitial() { if (window["tt"].createInterstitialAd) { console.error("插屏广告id:", this.interstitialUid); this.interstitialAd = window["tt"].createInterstitialAd({ adUnitId: this.interstitialUid //传入自己的id,此处为插屏广告位ID }); } } init() { if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) { this.initBanner(); this.initVideo(); // 创建插屏广告实例,提前初始化 this.initInterstitial(); this.passivityShare(); window["tt"].onShow(op => { if (op.location == "sidebar_card") { console.log("应用侧边栏启动"); } console.log("监听应用启动", op); }); } } // 主动分享 initativeShare(callBack) { var shareTitle = this.shareTilt; var imageUrl = this.shareImageUrl; // 主动拉起转发,进入选择通讯录界面 window["tt"].shareAppMessage({ // 转发标题, 没有则默认使用小游戏的昵称 title: shareTitle, // 图片链接, imageUrl: imageUrl }); } passivityShare(callBack) { // 授权显示菜单 window["tt"].showShareMenu({ withShareTicket: false, // 显示菜单 menus: ['shareAppMessage', 'shareTimeline'], success: res => { console.log("开始被动转发shareMenu成功"); }, fail: () => { console.log("开始被动转发shareMenu失败"); } }); } showBanner() { this.bannerAdv.show(); } hideBanner() { this.bannerAdv.hide(); } showInterstitial() { // 在适合的场景显示插屏广告 if (this.interstitialAd) { this.interstitialAd.show().catch(err => { console.error(err); }); } } showVideo(successCallback, failCallback) { // 用户触发广告后,显示激励视频广告 var self = this; this.successCallback = successCallback; this.failedCallback = failCallback; self.videoAdv.onError(res => { console.log('广告出错监听', res); }); // /**展示 */ self.videoAdv.show().then(() => {}).catch(err => { console.log('打印激励视频错误', err); // 可以手动加载一次 self.videoAdv.load().then(() => { // 加载成功后需要再显示广告 return self.videoAdv.show(); }); }); } }, _class3.instance = void 0, _class3), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "bannerId", [_dec2], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return "test"; } }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "videoUid", [_dec3], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return "test"; } }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "interstitialUid", [_dec4], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return "test"; } }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "shareImageUrl", [_dec5], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return "https://mmocgame.qpic.cn/wechatgame/fNvVoACuBEOmNhzE802RLqnUuQyZ4rXTicDqz7OlVKypjYcHHo7nyfoYe7Urvdk6T/0"; } }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "shareTilt", [_dec6], { configurable: true, enumerable: true, writable: true, initializer: function initializer() { return "分享文本"; } })), _class2)) || _class)); _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=0ac499867c38f0c346de057171246da0ed544830.js.map