import { ModuleType } from './../../libs/tc/enum/ModuleType';
import { NetManager } from "../../libs/tw/manager/NetManager";
import SceneCtrl from "../ctrls/sceneCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import PanelCtrl from "../ctrls/panelCtrl";
import Panel from "../views/Panel";

import { Buried } from "../../libs/tw/util/Buried";

export default class SwitchPigPanel extends Panel {

    protected get skinKey() { return 'SwitchPig' }

    public bg: eui.Image;
    public switchBtn: eui.Button;
    public msgTxt: eui.Label;

    //埋点
    private exposure;

    // 开始
    start(data) {
        this.initBuired();
    }

    get picWidth() { return 240 };
    get picBigWidth() { return 510 };
    get bigPicRatio() { return 640 / 300 }

    initBuired() {
        var dpm = Buried.connectDpm(40, 6, 5);
        var num;
        switch (window["currentPigData"].identifier) {
            case "wastonA":
                num = 1;
                break;
            case "wastonB":
                num = 2;
                break;
            case "wastonC":
                num = 3;
                break;
        }
        var dcm = Buried.connectDcm(230, window['skinID'], num);
        this.exposure = Buried.createExposure(dpm, dcm);

        //曝光
        NetManager.ins.showLog(this.exposure);
    }

    initEvents() {
        super.initEvents();
        this.switchBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_SwitchBtn, this);
    }

    onTap_SwitchBtn() {
        //点击埋点
        NetManager.ins.clickLog(this.exposure);

        let data = { isSwitch: true };
        this.hidePanel();
        SceneCtrl.instance.change(ModuleTypes.PIGTHEME_SCENE, data);
    }
}