1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| mergeInto(LibraryManager.library, {
InitSDK: function (adUnitId, type) { const qg = window.qg;//qg OPPO 小游戏平台提供的全局对象 if (qg) { console.log("-------window.qg 存在") var systemInfo = qg.getSystemInfoSync(); console.log(systemInfo); switch (Pointer_stringify(type)) { case "banner": var bannerAd = qg.createBannerAd({ adUnitId: Pointer_stringify(adUnitId), //字符串需要转换一下 style: { left: 0, top: systemInfo.screenHeight - 100 - 10, width: systemInfo.screenWidth, height: 50 } }); if (!window.OPPOAD) { window.OPPOAD = {}; } window.OPPOAD.bannerAd = bannerAd; break; case "video": var videoAd = qg.createRewardedVideoAd({ adUnitId: Pointer_stringify(adUnitId) }) if (!window.OPPOAD) { window.OPPOAD = {}; } window.OPPOAD.videoAd = videoAd; break; case "gameBanner": // var gameBannerAd = qg.createGameBannerAd({ // adUnitId: Pointer_stringify(adUnitId) // }) break; default: break; } } else { SendMessage('BtnRoot', 'CallBack', 'init failed mybe not OPPO-quickgame'); //组件名,方法名,参数 } },
JSShowBannerAd: function () { if (window.OPPOAD && window.OPPOAD.bannerAd) { const bannerAd = window.OPPOAD.bannerAd; console.log("-------bannerAd.show()"); bannerAd.show(); bannerAd.onLoad(function () { console.log('banner 广告加载成功') SendMessage('BtnRoot', 'CallBack', 'bannerAd load success'); }); bannerAd.onError(function (err) { console.log("this.bannerAd onError", res); }); } else { console.log("------- no bannerAd"); };
},
JSHideBannerAd: function () { if (window.OPPOAD && window.OPPOAD.bannerAd) { const bannerAd = window.OPPOAD.bannerAd; console.log("-------bannerAd.hide()"); bannerAd.hide(); bannerAd.onHide(function () { console.log('banner 广告隐藏') SendMessage('BtnRoot', 'CallBack', 'bannerAd hide'); }); } else { console.log("------- no bannerAd"); }; },
JSShowVideoAd: function () { if (window.OPPOAD && window.OPPOAD.videoAd) { const videoAd = window.OPPOAD.videoAd; videoAd.load(); videoAd.onLoad(function () { console.log('激励视频加载成功') videoAd.show() }); videoAd.onClose(function(res) { if (res.isEnded) { console.log('激励视频广告完成,发放奖励'); SendMessage('BtnRoot', 'CallBack', 'videoAd isEnded, Rewarded'); } else { console.log('激励视频广告取消关闭,不发放奖励'); SendMessage('BtnRoot', 'CallBack', 'videoAd cancle, no Rewarded'); } }); } else { console.log("------- no videoAd"); }; },
JSVibrateShort: function () {//震动 if (window.qg) { qg.vibrateShort({ success: function (res) { }, fail: function (res) { }, complete: function (res) { console.log("-------qg.vibrateShort complete"); } }); }; },
});
|