import { TuCaoData } from "../datas/TuCaoData"; import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM"; import GuideMng from "../manager/GuideMng"; import AdRbItem from "../other/item/AdRbItem"; import BasePanel from "../uiFrames/BasePanel"; import UIMng, { PanelType } from "../uiFrames/UIMng"; import EffectNode from "./EffectNode"; const { ccclass, property } = cc._decorator; @ccclass export default class AdRbPanel extends BasePanel { @property(cc.Label) txtBigNum: cc.Label = null; @property(cc.Label) txtAddEft: cc.Label = null; @property(cc.RichText) txtTipAd: cc.RichText = null; @property(cc.RichText) txtBigDelta: cc.RichText = null; @property(cc.RichText) txtBigTask: cc.RichText = null; @property(cc.RichText) txtRemaindAdNum: cc.RichText = null; @property(AdRbItem) adRbItem: AdRbItem = null; @property(cc.Node) itemContent: cc.Node = null; @property(cc.Node) btnCash: cc.Node = null; @property(cc.Node) btnAd: cc.Node = null; @property(cc.Animation) aniBigAdBtn: cc.Animation = null; @property(cc.Node) adIcon: cc.Node = null; @property(cc.Animation) aniBtnAd: cc.Animation = null; @property(cc.Node) rbOpenBtn: cc.Node = null; @property(cc.Node) nodeRb: cc.Node = null; @property(cc.Label) txtRbNum: cc.Label = null; @property(cc.Node) nodeHelp: cc.Node = null; @property(cc.Node) testNode: cc.Node = null; @property(cc.EditBox) inputBox: cc.EditBox = null; @property(cc.Node) cashSurePanel: cc.Node = null; @property(cc.Label) cashSureTxtNum: cc.Label = null; //@property(cc.Node) //panelNode: cc.Node = null; private isInit: boolean = false /**红包页面类型 1 大额 2 任务*/ private rbPanelType: number = 0; private adrbArray: AdRbItem[] = []; onLoad() { this.testNode.active = GameM.commonData.globalCfg.VideoRedBagEmpty == 1; } OnEnter() { //this.panelNode.scale = 0; this.node.active = true; //cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" }) // .call(() => { // // }) // .start(); if (!this.isInit) { TuCaoData.Ins.adRbPanel = this; } this.isPlayAni = false; this.UpdateInfo(false, true); if (GuideMng.Ins.CurGuideId == 28) GuideMng.Ins.ResumeGuide(); } OnExit() { this.node.active = false; if (this.adrbArray.length >= 4) { for (let i = 0; i < this.adrbArray.length; i++) { this.adrbArray[i].OnExit(); } } } update(dt) { this.PlayMoneyAniUpdate(dt); } UpdateInfo(isPlayAni: boolean = false, isPlayInitAni: boolean = false) { let data = TuCaoData.Ins.videoRbData; this.targetProgress = data.cumulativeAmount; this.txtBigDelta.node.active = data.showTask != 1; this.txtBigTask.node.active = data.showTask == 1; this.txtTipAd.string = data.showTask == 1 ? "提现中..." : "" + data.requestAmount + "元可提现"; //this.txtBigNum.string = data.cumulativeAmount + "元"; this.txtBigDelta.string = "每次视频额外奖励" + data.videoAmountPerTime + "元"; this.txtBigTask.string = "金额已达标,完成观看视频任务可到账" + "\n观看视频次数:" + data.taskVideoWatchTime + "/" + data.taskVideoTime + ",连续观看天数:" + data.taskVideoWatchDay + "/" + data.taskVideoDay + "" this.txtRemaindAdNum.string = "今日剩余次数:" + data.videoTime + ""; this.adIcon.active = data.needToWatchTheVideo == 1; if (isPlayAni) { if (this.lastNum < data.cumulativeAmount) { EffectNode.instance.PlayCoinAnim(1, 10, this.btnAd.getPosition(), true, this.btnCash.getPosition(), () => { this.aniBigAdBtn.setCurrentTime(0); this.aniBigAdBtn.play(); }); this.txtAddEft.node.setPosition(cc.v2(0, 380)); this.txtAddEft.string = "+" + data.videoAmountPerTime + "元"; this.txtAddEft.node.stopAllActions(); this.txtAddEft.node.scale = 0; this.txtAddEft.node.opacity = 255; this.txtAddEft.node.active = true; let a0 = cc.delayTime(0.8); let a1t = cc.sequence(cc.scaleTo(0.15, 1.2), cc.scaleTo(0.15, 1)); let a1a = cc.spawn(cc.moveBy(0.3, cc.v2(0, 30)), a1t); let a2 = cc.delayTime(0.5); let a3 = cc.fadeOut(0.15); let a4 = cc.callFunc(() => { //this.txtBigNum.string = data.cumulativeAmount + "元"; this.PlayMoneyAni(0.2); this.txtAddEft.node.active = false; }); this.txtAddEft.node.runAction(cc.sequence(a0, a1a, a2, a3, a4)); } else { this.txtBigNum.string = data.cumulativeAmount.toFixed(2) + "元"; this.lastNum = data.cumulativeAmount; } } else { this.txtBigNum.string = data.cumulativeAmount.toFixed(2) + "元"; this.lastNum = data.cumulativeAmount; } let isFourProFinish = true; if (this.adrbArray.length < 4) { this.adrbArray = []; this.itemContent.removeAllChildren(); for (let i = 0; i < data.redMonies.length; i++) { let copyitem = cc.instantiate(this.adRbItem.node); copyitem.active = true; this.itemContent.addChild(copyitem); let copySrc = copyitem.getComponent(AdRbItem); copySrc.Init(data.redMonies[i], isPlayAni, isPlayInitAni); this.adrbArray.push(copySrc); if (data.redMonies[i].progressRate < 100) isFourProFinish = false; } } else { for (let i = 0; i < data.redMonies.length; i++) { this.adrbArray[i].Init(data.redMonies[i], isPlayAni, isPlayInitAni); if (data.redMonies[i].progressRate < 100) isFourProFinish = false; } } //29 引导大额任务 if (isFourProFinish) { GuideMng.Ins.CheckAdRbGuide29(); } } private isPlayAni = false; targetProgress: number = 0; delta: number = 0; curValue: number = 0; curTime: number = 0; totalTime: number = 0; lastNum: number = 0; PlayMoneyAni(time) { this.totalTime = time; this.delta = (this.targetProgress - this.lastNum) / time; this.curValue = this.lastNum; this.curTime = 0; console.log("--->Update Time: " + time + " delta: " + this.delta + " curValue: " + this.curValue + " lastNum: " + this.lastNum); this.isPlayAni = true; } PlayMoneyAniUpdate(dt) { if (this.isPlayAni) { if (this.curTime < this.totalTime) { this.curTime += dt; this.curValue += this.delta * dt; if (this.curValue >= this.targetProgress) { this.isPlayAni = false; this.curValue = this.targetProgress; this.lastNum = this.targetProgress; } console.log("-->CurValue:" + this.curValue); } else { this.isPlayAni = false; this.curTime = this.totalTime; //this.unschedule(this.UpdateAni); this.curValue = this.targetProgress; this.lastNum = this.targetProgress; } this.txtBigNum.string = this.curValue.toFixed(2) + "元"; } } Click_AdProgressBtn() { if (TuCaoData.Ins.videoRbData.needToWatchTheVideo != 1) { //免费加进度 TuCaoData.Ins.HttpNoAdProgress((data) => { this.UpdateInfo(true); }); } else { if (TuCaoData.Ins.videoRbData.videoTime > 0) { GameM.adM.watchVideo(VIDEO_TYPE.adRbProgressAd); } else { EffectNode.instance.PlayTip("今日观看次数已用完"); } } GameM.audioM.playEffect(AUDIO_TYPE.button); console.log("--->You Click AdProgressBtn"); } /**看视频拿红包 增加提现进度回调*/ AdProgressEnd() { //EffectNode.instance.PlayTip("进度增加成功"); } /** * 打开红包页面 * @param type 打开红包类型 1 大额红包 2 任务红包 * @param num 红包金额 */ OpenRbPanel(type: number, num: number) { this.rbPanelType = type; this.txtRbNum.string = num + "元"; this.nodeRb.active = true; this.rbOpenBtn.active = true; } CheckCashRedCode() { let data = TuCaoData.Ins.videoRbData; if (data.redMoneyCode.length > 0) { for (let i = 0; i < data.redMoneyCode.length; i++) { if (data.preLargeAmountCashId == data.redMoneyCode[i].RedMoneyId) { if (data.redMoneyCode[i].RedMoneyCode != "") { UIMng.Ins.AsyncGetPanel(PanelType.RedCodePanel, (panel) => { let num = TuCaoData.Ins.videoRbData.redMoneyCode.length; panel.OnEnter({ money: data.redMoneyCode[i].VideoCashBig, code: data.redMoneyCode[i].RedMoneyCode }); }); } else { EffectNode.instance.PlayTip("提现成功"); } return; } } } EffectNode.instance.PlayTip("请先完成提现任务"); } Click_CashBtn() { console.log("--->You Click CashBtn"); if (TuCaoData.Ins.videoRbData.cumulativeAmount >= TuCaoData.Ins.videoRbData.requestAmount) { TuCaoData.Ins.HttpCashBig((data) => { console.log("-->BigRbData:" + JSON.stringify(data)); this.UpdateInfo(); //this.nodeRb.active = false; if (data.code == 1) { //弹红包码界面 this.CheckCashRedCode(); } else { EffectNode.instance.PlayTip("请先完成提现任务"); } }) } else { EffectNode.instance.PlayTip("累计到" + TuCaoData.Ins.videoRbData.requestAmount + "元才可提现"); } //if (TuCaoData.Ins.videoRbData.canCash == 1) { // TuCaoData.Ins.bigRbNum = TuCaoData.Ins.videoRbData.requestAmount; // //如果提现条件满足弹出红包界面 // this.OpenRbPanel(1, TuCaoData.Ins.videoRbData.requestAmount); //} else { // EffectNode.instance.PlayTip("累计到"+TuCaoData.Ins.videoRbData.requestAmount+"元才可提现"); //} } canOpen: boolean = true; /**红包界面开按钮*/ Click_CashOpenBtn() { if (!this.canOpen) return; this.canOpen = false; if (this.rbPanelType == 1) { //走不到这 改用Click_CashBtn TuCaoData.Ins.HttpCashBig((data) => { console.log("-->BigRbData:" + JSON.stringify(data)); this.UpdateInfo(); this.nodeRb.active = false; UIMng.Ins.AsyncGetPanel(PanelType.CashProPanel, (panel) => { panel.OnEnter(TuCaoData.Ins.bigRbNum); }); }) } else { //弹确认提现界面 this.rbOpenBtn.active = false; this.aniBtnAd.node.active = true; this.aniBtnAd.setCurrentTime(0); this.aniBtnAd.play(); setTimeout(() => { //this.aniBtnAd.node.active = false; this.aniBtnAd.stop(); this.aniBtnAd.node.active = false; this.rbOpenBtn.active = true; //this.aniBtnAd.enabled = false; this.nodeRb.active = false; this.cashSureTxtNum.string = "¥" + TuCaoData.Ins.taskRbNum; this.cashSurePanel.active = true; this.canOpen = true; }, 1000); } } //提现确认界面 任务红包提现 Click_CashSureBtn() { //this.cashSurePanel.active = false; //return; TuCaoData.Ins.HttpCashTask((data) => { console.log("-->TaskRbData:" + JSON.stringify(data)); this.UpdateInfo(); this.nodeRb.active = false; this.cashSurePanel.active = false; if (data.code == 1) { UIMng.Ins.AsyncGetPanel(PanelType.CashProPanel, (panel) => { panel.OnEnter(TuCaoData.Ins.taskRbNum); }); } }) } Click_RedCodeBtn() { UIMng.Ins.AsyncGetPanel(PanelType.RedCodeListPanel, (panel) => { panel.OnEnter(60); }); } Click_HelpBtn() { this.nodeHelp.active = true; GameM.audioM.playEffect(AUDIO_TYPE.button); } Click_CloseHelpBtn() { this.nodeHelp.active = false; GameM.audioM.playEffect(AUDIO_TYPE.button); } Click_InitData() { TuCaoData.Ins.HttpInitAdRbData(); } Click_CloseBtn() { this.OnExit(); GameM.audioM.playEffect(AUDIO_TYPE.button); } EditBox_End() { console.log("-->Input:", this.inputBox.string); TuCaoData.Ins.adsource_id_value = this.inputBox.string; } }