define(['config','utils'],function(config,utils){
    var apiUrl = config.apiUrl;
    var l = new SQ.Login({
        game_id: config.game_id,//游戏ID
        dialog: true,//关闭统一登录浮窗
        lr: function(userInfo, res){ //注册或者登录成功的回调
            //userInfo为组件拼接用户信息，res为接口返回的信息
            l.lrCallback&&l.lrCallback();
            $('.lr_box').children().eq(0).addClass("hide").next().removeClass("hide");
            var username = userInfo.SHOW_NAME;
            if (userInfo.AUTH_TYPE && !userInfo.ALIAS_ACCOUNT) {
                username = "<img src='http://img1.37wanimg.com/www/css/images/game_site/ico-" + userInfo.AUTH_TYPE + ".png' alt=''/> " + username;
            }
            SQ.byId("top-login-name").innerHTML = username;
            SQ.byId("start_game_link").href= config.getPlayGameUrl();
        },
        unlog: function(res, type){ //登录失败回调
            type === "log" && res.message && alert( res.message );
        },
        unreg: function(res, type){ //注册失败回调
            type === "reg" && res.message && alert( res.message );
        },
        out: function(){    //注销登录回调
            window.location.reload();
        }
    });

    $(document).on("click","#top-log-btn",function(){
        l.dialog.show(0);
    }).on("click","#top-reg-btn",function(){
        l.dialog.show(1);
    }).on("click","#top-out-btn",function(){
        l.toOut();
    });

    return l;
});