kaka 4 سال پیش
والد
کامیت
1a7cb19bbd

+ 1 - 1
assets/script/game/data/AdData.ts

@@ -279,7 +279,7 @@ export class AdData {
                 }, delay1);
                 break;
             case 4:
-                gData.moreGame.popMoreGamePopNode();
+                gData.moreGame.popNewOpenRedBag();
                 break;
         }
     }

+ 6 - 2
assets/script/game/data/module/MoreGameData.ts

@@ -26,6 +26,8 @@ export class MoreGameData extends Data {
     /** 下载中列表 */
     private static downLoadTaskMap: Map<string, DownloadTaskClazz> = new Map<string, any>()
 
+    init_newOpenRedBag = false;
+
     /** 测试数据 */
     private testData = {
         "normal": [
@@ -194,7 +196,7 @@ export class MoreGameData extends Data {
         return data
     }
 
-    /** 弹出互推红包弹窗 */
+    /** 弹出互推红包弹窗 (已废弃)*/
     popMoreGamePopNode() {
         if (mk.guide.isGuiding || mk.ui.getCurOnPanel('reward')) {
             return;
@@ -205,8 +207,10 @@ export class MoreGameData extends Data {
         }
     }
 
+    /** 弹出互推红包弹窗 */
     popNewOpenRedBag() {
-        
+        this.init_newOpenRedBag = true;
+        mk.ui.openPanel('module/newOpenRedBag/newOpenRedBag');
     }
 
     /** 点击互推插屏获取红包币 */

+ 58 - 40
assets/script/game/module/newOpenRedBag/NewOpenRedBag.ts

@@ -1,6 +1,7 @@
 import Util from "../../../before/util/Util";
+import JsbSystem from "../../../mk/system/JsbSystem";
 import { AdFun } from "../../data/AdData";
-import { VideoAdType } from "../../data/GameData";
+import { DataEventId, VideoAdType } from "../../data/GameData";
 
 const { ccclass, property } = cc._decorator;
 @ccclass
@@ -24,47 +25,34 @@ export default class NewOpenRedBag extends cc.Component {
     @property(cc.Node)
     private node_video: cc.Node = null;
 
+    data = null
     start() {
+        if (gData.moreGame.init_newOpenRedBag) {
+            gData.moreGame.init_newOpenRedBag = false;
+            this.showElectUI();
+        }
         this.showChangePart();
-
     }
 
-    showElectUI()
-    {
+    showElectUI() {
         this.sendRecommendList();
     }
 
     async sendRecommendList() {
-        if (gData.gameData.gameData.moreGameData == null || gData.gameData.gameData.moreGameData == undefined) {
-            let data = {
-                //是否支持小游戏 1:支持,0:不支持
-                isSupportMiniGames: 1
-            };
-            let response = await mk.http.sendData('/fission/recommend-info', data);
-            if (response.errcode != 0) {
-                return;
-            }
-
-            gData.gameData.gameData.moreGameData = response.data;
+        this.sp_icon.node.active = true;
+        this.data = gData.moreGame.getRandomNormal();
+        if (this.data) {
+            cc.loader.load(this.data.icon, (err, res) => {
+                if (err) {
+                    console.log('err:', err);
+                    return;
+                }
+                let tex: cc.Texture2D = res as cc.Texture2D;
+                this.sp_icon.spriteFrame = new cc.SpriteFrame(tex);
+            })
         }
 
-        if(gData.gameData.gameData.moreGameData)
-        {
-            this.node_video.active = false;
-
-            let index = mk.math.random(0, gData.gameData.gameData.moreGameData.normal.length - 1)
-            let data = gData.gameData.gameData.moreGameData.normal[index]
-            if (cc.sys.os != cc.sys.OS_WINDOWS && data) {
-                cc.loader.load(data.icon, (err, res)=>{
-                    if (err) {
-                        console.log('err:', err);
-                        return;
-                    }
-                    let tex: cc.Texture2D = res as cc.Texture2D;
-                    this.sp_icon.spriteFrame = new cc.SpriteFrame(tex);
-                })               
-            }
-        }
+        this.node_video.active = false;
     }
 
     update(dt) {
@@ -133,18 +121,48 @@ export default class NewOpenRedBag extends cc.Component {
     private clickOpenBtn() {
         mk.audio.playEffect("button");
         mk.ui.closePanel(this.name);
-        mk.ad.videoAdType = VideoAdType.StartQiPaoRedBag;
-        mk.ad.watchAd((success: boolean) => {
-            mk.console.log("watchAD:" + success);
-            if (success) {
-                gData.adData.watchVideo(AdFun.bubble);
-            }
-        });
-
+        if (this.sp_icon.node.active) {
+            this.creatorDownLoadTask();
+            //增加红包币
+            
+        }
+        else {
+            mk.ad.videoAdType = VideoAdType.StartQiPaoRedBag;
+            mk.ad.watchAd((success: boolean) => {
+                mk.console.log("watchAD:" + success);
+                if (success) {
+                    gData.adData.watchVideo(AdFun.bubble);
+                }
+            });
+        }
     }
 
     private clickCloseBtn() {
         // mk.audio.playEffect("closeButton");
         gData.adData.checkShowFullInter(1);
     }
+
+    cool = false
+    creatorDownLoadTask() {
+        if (!CC_JSB) {
+            return;
+        }
+
+        if (this.cool) {
+            return
+        }
+
+        this.cool = true
+        mk.data.sendDataEvent(DataEventId.hutuiFunction, "互推插屏下载");
+        if (this.data.appType == 1) {
+            if (!JsbSystem.ifCanStartGame(this.data.packageName, true)) {
+                gData.moreGame.createNewTask(this.data)
+            }
+        }
+        else if (this.data.appType == 2) {
+            cc.sys.openURL(this.data.recommendLink);
+        }
+
+        gData.moreGame.popNodeGetRedBag();
+    }
 }