| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- 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 ? "提现中..." : "<b>满<color=#FFE00C>" + data.requestAmount + "元</color>可提现</b>";
- //this.txtBigNum.string = data.cumulativeAmount + "元";
- this.txtBigDelta.string = "<outline color=#8C1010 width=4><b>每次视频额外奖励<color=#FFE00C>" + data.videoAmountPerTime + "元</color></b></outline>";
- this.txtBigTask.string = "<outline color=#8C1010 width=4>金额已达标,完成<color=#4EB7FF>观看视频</color>任务可到账"
- + "\n观看视频次数:<color=#FFE00C>" + data.taskVideoWatchTime + "/" + data.taskVideoTime + "</color>,连续观看天数:<color=#FFE00C>" + data.taskVideoWatchDay + "/" + data.taskVideoDay + "</color></outline>"
- this.txtRemaindAdNum.string = "<b>今日剩余次数:<color=#B02D29>" + data.videoTime + "</color></b>";
- 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;
- }
- }
|