WithdrawalRecordViewComp.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * @Author: mojunshou 1637302775@qq.com
  3. * @Date: 2025-03-21 10:17:49
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-15 16:58:21
  6. * @Description: 提现记录
  7. */
  8. import { _decorator, Label, Node } from "cc";
  9. import { oops } from "db://oops-framework/core/Oops";
  10. import { DeviceUtil } from "db://oops-framework/core/utils/DeviceUtil";
  11. import { ecs } from "db://oops-framework/libs/ecs/ECS";
  12. import { CCComp } from "db://oops-framework/module/common/CCComp";
  13. import { UIID } from "../common/config/GameUIConfig";
  14. import { smc } from "../common/SingletonModuleComp";
  15. import List from "../ui/List";
  16. const { ccclass, property } = _decorator;
  17. /** 视图层对象 */
  18. @ccclass('WithdrawalRecordViewComp')
  19. @ecs.register('WithdrawalRecordView', false)
  20. export class WithdrawalRecordViewComp extends CCComp {
  21. /** 视图层逻辑代码分离演示 */
  22. @property(List)
  23. recordList: List = null!;
  24. data: any[] = [];
  25. @property(Node)
  26. noRecord: Node = null!;
  27. @property(Node)
  28. content: Node = null!;
  29. start() {
  30. this.setButton();
  31. // const entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
  32. if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
  33. const count = smc.game.GameModel.recordList.length;
  34. this.noRecord.active = count <= 0;
  35. this.content.active = count > 0;
  36. if (count > 0) {
  37. this.data = smc.game.GameModel.recordList;
  38. this.recordList.numItems = this.data.length;
  39. }
  40. } else {
  41. const data = {
  42. amount: 0.01,
  43. payMethod: 1, //1支付宝 2微信
  44. createTime: "2025-04-09 18:09:09",
  45. successTime: "2025-04-09 18:09:09",
  46. status: oops.random.getRandomInt(0, 4)
  47. }
  48. for (let i = 0; i < 20; i++) {
  49. data.amount = i;
  50. this.data.push(data);
  51. }
  52. this.recordList.numItems = this.data.length;
  53. }
  54. }
  55. // 列表渲染器
  56. private onListRender(item: Node, idx: number) {
  57. // item.getComponentInChildren(Label)!.string = this.data[idx] + '';
  58. const data = this.data[idx];
  59. let str: string = ""
  60. switch (data.status) {
  61. case 1:
  62. str = "待审核"
  63. break;
  64. case 2:
  65. str = "提现成功"
  66. break
  67. case 3:
  68. str = "提现失败"
  69. break
  70. case 4:
  71. str = "已拒绝"
  72. break
  73. case 5:
  74. str = ""
  75. break
  76. }
  77. const stateLabel = item.getChildByName("lab_state")?.getComponent(Label);
  78. if (stateLabel) stateLabel.string = str;
  79. const timeLabel = item.getChildByName("lab_time")?.getComponent(Label);
  80. if (timeLabel) timeLabel.string = data.createTime;
  81. const moneyLabel = item.getChildByName("lab_money")?.getComponent(Label);
  82. if (moneyLabel) moneyLabel.string = data.amount + "元";
  83. //TS原生随机数0 或者1
  84. const statusNode1 = item.getChildByName("record_state1");
  85. if (statusNode1) statusNode1.active = data.status == 2;
  86. const statusNode2 = item.getChildByName("record_state2");
  87. if (statusNode2) statusNode2.active = data.status != 2;
  88. }
  89. private btn_back() {
  90. oops.gui.remove(UIID.WithdrawRecord)
  91. }
  92. /** 视图对象通过 ecs.Entity.remove(WithdrawalRecordViewComp) 删除组件是触发组件处理自定义释放逻辑 */
  93. reset() {
  94. this.node.destroy();
  95. }
  96. }