| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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_rmb_value: cc.Label = null;
- @property({ displayName: '通关条件', type: cc.Label })
- lbl_pass: 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;
- 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 + '元';
- this.lbl_pass.string = `通关第${this.item_data.levelNum}关`;
- 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.nextCondition) {
- // 未达成条件二
- this.node_none.active = false;
- this.node_lock.active = true;
- this.node_unlock.active = false;
- this.lbl_pass.string = `连续登录10天且每日通关数>100`;
- } 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 (this.node_none.active) 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);
- }
- }
|