
import Image = Laya.Image;
import Text = Laya.Text;
import Box = Laya.Box;
import Button = Laya.Button;
import BannerAndVideo1 from "../../game_module/BannerAndVideo1";
import UserModel from "../../game_module/UserModel";
import NetManager, { PROTOCOLS } from "../../game_module/NetManager";

export default class SkinItem extends Laya.Script {
    public _self: Box;

    private _icon: Image;
    private _btn: Button;

    private _usingBtn: Image;
    private _useBtn: Image;

    private _coinBtn: Image;
    private _coinValue: Text;

    private _videoBtn: Image;
    private _videoValue: Text;

    private _data: any;
    private buyPrice: number;
    constructor() {
        super();
    }
    onAwake() {
        this._self = this.owner as Box;
        this._icon = this._self.getChildByName("_icon") as Image;
        this._usingBtn = this._self.getChildByName("_usingBtn") as Image;
        this._useBtn = this._self.getChildByName("_useBtn") as Image;
        this._coinBtn = this._self.getChildByName("_coinBtn") as Image;
        this._coinValue = this._coinBtn.getChildByName("_coinValue") as Text;
        this._videoBtn = this._self.getChildByName("_videoBtn") as Image;
        this._videoValue = this._videoBtn.getChildByName("_videoValue") as Text;

        this._btn = this._self.getChildByName("_btn") as Button;

        this._btn.clickHandler = new Laya.Handler(this, this.ClickHandler);
    }

   
    Refresh() {
       
    }
    ClickHandler() {
     
    }
    VideoBtnHandler() {
        BannerAndVideo1.ShowVideo((done) => {
            if (done) {
                this.NetVideo();
            }
        })
    };
    NetVideo() {
        var param = [{ "t": UserModel.Instance.CurModel.ServerTime.toString() }, { "id": this._data.id }, { "channel": "video" }];
        NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.themefission, param,
            (data: any) => {
                // PlayerManager.Instance.SetTheme();
                // //this.ShowDis();
                // this.Refresh(this._type);
            },
            (data) => {

            });
    }
    NetBuy() {
        var param = [{ "id": this._data.id }];
        NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Buy, param,
            (data: any) => {
                
            },
            (data) => {

            });
    }
    NetEquip() {
        var param = [{ "id": this._data.id }];
        NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Equip, param,
            (data: any) => {
               
            },
            (data) => {

            });
    

   
    }
    onDestroy() {
        this._btn.clickHandler = null;
    }

}