123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
- import { rankData } from '../../data';
- import { tools } from '../../tools';
- import { GameManager } from '../../GameManager';
- const { ccclass, property } = _decorator;
- @ccclass('rank_my_info')
- export class rank_my_info extends Component {
- @property(Node) img_weishangbang:Node = null
- @property(Node) icon_number_bg:Node = null
- @property(Node) icon_number_img:Node = null
- @property(SpriteFrame) sf_rank_icon_1:SpriteFrame = null
- @property(SpriteFrame) sf_rank_icon_2:SpriteFrame = null
- @property(SpriteFrame) sf_rank_icon_3:SpriteFrame = null
- @property(Node) img_avatar:Node = null
- @property(Node) lab_nickname:Node = null
- @property(Node) lab_score:Node = null
- @property(Node) img_car:Node = null
- initView(data:rankData) {
- if(data.number>0 && data.number<=3) {
- this.img_weishangbang.active = false
- this.icon_number_bg.active = true
- switch (data.number) {
- case 1:
- this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_1
- break;
- case 2:
- this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_2
- break;
- case 3:
- this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_3
- break;
- default:
- break;
- }
- } else {
- this.img_weishangbang.active = true
- this.icon_number_bg.active = false
- }
- tools.loadRemoteImg(data.avatarUrl, (r)=>{
- this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
- })
- this.lab_nickname.getComponent(Label).string = data.nickName
- this.lab_score.getComponent(Label).string = data.score + ' 分'
- this.img_car.getComponent(Sprite).spriteFrame = GameManager.getUserDefaultCarSf()
- }
- }
|