﻿var _apiUrl = "";
//var _manageUrl = "http://192.168.0.30:4008";
var _manageUrl = "https://member.fy35.com";
var _tpl = {

    getLoginHtml: function () {
        return `
     <div class="fy-logon fy-logon-height">
        <div class="logon-tt">
            <a href="/" title="飞阳商务网">
                <img src="/img/logon-log.png" alt="飞阳商务网Logo" />
            </a>
            <div class="logon-close lgclose"></div>
        </div>
        <div class="logon-info logon-info-height">
            <div class="logon-left logon-height">
                <div class="logon-h">
                    <h3>用户登录</h3>
                    <div class="logon-lg">
                        <a class="zc_register btn_register" href="javascript:;" rel="nofollow">免费注册</a>
                        <a href="${_manageUrl}/forget/password.html" target="_blank" rel="nofollow" class="wj_passwd">忘记密码？</a>
                    </div>
                </div>
                <div class="login-account">
                    <ul class="clearfix">
                        <li>
                            <span class="l_name_span">手机</span>
                            <input class="r_input txtAccount" type="text" placeholder="请输入手机/账号/邮箱"  value="" maxlength="40">
                        </li>
                        <li class="fy-passwd">
                            <span class="l_name_span">密码</span>
                            <input class="r_input txtPassword" type="password" autocomplete="new-password" value="" maxlength="20" placeholder="请输入密码，字母区分大小写">
                            <span class="log_showpwd log_hidePwd" title="显示密码"></span>
                        </li>
                        <li class="fy-yzm clearfix yzmbox" style="display: none">
                            <div class="yzm-nr">
                                <span class="l_name_span">验证码</span>
                                <input class="r_input yzm_input txtImgYzm" type="text" maxlength="6" placeholder="请输入验证码">
                            </div>
                            <span class="yzm_img">
                                <a href="javascript:">
                                    <img class="imgValidateCode" src="" width="80" height="40" />
                                </a>
                            </span>
                        </li>
                    </ul>
                    <input type="button" class="login_btn btn_login" value="立即登录" />
                    <div class="fy-zdlogin">
                       
                    </div>
                    <div class="fy-login-xy">
                        登录即表示已阅读并同意《<a target="_blank" href="https://help.fy35.com/helpdetail25.html">用户协议</a>》和《<a target="_blank" href="https://help.fy35.com/helpdetail25.html">隐私政策</a>》
                    </div>
                </div>
            </div>
            <div class="logon-right logon-height">
                <span class="span-text">第三方登录</span>
                <a class="login_qq btn_qq_login" style="cursor: pointer;">使用QQ帐号登录</a>
                <a class="login_wx btn_wx_login" style="cursor: pointer;">使用微信帐号登录</a> 
            </div>
        </div>
    </div>
`;
    }
    , getRegisterHtml: function () {

        return ` <div class="fy-logon">
        <div class="logon-tt">
            <a href="/" title="飞阳商务网">
                <img src="/img/logon-log.png" alt="飞阳商务网Logo" />
            </a>
            <div class="register-close lgclose"></div>
        </div>
        <div class="logon-info">
            <div class="logon-left">
                <div class="logon-h">
                    <h3>用户注册</h3>
                    <div class="logon-lg">已有账号，<a class="dl_login btn_login" href="javascript:;">直接登录</a></div>
                </div>
                <div class="login-account">
                    <ul class="clearfix">
                        <li>
                            <span class="l_name_span">手机</span>
                            <input class="r_input txtAccount" type="text" placeholder="请输入手机号码" value="" autocomplete="off" value="" maxlength="11" />
                        </li>
                        <li class="fy-passwd">
                            <span class="l_name_span">密码</span>
                            <input class="r_input txtPassword" type="password" autocomplete="new-password" maxlength="20" placeholder="8-20位字母+数字组成，字母区分大小写">
                            <span class="log_showpwd log_hidePwd" title="显示密码"></span>
                        </li>
                        <li class="short_message">
                            <input class="r_input yzm_input txtSmsYzm" type="text" maxlength="6" placeholder="请输入验证码">
                            <input type="button" class="btn_get_yzm ph_yzm_btn btnSendValidateCode" value="获取验证码" />
                        </li>
                    </ul>
                    <div class="fy-xy">
                        <label class="remb_pwd">
                            <input type="checkbox" class="chkAccept" checked="checked">
                            我表示已阅读并同意《<a target="_blank" href="https://help.fy35.com/helpdetail25.html">用户协议</a>》和《<a target="_blank" href="https://help.fy35.com/helpdetail25.html">隐私政策</a>》
                        </label>
                    </div>
                    <input type="button" class="login_btn btn_register" value="免费注册" />
                </div>
            </div>
            <div class="logon-right">
                <span class="span-text">第三方注册</span>
                
                <a class="login_qq btn_qq_login" style="cursor: pointer;">使用QQ帐号注册</a>
                <a class="login_wx btn_wx_login" style="cursor: pointer;">使用微信帐号注册</a>

            </div>
        </div>
    </div>`;

    }
    , getImgverifyHtml: function () {

        return ` <div class="img_VerifyBox">
        <div class="fy-form-row">
            <label class="fy-form-label">验证码</label>
            <span class="fy-input-inline">
                <input class="fy-input fy-w-150 txtValidateCode" type="text" maxlength="6" placeholder="验证码">
            </span>
            <div class="fy-form-mid fy-ml-5">
                <img src="/ValidateCode.aspx" class="imgValidateCode" width="100" height="34" alt="" />
                <span class="refreshBtn  fy-ml-5">换一张</span>
            </div>
        </div>
        <div class="fy-form-row">
            <div>
                <p class="msg-warn fy-w-300" style="margin-left: 120px;"></p>
            </div>
            <div class="fy-input-block">
                <button class="fy-btn fy-btn-lg fy-w-200 btnConfirmSend">确定</button>
            </div>
        </div>
    </div>`;
    }
    , getWxloginHtml: function () {

        return `<div class="wxbox">
        <div class="ercode">
            <img id="imgCode" src="/img/noercode.png" style="height: 200px; width: 200px;">
            <div class="info">
                <p>微信扫一扫，“关注”后可登录</p>
            </div>
        </div>
    </div>`;
    }
}



