RedBagCashItem.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { DataEventId, GameProp, RewardState } from "../../data/GameData";
  2. import { CDataType } from "../../data/module/RedBagCashData";
  3. const { ccclass, property } = cc._decorator;
  4. /**
  5. * 常规提现条目
  6. * @author 薛鸿潇
  7. */
  8. @ccclass
  9. export default class RedBagCashItem extends cc.Component {
  10. @property({ displayName: '已领取', type: cc.Node })
  11. node_none: cc.Node = null;
  12. @property({ displayName: '未达成', type: cc.Node })
  13. node_lock: cc.Node = null;
  14. @property({ displayName: '可领取', type: cc.Node })
  15. node_unlock: cc.Node = null;
  16. @property({ displayName: '毛币数量', type: cc.Label })
  17. lbl_rmb_value: cc.Label = null;
  18. @property({ displayName: '通关条件', type: cc.Label })
  19. lbl_pass: cc.Label = null;
  20. /** 条目数据 */
  21. private item_data: CDataType = null;
  22. onLoad() {
  23. }
  24. start() {
  25. }
  26. /**
  27. * 初始化数据
  28. */
  29. public async setItemData(item_data) {
  30. // if (this.item_data == null && item_data.index == 1) {
  31. // mk.event.register("event_guide", this.clickGuide.bind, this);
  32. // }
  33. await this.initStyle(item_data);
  34. }
  35. private clickGuide(data: string) {
  36. if (data == "2_2") {
  37. this.clickCashOP();
  38. }
  39. }
  40. /**
  41. * 初始化样式
  42. * @param item_data 条目数据
  43. */
  44. private initStyle(item_data) {
  45. this.item_data = item_data;
  46. let rmb_value = this.item_data.money / 100;
  47. rmb_value = rmb_value > 1 ? rmb_value : parseFloat(rmb_value.toFixed(2))
  48. this.lbl_rmb_value.string = rmb_value + '元';
  49. this.lbl_pass.string = `通关第${this.item_data.levelNum}关`;
  50. if (this.item_data.state === RewardState.none) {
  51. // 已提现
  52. this.node_none.active = true;
  53. this.node_lock.active = false;
  54. this.node_unlock.active = false;
  55. } else if (this.item_data.state === RewardState.lock) {
  56. // 未达成
  57. this.node_none.active = false;
  58. this.node_lock.active = true;
  59. this.node_unlock.active = false;
  60. } else if (this.item_data.state === RewardState.nextCondition) {
  61. // 未达成条件二
  62. this.node_none.active = false;
  63. this.node_lock.active = true;
  64. this.node_unlock.active = false;
  65. this.lbl_pass.string = `连续登录10天且每日通关数>100`;
  66. } else if (this.item_data.state === RewardState.unlock) {
  67. // 已解锁
  68. this.node_none.active = false;
  69. this.node_lock.active = false;
  70. this.node_unlock.active = true;
  71. }
  72. }
  73. /**
  74. * 提现操作
  75. */
  76. private clickCashOP() {
  77. if (this.node_none.active) return;
  78. // if (this.item_data.index > gData.redBagCash.cash_bar + 1) {
  79. // mk.tip.pop('请按顺序提现');
  80. // return;
  81. // }
  82. gData.redBagCash.cashOP();
  83. }
  84. onDestroy() {
  85. mk.event.remove("event_guide", this.clickGuide, this);
  86. }
  87. }