import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc'; import { UI_Head_Icon } from '../UI/UI_Head_Icon'; import { ch } from '../../../ch/ch'; const { ccclass, property } = _decorator; @ccclass('UI_Rank_Item') export class UI_Rank_Item extends Component { @property(Sprite) Bg: Sprite = null; @property([SpriteFrame]) Bgs: SpriteFrame[] = []; @property(Sprite) Medal:Sprite = null; @property([SpriteFrame]) Medals: SpriteFrame[] = []; @property(Label) Num: Label = null; @property(UI_Head_Icon) Head_Icon: UI_Head_Icon = null; @property(Label) Name: Label = null; @property(Label) Level: Label = null; showInfo(index: number, type: number, data: { head: string, nickName: string, score: number, userId: number, [key: string]: any }, me: boolean): void { if (!data) { this.node.active = false; return; } this.node.active = true; if (me) { this.Bg.spriteFrame=this.Bgs[4]; index<=3?this.Medal.spriteFrame=this.Medals[index-1]:this.Medal.spriteFrame=this.Medals[3]; } else { index<=3?this.Bg.spriteFrame=this.Bgs[index-1]:this.Bg.spriteFrame=this.Bgs[3]; index<=3?this.Medal.spriteFrame=this.Medals[index-1]:this.Medal.spriteFrame=this.Medals[3]; } if(index>3) { this.Medal.node.active=false; }else { this.Medal.node.active=true; } this.Num.string = index==101? "未上榜": index<=3? '':index.toString(); this.Name.string = ch.sdk.getDefNickName(data); this.Level.string = `${data.score ?? 0}关`; console.log(data); this.Head_Icon.show(data.userId.toString(), data.head); } }