/*登录*/
var _login = (function () {

    let txtAccount = ".txtAccount",
        txtPassword = '.txtPassword',
        txtImgYzm = '.txtImgYzm',
        imgValidateCode = ".imgValidateCode",
        yzmbox = '.yzmbox',
        btnLogin = ".btn_login",
        btn_register = '.btn_register',
        btn_wx_login = '.btn_wx_login',
        btn_qq_login = '.btn_qq_login',
        $layDom = null,
        layerIndex = 0,
        jumpType = 0,//是否跳转到管理页面 0:管理页  1当前页刷新
        v = "1.0";

    function init(_jumpType) {
        jumpType = _jumpType || 0;
        var logoHtml = _tpl.getLoginHtml();
        //自定页 
        layer.open({
            type: 1,
            skin: 'fy-layer-login', //样式类名
            area: ['766px', '470px'],
            closeBtn: 0, //不显示关闭按钮
            title: false,
            content: logoHtml
            , success: function (layero, index) {

                initShow(layero, index);

            }
        });
    }

    function initShow(layDom, index) {

        $layDom = $(layDom);
        layerIndex = index;

        //验证码
        //refreshYzm();

        //验证码点击回车-直接提交校验验证码
        $(txtImgYzm).keydown(function (event) {
            if (event.keyCode == 13 || event.which == 13) {
                goLogin();
            }
        });

        $(txtPassword).keydown(function (event) {
            if (event.keyCode == 13 || event.which == 13) {
                goLogin();
            }
        });

        //绑定关闭按钮
        $layDom.on("click", ".lgclose", function () {
            layer.close(index);

        });
        //点击登录
        $layDom.on("click", btnLogin, function () {
            goLogin();
        });
        //显示密码
        $layDom.on("click", ".log_showpwd", function () {

            var self = $(this);
            var b = self.hasClass("log_hidePwd");
            if (b) {
                $(txtPassword)[0].setAttribute('type', 'text');
                self.removeClass("log_hidePwd");
            } else {
                self.addClass("log_hidePwd");
                $(txtPassword)[0].setAttribute("type", "password");
            }

        });

        //刷新图片验证码
        $layDom.on("click", imgValidateCode, function () {
            refreshYzm();
        });

        //点击-免费注册
        $layDom.on("click", btn_register, function () {
            _register.init(jumpType);
            layer.close(index);
        });


        //打开微信登录
        $layDom.on("click", btn_wx_login, function () {
            _wxLogin.init(jumpType);
        });

        //打开QQ登录
        $layDom.on("click", btn_qq_login, function () {
            _qqLogin.init();
        });

    }

    //刷新验证码
    function refreshYzm() {
        $(txtImgYzm).val("");
        $(imgValidateCode).attr('src', _apiUrl + '/ValidateCode.aspx?r=' + parseInt(Math.random() * 1000));
        $(txtImgYzm).focus();
    }

    //登录前的检测
    function checkLoginJS() {

        var $btn = $layDom.find(btnLogin);
        var $txtAccount = $layDom.find(txtAccount);
        var $txtPassword = $layDom.find(txtPassword);
        var $txtImgYzm = $layDom.find(txtImgYzm);
        var $imgValidateCode = $layDom.find(imgValidateCode);

        var account = $.trim($txtAccount.val());
        var password = $.trim($txtPassword.val());
        //var yzm = $.trim($txtImgYzm.val());

        if (account.length <= 1) {
            fy.msg("账号不正确");
            $txtAccount.focus();
            return false;
        }

        if (password.length <= 1) {
            fy.msg("请输入密码");
            $txtPassword.focus();
            return false;
        }
        //if (yzm.length <= 1) {
        //    fy.msg("请输入图片验证码");
        //    $txtImgYzm.focus();
        //    return false;
        //}

        return true;
    }

    //去登录
    function goLogin() {

        var $btn = $layDom.find(btnLogin);
        var $txtAccount = $layDom.find(txtAccount);
        var $txtPassword = $layDom.find(txtPassword);
        var $txtImgYzm = $layDom.find(txtImgYzm);
        var $imgValidateCode = $layDom.find(imgValidateCode);

        var account = $.trim($txtAccount.val());
        var password = $.trim($txtPassword.val());
        var yzm = $.trim($txtImgYzm.val());

        if (!checkLoginJS($layDom)) {
            return;
        }

        $btn.attr("disabled", "disabled");
        var _layerWaiting = fy.showWaiting("正在拼命的登录...");
        $.post(_apiUrl + "/ajax/LoginHandler.ashx", {
            action: "Login",
            account: account,
            password: password,
            yzm: yzm,
            ref: document.referrer
        }).done(function (result) {

            if (result.code == 1) {
                fy.msg("登录成功"); 
                if (jumpType == 1) { 
                    fy.delayRefreshPage();
                }
                else {
                    window.location.href = "/super/index.aspx"; 
                }
            }
            else {
                if (result.code == 1001) {
                    showImgVerify(true);
                }
                $txtImgYzm.val("");
                $btn.removeAttr('disabled');
                fy.alert(result.msg);
                layer.close(_layerWaiting);
                refreshYzm();
            }
        }).fail(function (ex) {

            $btn.removeAttr('disabled');
            fy.alert('系统繁忙');
            layer.close(_layerWaiting);
            refreshYzm();
        });
    }


    //显示图片验证码
    function showImgVerify(need) {
        if (need) {
            $(yzmbox).show();
            refreshYzm();
        }
        else {
            $(yzmbox).hide();
        }
    }

    return {
        init: init
    }

})();


