RedPackeItemView.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-20 18:39:37
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-15 18:51:35
  6. * @Description: 红包列表item
  7. */
  8. import { _decorator, Label, Node, ProgressBar, Sprite } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
  11. import { smc } from '../common/SingletonModuleComp';
  12. import { TableLevelConfig } from '../common/table/TableLevelConfig';
  13. import { ServerHandler } from '../common/manager/ServerHandler';
  14. const { ccclass, property } = _decorator;
  15. /** 显示对象控制 */
  16. @ccclass('RedPackeItemView')
  17. export class RedPackeItemView extends GameComponent {
  18. @property(Node)
  19. private receiveNode: Node = null!;
  20. @property(Node)
  21. private receivedNode: Node = null!;
  22. @property(Node)
  23. private unReceiveNode: Node = null!;
  24. @property(Label)
  25. private lab_title: Label = null!;
  26. @property(Label)
  27. private lab_progress: Label = null!;
  28. @property(ProgressBar)
  29. private pro_progress: ProgressBar = null!;
  30. private sp_icon: Sprite = null!;
  31. @property(Label)
  32. private lab_num: Label = null!;
  33. data: any = {
  34. id: 0,
  35. title_num: 0,
  36. cur_num: 0,
  37. total_num: 0,
  38. status: 0,
  39. reward: [],
  40. level: 0
  41. }
  42. protected start() {
  43. }
  44. setItem(data: any, idx: number) {
  45. this.data.id = data.id;
  46. this.data.level = data.level;
  47. this.data.title_num = data.target;
  48. this.data.cur_num = smc.account.AccountModel.xcCount;
  49. this.data.total_num = data.target;
  50. this.data.status = data.status;
  51. this.data.reward = data.reward;
  52. this.updateData();
  53. }
  54. //更新数据
  55. private updateData() {
  56. this.unReceiveNode.active = this.data.status == 0;
  57. this.receiveNode.active = this.data.status == 1;
  58. this.receivedNode.active = this.data.status == 2;
  59. this.lab_title.string = this.data.title_num + "次";
  60. this.lab_num.string = this.data.reward[0].propNum + "元";
  61. this.lab_progress.string = `${this.data.cur_num}/${this.data.total_num}`;
  62. const loadNum = this.data.cur_num / this.data.total_num > 1 ? 1 : this.data.cur_num / this.data.total_num;
  63. this.pro_progress.progress = loadNum;
  64. }
  65. //进行中按钮
  66. private btn_none() {
  67. oops.gui.toast("完成任务即可领取红包~");
  68. }
  69. //可领取按钮
  70. private btn_receive() {
  71. //发送领取红包请求
  72. if (this.data.status == 1) {
  73. console.log("发送领取红包请求");
  74. ServerHandler.inst.getDailyReward(this.data.level);
  75. }
  76. }
  77. }