RedBagCashItem.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { CDataType } from "../../data/module/RedBagCashData";
  2. const { ccclass, property } = cc._decorator;
  3. /**
  4. * 常规提现条目
  5. * @author 薛鸿潇
  6. */
  7. @ccclass
  8. export default class RedBagCashItem extends cc.Component {
  9. @property({ displayName: '已领取', type: cc.Node })
  10. node_none: cc.Node = null;
  11. @property({ displayName: '未达成', type: cc.Node })
  12. node_lock: cc.Node = null;
  13. @property({ displayName: '可领取', type: cc.Node })
  14. node_unlock: cc.Node = null;
  15. @property({ displayName: '红包数量', type: cc.Label })
  16. lbl_red_value: cc.Label = null;
  17. @property({ displayName: '毛币数量', type: cc.Label })
  18. lbl_rmb_value: cc.Label = null;
  19. /** 条目数据 */
  20. private item_data: CDataType = null;
  21. onLoad() {
  22. }
  23. start() {
  24. }
  25. /**
  26. * 初始化数据
  27. */
  28. public async setItemData(item_data) {
  29. await this.initStyle(item_data);
  30. }
  31. /**
  32. * 初始化样式
  33. * @param item_data 条目数据
  34. */
  35. private initStyle(item_data) {
  36. this.item_data = item_data;
  37. this.lbl_red_value.string = `${this.item_data.type_value}`;
  38. let rmb_value = this.item_data.money / 100;
  39. rmb_value = rmb_value > 1 ? rmb_value : parseFloat(rmb_value.toFixed(2))
  40. this.lbl_rmb_value.string = rmb_value + '元';
  41. if (this.item_data.index <= gData.redBagCash.cash_bar) {
  42. // 已提现
  43. this.node_none.active = true;
  44. this.node_lock.active = false;
  45. this.node_unlock.active = false;
  46. } else {
  47. // 可提现
  48. if (gData.gameData.gameData.redMoney >= this.item_data.type_value) {
  49. this.node_none.active = false;
  50. this.node_lock.active = false;
  51. this.node_unlock.active = true;
  52. } else {
  53. // 未达成
  54. this.node_none.active = false;
  55. this.node_lock.active = true;
  56. this.node_unlock.active = false;
  57. }
  58. }
  59. }
  60. /**
  61. * 提现操作
  62. */
  63. private clickCashOP() {
  64. // if (!gData.redBagCash.cash_enable) return;
  65. if (this.item_data.index > gData.redBagCash.cash_bar + 1) {
  66. mk.tip.pop('请按顺序提现');
  67. return;
  68. }
  69. gData.redBagCash.cashOP();
  70. cc.log('红包现成功')
  71. }
  72. }