/*注册*/
var _register = (function () {
    var txtAccount = ".txtAccount",
        txtPassword = '.txtPassword',
        txtImgYzm = '.txtImgYzm',
        txtSmsYzm = '.txtSmsYzm',
        btn_register = ".btn_register",
        btn_login = '.btn_login',
        btn_wx_login = '.btn_wx_login',
        btn_qq_login = '.btn_qq_login',
        chkAccept = '.chkAccept',
        btnSendValidateCode = '.btnSendValidateCode',
        $layDom = null,
        layerIndex = 0,
        jumpType = 0,//是否跳转到管理页面 0:管理页  1当前页刷新
        v = "1.0";
    function init(_jumpType) {
        jumpType = _jumpType || 0;
        var html = _tpl.getRegisterHtml();
        //自定页 
        layer.open({
            type: 1,
            skin: 'fy-layer-login', //样式类名
            area: ['766px', '500px'],
            closeBtn: 0, //不显示关闭按钮
            title: false,
            content: html
            , success: function (layero, index) {
                initShow(layero, index);
            }
        });
    }


    function initShow(layDom, index) {
        $layDom = $(layDom);
        layerIndex = index;

        //绑定关闭按钮
        $layDom.on("click", ".lgclose", function () {
            layer.close(index);

        });
        //点击注册
        $layDom.on("click", btn_register, function () {
            goReg();
        });
        //显示密码
        $layDom.on("click", ".log_showpwd", function () {

            var self = $(this);
            var b = self.hasClass("log_hidePwd");
            if (b) {
                $(txtPassword)[0].setAttribute('type', 'text');
                self.removeClass("log_hidePwd");
            } else {
                self.addClass("log_hidePwd");
                $(txtPassword)[0].setAttribute("type", "password");
            }

        });

        //点击-直接登录
        $layDom.on("click", btn_login, function () {
            _login.init(jumpType);
            layer.close(index);
        });

        // 点击发送手机验证码
        $layDom.on("click", btnSendValidateCode, function () {
            if (checkPhoneJs()) {
                _imgVerify.show();
            }
            else {
                $(txtAccount).focus();
            }
        });

        //打开微信登录
        $layDom.on("click", btn_wx_login, function () {
            _wxLogin.init(jumpType);
        });
        //打开QQ登录
        $layDom.on("click", btn_qq_login, function () {
            _qqLogin.init();
        });

    }
    //js校验账号
    function checkPhoneJs() {
        var $acct = $layDom.find(txtAccount);
        var account = $.trim($acct.val());
        if (!fy.isPhone(account)) {
            fy.msg("请输入正确的手机号码");
            return false;
        }
        else {

        }
        return true;

    }
    //校验密码的复杂度 
    function checkPwdJs() {
        var $pwd = $layDom.find(txtPassword);
        var pwd = $.trim($pwd.val());
        var msg = "";
        if (!pwd) {
            msg = '请输入密码';
        }
        else if (pwd.length < 8 || pwd.length > 20) {
            msg = '8-20位字母+数字组成，字母区分大小写';
        }
        else if (!/[a-zA-Z]/.test(pwd)) {
            msg = '密码必须包含字母';
        }
        else if (!/[0-9]/.test(pwd)) {
            msg = '密码必须包含数字';
        }
        if (msg) {
            fy.msg(msg);
            return false;
        } else {
            fy.msg("密码输入正确");
            return true;
        }
    }
    //js校验验证码
    function checkSmsCodeJs() {
        var $verCode = $layDom.find(txtSmsYzm), msg = '';
        var verifyCode = $.trim($verCode.val());
        if (!verifyCode) {
            msg = '请输入验证码';
        } else if (verifyCode.length < 4) {
            msg = '请输入正确的验证码';
        }

        if (msg) {
            fy.msg(msg);
            return false;
        } else {
            return true;
        }
    }

    //发送注册 短信验证码 
    function sendSMSCode(imgYzmCode) {

        var $btn = $layDom.find(btnSendValidateCode);
        var phone = $.trim($layDom.find(txtAccount).val());
        var p = new Promise(function (resolve, reject) {

            $btn.attr("disabled", "disabled");
            $.post("/ajax/LoginHandler.ashx", {
                action: "SendRegisterSMS",
                phone: phone,
                yzmCode: imgYzmCode
            }).done(function (result) {
                _imgVerify.refresh();

                if (result.code == 1) {

                    fy.msg('验证码已发送到手机,5分钟内有效');
                    //smsNum++; 
                    //if (smsNum > 1) {
                    //    _form2.showSuc($btn, '验证码已发送到手机,5分钟内有效');
                    //}
                    //else {
                    //    _form2.showSuc($btn, '验证码已发送到手机,5分钟内有效<a target="_blank" style=" color: #9b9b9c;    margin-left: 20px; "  href="https://help.fy35.com/helpdetail51.html">收不到验证码？</a>');
                    //}
                    //发送成功
                    _timeController.goTime($btn);
                    //if (typeof callbackSuc == 'function') {
                    //    callbackSuc();
                    //}

                    resolve('成功') // 数据处理完成
                }
                else {
                    $btn.val('重新获取').removeAttr('disabled');
                    fy.msg(result.msg);
                    if (result.code == 1001) {
                        imgVerify.show();
                    }
                    else {
                        reject('失败') // 数据处理出错
                    }
                }

            }).fail(function () {
                imgVerify.refresh();
                fy.msg('发送短信失败，系统繁忙');
                //_form2.showErr($btn, '发送短信失败，系统繁忙');
                //if (typeof callbackErr == 'function') {
                //    callbackErr("系统繁忙");
                //}
                $btn.val('重新获取').removeAttr('disabled');
                reject('失败') // 数据处理出错
            });

        });
        return p;
    }


    //提交注册信息
    function goReg() {
        var isAccept = $layDom.find(chkAccept).prop("checked");
        if (!isAccept) {
            fy.msg("您尚未同意服务条款");
            return false;
        }
        //检查账号 
        if (!checkPhoneJs()) {
            $layDom.find(txtAccount).focus();
            return false;
        }
        if (!checkPwdJs()) {
            $layDom.find(txtPassword).focus();
            return false;
        }

        if (!checkSmsCodeJs()) {
            $layDom.find(txtSmsYzm).focus();
            return false;
        }

        var mobile = $.trim($(txtAccount).val());
        var password = $.trim($(txtPassword).val());
        var smsYzm = $.trim($layDom.find(txtSmsYzm).val());
        var $btn = $layDom.find(btn_register);
        $btn.attr("disabled", "disabled");
        var _layerWaiting = fy.showWaiting("正在为您注册账号，请稍等...");
        $.post("/ajax/LoginHandler.ashx", { action: "Register", phone: mobile, password: password, smsYzm: smsYzm }).done(function (result) {

            if (result.code == 1) {
                fy.msg(result.msg);
                if (jumpType == 1) {
                    fy.delayRefreshPage(); 
                }
                else {
                    //fy.msg(result.msg);
                    //layer.close(layerIndex);
                    window.location.href = "/super/index.aspx";
                }

            } else {

                msg = result.msg;
                fy.msg(msg);
                layer.close(_layerWaiting);
                $layDom.find(txtSmsYzm).val("");
                $btn.removeAttr('disabled');
            }
        }).fail(function () {

            fy.msg(msg);
            layer.close(_layerWaiting);
            $btn.removeAttr('disabled');
        });
    }

    return {
        init: init,
        sendSMSCode: sendSMSCode
    }

})();

