Files
game1/assets/_script/Platform.js
T
tothvillar e896e2ead4 init
2026-07-09 15:04:14 +08:00

318 lines
11 KiB
JavaScript

function i(e, o) {
if (!(e instanceof o)) {
throw new TypeError("Cannot call a class as a function");
}
}
function n(e, o) {
for (var t = 0; t < o.length; t++) {
var i = o[t];
i.enumerable = i.enumerable || false;
i.configurable = true;
"value" in i && (i.writable = true);
Object.defineProperty(e, i.key, i);
}
}
function a(e, o, t) {
o && n(e.prototype, o);
t && n(e, t);
return e;
}
var c = function () {
function o() {
i(this, o);
this.VideoSuccessCallBack = null;
this.VideoFailureCallBack = null;
this.PlatformTool = null;
var t = null;
if (window.swan) {
console.log("加载百度信息, 并初始化");
this.PlatformTool = require("_baidu");
this.PlatformTool.doInitialize();
} else if (GlobData.isHuaWeiMiNiGame) {
console.log("加载华为信息, 并初始化....");
this.PlatformTools = require("huaweiUtil");
this.PlatformTools.initHuawei();
} else if (cc.sys.platform == cc.sys.OPPO_GAME) {
null != oppoUtil && cc.sys.platform === cc.sys.OPPO_GAME && oppoUtil.initQQShow();
} else if (window.h5api) {
console.log("加载4399渠道信息, 并初始化....");
GlobData.is4399MiNiGame = true;
} else if (window.tt) {
null != TouTiaoTools && window.tt && TouTiaoTools.initQQShow();
} else if (GlobData.isUcMiNiGame) {
console.log("加载UC信息, 并初始化");
this.PlatformTool = require("uc");
this.PlatformTool.doInitialize();
} else if (window.qq) {
this.PlatformTool = require("qq");
this.PlatformTool.doInitialize();
this.PlatformTool.kaipingVideo();
} else if ("undefined" != typeof mz_jsb) {
MeiZuUtil.initQQShow();
} else if (window.ks) {
t = require("KuaishouUtil");
} else if (undefined != window.vivoUtil) {
window.GameConfig.levelOrder = window.levelOrder;
window.vivoUtil.initQQShow();
} else {
cc.sys.platform === cc.sys.ANDROID && GlobData.doInitialize();
}
if (t) {
this.PlatformTool = new t();
this.PlatformTool.doInitialize && this.PlatformTool.doInitialize();
}
}
a(o, [{
key: "executeShowBanner",
value: function () {
console.log("调用插屏");
if (cc.sys.platform !== cc.sys.ANDROID) {
undefined != window.vivoUtil && vivoUtil.showAd_Banner();
"undefined" != typeof mz_jsb && MeiZuUtil.showAd_Banner();
cc.sys.platform === cc.sys.OPPO_GAME && null != oppoUtil && oppoUtil.showAd_Banner();
if (null != TouTiaoTools && window.tt) {
TouTiaoTools.showBanner();
} else {
this.PlatformTool && this.PlatformTool.executeShowBanner && this.PlatformTool.executeShowBanner();
}
} else {
GlobData.showBanner();
}
}
}, {
key: "executeYinSiBtn",
value: function () {
cc.sys.platform !== cc.sys.ANDROID || GlobData.executeYinSiBtn();
}
}, {
key: "executeHideBalock",
value: function () {
if (window.qq) {
if (!this.PlatformTool) {
return;
}
this.PlatformTool.closeBlockAd && this.PlatformTool.closeBlockAd();
}
}
}, {
key: "winVideo",
value: function () {
"undefined" != typeof mz_jsb && MeiZuUtil.winVideo();
window.ks && this.PlatformTool.Suijivideo && this.PlatformTool.Suijivideo(GameConfig.randomShowvideo, null);
if (window.qq) {
if (!this.PlatformTool) {
return;
}
this.PlatformTool.winVideo && this.PlatformTool.winVideo();
}
}
}, {
key: "executeShowVivoChaPing",
value: function () {
if (cc.sys.platform !== cc.sys.ANDROID) {
undefined != window.vivoUtil && vivoUtil.showAd_ChaPing();
null != oppoUtil && cc.sys.platform == cc.sys.OPPO_GAME && oppoUtil.showAd_ChaPing();
window.qg && (window.sendDesk || window.GameConfig.sendDesk) && window.qg.hasShortcutInstalled({
success: function (e) {
if (e) {
console.log("桌面有图标:", e);
} else {
console.log("桌面无图标:", e);
window.qg.installShortcut({
success: function () {},
fail: function (e) {},
complete: function () {}
});
}
}.bind(this),
fail: function (e) {}.bind(this),
complete: function () {}.bind(this)
});
"undefined" != typeof mz_jsb && MeiZuUtil.showAd_ChaPing();
this.PlatformTool && this.PlatformTool.executeJieSuanChaPing && this.PlatformTool.executeJieSuanChaPing();
} else {
GlobData.showInterstitial();
}
}
}, {
key: "showMainCaiqian",
value: function () {
var e = arguments.length > 0 && undefined !== arguments[0] && arguments[0];
this.PlatformTool && this.PlatformTool.showMainCaiqian && this.PlatformTool.showMainCaiqian(e);
}
}, {
key: "executeShowVIVOInGame",
value: function () {
if (undefined != window.vivoUtil) {
vivoUtil.showAdInGame();
} else if (null != oppoUtil && cc.sys.platform === cc.sys.OPPO_GAME) {
oppoUtil.showAdInGame();
} else {
"undefined" != typeof mz_jsb && MeiZuUtil.showAd_Banner();
}
this.PlatformTool && this.PlatformTool.executeShowBanner && this.PlatformTool.executeShowBanner();
}
}, {
key: "executeHideBanner",
value: function () {
if (cc.sys.platform !== cc.sys.ANDROID) {
null != oppoUtil && cc.sys.platform === cc.sys.OPPO_GAME && oppoUtil.closeBanner();
null != TouTiaoTools && window.tt && TouTiaoTools.hideBanner();
this.PlatformTool && this.PlatformTool.executeHideBanner && this.PlatformTool.executeHideBanner();
} else {
GlobData.destroyBanner();
}
}
}, {
key: "executeRandVideo",
value: function () {
console.log("调用随机视频");
null != TouTiaoTools && window.tt && TouTiaoTools.randomVideo();
"undefined" != typeof mz_jsb && MeiZuUtil.randomVideo();
if (this.PlatformTool) {
console.log("随机视频-----:" + GameConfig.randomShowvideo);
this.PlatformTool.Suijivideo && this.PlatformTool.Suijivideo(GameConfig.randomShowvideo, null);
}
}
}, {
key: "executeKaiPing",
value: function () {
this.PlatformTool && this.PlatformTool.Suijivideo && this.PlatformTool.Suijivideo(GameConfig.randomSplshvideo, null);
}
}, {
key: "executeShowInterstitial",
value: function () {
if (!GlobData.isUcMiNiGame) {
if (null != TouTiaoTools && window.tt) {
TouTiaoTools.showChaPing();
} else {
this.PlatformTool && this.PlatformTool.executeShowInterstitial && this.PlatformTool.executeShowInterstitial();
}
}
}
}, {
key: "executeVideoRecorder",
value: function () {
if (null != TouTiaoTools && window.tt) {
TouTiaoTools.luzhiKaishi();
} else {
this.PlatformTool && this.PlatformTool.executeRecorder && this.PlatformTool.executeRecorder();
}
}
}, {
key: "executeStopVideoRecorder",
value: function () {
if (null != TouTiaoTools && window.tt) {
TouTiaoTools.luzhijieshu();
} else {
this.PlatformTool && this.PlatformTool.stopRecorder && this.PlatformTool.stopRecorder();
}
}
}, {
key: "executeShareRecorderVideo",
value: function (e, o) {
if (null != TouTiaoTools && window.tt) {
TouTiaoTools.fenxiangVideo(e, o);
} else if (this.PlatformTool) {
this.PlatformTool.executeShareRecorder && this.PlatformTool.executeShareRecorder(e, o);
} else {
e && e();
}
}
}, {
key: "executeShowAwardVideo",
value: function (e, o) {
if (GlobData.is4399MiNiGame) {
console.log("当前平台为4399平台, 开始实例化相关参数");
return void window.h5api.canPlayAd(function (t) {
console.log("是否可播放广告", t.canPlayAd, "剩余次数", t.remain);
window.h5api.playAd(function (t) {
console.log("代码:" + t.code + ",消息:" + t.message);
if (1e4 === t.code) {
console.log("开始播放");
} else if (10001 === t.code) {
console.log("播放结束");
e && e();
} else {
console.log("广告异常");
o && o();
}
});
});
}
if (cc.sys.platform !== cc.sys.ANDROID) {
if ("undefined" == typeof mz_jsb) {
if (null != TouTiaoTools && window.tt) {
TouTiaoTools.getVideoAd(e, o);
} else if (null == oppoUtil || cc.sys.platform !== cc.sys.OPPO_GAME) {
console.log("执行了这个?");
if (undefined == window.vivoUtil) {
if (this.PlatformTool) {
this.PlatformTool.executeShowAwardVideo && this.PlatformTool.executeShowAwardVideo(e, o);
} else {
e && e();
}
} else {
vivoUtil.getVideoAd(e, o);
}
} else {
oppoUtil.getVideoAd(e, o);
}
} else {
MeiZuUtil.getVideoAd(e, o);
}
} else {
GlobData.showVideo(e, o);
}
}
}, {
key: "executeShowPushBox",
value: function () {
if (null != oppoUtil && cc.sys.platform === cc.sys.OPPO_GAME) {
oppoUtil.closeBanner();
oppoUtil.showMoreGame();
}
GlobData.is4399MiNiGame && window.h5api.showRecommend();
null != TouTiaoTools && window.tt && TouTiaoTools.moreGame();
this.PlatformTool && this.PlatformTool.executeShowPushBox && this.PlatformTool.executeShowPushBox();
}
}, {
key: "addZhuoMianJianCe",
value: function (e, o) {
(window.qg || "undefined" != typeof mz_jsb) && window.qg.hasShortcutInstalled({
success: function (t) {
if (t) {
e && e();
} else {
o && o();
}
},
fail: function (e) {},
complete: function () {}
});
this.Platform && this.Platform.isInstalledShortcut && this.Platform.isInstalledShortcut(e, o);
}
}, {
key: "sendToDesktop",
value: function (e) {
var o = arguments.length > 1 && undefined !== arguments[1] && arguments[1];
cc.sys.platform !== cc.sys.VIVO_GAME && cc.sys.platform !== cc.sys.OPPO_GAME && "undefined" == typeof mz_jsb || window.qg.installShortcut({
success: function () {
e && (e.active = false);
},
fail: function (e) {
null != oppoUtil && cc.sys.platform === cc.sys.OPPO_GAME && oppoUtil.showAd_Banner();
},
complete: function () {}
});
this.PlatformTool && this.PlatformTool.showAddZhuomian && this.PlatformTool.showAddZhuomian(e, o);
}
}, {
key: "executeBlockAdShow",
value: function (e, o) {
window.swan || this.PlatformTool && this.PlatformTool.executeBlockAdShow && this.PlatformTool.executeBlockAdShow(e, o);
}
}]);
return o;
}();
module.exports = c;