import ViewObject from "../../../../../main/ViewObject";
import { HttpStateType, ReveData } from "../../../../../util/CHttp";

/**
 * 获得水晶瓶界面提示
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class FSjpPanel extends ViewObject {

    public callback:()=>void;
    
    public setCallback(callback:()=>void){
        this.callback = callback
    }

    public onclick(){
        this.openSkill()
    }

    public openSkill(){
        this.main.startLoad()
        this.main.gameHttp.sendJson('stage/v1/openSkill',{},(state,reve:ReveData)=>{
            this.main.stopLoad();
            if(state == HttpStateType.SUCCESS){
                if(reve.retCode == 0){
                    let role = this.main.player.role
                    role.openSkill = 1
                    this.callback()
                    this.exitDistroy()
                }else{
                    this.main.showTips(reve.message);
                }
            }else{
                this.main.showTips('网络异常');
            }
        });

    }


}