/*定时器*/
var _timeController = {
    timer: null,
    second: 59,
    clickCount: 0,
    goTime: function ($btn) {
        var self = this;
        clearInterval(self.timer);
        self.second = 59;
        $btn.val('已发送(' + self.second + ')');

        self.timer = setInterval(function () {
            if (self.second > 0) {
                $btn.val('已发送(' + self.second + ')');
                self.second--;
            } else {
                $btn.val('重新获取').removeAttr('disabled');
                clearInterval(self.timer);
                self.timer = null;
            }

        }, 1000);
    },
    stop: function () {
        var self = this;
        clearInterval(self.timer);
    }
};

/*弹窗 图片验证码*/
var _imgVerify = (function () {
    var
        $layDom = null,
        layerIndex = null,
        imgValidateCode = '.imgValidateCode',
        txtValidateCode = '.txtValidateCode',
        btnConfirmSend = '.btnConfirmSend',
        refreshBtn = '.refreshBtn',
        v = "1.0";
    function show() {
        var domHtml = _tpl.getImgverifyHtml();
        layer.open({
            type: 1,
            title: "请先完成下方验证",
            area: ['500px', '300px'], //宽高
            content: domHtml,
            success: function (layero, index) {
                $layDom = $(layero);
                layerIndex = index;

                refresh();
                bindEvent();
                $layDom.find(txtValidateCode).focus();
            },
            cancel: function (index, layero) {
                layer.close(index);
                return false;
            }
        });
    }

    function refresh() {
        $layDom.find(imgValidateCode).attr('src', '/ValidateCode.aspx?type=1&r=' + parseInt(Math.random() * 1000));
        $layDom.find(imgValidateCode).val("");
        $layDom.find(imgValidateCode).focus();
    };

    function checkVerifyCodeJs(code) {

        var msg = null;

        if (!code) {
            msg = '请输入图片验证码';
        } else if (code.length != 4) {
            msg = '请输入正确的图片验证码';
        }
        if (msg) {
            fy.msg(msg);
            return false;
        } else {
            return true;
        }
    }

    function bindEvent() {

        //点击图片
        $layDom.find(imgValidateCode).click(refresh);
        //换一张
        $layDom.find(refreshBtn).click(refresh);

        $layDom.find(txtValidateCode).keydown(function (event) {
            if (event.keyCode == 13 || event.which == 13) {
                event.preventDefault();
                event.stopPropagation();
                next();
            }
        });

        //提交
        $layDom.find(btnConfirmSend).click(function () {
            next();
        });

    }
    //校验图片验证码
    function next() {
        var $btn = $layDom.find(btnConfirmSend);
        var $txtValidateCode = $layDom.find(txtValidateCode);
        var code = $.trim($txtValidateCode.val());

        if (checkVerifyCodeJs(code)) {
            var code = $.trim($layDom.find(txtValidateCode).val());
            //$btn.attr('disabled', 'disabled');

            _register.sendSMSCode(code).then(
                (res) => {
                    layer.close(layerIndex);
                    //$btn.removeAttr('disabled');
                }, (err) => {
                    //$btn.removeAttr('disabled');
                })

        }
        else {
            $layDom.find(txtValidateCode).val("")
            $txtValidateCode.focus();
        }
    }

    return {
        refresh: refresh,
        show: show
    }
})();


