import { ui } from "../ui/layaMaxUI";
// import { ZSSdk } from "../Net/ZSSdk";
import { ViewManager, ViewType } from "./ViewManager";
import { SDKZS } from "../Net/SDKZS";
import { WXSDK } from "../Net/WXSDK";

export default class ExportView extends ui.ExportViewUI{
    OnOpen(data?){
        WXSDK.AldEvent("打开全屏幕导出界面");
        this.CloseExportBtn.clickHandler = Laya.Handler.create(this,this.ClickClose,[data]);
        this.SetData();
        this.height = Laya.stage.height;
        Laya.stage.on(Laya.Event.RESIZE,this,()=>
        {
            this.height = Laya.stage.height;
        })
    }
    OnHide(){
        Laya.timer.clearAll(this);
        WXSDK.AldEvent("关闭全屏导出界面");
    }
    ClickClose(data?){
        ViewManager.Instance.ClosePopView(ViewType.ExportView);
        // if(data){
        //     ViewManager.Instance.ShowView(ViewType.MainView);
        // }
    }
    SetData() {
        SDKZS.SetHuTuiList(this.HList, 2, "");
        SDKZS.SetHuTuiList(this.VList, 1, "");
        this.GunGun();
    }
    GunGun() {
        var maxTop;
        var maxBtm;
        try {
            this.VList.scrollBar.value = 0;
            this.HList.scrollBar.value = 0;
            maxTop = this.HList.scrollBar.max;
            maxBtm = this.VList.scrollBar.max;
        } catch (error) {
            console.error(error);
            return;
        }
        var tempTop = 1;
        var tempBtm = 1;
        Laya.timer.frameLoop(1, this, () => {
            this.HList.scrollBar.value += tempTop;
            if (this.HList.scrollBar.value >= maxTop || this.HList.scrollBar.value <= 0) {
                tempTop = -tempTop;
            }
            this.VList.scrollBar.value += tempBtm;
            if (this.VList.scrollBar.value >= maxBtm || this.VList.scrollBar.value <= 0) {
                tempBtm = -tempBtm;
            }
        });
    }
}