123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- System.register(["cc"], function (_export, _context) {
- "use strict";
- var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, PlatformTT, _crd, TT_CONFIG, globalTT, delayTime;
- return {
- setters: [function (_cc) {
- _cclegacy = _cc.cclegacy;
- __checkObsolete__ = _cc.__checkObsolete__;
- __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
- }],
- execute: function () {
- _crd = true;
- _cclegacy._RF.push({}, "c097aDI7bFCML/d7lEO/gd8", "PlatformTT", undefined);
- __checkObsolete__(['Vec2', '_decorator']);
- TT_CONFIG = {
- AD_ID: {
- /** banner广告 */
- banner: '30a3ll993k15aakgla',
- /** 视频广告 */
- video: 'o1h5n7r8fnp31df3g1',
- /** 插屏广告 */
- interstitial: '4687fak66i8aklc5hd'
- }
- };
- delayTime = 1900;
- PlatformTT = class PlatformTT {
- constructor() {
- this._onHideTime = Infinity;
- this._shareTimes = 0;
- this._rewardVideo = void 0;
- this._bannerAd = void 0;
- this._interstitialAd = void 0;
- this._shareSuccessHandler = null;
- this._videoSuccessHandler = null;
- this._showInterstitialAdTime = null;
- this._shareModalIsActive = false;
- this._shareStr = "东北F4来到美国西部拓荒时代,保卫城镇,完成自我救赎。";
- }
- initialize() {
- //@ts-ignore
- globalTT = tt;
- console.log("初始化抖音框架"); //监听游戏生命周期回调
- globalTT.onShow(function (res) {
- //判断是否是从侧边栏复访
- if (res.scene == 1104) {
- console.log('从侧边栏复访');
- }
- });
- globalTT.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline'],
- success: () => {},
- fail: () => {},
- complete: () => {}
- }); //发送给朋友
- globalTT.onShareAppMessage(function () {
- globalTT.shareAppMessage({
- title: this._shareStr,
- query: 'shareMsg=' + 'a=1'
- });
- }.bind(this));
- globalTT.onShow(res => {
- if (this._shareSuccessHandler == null) return;
- if (this._shareModalIsActive) return;
- if (Date.now() - this._onHideTime >= delayTime) {
- if (this._shareSuccessHandler) this._shareSuccessHandler(true);
- } else {
- globalTT.showModal({
- title: '分享提示',
- content: '成功分享到群即可获得奖励',
- success: res => {
- if (res.confirm) {
- this.shareShowReward(this._shareSuccessHandler(false));
- } else if (res.cancel) {
- this._shareSuccessHandler = null;
- }
- this._shareModalIsActive = false;
- }
- });
- this._shareModalIsActive = true;
- }
- this._onHideTime = Infinity;
- }); //this.__createBannerAd();
- this.__createVideoAd(); //this.__createInterstitialAd();
- } //检查当前宿主是否支持跳转到侧边栏
- isCheckScene(handler) {
- if (handler === void 0) {
- handler = null;
- }
- globalTT.checkScene({
- scene: 'sidebar',
- success(res) {
- if (handler) {
- if (res.isExist) {
- //支持
- if (true) {
- handler(false);
- } else {
- handler(true);
- }
- } else {
- //不支持
- handler(false);
- }
- }
- },
- fail(err) {
- console.error('检查侧边栏支持失败', err); // 可以选择默认操作,例如不展示奖励入口
- if (handler) {
- handler(false);
- }
- }
- });
- } //添加测边栏功能
- openSideBar(handler) {
- if (handler === void 0) {
- handler = null;
- }
- globalTT.navigateToScene({
- scene: 'sidebar',
- success() {
- handler == null || handler('成功打开侧边栏', true);
- },
- fail(err) {
- handler == null || handler('打开侧边栏失败', false);
- }
- });
- }
- /**
- * 是否支持添加桌面
- * @returns
- */
- isSupportDesk() {
- return true;
- } //添加到桌面
- addDesk(handler) {
- if (handler === void 0) {
- handler = null;
- }
- // 调用创建桌面快捷方式 API
- globalTT.addShortcut({
- success() {
- globalTT.showToast({
- title: '创建桌面快捷方式成功'
- });
- },
- fail(err) {
- globalTT.showToast({
- title: '创建桌面快捷方式失败',
- err
- });
- }
- });
- }
- showToast(param) {
- var finalParam = {
- title: '',
- icon: 'none',
- duration: 2000
- };
- Object.assign(finalParam, param);
- globalTT.showToast(finalParam);
- }
- shareAppMessage(param) {
- if (param === void 0) {
- param = {};
- }
- globalTT.shareAppMessage(param);
- }
- vibrateShort(param) {
- if (param === void 0) {
- param = {};
- }
- globalTT.vibrateShort(param);
- }
- vibrateLong(param) {
- if (param === void 0) {
- param = {};
- }
- globalTT.vibrateLong(param);
- }
- showCustomAd(close) {}
- hideCustomAd() {}
- showSigleCustomAd() {}
- hideSigleCustomAd() {} //分享
- shareShowReward(handler) {
- if (handler === void 0) {
- handler = null;
- }
- if (handler) {
- this._shareSuccessHandler = handler;
- }
- this._onHideTime = Date.now();
- this.shareAppMessage({
- title: this._shareStr,
- query: 'shareMsg=' + 'a=1'
- });
- }
- showRewardVideo(handler) {
- if (handler === void 0) {
- handler = null;
- }
- //console.log('当日视频次数: ', ArchiveSystem.localData.videoRewardTimesToday);
- /*if (ArchiveSystem.localData.videoRewardTimesToday % 2 === 1) {
- cc.log(ArchiveSystem.localData.videoRewardTimesToday, '转为分享');
- this.__turnVideoToShare(handler);
- return;
- }*/
- if (!this._rewardVideo) {
- this.__turnVideoToShare(handler);
- return;
- }
- this._videoSuccessHandler = handler;
- this._rewardVideo.show().then(() => {
- console.log("视频播放成功");
- }).catch(err => {
- this._rewardVideo.load().then(() => {
- this._rewardVideo.show().then(() => {
- console.log("视频重新加载,播放成功");
- });
- }).catch(err2 => {
- var _this$_videoSuccessHa;
- (_this$_videoSuccessHa = this._videoSuccessHandler) == null || _this$_videoSuccessHa.call(this, false);
- this.shareShowReward(handler);
- this._videoSuccessHandler = null;
- });
- });
- }
- showBannerAd() {
- if (!this._bannerAd) return;
- var {
- screenWidth,
- screenHeight
- } = globalTT.getSystemInfoSync();
- this._bannerAd.show().then(() => {
- this._bannerAd.style.left = (screenWidth - this._bannerAd.style.realWidth) / 2;
- this._bannerAd.style.top = screenHeight - this._bannerAd.style.realHeight;
- }).catch(e => {
- console.log('banner广告显示出错', e);
- });
- }
- hideBannerAd(recreate) {
- if (recreate === void 0) {
- recreate = false;
- }
- if (!this._bannerAd) return;
- this._bannerAd.hide();
- if (recreate) {
- this.refreshBannerAd();
- }
- }
- refreshBannerAd() {
- if (!this._bannerAd) return;
- this._bannerAd.destroy();
- this.__createBannerAd();
- }
- showInterstitialAd(force) {
- if (force === void 0) {
- force = false;
- }
- if (force) {
- if (!this._interstitialAd) return;
- this._interstitialAd.show();
- } else {
- if (!this._interstitialAd) return;
- var timeNow = Date.now();
- if (this._showInterstitialAdTime == null) {
- this._showInterstitialAdTime = timeNow;
- return;
- }
- if (timeNow - this._showInterstitialAdTime > 120 * 1000) {
- this._interstitialAd.show();
- this._showInterstitialAdTime = timeNow;
- }
- }
- }
- exitGame() {
- wx.exitMiniProgram({});
- }
- __createVideoAd() {
- if (!TT_CONFIG.AD_ID.video) return;
- this._rewardVideo = globalTT.createRewardedVideoAd({
- adUnitId: TT_CONFIG.AD_ID.video
- }); // 注册视频的onClose事件
- this._rewardVideo.onClose(res => {
- if (res && res.isEnded || res === undefined) {
- var _this$_videoSuccessHa2;
- (_this$_videoSuccessHa2 = this._videoSuccessHandler) == null || _this$_videoSuccessHa2.call(this, true);
- } else {
- var _this$_videoSuccessHa3;
- this.showToast({
- title: "完整观看视频才有奖励哦"
- });
- (_this$_videoSuccessHa3 = this._videoSuccessHandler) == null || _this$_videoSuccessHa3.call(this, false);
- }
- this._videoSuccessHandler = null;
- }); // 注册视频的onError事件
- this._rewardVideo.onError(res => {
- var _this$_videoSuccessHa4;
- (_this$_videoSuccessHa4 = this._videoSuccessHandler) == null || _this$_videoSuccessHa4.call(this, false);
- this.showToast({
- title: "暂时没有可观看的视频"
- });
- this.shareShowReward(this._videoSuccessHandler);
- this._videoSuccessHandler = null;
- });
- }
- __createBannerAd() {
- if (!TT_CONFIG.AD_ID.banner) return;
- var {
- screenWidth,
- screenHeight
- } = globalTT.getSystemInfoSync();
- var w = screenWidth * 0.85;
- var left = (screenWidth - w) / 2.0;
- this._bannerAd = globalTT.createBannerAd({
- adUnitId: TT_CONFIG.AD_ID.banner,
- adIntervals: 48,
- style: {
- left: left,
- top: screenHeight - 70,
- width: w,
- height: 70
- }
- });
- this._bannerAd.onError(err => {
- switch (err.errCode) {
- case 1001:
- {
- break;
- }
- case 1004:
- {
- break;
- }
- }
- });
- this._bannerAd.onResize(() => {});
- }
- __createInterstitialAd() {
- if (!TT_CONFIG.AD_ID.interstitial) return;
- this._interstitialAd = globalTT.createInterstitialAd({
- adUnitId: TT_CONFIG.AD_ID.interstitial
- });
- }
- __turnVideoToShare(handler) {
- this.shareShowReward(handler);
- this._videoSuccessHandler = null;
- }
- };
- _export("default", new PlatformTT());
- _cclegacy._RF.pop();
- _crd = false;
- }
- };
- });
- //# sourceMappingURL=2a5c63ac12d75132c52c8f7691451f27e85f9a6e.js.map
|