/*微信二维码登录*/
var _wxLogin = (function () {
    var imgCode = "#imgCode",
        ercode = '.ercode',
        sxbox = '.sxbox',
        sxboxhtml = '<div class="sxbox"><div><p>二维码失效</p><p>请点击刷新</p></div>',
        key = null,
        $layDom = null,
        layerIndex = null,
        timeNum = 0,//事件次数
        hdnReturnUrl = "#hdnReturnUrl",
        jumpType = 0,//是否跳转到管理页面 0:管理页  1当前页刷新
        v = "1.0";

    function init(_jumpType) {
        jumpType = _jumpType || 0;
        var domHtml = _tpl.getWxloginHtml();
        layer.open({
            type: 1,
            title: "微信登录",
            area: ['400px', '350px'], //宽高
            content: domHtml,
            success: function (layero, index) {
                $layDom = $(layero), layerIndex = index;
                createWxQrCode();//创建一个微信二维码  
            },
            cancel: function (index, layero) {
                timeNum = 0;
                layer.close(index);
                return false;
            }
        });
    }
    //创建一个微信二维码
    function createWxQrCode() {
        $.post("/ajax/WeixinHandler.ashx", { action: "GetWXLoginQrCode" }).done(function (result) {
            if (result.code == 1) {
                key = result.data.key;
                $layDom.find(imgCode).attr("src", result.data.url);
                //刷新任务
                timeNum = 30;
                refreshTask();
            } else {
                fy.alert(result.msg);
            }
        }).fail(function () {
            fy.alert("系统繁忙，请稍后再试");
        });
    }
    function refreshTask() {

        setTimeout(function () {
            timeNum--;
            if (timeNum > 0) {
                refreshQrCodeState();
            }
            else {
                //ie8不兼容样式写法 改为图片失效模式
                var $imgCode = $layDom.find(imgCode);
                $imgCode.attr("src", "/img/sxercode.png");
                $imgCode.css("cursor", "pointer");
                $imgCode.click(function () {
                    createWxQrCode();
                    $imgCode.unbind("click");
                    $imgCode.css("cursor", "inherit");
                })
                //显示刷新二维码
                //$(layero).find(ercode).append(sxboxhtml);
                //var $sxbox = $(layero).find(sxbox);
                //$sxbox.click(function () {
                //    createWxQrCode();
                //    $sxbox.remove();
                //})
            }

        }, 1500);
    }
    //启动刷新
    function refreshQrCodeState() {
        console.log("刷新登录状态");
        $.post("/ajax/WeixinHandler.ashx", { action: "GetWXLoginQrCodeState", key: key }).done(function (result) {
            if (result.code == 1) {

                if (jumpType == 1) {
                    window.location.reload();
                }
                else {
                    window.location.href = "/super/index.aspx";
                }

            }
            else {
                refreshTask();
                //alert(result.msg);
            }
        })
    }

    return {
        init: init
    }

})();

