ChildListItem.ts 1.2 KB

1234567891011121314151617181920212223242526272829
  1. import { _decorator, Sprite, Label, assetManager, ImageAsset, SpriteFrame, Texture2D } from 'cc';
  2. import InfiniteCell from '../../core/InfiniteList/InfiniteCell';
  3. import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils';
  4. import { BitmapFont } from '../../core/ui/BitmapFont';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('ChildListItem')
  7. export class ChildListItem extends InfiniteCell {
  8. @property({ type: Sprite, tooltip: "头像" }) head: Sprite;
  9. @property({ type: Label, tooltip: "昵称" }) nickNameLabel: Label;
  10. @property({ type: BitmapFont, tooltip: "贡献" }) gxLabel: BitmapFont;
  11. start() {
  12. }
  13. async UpdateContent(itemData: any) {
  14. if (itemData.avatar) {
  15. let img = await ResourcesUtils.loadRemote<ImageAsset>(itemData.avatar, { ext: ".png" }, this);
  16. const spriteFrame = new SpriteFrame();
  17. const texture = new Texture2D();
  18. texture.image = img;
  19. spriteFrame.texture = texture;
  20. this.head.spriteFrame = spriteFrame;
  21. }
  22. this.nickNameLabel.string = itemData.nickname;
  23. this.gxLabel.string = itemData.totalRevenueAmount == 0 ? "0" : itemData.totalRevenueAmount + "";
  24. }
  25. }