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

@ccclass('user_info_view')
export class user_info_view extends base_ui {
    @property(Node) btn_close:Node = null
    @property(Node) img_head:Node = null
    @property(Node) lab_region:Node = null
    @property(Node) lab_nickname:Node = null
    @property(Node) img_car:Node = null
    @property(Node) img_number:Node = null
    @property(Node) lab_score:Node = null
    start() {
        this.btn_close.on(Node.EventType.TOUCH_END, ()=>{
            this.close()
        })
    }

    initView(data:rankData) {
        tools.loadRemoteImg(data.avatarUrl, (d)=>{
            this.img_head.getComponent(Sprite).spriteFrame = d.sf
        })
        this.lab_region.getComponent(Label).string = data.province_name + ' - ' + data.city_name
        this.lab_nickname.getComponent(Label).string = data.nickName
        this.img_car.getComponent(Sprite).spriteFrame = imageCacheManager.getRankCarImageById(data.car_id)
        this.lab_score.getComponent(Label).string = data.score + '分'

    }
}

