define(['login','utils','config'],function (login,utils,config) {
    var apiUrl = config.apiUrl;
    window._bd_share_config = {
        "common": {
            "bdSnsKey": {},
            "bdText": "组建最佳阵容，邀请好友预约还能获得电影票哦",
            "bdUrl":"http://huodong.37.com/dist/zjzr/20161021/",
            "bdMini": "2",
            "bdMiniList": false,
            "bdPic": "",
            "bdStyle": "0",
            "bdSize": "32",
            "onBeforeClick": function () {
            },
            "onAfterClick": function (cmd) {
            }
        }, "share": {}
    };

    login.lrCallback = function(){
        utils._jsonP({
            url:apiUrl.generateCode
        },function(res){
            if(+res.result ===1){
                $("#share_link").val("http://huodong.37.com/dist/zjzr/20161021/?from="+res.val);
                $("#share_copy_btn").attr("data-clipboard-text","http://huodong.37.com/dist/zjzr/20161021/?from="+res.val);
                SQ.clip(SQ.byId("share_copy_btn"));
                window._bd_share_config.common.bdUrl = "http://huodong.37.com/dist/zjzr/20161021/?from="+res.val;
                with (document)0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
            }
        });
    };
    var shared = false;
    $(document)
        .on("click", ".share", function (e) {
            if (!shared)
                if (login.hasLogin()) {
                    $(".shareContainer").toggleClass("hide");
                } else {
                    login.dialog.show(0);
                }
        });
});
