/** 常规提现界面 */ import GameM, { AUDIO_TYPE, VIDEO_TYPE } from "../manager/GameM"; import CashItem from "../prefabs/CashItem"; import EffectNode from "./EffectNode"; import UiM, { PANEL_NAME } from "../manager/UiM"; import { HTTP_TYPE } from "../datas/CommonData"; import Main from "../Main"; import AdM from "../manager/AdM"; import RedCodeNode from "./RedCodeNode"; import CashRecordNode from "./CashRecordNode"; import CashOutData from "../datas/CashOutData"; import GuideMng from "../manager/GuideMng"; import { PlayerPrefs } from "../tools/MyExtends"; import LogUtil from "../utils/LogUtil"; import { FightData } from "../datas/FightData"; import { GameController } from "../manager/GameController"; import { Utils } from "../utils/Utils"; const { ccclass, property } = cc._decorator; @ccclass export default class CashOut extends cc.Component { @property(cc.Label) labRedMoney: cc.Label = null; @property(cc.Node) contentBg: cc.Node = null; @property(cc.Node) content: cc.Node = null; @property(cc.Node) cashMain: cc.Node = null; @property(cc.Label) labShowMoney: cc.Label = null; @property(cc.Node) cashPro: cc.Node = null; @property(cc.Label) labMoney: cc.Label = null; @property(cc.Label) labTime: cc.Label = null; @property(cc.Node) loadPart: cc.Node = null; @property(cc.Animation) loadAni: cc.Animation = null; @property(cc.Node) tip: cc.Node = null; @property(cc.Node) hand: cc.Node = null; //授权部分 @property(cc.Node) authPart: cc.Node = null; @property(cc.Node) authBg: cc.Node = null; @property(cc.Toggle) toggle: cc.Toggle = null; @property(cc.Node) btnGoAuth: cc.Node = null; @property(cc.Node) guide2: cc.Node = null; @property(cc.Node) labRedCode: cc.Node = null @property(cc.Node) redCodePart: cc.Node = null //------红包动画部分 @property(cc.Node) moneyBg: cc.Node = null; @property(cc.Node) frontNode: cc.Node = null; @property(cc.Animation) openAni: cc.Animation = null; @property(cc.Node) hongbaoTop: cc.Node = null; @property(cc.Node) hongbaoDown: cc.Node = null; @property(cc.Node) btnRedClose: cc.Node = null; @property(cc.Label) labShowRed: cc.Label = null; @property(cc.Node) moneyPart: cc.Node = null; @property(cc.Node) boxNode: cc.Node = null; @property(cc.Node) guideRect: cc.Node = null; curSelItem = null curData = null // <=0 时间上满足提现 isTimeFull: number = 0 videoNode = null addTotal = 0 addNum = 0 _n = 0 _dis = 2 cfg = null itemP = null //排序数组 rankArr = [] onLoad() { this.cashMain.height = cc.winSize.height this.cashPro.height = cc.winSize.height this.node.height = cc.winSize.height let addY = cc.winSize.height - 1334 this.content.parent.height += addY this.content.parent.parent.height += addY this.contentBg.height += addY } async onEnable() { this.itemP = await Utils.loadResPromise('prefabs/CashItem') this.hasTap = false this.curData = null this.checkEnable(true) this.hand.active = false this.guideRect.active = GuideMng.Ins.CurGuideId == 14; } showGuide() { //西游 //引导 this.guideRect.active = GuideMng.Ins.CurGuideId == 14; console.log('GuideMng.Ins.CurGuideId ', GuideMng.Ins.CurGuideId) if (GuideMng.Ins.CurGuideId == 14) { this.scheduleOnce(() => { console.log('GuideMng.Ins.CurGuideId >>> ', GuideMng.Ins.CurGuideId) GuideMng.Ins.ResumeGuide(); }, 0.6); } } onDisable() { //西游 GameM.audioM.setTempEffect(true) GameController.Ins.SwitchAudio(1); //GameM.audioM.setResumeMusic() } start() { let y = this.boxNode.y let x = this.boxNode.x let delayTime = Math.random() this.scheduleOnce(() => { this.boxNode.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5, cc.v2(x, y - 5)), cc.moveTo(1.2, cc.v2(x, y + 5))))) }, delayTime) } /** 授权返回刷新 */ authBack() { this.authPart.active = false } checkEnable(first = false) { this.cfg = null if (first) { this.content.removeAllChildren() this.cfg = CashOutData.Instance.cashCft let hasCashArr = [] for (var i = 0; i < this.cfg.length; i++) { let obj = CashOutData.Instance.getCashStatusByIndex(this.cfg[i].index) if (obj && obj.status == 1) { hasCashArr.push(this.cfg[i]) } else { this.rankArr.push(this.cfg[i]) } } this.rankArr = this.rankArr.concat(hasCashArr) this.addNum = 0 this.addTotal = this.cfg.length } else { this.cfg = CashOutData.Instance.cashCft for (var i = 0; i < this.cfg.length; i++) { let item = this.content.getChildByName(this.cfg[i].index.toString()) if (cc.isValid(item)) { let s = item.getComponent(CashItem) let hasGet = false let redCode = '' let amount = 0 let obj = CashOutData.Instance.getCashStatusByIndex(this.cfg[i].index) if (this.cfg[i].num == 1 && obj && obj.status == 1) { hasGet = true amount = obj.amount if (obj.withdrawalCode) { redCode = obj.withdrawalCode } } s.init(this.cfg[i], hasGet, redCode, amount) } } } let realMoney = GameM.commonData.redMoney / 10000 this.labRedMoney.string = `${Math.round(GameM.commonData.redMoney)} ≈ ${realMoney}元` } setRedCode(index, withdrawalCode) { let item = this.content.getChildByName(index.toString()) let s = item.getComponent(CashItem) s.setRedCode(withdrawalCode) } update() { if (!this.cfg) { return } if (this.addNum < this.addTotal) { if (this._n <= this._dis) { this._n++ } else { this._n = 0 let item: cc.Node = cc.instantiate(this.itemP) let s = item.getComponent(CashItem) let hasGet = false let redCode = '' let amount = 0 let curCfg = this.rankArr[this.addNum] let obj = CashOutData.Instance.getCashStatusByIndex(curCfg.index) item.name = curCfg.index.toString() if (curCfg.num == 1 && obj && obj.status == 1) { hasGet = true amount = obj.amount if (obj.withdrawalCode) { redCode = obj.withdrawalCode } } s.init(curCfg, hasGet, redCode, amount) this.content.addChild(item) this.addNum++ //if (this.addNum == this.addTotal) { //if (this.addNum == 2) { // //西游 // //引导 // this.scheduleOnce(() => { // GuideMng.Ins.CheckCashGuide10(); // }, 0.6); // //if(PlayerPrefs.GetInt("GGuide10", 0)!=1){ // // GuideMng.Ins.ResumeGuide(); // //} //} } } } clickOpenRecord() { GameM.audioM.playEffect(AUDIO_TYPE.button) UiM.Instance.onPanel(PANEL_NAME.CashRecordNode, true, () => { if (cc.isValid(UiM.Instance.cashRecordNode)) { UiM.Instance.cashRecordNode.getComponent(CashRecordNode).initType() } }) } clickClose() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (GameM.commonData.richbank_noSave > 0) { UiM.Instance.hallNode.getComponent(Main).BankQipaoTip.creatPacketAnim(1) GameM.commonData.richbank_noSave = 0 } UiM.Instance.offPanel(PANEL_NAME.CashNode, true, () => { AdM.createInter(16); }) UiM.Instance.offPanel(PANEL_NAME.SettingNode, false) if (PlayerPrefs.GetInt("GGuide14") == 1) { GuideMng.Ins.CheckDailyGuide16(); } } clickHelp() { // //test // this.checkEnable() // return GameM.audioM.playEffect(AUDIO_TYPE.button) this.redCodePart.active = true } clickCloseHelp() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.redCodePart.active = false } onTixian(cfg) { //提现 this.curData = cfg this.showRed() GameM.commonData.getCashMoney(this.curData.index) } clickCloseTixian() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.moneyPart.active = false this.moneyBg.active = false this.frontNode.active = false } clickTixian() { GameM.audioM.playEffect(AUDIO_TYPE.button) //提现 GameM.httpM.sendDatas(HTTP_TYPE.cash, { 'index': this.curData.index }, CashOutData.Instance.resultCash.bind(CashOutData.Instance), CashOutData.Instance.resultCashFail.bind(CashOutData.Instance)) this.loadPart.active = true this.loadAni.play('load', 0) } tiXianSuccess(showPro, tmoney) { this.scheduleOnce(() => { this.loadPart.active = false this.showCashPro(showPro, tmoney) }, 1.5) this.scheduleOnce(() => { this.checkEnable() }, 2) if (!showPro) { this.moneyPart.active = false this.moneyBg.active = false this.frontNode.active = false } } tixianFail() { this.scheduleOnce(() => { this.loadPart.active = false }, 1.5) } showCashPro(showPro, tmoney) { CashOutData.Instance.canCashIndex = -1 UiM.Instance.hallNode.getComponent(Main).hideCashHand() this.labMoney.string = `¥${tmoney.toFixed(2)}` if (showPro) { UiM.Instance.openPanel(this.cashPro) } } clickCloseCashPro() { GameM.audioM.playEffect(AUDIO_TYPE.button) GameM.commonData.backShowDaily = true UiM.Instance.closePanelM() this.moneyPart.active = false this.moneyBg.active = false this.frontNode.active = false //注释裂变弹窗 // UiM.Instance.onPanel(PANEL_NAME.clubGuideNode) } showAuth() { this.authPart.active = true this.authBg.position.y = -880 cc.tween(this.authBg).to(0.3, { y: -457 }).start() this.guide2.active = true } clickBackBg() { cc.tween(this.authBg).to(0.3, { y: -880 }).call(() => { this.authPart.active = false }).start() this.guide2.active = false } clickToggle() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.toggle.isChecked) { this.btnGoAuth.getChildByName('No').active = false this.btnGoAuth.getChildByName('Yes').active = true } else { this.btnGoAuth.getChildByName('No').active = true this.btnGoAuth.getChildByName('Yes').active = false } } private hasTap = false clickGoAuth() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.toggle.isChecked) { if (!this.hasTap) { console.log('clickGoAuth') this.hasTap = true AdM.WxLogin() } } else { EffectNode.instance.PlayTip('请选择提现方式') } } clickRedCode() { GameM.audioM.playEffect(AUDIO_TYPE.button) UiM.Instance.onPanel(PANEL_NAME.RedCodeNode, false, () => { UiM.Instance.redCodeNode.getComponent(RedCodeNode).init(1) }) } /** 点击复制公众号 */ clickCopyOfficial() { GameM.audioM.playEffect(AUDIO_TYPE.button) AdM.setClipboard("白羊游戏社") } coolTime = false /** 点击教程 */ async clickTeach() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.coolTime) { return } this.coolTime = true GameM.commonData.teachVideoType = 1; console.log('clickTeach') let temp = await Utils.loadResPromise('prefabs/VideoNode') this.videoNode = cc.instantiate(temp) this.videoNode.getChildByName('video').on("completed", this.onCompleted, this) this.node.addChild(this.videoNode) } onCompleted() { this.videoNode.getChildByName('video').off("completed", this.onCompleted, this) this.videoNode.destroy() //西游 GameM.audioM.setTempEffect(true) GameController.Ins.SwitchAudio(1) //GameM.audioM.setResumeMusic() this.coolTime = false } /** 开红包动画 */ showRed() { this.moneyBg.active = true this.frontNode.active = true this.moneyPart.active = false this.hongbaoTop.setScale(0.78, 0.78) this.hongbaoDown.setScale(0.78, 0.78) this.hongbaoTop.setPosition(0, -293.5) this.hongbaoDown.setPosition(0, -178.1) this.labShowRed.string = `${this.curData.moneyshow}` this.openAni.currentClip = null cc.loader.loadRes('gift/tongbi', cc.SpriteFrame, (err, assets) => { if (err) { cc.error(err); return; } this.openAni.node.getComponent(cc.Sprite).spriteFrame = assets; }) this.openAni.node.active = true } clickCloseRed() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.moneyBg.active = false this.frontNode.active = false this.moneyPart.active = false } clickOpenRed() { GameM.audioM.playEffect(AUDIO_TYPE.button) this.openAni.play('openAni', 0) this.scheduleOnce(this.schedueOpen, 0.9) } schedueOpen() { this.openAni.stop() this.openAni.node.active = false let toy = 473 + (cc.winSize.height - 1334) * 0.5 cc.tween(this.hongbaoTop).to(0.3, { scale: 1, position: cc.v2(0, toy) }).start() cc.tween(this.hongbaoDown).to(0.3, { scale: 1, position: cc.v2(0, -1000) }).start() this.scheduleOnce(() => { this.moneyPart.active = true }, 0.1) this.btnRedClose.active = true } Click_GuideRect() { this.guideRect.active = false; } /**战斗按钮*/ Click_FightBtn() { AdM.onSendEvent('button_2', '降妖伏魔icon', 'button') GameM.audioM.playEffect(AUDIO_TYPE.button); this.hand.active = false FightData.Ins.EnterFight(); } /** 显示小手 */ showHand() { //注释 // this.hand.active = true; } }