Browse Source

添加banner广告

Duowan 6 years ago
parent
commit
dc0d9cc4dd
3 changed files with 42 additions and 35 deletions
  1. 5 5
      assets/Script/Game/GameSence.js
  2. 11 30
      assets/Script/Home/HomeSence.js
  3. 26 0
      assets/Script/UserInfoJS.js

+ 5 - 5
assets/Script/Game/GameSence.js

@@ -169,7 +169,7 @@ cc.Class({
 
         var gameOverNode = this.node.getChildByName("GameOver");
         gameOverNode.active = true;
-        // window.deadBanner.show();
+        UserInfo.showDeadBanner();
 
         var endLayerNumLabel = gameOverNode.getChildByName("EndLayerNumLabel");
         endLayerNumLabel.getComponent("cc.Label").string = this.sumScore;
@@ -261,13 +261,13 @@ cc.Class({
             UserInfo.addGold(this.sumScore);
         })
 
-        // window.deadBanner.hide();
+        UserInfo.destroyDeadBanner();
         // window.accountBanner.show();
     },
 
 
     continueGame: function () {
-        // window.deadBanner.hide();
+        UserInfo.destroyDeadBanner();
         // window.accountBanner.hide();
         this.bShare = false;
         this.bDead = false;
@@ -854,7 +854,7 @@ cc.Class({
         this.gameOver();
 
         if (CC_QQPLAY) {
-            // window.deadBanner.hide();
+            UserInfo.destroyDeadBanner();
             this.rankScene.status = 3;
             this.showRank();
             this.updateXYXScore('showMyRank', null);
@@ -964,7 +964,7 @@ cc.Class({
         this.node.getChildByName("GameOver").active = false;
         this.node.parent.getChildByName("PHB").active = false;
         this.node.parent.getComponent("SenceManager").enterSence("Game", "Home");
-        // window.indexBanner.show();
+        UserInfo.showIndexBanner();
     },
 
     onBtnAudio: function () {

+ 11 - 30
assets/Script/Home/HomeSence.js

@@ -70,10 +70,11 @@ cc.Class({
         //     }
         // })
 
-		// if (CC_QQPLAY) {
-		// 	this.QQLogin();
-		// 	this.initShare();
-		// }
+		if (CC_QQPLAY) {
+			// this.QQLogin();
+            // this.initShare();
+            UserInfo.showIndexBanner();
+		}
     },
 
     start() {
@@ -91,7 +92,6 @@ cc.Class({
 			BK.Console.log('登录成功')
 		}
 	},
-
     // initShare(data) {
     //     let datavalue = UserInfo.getString('allscore');
     //     let key = UserInfo.getCurWeekScoreValue();
@@ -153,11 +153,6 @@ cc.Class({
     // },
 
     onRankBtn: function (event, optData) {
-        console.log('onrankbtn:', optData)
-        // wx.postMessage({
-        //     method: 'showFriendRank',
-        //     data: optData
-        // });
 
         cc.find("Canvas/PHB").getChildByName("BtnPHBClose").active = (optData == "true");
         cc.find("Canvas/PHB").getChildByName("emptyBtn").active = (optData == "true");
@@ -165,16 +160,12 @@ cc.Class({
 		
         if (this.node.active) {
             if ("true" == optData) {
-                // window.indexBanner.hide();
+                UserInfo.destroyIndexBanner();
                 this.rankScene.status = 1;
                 this.showRank();
             }
             if ("false" == optData) {
-                // window.indexBanner.show();
-                // wx.postMessage({
-                //     method: 'hideRank',
-                //     data: optData
-                // });
+                UserInfo.showIndexBanner();
                 cc.find("Canvas/PHB").active = false;
             }
         } else {
@@ -207,7 +198,7 @@ cc.Class({
 
     onGameStartBtn: function () {
         this.node.parent.getChildByName("SkinNode").active = false;
-        // window.indexBanner.hide();
+        UserInfo.destroyIndexBanner();
         if (this.showGuide()) {
             this.GuideNode.active = true;
         } else {
@@ -254,10 +245,10 @@ cc.Class({
             sumScoreLabel.getComponent("cc.Label").string = UserInfo.getTotalGold();
 
             this.updateSkinNode();
-            // window.indexBanner.hide();
+            UserInfo.destroyIndexBanner();
         } else if (optData == "false") {
             this.node.parent.getChildByName("SkinNode").active = false;
-            // window.indexBanner.show();
+            UserInfo.showIndexBanner();
         }
     },
 
@@ -339,7 +330,7 @@ cc.Class({
 
     onGuideBtn: function (event) {
         this.node.parent.getChildByName("Guide").active = false;
-        // window.indexBanner.show();
+        // UserInfo.showIndexBanner();
     },
 
     onNextBtn: function (event, optData) {
@@ -386,14 +377,6 @@ cc.Class({
     },
 
     onShareBtn: function () {
-        if (CC_WECHATGAME) {
-            var data = {
-                titleData: UserInfo.shareDesc,
-                imgurlData: UserInfo.shareUrl
-            }
-            WxCommon.ShareAppMessage(data, this, null);
-		}
-		
 		if (CC_QQPLAY) {
 			var data = {
                 titleData: UserInfo.shareDesc,
@@ -451,7 +434,5 @@ cc.Class({
         cc.audioEngine.playEffect(this.buttonAudio);
     }
 
-
-
     // update (dt) {},
 });

+ 26 - 0
assets/Script/UserInfoJS.js

@@ -338,4 +338,30 @@ window.UserInfo = {
 		var week = Math.ceil((d + 1) / 7);
 		return week;
 	},
+
+	showIndexBanner() {
+		this.indexBanner = BK.Advertisement.createBannerAd({
+            viewId:1001,
+            style: {x: 0, y: 0}
+		});
+
+		this.indexBanner.show()
+	},
+
+	destroyIndexBanner() {
+		this.indexBanner.destory()
+	},
+
+	showDeadBanner() {
+		this.deadBanner = BK.Advertisement.createBannerAd({
+            viewId:1002,
+            style: {x: 0, y: 0}
+		});
+
+		this.deadBanner.show()
+	},
+
+	destroyDeadBanner() {
+		this.deadBanner.destory()
+	},
 };