var _qqLogin = function () {

    function init() {
        var name;
        var iWidth = "900";
        var iHeight = "600";
        //获得窗口的垂直位置 
        var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
        //获得窗口的水平位置 
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;

        window.open(_manageUrl + '/ThreeLogin/QQLogin.aspx?type=1&urlType=1', name, 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');

        //window.open(_manageUrl + '/callback/QQ_CallBack.aspx?code=1&urlType=1', name, 'height=' + iHeight + ',innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
    }
    return {
        init: init
    }
}();

/*当前页面 绑定事件*/
$(function () {

    //去退出
    function goQuit() {
        var _layerWaiting = fy.showWaiting("正在退出...");
        $.post(_apiUrl + "/ajax/LoginHandler.ashx", {
            action: "Quit"
        }).done(function (result) {
            if (result.code == 1) {
                fy.msg("退出成功");
                fy.delayRefreshPage();
            } else {
                fy.alert(result.msg);
                layer.close(_layerWaiting);
            }
        }).fail(function (ex) {
            fy.alert('系统繁忙');
            layer.close(_layerWaiting);
        });
    }

    //退出
    $(document).on("click", ".btn_a_quit", function () {
        goQuit();
    });
    //点击 登录按钮
    $(document).on("click", ".btn_a_login", function () {

        _login.init(1);

    });

    //点击 注册按钮
    $(document).on("click", ".btn_a_register", function () {

        _register.init(1);

    });

})