RedPackeItemView.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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-11 14:06:25
  6. * @Description: 红包列表item
  7. */
  8. import { _decorator, Label, Node, ProgressBar, Sprite } from 'cc';
  9. import { oops } from 'db://oops-framework/core/Oops';
  10. import VMParent from 'db://oops-framework/libs/model-view/VMParent';
  11. const { ccclass, property } = _decorator;
  12. /** 显示对象控制 */
  13. @ccclass('RedPackeItemView')
  14. export class RedPackeItemView extends VMParent {
  15. @property(Node)
  16. private receiveNode: Node = null!;
  17. @property(Node)
  18. private unReceiveNode: Node = null!;
  19. private lab_title: Label = null!;
  20. private lab_progress: Label = null!;
  21. private pro_progress: ProgressBar = null!;
  22. private sp_icon: Sprite = null!;
  23. private lab_num: Label = null!;
  24. data: any = {
  25. title: "完成任务即可领取红包~",
  26. current: 10,
  27. total: 100,
  28. state: 1,
  29. goods: [
  30. {
  31. type: 1001,
  32. num: 100
  33. }
  34. ]
  35. }
  36. protected start() {
  37. this.setButton();
  38. this.initComponent();
  39. }
  40. private initComponent() {
  41. this.lab_title = this.node.getChildByPath("Bg/lab_title")?.uiLabel!;
  42. this.lab_progress = this.node.getChildByPath("Bg/lab_progress")?.uiLabel!;
  43. this.pro_progress = this.node.getChildByPath("Bg/pro_progress")?.uiProgressBar!;
  44. this.sp_icon = this.node.getChildByPath("Bg/sp_icon")?.uiSprite!;
  45. this.lab_num = this.node.getChildByPath("Bg/lab_num")?.uiLabel!;
  46. }
  47. setItem(data: any, idx: number) {
  48. console.log("setData>>>>>>>>>>>>>", data);
  49. this.data = data;
  50. this.updateData();
  51. }
  52. //更新数据
  53. private updateData() {
  54. console.log("updateData", this.data);
  55. if (this.data.state == 0) {
  56. this.receiveNode.active = false;
  57. this.unReceiveNode.active = true;
  58. } else if (this.data.state == 1) {
  59. this.receiveNode.active = true;
  60. this.unReceiveNode.active = false;
  61. }
  62. // this.lab_title.string = this.data.title;
  63. // this.lab_progress.string = `${this.data.current}/${this.data.total}`;
  64. // this.pro_progress.progress = this.data.current / this.data.total;
  65. // // this.sp_icon.spriteFrame = oops.res.getSpriteFrame(this.data.goods[0].type);
  66. // this.lab_num.string = this.data.goods[0].num;
  67. }
  68. //进行中按钮
  69. private btn_none() {
  70. oops.gui.toast("完成任务即可领取红包~");
  71. }
  72. //可领取按钮
  73. private btn_receive() {
  74. oops.gui.toast("领取红包~");
  75. //发送领取红包请求
  76. }
  77. }