import SubHallManger from '../view/subHallManger'
cc.Class({
    extends: SubHallManger,

    properties: {
        gamesNode:cc.Node,
        webview: cc.WebView,
    },
    onLoad(){
        cc.vv.userMgr.agentLogin(this.gameid,function (ret) {
            this.reqSuccess(ret)
        }.bind(this))
    },

    onWebFinishLoad: function (sender, event) {
        var loadStatus = "";
        if (event === cc.WebView.EventType.LOADED) {
            loadStatus = " is loaded!";
        } else if (event === cc.WebView.EventType.LOADING) {
            loadStatus = " is loading!";
        } else if (event === cc.WebView.EventType.ERROR) {
            loadStatus = ' load error!';
        }
        console.log(loadStatus)
    },
    
    // setView(gameid){
    //     this.gameid = gameid
    // },

    reqSuccess(ret){
        if(ret.status !== 1){
            this.visitURL('http://sports.meme100.com/m/#/')
        }else{
            this.visitURL('http://sports.meme100.com/m/#/?token='+ret.data.apiToken)
        }
        
    },

    visitURL: function (url) {
        this.webview.url = url;
    }
});
