import ViewObject from "../main/ViewObject";
import { HttpStateType } from "../util/CHttp";
/**
 * 公告
 */
const { ccclass, property } = cc._decorator;

@ccclass
export default class Tap_set_Ann extends ViewObject {

    
    @property(cc.Label)
    mTitle: cc.Label = null;

    @property(cc.Label)
    mContent: cc.Label = null;

    public onLoad() {

        let http = this.main.loginHttp;


        this.main.startLoad();
        http.sendForm('/notice?channel=1',{},(state,reve:any)=>{
            this.main.stopLoad();
            if(state == HttpStateType.SUCCESS){
                let data = JSON.parse(reve.data)
                if(data && data.title){
                    this.mTitle.string = data.title;
                    this.mContent.string = data.content
                }
            }else{
                this.main.showTips('网络异常');
            }
        })


    }

    /**
     * 
     * @param prev 父界面
     */
     public show(prev?:ViewObject){
        if(prev){
            this.prev = prev;
            this.prev.__close();
        }
        this.main.viewManage.popView1(this.node);
        if(this.main && this.main.gameHttp){
            this.main.gameHttp.pushEvent(this);
        }
    }

   
   
}
