RedPackeItemView.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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-29 16:28:24
  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. import { DCHandler } from '../common/manager/DCHandler';
  15. const { ccclass, property } = _decorator;
  16. /** 显示对象控制 */
  17. @ccclass('RedPackeItemView')
  18. export class RedPackeItemView extends GameComponent {
  19. @property(Node)
  20. private receiveNode: Node = null!;
  21. @property(Node)
  22. private receivedNode: Node = null!;
  23. @property(Node)
  24. private unReceiveNode: Node = null!;
  25. @property(Label)
  26. private lab_title: Label = null!;
  27. @property(Label)
  28. private lab_progress: Label = null!;
  29. @property(ProgressBar)
  30. private pro_progress: ProgressBar = null!;
  31. private sp_icon: Sprite = null!;
  32. @property(Label)
  33. private lab_num: Label = null!;
  34. data: any = {
  35. id: 0,
  36. title_num: 0,
  37. cur_num: 0,
  38. total_num: 0,
  39. status: 0,
  40. reward: [],
  41. level: 0
  42. }
  43. protected start() {
  44. this.setButton();
  45. }
  46. setItem(data: any, idx: number) {
  47. this.data.id = data.id;
  48. this.data.level = data.level;
  49. this.data.title_num = data.target;
  50. this.data.cur_num = smc.account.AccountModel.xcCount;
  51. this.data.total_num = data.target;
  52. this.data.status = data.status;
  53. this.data.reward = data.reward;
  54. this.updateData();
  55. }
  56. //更新数据
  57. private updateData() {
  58. this.unReceiveNode.active = this.data.status == 0;
  59. this.receiveNode.active = this.data.status == 1;
  60. this.receivedNode.active = this.data.status == 2;
  61. this.lab_title.string = this.data.title_num + "次";
  62. this.lab_num.string = this.data.reward[0].propNum + "元";
  63. this.lab_progress.string = `${this.data.cur_num}/${this.data.total_num}`;
  64. const loadNum = this.data.cur_num / this.data.total_num > 1 ? 1 : this.data.cur_num / this.data.total_num;
  65. this.pro_progress.progress = loadNum;
  66. }
  67. //进行中按钮
  68. private btn_none() {
  69. oops.gui.toast("完成任务即可领取红包~");
  70. }
  71. //可领取按钮
  72. private btn_receive() {
  73. //发送领取红包请求
  74. if (this.data.status == 1) {
  75. console.log("发送领取红包请求");
  76. ServerHandler.inst.getDailyReward(this.data.level);
  77. DCHandler.inst.reportData(3000902, this.data.level);
  78. }
  79. }
  80. }