WithdrawalList.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { _decorator, Component, Node, Prefab, instantiate, RichText } from 'cc';
  2. import { Http } from '../../core/net/Http';
  3. import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
  4. import { WindowManager } from '../../core/ui/window/WindowManager';
  5. import { ConfigData } from '../../Data/ConfigData';
  6. import { g } from '../../Data/g';
  7. import { WithdrawIteml } from '../../Item/WithdrawIteml';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('WithdrawalList')
  10. export class WithdrawalList extends Component {
  11. @property({ tooltip: "item父级节点", type: Node })
  12. public itemBox: Node;
  13. @property({ tooltip: "item预制体路径" })
  14. public itemPrefab = "";
  15. @property({ tooltip: "提现总金额", type: Node })
  16. public totalMoney: Node;
  17. @property({ type: Http, tooltip: "Http服务" })
  18. http: Http;
  19. start() {
  20. }
  21. private async onOpenHandler() {
  22. if (g.gameData.hasNewwithdrawalLog) {
  23. g.gameData.hasNewwithdrawalLog = false;
  24. let result = await this.http.send("/api/fission/GetContributionLogs");
  25. if (!result.code) {
  26. g.gameData.withdrawalLogs = result.data.logs;
  27. } else {
  28. WindowManager.showTips(g.CodeMsg[result.code]);
  29. }
  30. }
  31. this.addItems(g.gameData.withdrawalLogs);
  32. }
  33. /**
  34. * TODO 缺少数据
  35. * @param data 体现记录array
  36. */
  37. public async addItems(data: any[]) {
  38. let num = 0;
  39. for (let i = 0; i < data.length; i++) {
  40. let prefabData = await ResourcesUtils.load<Prefab>(this.itemPrefab, null, this.node);
  41. var itemNode = instantiate(prefabData);
  42. itemNode.parent = this.itemBox;
  43. itemNode.getComponent(WithdrawIteml).setData(data[i]);
  44. num += Math.abs(data[i].value);
  45. }
  46. this.totalMoney.getComponent(RichText).string = "<color=#000000>累计提现:</color><color=#ff7f00>" + (num / ConfigData.configMap.get("systemConfig").moneyRate) + "元</color>";//TODO 获取提现金额
  47. }
  48. }