zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
$(document).ready(function() {
    getCookie();
    onfocus();
    $(".on_off_checkbox").iphoneStyle();
    $('.tip a ').tipsy({
        gravity : 'sw'
    });
    $('#login').show().animate({
        opacity : 1
    }, 2000);
    $('.logo').show().animate({
        opacity : 1,
        top : '32%'
    }, 800, function() {
        $('.logo').show().delay(1200).animate({
            opacity : 1,
            top : '1%'
        }, 300, function() {
            $('.formLogin').animate({
                opacity : 1,
                left : '0'
            }, 300);
            $('.userbox').animate({
                opacity : 0
            }, 200).hide();
        });
    });
 
 
$('.userload').click(function(e) {
    $('.formLogin').animate({
        opacity : 1,
        left : '0'
    }, 300);
    $('.userbox').animate({
        opacity : 0
    }, 200, function() {
        $('.userbox').hide();
    });
});
// 重置
$('#forgetpass').click(function(e) {
    $('#userName,#password').val("");
});
// 点击登录
$('#but_login').click(function(e) {
    submit();
});
//回车登录
$(document).keydown(function(e){
    if(e.keyCode == 13) {
        submit();
    }
});
 
$('#Kaptcha').click(
        function() {
           $(this).hide().attr('src','Kaptcha.jpg?' + Math.floor(Math.random() * 100)).fadeIn();
    });
});
//表单提交
function submit()
{
    var submit = true;
    $("input[nullmsg]").each(function() {
        if ($("#" + this.name).val() == "") {
            showError($("#" + this.name).attr("nullmsg"), 500);
            jrumble();
            setTimeout('hideTop()', 1000);
            submit = false;
            return false;
        }
    });
    if (submit) {
        hideTop();
        loading('登录中..', 1);
        setTimeout("unloading()", 1000);
        setTimeout("Login()", 1000);
    }
 
}
//登录处理函数
function Login() {
    setCookie();
    var actionurl=$('form').attr('action');//提交路径
    $.ajax({
        async : false,
        cache : false,
        type : 'POST',
        dataType:"JSON",
        url : actionurl,// 请求的action路径
        data : {
            "loginName" : document.getElementById("userName").value,
            "pwd" : document.getElementById("password").value
        },
        error : function(data) {// 请求失败处理函数
            alert();
        },
        success : function(data) {
            //var d = $.parseJSON(data);
            if (data.success) {
                loginsuccess();
                var pathName=window.document.location.pathname;
                //获取带"/"的项目名,如:/Tmall
                $.basePath=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
                setTimeout("window.location.href='"+$.basePath+"/pms/sysUser/index.do'", 1000);
            } else {
                showError(data.msg);
            }
        }
    });
}
//设置cookie
function setCookie()
{
 
    if ($('#on_off').val() == '1') {
 
        /*$("input[iscookie='true']").each(function() {
            $.cookie(this.name, $("#"+this.name).val(), "/",24);
            $.cookie("COOKIE_NAME","true", "/",24);
        });*/
        localStorage.setItem("loginName",document.getElementById("userName").value);
    } else {
        /*$("input[iscookie='true']").each(function() {
            $.cookie(this.name,null);
            $.cookie("COOKIE_NAME",null);
        });*/
        localStorage.removeItem("loginName");
    }
}
//读取cookie
function getCookie()
{
    /*var COOKIE_NAME=$.cookie("COOKIE_NAME");
    if (COOKIE_NAME !=null) {
        $("input[iscookie='true']").each(function() {
            $($("#"+this.name).val( $.cookie(this.name)));
        });
        $("#on_off").attr("checked", true);
        $("#on_off").val("1");
    }
    else
    {
        $("#on_off").attr("checked", false);
        $("#on_off").val("0");
    }*/
 
    var username = localStorage.getItem("loginName");
    if (username!=undefined) {
        $("#userName").val(username);
        $("#on_off").attr("checked", true);
        $("#on_off").val("1");
    }else{
        $("#on_off").attr("checked", false);
        $("#on_off").val("0");
    }
 
}
//点击消息关闭提示
$('#alertMessage').click(function() {
    hideTop();
});
//显示错误提示
function showError(str) {
    $('#alertMessage').addClass('error').html(str).stop(true, true).show().animate({
        opacity : 1,
        right : '0'
    }, 500);
 
}
//验证通过加载动画
function loginsuccess()
{
    $("#login").animate({
        opacity : 1,
        top : '40%'
    }, 200, function() {
        $('.userbox').show().animate({
            opacity : 1
        }, 500);
        $("#login").animate({
            opacity : 0,
            top : '60%'
        }, 500, function() {
            $(this).fadeOut(200, function() {
                $(".text_success").slideDown();
                $("#successLogin").animate({
                    opacity : 1,
                    height : "200px"
                }, 1000);
            });
        });
    });
}
function showSuccess(str) {
    $('#alertMessage').removeClass('error').html(str).stop(true, true).show().animate({
        opacity : 1,
        right : '0'
    }, 500);
}
 
function onfocus() {
    if ($(window).width() > 480) {
        $('.tip input').tipsy({
            trigger : 'focus',
            gravity : 'w',
            live : true
        });
    } else {
        $('.tip input').tipsy("hide");
    }
}
 
function hideTop() {
    $('#alertMessage').animate({
        opacity : 0,
        right : '-20'
    }, 500, function() {
        $(this).hide();
    });
}
//加载信息
function loading(name, overlay) {
    $('body').append('<div id="overlay"></div><div id="preloader">' + name + '..</div>');
    if (overlay == 1) {
        $('#overlay').css('opacity', 0.1).fadeIn(function() {
            $('#preloader').fadeIn();
        });
        return false;
    }
    $('#preloader').fadeIn();
}
 
function unloading() {
    $('#preloader').fadeOut('fast', function() {
        $('#overlay').fadeOut();
    });
}
// 表单晃动
function jrumble() {
    $('.inner').jrumble({
        x : 4,
        y : 0,
        rotation : 0
    });
    $('.inner').trigger('startRumble');
    setTimeout('$(".inner").trigger("stopRumble")', 500);
}