WithdrawalList.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { _decorator, Component, Node, Prefab, instantiate, RichText } from 'cc';
  2. import { Http, HttpResponseCode } from '../core/net/Http';
  3. import List from '../core/ui/virtualList/List';
  4. import { WindowSystem } from '../core/ui/window/WindowSystem';
  5. import { WithdrawalItem } from '../myWallet/WithdrawalItem';
  6. import { WithdrawaGTlItem } from './WithdrawaGTlItem';
  7. const { ccclass, property, requireComponent } = _decorator;
  8. /**
  9. * 贡献提现记录
  10. */
  11. @ccclass('WithdrawalList')
  12. @requireComponent(Http)
  13. export class WithdrawalList extends Component {
  14. @property({ tooltip: "任务列表", type: List }) list: List;
  15. @property({ tooltip: "提现总金额", type: Node }) totalMoney: Node;
  16. private listData = [];
  17. start() {
  18. }
  19. private async onOpenHandler() {
  20. let result = await this.getComponent(Http).send("/api/fission/GetContributionLogs");
  21. let num = 0;
  22. if (result && result.code == HttpResponseCode.Success) {
  23. this.listData = result.data.logs;
  24. this.listData.sort((a: any, b: any): number => {
  25. if (a.createTime > b.createTime) {
  26. return -1;
  27. }
  28. });
  29. for (let i = 0; i < this.listData.length; i++) {
  30. num += this.listData[i].value;
  31. }
  32. this.list.numItems = this.listData.length;
  33. } else {
  34. WindowSystem.showTips('获取记录失败');
  35. }
  36. this.totalMoney.getComponent(RichText).string = "<color=#000000>累计提现:</color><color=#ff7f00>" + (num / 10000) + "元</color>";//TODO 获取提现金额
  37. // this.addItems();
  38. }
  39. /**
  40. * TODO 缺少数据
  41. * @param data 体现记录array
  42. */
  43. // public async addItems() {
  44. // for (let i = 0; i < 30; i++) {
  45. // this.listData.push({ value: 1000, createTime: 1624952208 });
  46. // }
  47. // this.list.numItems = this.listData.length;
  48. // }
  49. /**
  50. * 当列表项渲染
  51. */
  52. public onListRender(item: Node, index: number) {
  53. item.getComponent(WithdrawaGTlItem).onDataChange(this.listData[index]);
  54. }
  55. }