import { DataEventId, GameProp, RewardState } from "../../data/GameData"; import { CDataType } from "../../data/module/RedBagCashData"; const { ccclass, property } = cc._decorator; /** * 常规提现条目 * @author 薛鸿潇 */ @ccclass export default class RedBagCashItem extends cc.Component { @property({ displayName: '已领取', type: cc.Node }) node_none: cc.Node = null; @property({ displayName: '未达成', type: cc.Node }) node_lock: cc.Node = null; @property({ displayName: '可领取', type: cc.Node }) node_unlock: cc.Node = null; @property({ displayName: '红包数量', type: cc.Label }) lbl_red_value: cc.Label = null; @property({ displayName: '毛币数量', type: cc.Label }) lbl_rmb_value: cc.Label = null; /** 条目数据 */ private item_data: CDataType = null; onLoad() { } start() { } /** * 初始化数据 */ public async setItemData(item_data) { // if (this.item_data == null && item_data.index == 1) { // mk.event.register("event_guide", this.clickGuide.bind, this); // } await this.initStyle(item_data); } private clickGuide(data: string) { if (data == "2_2") { this.clickCashOP(); } } /** * 初始化样式 * @param item_data 条目数据 */ private initStyle(item_data) { this.item_data = item_data; this.lbl_red_value.string = `${this.item_data.type_value}`; let rmb_value = this.item_data.money / 100; rmb_value = rmb_value > 1 ? rmb_value : parseFloat(rmb_value.toFixed(2)) this.lbl_rmb_value.string = rmb_value + '元'; if (this.item_data.state === RewardState.none) { // 已提现 this.node_none.active = true; this.node_lock.active = false; this.node_unlock.active = false; } else if (this.item_data.state === RewardState.lock) { // 未达成 this.node_none.active = false; this.node_lock.active = true; this.node_unlock.active = false; } else if (this.item_data.state === RewardState.unlock) { // 已解锁 this.node_none.active = false; this.node_lock.active = false; this.node_unlock.active = true; } } /** * 提现操作 */ private clickCashOP() { // if (!gData.redBagCash.cash_enable) return; if (this.item_data.index > gData.redBagCash.cash_bar + 1) { mk.tip.pop('请按顺序提现'); return; } gData.redBagCash.cashOP(); } onDestroy() { mk.event.remove("event_guide", this.clickGuide, this); } }