import { HtmlTextParser } from './../ctrls/HtmlTextParser';
import Panel from "../views/Panel";
import { NetManager } from "../../libs/tw/manager/NetManager";
import { DataManager } from "../../libs/tw/manager/DataManager";
import { GetBuriedData } from '../ctrls/GetBuriedData';
import PanelCtrl from '../ctrls/panelCtrl';
export default class RulePanel extends Panel {
    public ruleGroup:eui.Group;
    public ruleLb:eui.Label;
    public ruleBackBtn:eui.Button;
    public ruleBg:eui.Image;
    private ruleTexture:egret.Texture;
    public get skinKey() { return 'RulePanel' }
    public get groupName() { return 'rule_panel' }
    public bg:eui.Image;
    constructor(data: any) {
        super(data);
    }
    protected async preLoadRes() {
        this.ruleTexture = await RES.getResAsync('prizeBg_jpg');
        return new Promise(function (resolve, reject) {
            resolve();
        });
    }
    onSkinComplete(): void {
        super.onSkinComplete();
        this.ruleBg.texture = this.ruleTexture;
        this.once(egret.Event.ADDED_TO_STAGE, this.onLoad, this);
        if (this.stage) {
            this.onLoad();
        }
        this.showAct();
    }

    start(): void {
        this.percentHeight = 100;
    }

    initEvents(): void {
        super.initEvents();
        this.ruleBackBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickBack, this);
    }

    removeEvents(): void {
        super.removeEvents();
        this.ruleBackBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickBack, this);
    }

    private onLoad():void{
        //this.ruleLb.textColor = 0xBBD7E6;
        // console.log('屏幕',screen.width,screen.height)
        // if(screen.height/screen.width >= 2.22)
        // {
        //     this.ruleGroup.y = 140;
        // }
        this.ruleLb.stroke = 0;
        this.ruleLb.text = window['rule'];
        NetManager.ins.showLog(GetBuriedData(11));
    }
    private onClickBack(){
        PanelCtrl.instance.btnDelay(this.ruleBackBtn);
        NetManager.ins.clickLog(GetBuriedData(11));
        this.onTouchTap();
    }
}