import { ui } from "../ui/layaMaxUI";
import { GameTool } from "../Util/GameTool";
import { FYHD_Sdk } from "../Net/FYHD_Sdk";
import { ViewManager, ViewType } from "../Net/ViewManager";
import { GameManager } from "../Game/GameManager";
export default class ExitView extends ui.ExitViewUI{
    private static ins:ExitView;
    jump = false;
    constructor(){
        super();
        ExitView.ins = this;
    }
    public static get Instance():ExitView{
        if(ExitView.ins){
            return ExitView.ins;
        }
        else{
            return new ExitView();
        }
    }
    OnShow(data?){
        this.SetData();
        this.Jump();
        if(data){
            this.CloseBtn.clickHandler =  new Laya.Handler(this,this.ClickClose,[data]);
        }
        else{
            this.CloseBtn.clickHandler =  new Laya.Handler(this,this.ClickClose);
        }

        this.CloseBtn.visible = false;
        Laya.timer.once(2000,this,()=>{
            this.CloseBtn.visible = true;
        })

        
        
        this.height = Laya.stage.height;
        Laya.stage.on(Laya.Event.RESIZE,this,()=>
        {
            this.height = Laya.stage.height;
        })
    }
    OnClose(){
    }
    ClickClose(data){
        // ViewManager.Instance.ClosePopView(ViewType.ExitView);
        ViewManager.Instance.CloseView(ViewType.ExitView);
        if(data){
            ViewManager.Instance.AddView(ViewType.CompleteView,GameManager.WINORLOSE);
        }
    }
    private SetData() {
        FYHD_Sdk.SetHuTuiList(this.PushList, 1, "");
    }

    Jump(){
        let ran = GameTool.randomInt(0, FYHD_Sdk.pushData.length);
        let item = FYHD_Sdk.pushData[ran];
        FYHD_Sdk.ClickAd(FYHD_Sdk.Ad_ClickType.PushClick);
        FYHD_Sdk.ShowHuTuiJump(item);
    }

    

}