| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { _decorator, Sprite, Label, SpriteFrame, ImageAsset, Texture2D } from 'cc';
- import InfiniteCell from '../core/InfiniteList/InfiniteCell';
- import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils';
- import { BitmapFont } from '../core/ui/BitmapFont';
- import { ISJSB } from '../Data/platform';
- import { FsUtils } from '../FsUtils/FsUtils';
- const { ccclass, property } = _decorator;
- @ccclass('FriendItem')
- export class FriendItem extends InfiniteCell {
- @property({ type: Sprite, tooltip: "头像" })
- headImg: Sprite;
- @property({ type: Label, tooltip: "昵称文本" })
- nickNameLabel: Label;
- // @property({ type: Label, tooltip: "等级文本" })
- // LvLabel: Label;
- // @property({ type: Label, tooltip: "关系文本" })
- // relationLabel: Label;
- @property({ type: BitmapFont, tooltip: "贡献文本" })
- contributionLabel: BitmapFont;
- private numArr = ["一", "二", "三", "四", "五"];
- start() {
- }
- async UpdateContent(itemData: any) {
- if (ISJSB && itemData.avatar) {
- let img = await ResourcesUtils.loadRemote<ImageAsset>(itemData.avatar, { ext: ".png" }, this);
- const spriteFrame = new SpriteFrame();
- const texture = new Texture2D();
- texture.image = img;
- spriteFrame.texture = texture;
- this.headImg.spriteFrame = spriteFrame;
- }
- this.nickNameLabel.string = FsUtils.beautySub(itemData.nickname, 4);
- let lv = itemData.lv ? itemData.lv : 1;
- itemData.totalRevenueAmount = itemData.totalRevenueAmount || 0;
- this.contributionLabel.string = itemData.totalRevenueAmount.toFixed(0);
- }
- }
|