$(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);
|
}
|