bklLiudl
2024-07-23 277bbae216debe7e6c04e8cc6ee6e1ba9763e14b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
$(document).ready(function () {
    $("#txt_account").keydown(function (e) {
        if (e.which == 13) {
            $("#txt_password").focus();
        }
    });
 
    $("#txt_code").keydown(function (e) {
        if (e.which == 13) {
            User.Login();
        }
    });
 
    $("#txt_password").keydown(function (e) {
        if (e.which == 13) {
            User.Login();
        }
    });
 
    $("#login_button").click(function () {
        User.Login();
    });
 
    $("#imgcode").click(function () {
        User.imgcode();
    });
 
    User.init();
    User.imgcode();
});
 
var User = {
    formMessage: function (msg) {
        $('.login_tips').find('.tips_msg').remove();
        $('.login_tips').append('<div class="tips_msg"><i class="icon-spinner"></i>' + msg + '</div>');
    },
    Login: function () {
        var username = $("#txt_account");
        var password = $("#txt_password");
        var code = $("#txt_code");
        if (username.val() == "") {
            username.focus();
            User.formMessage('请输入用户名/手机号/邮箱。');
            return false;
        } else if (password.val() == "") {
            password.focus();
            User.formMessage('请输入登录密码。');
            return false;
        }
        // liudl 注释 暂停验证码功能
        //else if (code.val() == "") {
        //    code.focus();
        //    User.formMessage('请输入验证码。');
        //    return false;
        //}
        else {
            $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
            $.ajax({
                url: "/Login/CheckLogin",
                data: { username: $.trim(username.val()), password: $.trim(password.val()), code: $.trim(code.val()) },
                type: "post",
                dataType: "json",
                success: function (data) {
                    if (data.state == "success") {
                        $("#login_button").find('span').html("登录成功,正在跳转...");
                        window.setTimeout(function () {
                            var url = $("#hdUrl").val();
                            if (url == undefined || url == "")
                                window.location.href = "/Home/Index";
                            else
                                window.location.href = url;
                        }, 500);
                    } else {
                        $("#login_button").removeAttr('disabled').find('span').html("登录");
                        User.imgcode();
                        code.val('');
                        User.formMessage(data.message);
                    }
                }
            });
        }
    },
    init: function () {
        $('.wrapper').height($(window).height());
        $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
        $(".logo").css("padding-left", ($(".logo").width() - ($("#logoId").width() + $("#logoName").width())) / 2 + 10);
        $(window).resize(function (e) {
            $('.wrapper').height($(window).height());
            $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
            $(".logo").css("padding-left", ($(".logo").width() - ($("#logoId").width() + $("#logoName").width())) / 2 + 10);
        });
 
        $("#txt_account").focus();
    },
    imgcode: function () {
        $("#imgcode").attr("src", "/Login/GetAuthCode?time=" + Math.random());
    }
}