| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { CURRENCY_TYPE, CurrencyType } from '@scripts/define/Define';
- import { IGameHistory } from '@scripts/store/gameStore/data';
- import { formatCurrency, formatGCNum, formatGoodsNum, formatSCNum } from '@scripts/utils/Helper';
- import { setSpriteFrame } from '@scripts/utils/ResHelper';
- import { _decorator, Component, isValid, Label, Node, Sprite } from 'cc';
- const { ccclass, property } = _decorator;
- @ccclass('PlayHisItem')
- export class PlayHisItem extends Component {
- @property(Sprite)
- sptIcon: Sprite = null;
- @property(Label)
- lblName: Label = null;
- @property(Label)
- lblTimes: Label = null;
- @property(Node)
- scNode: Node;
- @property(Node)
- gcNode: Node;
- @property(Label)
- scEntryText: Label;
- @property(Label)
- scWinText: Label;
- @property(Label)
- gcEntryText: Label;
- @property(Label)
- gcWinText: Label;
- private m_data: IGameHistory;
- updateView(data: IGameHistory) {
- this.m_data = data;
- const isGC = data.currency === CURRENCY_TYPE.GC;
- this.scNode.active = !isGC;
- this.gcNode.active = isGC;
- const entryValue = data.entry
- const winValue = data.win;
- const lblEntry = isGC ? this.gcEntryText : this.scEntryText;
- const lblWin = isGC ? this.gcWinText : this.scWinText;
- lblEntry.string = isGC ? formatGoodsNum(entryValue) : formatSCNum(entryValue);
- lblWin.string = isGC ? formatGoodsNum(winValue) : formatSCNum(winValue);
- const roundId = data.roundId;
- setSpriteFrame(this.sptIcon, data.coverUrl, {
- onCheck: () => {
- return this.m_data.roundId === roundId && isValid(this.node);
- },
- });
- }
- }
|