/** 红包码界面 */ import { HTTP_TYPE, RecordTYPE } from "../datas/CommonData"; import { TuCaoData } from "../datas/TuCaoData"; import GameM, { AUDIO_TYPE } from "../manager/GameM"; import UiM, { PANEL_NAME } from "../manager/UiM"; import RedCodeItem from "../prefabs/RedCodeItem"; import LogUtil from "../utils/LogUtil"; import { Utils } from "../utils/Utils"; import CashOut from "./CashOut"; const { ccclass, property } = cc._decorator; @ccclass export default class RedCodeNode extends cc.Component { @property(cc.Node) content: cc.Node = null; @property(cc.Node) labEmpty: cc.Node = null; @property(cc.Node) parNode: cc.Node = null; cashType = 0 itemP = null async onLoad() { this.itemP = await Utils.loadResPromise('prefabs/RedCodeItem') } /** 初始化 * @param cashType 1、常规提现 2、每日提现 3、夺宝提现 4、富翁提现 50、裂变提现 60、看视频领红包提现*/ init(cashType) { this.cashType = cashType this.content.removeAllChildren() if (this.cashType == 50) { GameM.ClubData.requestClubWithDrawRecords() } else if (this.cashType == 60) { this.freshRecord(); } else { GameM.httpM.sendDatas(HTTP_TYPE.getCashRecord, null, GameM.commonData.resultCashRecord.bind(GameM.commonData)) } } freshRecord() { let arr = [] if (this.cashType == 50) { arr = GameM.ClubData.getRedCodeByClubCashType() } else if (this.cashType == 60) { arr = TuCaoData.Ins.videoRbData.redMoneyCode; } else { arr = GameM.commonData.getRedCodeByCashType(this.cashType) } for (var i = 0; i < arr.length; i++) { let item: cc.Node = cc.instantiate(this.itemP) let s = item.getComponent(RedCodeItem) let data = arr[i] if (this.cashType == 50) { let createTime: string = data.createTime LogUtil.logV(" createTime", createTime) let spliteStr = createTime.split(" ") s.init((data.amount * 0.0001).toFixed(2), spliteStr[0], data.withdrawCode, this.cashType) } else if (this.cashType == 60) { s.init(data.VideoCashBig, data.applyTime, data.RedMoneyCode); } else { s.init((data.amount * 0.01).toFixed(2), data.applyTime, data.withdrawalCode) } this.content.addChild(item) } if (arr.length <= 0) { this.labEmpty.active = true } else { this.labEmpty.active = false } } clickClose() { GameM.audioM.playEffect(AUDIO_TYPE.button) if (this.cashType == 1) { this.hideEff() } else { UiM.Instance.offPanel(PANEL_NAME.RedCodeNode) } } hideEff() { let pos = UiM.Instance.cashNode.getComponent(CashOut).labRedCode.position let addy = (cc.winSize.height - 1334) / 2 pos.y += addy cc.tween(this.parNode).to(0.2, { scale: 0, position: pos }).call(() => { UiM.Instance.offPanel(PANEL_NAME.RedCodeNode) }).start(); } }