SignIconItem.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const { ccclass, property } = cc._decorator;
  2. /** 天数描边 */
  3. enum DayOutLineColor {
  4. /** 红包 */
  5. red_bag = '#EB3A0E' as any,
  6. /** 提现 */
  7. cash = '#2AB718' as any,
  8. }
  9. /**
  10. * 签到icon组件
  11. * @author 薛鸿潇
  12. */
  13. @ccclass
  14. export default class SignIconItem extends cc.Component {
  15. @property({ displayName: '提现样式', type: cc.Node })
  16. private node_cash: cc.Node = null!;
  17. @property({ displayName: '红包样式', type: cc.Node })
  18. private node_redbag: cc.Node = null!;
  19. @property({ displayName: '天数', type: cc.Label })
  20. private lbl_day: cc.Label = null!;
  21. /** 数据 */
  22. private icon_data = {
  23. id: 0,
  24. reward_type: 0,
  25. count: 0,
  26. login_day: 0,
  27. video_limit: 0,
  28. }
  29. // onLoad () {}
  30. // start() {
  31. // }
  32. /**
  33. * 初始化数据
  34. */
  35. public async setItemData(icon_data) {
  36. await this.initIcon(icon_data);
  37. }
  38. /**
  39. * 初始化icon
  40. * @param icon_data 数据
  41. */
  42. private initIcon(icon_data) {
  43. if (!icon_data) {
  44. this.node.active = false;
  45. return
  46. }
  47. this.lbl_day.string = '第' + icon_data.login_day + '天';
  48. if (icon_data.reward_type) {
  49. this.node_cash.active = true;
  50. this.node_redbag.active = false;
  51. this.lbl_day.node.getComponent(cc.LabelOutline).color = cc.color(DayOutLineColor.cash);
  52. } else {
  53. this.node_cash.active = false;
  54. this.node_redbag.active = true;
  55. this.lbl_day.node.getComponent(cc.LabelOutline).color = cc.color(DayOutLineColor.red_bag);
  56. }
  57. this.icon_data = icon_data;
  58. }
  59. /**
  60. * 领取奖励
  61. */
  62. private clickReceiveReward() {
  63. if (this.icon_data.reward_type) {
  64. } else {
  65. }
  66. }
  67. // update (dt) {}
  68. }