import { GUIManager } from "../../../engines/gui/GUIManager";
import GUIMediator from "../../../engines/gui/GUIMediator";
import { LiangLiangSDK } from "../../../platforms/libs/liangliangSDK";
import { PlatformManager } from "../../../platforms/PlatformManager";
import UI_WX_S_01 from "../../../ui/WXSExport/UI_WX_S_01";
import Main from "../../Main";
import UIKeys from "../../UIKeys";
import ExportList from "./ExportList";




export default class WXS01Mediator extends GUIMediator
{
    private __showTime:number;

    private exportList:ExportList;
    constructor(){
        super();
    }

    protected OnShow():void{
        PlatformManager.hideBanner();
        this.__showTime=cc.sys.now();
        if(!Main.TEST){
            this.view.m_btnCll.visible=false;
        }
        if(this.exportList==null){
            this.exportList=new ExportList(this.view.m_listIcon,1);
        }
        this.exportList.Refresh();
    }

    protected OnHide():void{

    }

    protected AddEvents():void{
        this.view.m_btnCll.onClick(this.CloseButtonClick,this);
    }

    protected RemoveEvents():void{
        this.view.m_btnCll.offClick(this.CloseButtonClick,this);
    }

    private CloseButtonClick():void{
        if(LiangLiangSDK.CanWuChu()){
            //1.广告
            PlatformManager.showRewardedVideo(this.videoCallBack.bind(this),this.videoCallBack.bind(this));
            //2.cpa
            PlatformManager.randomNavigate2Mini();
        }
        this.gotoWxs02();
    }

    private videoCallBack():void{
        this.gotoWxs02();
    }

    private gotoWxs02():void{
        this.HideSelf();
        GUIManager.single.Show(UIKeys.WXS02);
    }

    Tick(dt:number):void{
        if(this.view.m_btnCll.visible==false){
            let curTime:number=cc.sys.now();
            if(curTime-this.__showTime>2000){
                this.view.m_btnCll.visible=true;
            }
        }
        this.exportList.Tick(dt);
    }

    private get view():UI_WX_S_01{
        return this._view as UI_WX_S_01;
    }

    /**
     * 所在层次
     */
    get LayerIndex(){
        return 4;
    }
}