import { _decorator, Component, Node, Prefab, instantiate, RichText } from 'cc'; import { Http } from '../../core/net/Http'; import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils'; import { WindowManager } from '../../core/ui/window/WindowManager'; import { ConfigData } from '../../Data/ConfigData'; import { g } from '../../Data/g'; import { WithdrawIteml } from '../../Item/WithdrawIteml'; const { ccclass, property } = _decorator; @ccclass('WithdrawalList') export class WithdrawalList extends Component { @property({ tooltip: "item父级节点", type: Node }) public itemBox: Node; @property({ tooltip: "item预制体路径" }) public itemPrefab = ""; @property({ tooltip: "提现总金额", type: Node }) public totalMoney: Node; @property({ type: Http, tooltip: "Http服务" }) http: Http; start() { } private async onOpenHandler() { if (g.gameData.hasNewwithdrawalLog) { g.gameData.hasNewwithdrawalLog = false; let result = await this.http.send("/api/fission/GetContributionLogs"); if (!result.code) { g.gameData.withdrawalLogs = result.data.logs; } else { WindowManager.showTips(g.CodeMsg[result.code]); } } this.addItems(g.gameData.withdrawalLogs); } /** * TODO 缺少数据 * @param data 体现记录array */ public async addItems(data: any[]) { let num = 0; for (let i = 0; i < data.length; i++) { let prefabData = await ResourcesUtils.load(this.itemPrefab, null, this.node); var itemNode = instantiate(prefabData); itemNode.parent = this.itemBox; itemNode.getComponent(WithdrawIteml).setData(data[i]); num += Math.abs(data[i].value); } this.totalMoney.getComponent(RichText).string = "累计提现:" + (num / ConfigData.configMap.get("systemConfig").moneyRate) + "元";//TODO 获取提现金额 } }