import Panel from "../../MVC/views/Panel";
import { GDispatcher } from "../../../libs/tc/util/GDispatcher";

export default class NoPrizePanel extends Panel {
	public group: eui.Group;
	public ok_btn: eui.Button;
	public closeBtn: eui.Button;

	public get skinKey() { return 'NoPrizePanel' }
	public get groupName() { return 'noPrize_panel' }
	constructor(data?) {
		super(data);

	}
	initEvents() {
		this.ok_btn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
		this.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
	}

	onTouchTap() {
		GDispatcher.dispatchEvent('panelEffect');
		return super.onTouchTap();
	}

	removeEvents() {
		this.ok_btn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
		this.closeBtn.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTap, this);
	}

	protected onSkinComplete(): void {
		super.onSkinComplete();

		this.preLoadRes();
		this.onLoad();
		
	}

	start(data?) {

	}

	protected onLoad(): void {
		this.initUI();
	}

	private initUI(): void {
		let _y = this.group.y;
		this.group.y = _y - 300;
		egret.Tween.get(this.group).to({y: _y}, 800, egret.Ease.bounceOut);
	}

	protected async preLoadRes() {


		return new Promise(function (resolve, reject) {
			resolve();
		});
	}
}