import { _decorator, Component, Label, Node, Sprite } from 'cc';
import { rankData } from '../../data';
import { tools } from '../../tools';
import { userDataManager } from '../../manager/userDataManager';
import { imageCacheManager } from '../../manager/imageCacheManager';
const { ccclass, property } = _decorator;

@ccclass('rank_my_info')
export class rank_my_info extends Component {
    @property(Node) lab_number:Node = null;
    @property(Node) img_avatar:Node = null;
    @property(Node) lab_nickname:Node = null;
    @property(Node) lab_car_number:Node = null;
    @property(Node) lab_score:Node = null;
    @property(Node) img_car:Node = null;

    initView(data:rankData) {
        this.lab_number.getComponent(Label).string = data.ranking_desc + ''
        tools.loadRemoteImg(data.avatarUrl, (r)=>{
            this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
        })
        this.lab_nickname.getComponent(Label).string = data.nickName
        this.lab_car_number.getComponent(Label).string = data.license_code
        this.lab_score.getComponent(Label).string = data.score + '分'
        
        this.img_car.getComponent(Sprite).spriteFrame = imageCacheManager.getHomeCarImageById(userDataManager.user_car_list.default_car_id)
    }
}

