|
|
@@ -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();
|
|
|
+ }
|
|
|
}
|