import Panel from "../views/Panel";
import { DataManager } from "../../libs/tw/manager/DataManager";
import { LotteryType } from "../../libs/tw/enum/LotteryType";
import { NetManager } from "../../libs/tw/manager/NetManager";
import SceneCtrl from "../ctrls/sceneCtrl";
import { ModuleTypes } from "../types/sceneTypes";
import PanelCtrl from "../ctrls/panelCtrl";
import GameConst from "../GameConst";

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

export default class SharePanel extends Panel {

    protected get skinKey() { return 'Share' }

    public closeBtn: eui.Button;
    public tips: eui.Label;


    //埋点
    private exposure;

    // 开始
    start(data) {

        this.closeBtn.y = GameConst.stage.stageHeight / 2 + 530;
        this.tips.y = GameConst.stage.stageHeight / 2 + 450;
        this.initBuired();
    }

    initBuired() {
        var dpm = Buried.connectDpm(40, 9, 1);
        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.img.once(egret.TouchEvent.TOUCH_TAP, this.onUse, this);
        this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_CloseBtn, this)
    }

    onTap_CloseBtn(e: egret.TouchEvent) {
        //点击买定
        NetManager.ins.clickLog(this.exposure);

        this.hidePanel();
        let img = document.getElementById('shareImg');
        img.style.display = 'none'
    }

}