import { _decorator, Component, Label, log, Node, Sprite, SpriteFrame } from 'cc'; import { ch } from 'db://assets/ch/ch'; import { UI_Head_Icon } from './UI_Head_Icon'; 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)//奖章 pm_Bg: Sprite = null; @property([SpriteFrame]) pm_Skin: SpriteFrame[] = []; @property(UI_Head_Icon)//头像 Headicon: UI_Head_Icon @property(Label) private rank_txt: Label;//排名 @property(Label) private name_txt: Label;//昵称 @property(Label) private score_txt: Label;//通关数 //index:排名 type:类型参数 data:用户数据 头像 昵称 通关数 用户id 是否是当前用户 showInfo(index: number, type: number, data: { head: string, nickName: string, score: number, userId: number, [key: string]: any }, me: boolean): void { log('UI_rank_item+++++++++',data) if (!data) { this.node.active = false; return; } this.node.active = true; if (me) { this.Bg.spriteFrame = this.Bgs[2] index <= 3 ? this.pm_Bg.spriteFrame = this.pm_Skin[index - 1] : this.pm_Bg.spriteFrame = this.pm_Skin[3]; } else { index <= 3 ? this.Bg.spriteFrame = this.Bgs[0] : this.Bg.spriteFrame = this.Bgs[1]; index <= 3 ? this.pm_Bg.spriteFrame = this.pm_Skin[index - 1] : this.pm_Bg.spriteFrame = this.pm_Skin[3]; } if (index > 3) { this.pm_Bg.node.active = false; } else { this.pm_Bg.node.active = true; } this.rank_txt.string = index==101? "未上榜": index<=3? '':index.toString(); this.name_txt.string = ch.sdk.getDefNickName(data); this.score_txt.string = `${data.score ?? 0}关`; console.log('UI_rank_item-------------------'); console.log(data) this.Headicon.show(data.userId.toString(), data.head); } }