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

@ccclass('exchange_car_success')
export class exchange_car_success extends base_ui {
    @property(Node) btn_true:Node = null
    @property(Node) img_car:Node = null
    @property(Node) lab_name:Node = null
    private m_cb = null
    start() {
        this.onButtonListen(this.btn_true, ()=>{
            this.close()
            this.m_cb && this.m_cb()
        })
    }

    initView(car_id:number, cb) {
        this.m_cb = cb
        let car_item = dataManager.getUserCarInfo(car_id)
        tools.loadRemoteImg(car_item.background_cover,(d)=>{
            this.img_car.getComponent(Sprite).spriteFrame = d.sf
        })
        this.lab_name.getComponent(Label).string = car_item.name
    }
    
}

