
import PanelCtrl from "../ctrls/panelCtrl";

export class WinnerItemComponent extends eui.Component{


    public recordLabel:eui.Label;
    /**
     * @param winnerName 获得者的名称
     * @param prizeName 奖品名称
     */
    constructor(){
        super();
        this.skinName     = 'resource/skins/component/WinnerItemComponent.exml';
        this.initUI();
    }

    private initUI(){
        this.x = 750 
        this.getModel();
        let randomTime = Math.floor(Math.random()*5000);
        setTimeout(() => {
            this.setMove();
        }, randomTime);
    }
    private setMove(){
        egret.Tween.get(this, {loop:false})
        .to({x : -400},4000).call(function(){this.initUI()}.bind(this))
    }
    private getModel(){
        let prefixArray = new Array("130", "131", "132", "133", "135", "137", "138", "170", "187", "189");
        let i = Math.floor(Math.random()*10);
        let prefix = prefixArray[i] + "****";
        for (let j = 0; j < 4; j++) {
            prefix += Math.floor(Math.random() * 10);
        }
        let prizeArray = new Array("腾讯视频VIP年卡", "腾讯视频VIP月卡");
        let index = Math.floor(Math.random()*2);
        let prizeString = prizeArray[index];
        let showLab = prefix + '砸中' + prizeString;
        this.recordLabel.text = showLab;
    }
}