window.MZys = { createChaping: function (e, o, t) { console.log("createchaping "); var i = cc.view.getVisibleSize(); cc.v2(i.width / 2, i.height / 2); var n = new cc.Node(); n.parent = cc.director.getScene(); n.zIndex = 9999; n.setContentSize(cc.winSize); var a = new cc.Texture2D(); var c = new cc.SpriteFrame(); a.initWithData(new Uint8Array([0, 0, 0]), cc.Texture2D.PixelFormat.RGB888, 1, 1, cc.winSize); c.setTexture(a); c.setRect(cc.rect(0, 0, 20 * cc.winSize.width, 20 * cc.winSize.width)); var s = new cc.Node(); s.parent = n; s.opacity = 1; s.addComponent(cc.Sprite).spriteFrame = c; s.on("touchend", function (e) {}); var l = new cc.Node(); l.parent = n; l.x = .5 * i.width; l.y = .5 * i.height; var r = l.addComponent(cc.Sprite); a = new cc.Texture2D(); c = new cc.SpriteFrame(); a.initWithData(new Uint8Array([0, 0, 0]), cc.Texture2D.PixelFormat.RGB888, 1, 1, cc.winSize); c.setTexture(a); c.setRect(cc.rect(0, 0, 630, 475)); r.spriteFrame = c; r.sizeMode = cc.Sprite.SizeMode.Custom; cc.loader.load(e, function (o, t) { r.spriteFrame = new cc.SpriteFrame(e); }); var d = new cc.Node(); d.parent = n; d.x = .5 * i.width; d.y = .5 * i.height; d.addComponent(cc.Sprite); d.on(cc.Node.EventType.TOUCH_END, function (e) { console.log("ad click"); t && t(); n.removeFromParent(); }); l.on(cc.Node.EventType.TOUCH_END, function (e) { console.log("ad click"); t && t(); n.removeFromParent(); }); var u = new cc.Node(); u.parent = n; u.x = i.width / 2 + 280; u.y = .75 * i.height; u.sizeMode = cc.Sprite.SizeMode.Custom; cc.loader.loadRes("ysguanggao/native_3", function (e, o) { u.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o); }); var h = new cc.Node(); h.parent = n; h.x = i.width / 2 + 270; h.y = .3 * i.height; cc.loader.loadRes("ysguanggao/native_1", function (e, o) { h.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o); }); var f = new cc.Node(); f.parent = n; f.x = i.width / 2 + 260; f.y = .21 * i.height; cc.loader.loadRes("ysguanggao/native_7", function (e, o) { f.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o); }); f.on(cc.Node.EventType.TOUCH_END, function (e) { console.log("ad click"); t && t(); n.removeFromParent(); }); var g = new cc.Node(); g.parent = n; g.opacity = 1; g.x = i.width / 2 + 280; g.y = .75 * i.height; g.scale = window.ServerConfigBd.closeBtnScale; cc.loader.loadRes("ysguanggao/native_3", function (e, o) { g.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o); }); g.on(cc.Node.EventType.TOUCH_END, function (e) { console.log("closeBtn click"); o && o(); n.removeFromParent(); }); return n; }, createBanner: function (e, o, t) { var i = cc.view.getVisibleSize(); cc.v2(i.width / 2, i.height / 2); var n = new cc.Node(); n.parent = cc.director.getScene(); n.zIndex = 9999; n.setContentSize(cc.winSize); var a = new cc.Node(); a.parent = n; a.x = .5 * i.width; a.y = .05 * i.height; var c = a.addComponent(cc.Sprite); var s = new cc.Texture2D(); var l = new cc.SpriteFrame(); s.initWithData(new Uint8Array([0, 0, 0]), cc.Texture2D.PixelFormat.RGB888, 1, 1, cc.winSize); l.setTexture(s); l.setRect(cc.rect(0, 0, .5 * cc.winSize.width, .14 * cc.winSize.height)); c.spriteFrame = l; c.sizeMode = cc.Sprite.SizeMode.CUSTOM; cc.loader.load(e, function (e, o) { c.spriteFrame = new cc.SpriteFrame(o); }); a.on(cc.Node.EventType.TOUCH_END, function (e) { console.log("ad click"); t && t(); n.removeFromParent(); }); var r = new cc.Node(); r.parent = n; r.x = .74 * i.width; r.y = .09 * i.height; cc.loader.loadRes("ysguanggao/native_3", function (e, o) { r.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o); }); var d = new cc.Node(); d.parent = n; d.x = .74 * i.width; d.y = .02 * i.height; cc.loader.loadRes("ysguanggao/native_1", function (e, o) { d.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o); }); r.on(cc.Node.EventType.TOUCH_END, function (e) { console.log("closeBtn click"); o && o(); n.removeFromParent(); }); return n; } }; window.MeiZuUtil = { shipinID: "viArHNtb", chapingID: "8T8j2Hy9", bannerID: "yxkS3shy", yuanshengID1: "os67rRSZ", yuanshengID2: "", yuanshengID3: "", rewardedVideoAd: null, AdSuccess: function () { if (null != MeiZuUtil.videoCallback) { MeiZuUtil.videoCallback(); MeiZuUtil.videoCallback = null; } }, Adfail: function () { if (null != MeiZuUtil.videofailCallback) { MeiZuUtil.videofailCallback(); MeiZuUtil.videofailCallback = null; } }, yuanshengIndex: 0, yuanshengADK: null, isVideo: true, videoInstance: null, isFrist: true, isShowChaping: 0, portalInstance: null, bannerNative: null, chapingnativeAd: null, lfenzhong: false, isReward: false, wincount: 0, SHOWIndex: 0, initQQShow: function () { MeiZuUtil.lfenzhong = true; MeiZuUtil.GaiLv(window.ServerConfigBd.randomkaiping) && MeiZuUtil.getVideoAd(null, null); }, getVideoAd: function (e, o) { MeiZuUtil.isReward = false; this.videoCallback = e; this.videofailCallback = o; MeiZuUtil.rewardedVideoAd = qg.createRewardedVideoAd({ adUnitId: MeiZuUtil.shipinID }); MeiZuUtil.rewardedVideoAd.load(); MeiZuUtil.rewardedVideoAd.onLoad(function () { console.log("激励视频加载成功"); MeiZuUtil.rewardedVideoAd.show(); }); MeiZuUtil.rewardedVideoAd.onRewarded(function () { MeiZuUtil.isReward = true; }); MeiZuUtil.rewardedVideoAd.onClose(function (e) { console.log("res11111:" + MeiZuUtil.isReward); if (MeiZuUtil.isReward) { MeiZuUtil.AdSuccess(); } else { MeiZuUtil.Adfail(); } }); MeiZuUtil.rewardedVideoAd.onError(function (e) { MeiZuUtil.Adfail(); console.log("激励视频::" + e); }); }, GaiLv: function (e) { return 1 + Math.floor(100 * Math.random()) <= e; }, showAd_Banner: function () { MeiZuUtil.clearAD(); MeiZuUtil.showBanner(); }, randomVideo: function () { MeiZuUtil.GaiLv(window.ServerConfigBd.randomShowvideo) && MeiZuUtil.getVideoAd(null, null); }, showAdInGame: function () { MeiZuUtil.clearAD(); MeiZuUtil.showBanner(); }, showAd_ChaPing: function () { MeiZuUtil.createNativeadChaping(); }, winVideo: function () { MeiZuUtil.wincount++; 0 !== window.ServerConfigBd.winVideo && MeiZuUtil.wincount % window.ServerConfigBd.winVideo == 0 && MeiZuUtil.getVideoAd(null, null); }, showBanner: function () { if (null != MeiZuUtil.bannerAd) { MeiZuUtil.bannerAd.offResize(); MeiZuUtil.bannerAd.offError(); MeiZuUtil.bannerAd.hide(); MeiZuUtil.bannerAd = null; } MeiZuUtil.bannerAd = qg.createBannerAd({ adUnitId: MeiZuUtil.bannerID, style: { left: (qg.getSystemInfoSync().screenWidth - .4 * qg.getSystemInfoSync().screenWidth) / 2, top: qg.getSystemInfoSync().screenHeight - 100, width: .4 * qg.getSystemInfoSync().screenWidth, height: .4 * qg.getSystemInfoSync().screenWidth * .24 } }); MeiZuUtil.bannerAd.onError(function (e) { console.log("banner sdk bannerAd错误日志" + e.errMsg + e.errCode); }); MeiZuUtil.bannerAd.onResize(function (e) { console.log("banner onResize:" + e.width, e.height); console.log("banner onResize:" + (qg.getSystemInfoSync().screenWidth - .4 * qg.getSystemInfoSync().screenWidth) / 2); MeiZuUtil.bannerAd.style.top = qg.getSystemInfoSync().screenHeight - e.height; MeiZuUtil.bannerAd.style.left = (qg.getSystemInfoSync().screenWidth - .4 * qg.getSystemInfoSync().screenWidth) / 2; MeiZuUtil.bannerAd.show(); }); }, closeBanner: function () { MeiZuUtil.clearAD(); }, showChaping: function () { MeiZuUtil.clearAD(); var e = qg.createInsertAd({ adUnitId: MeiZuUtil.chapingID }); e.onLoad(function () { console.log("insert 广告加载成功"); e.show(); }); e.onError(function (e) { console.log(e); }); e.load(); }, clearAD: function () { MeiZuUtil.bannerAd && MeiZuUtil.bannerAd.hide(); MeiZuUtil.yuanshengADK && MeiZuUtil.yuanshengADK.destroy(); }, createNativeadChaping: function () { if (MeiZuUtil.chapingnativeAd) { MeiZuUtil.chapingnativeAd.offLoad(); MeiZuUtil.chapingnativeAd.offError(); MeiZuUtil.chapingnativeAd = null; } var e = [MeiZuUtil.yuanshengID1]; MeiZuUtil.yuanshengIndex += 1; MeiZuUtil.yuanshengIndex >= e.length && (MeiZuUtil.yuanshengIndex = 0); MeiZuUtil.chapingnativeAd = qg.createNativeAd({ adUnitId: e[MeiZuUtil.yuanshengIndex] }); MeiZuUtil.chapingnativeAd.onLoad(function (e) { MeiZuUtil.chapingnativeAd.offLoad(); MeiZuUtil.chapingnativeAd.reportAdShow({ adId: e.adList[0].adId }); MeiZuUtil.clearAD(); MeiZuUtil.yuanshengADK = MZys.createChaping(e.adList[0].imgUrlList[0], function () { MeiZuUtil.chapingnativeAd.offLoad(); MeiZuUtil.chapingnativeAd.offError(); MeiZuUtil.yuanshengADK = null; }, function () { MeiZuUtil.chapingnativeAd.reportAdClick({ adId: e.adList[0].adId }); MeiZuUtil.chapingnativeAd.offLoad(); MeiZuUtil.chapingnativeAd.offError(); MeiZuUtil.yuanshengADK = null; }); }); MeiZuUtil.chapingnativeAd.onError(function (e) { MeiZuUtil.chapingnativeAd.offLoad(); MeiZuUtil.chapingnativeAd.offError(); MeiZuUtil.chapingnativeAd = null; console.log("插屏显示错误了----" + JSON.stringify(e)); MeiZuUtil.showChaping(); }); MeiZuUtil.chapingnativeAd.load(); }, createNativeadBanner: function () { if (MeiZuUtil.bannerNative) { MeiZuUtil.bannerNative.offLoad(); MeiZuUtil.bannerNative.offError(); MeiZuUtil.bannerNative = null; } MeiZuUtil.clearAD(); var e = [MeiZuUtil.yuanshengID1]; MeiZuUtil.yuanshengIndex += 1; MeiZuUtil.yuanshengIndex >= e.length && (MeiZuUtil.yuanshengIndex = 0); MeiZuUtil.bannerNative = qg.createNativeAd({ adUnitId: e[MeiZuUtil.yuanshengIndex] }); MeiZuUtil.bannerNative.onLoad(function (e) { MeiZuUtil.bannerNative.reportAdShow({ adId: e.adList[0].adId }); MeiZuUtil.clearAD(); MeiZuUtil.yuanshengADK = MZys.createBanner(e.adList[0].imgUrlList[0], function () { MeiZuUtil.bannerNative.offLoad(); MeiZuUtil.bannerNative.offError(); MeiZuUtil.yuanshengADK = null; }, function () { MeiZuUtil.bannerNative.reportAdClick({ adId: e.adList[0].adId }); MeiZuUtil.bannerNative.offLoad(); MeiZuUtil.bannerNative.offError(); MeiZuUtil.yuanshengADK = null; }); }); MeiZuUtil.bannerNative.onError(function (e) { MeiZuUtil.bannerNative.offLoad(); MeiZuUtil.bannerNative.offError(); console.log("调用banner错误了===" + JSON.stringify(e)); MeiZuUtil.GaiLv(window.ServerConfigBd.quitShow) && MeiZuUtil.showBanner(); }); MeiZuUtil.bannerNative.load(); }, createNativead: function () { var e = [MeiZuUtil.yuanshengID1]; MeiZuUtil.yuanshengIndex += 1; MeiZuUtil.yuanshengIndex >= e.length && (MeiZuUtil.yuanshengIndex = 0); var o = qg.createNativeAd({ adUnitId: e[MeiZuUtil.yuanshengIndex] }); o.onLoad(function (e) { o.offLoad(); o.reportAdShow({ adId: e.adList[0].adId }); }); o.onError(function (e) {}); o.load(); } };