cookiesRemember.js
cookiesRemember.js----结尾
user-login.jsp
<script type=text/javascript>
$(function(){
GetLastUser();
});
//登录
function login(){
var name = $("#user_name").val();
var password = $("#user_password").val();
var newUrl = "${url}";
if(name == "" || password == ""){
window.wxc.xcConfirm(‘用户名和密码不能为空‘, window.wxc.xcConfirm.typeEnum.info);
return;
}
var params = {
"name" : name,
"password" : password
};
//将最后一个用户信息写入到Cookie
SetLastUser(name);
if(!$("#checkboxLogin").attr("checked")==false){
alert("你选择了记住密码,我们将记住你的密码:"+password);
var expdate = new Date();
expdate.setTime(expdate.getTime() + 14 * (24 * 60 * 60 * 1000));
//将用户名和密码写入到Cookie
SetCookie(name,password, expdate);
}
else {
//如果没有选中记住密码,则立即过期
ResetCookie();
}
$.ajax({
type: "POST",
timeout: 20000,
url: ‘<%=request.getContextPath()%>/user/passport/login‘,
data: params,
dataType:"json",
success: function (data) {
if(data.returnCode == 0){
if(newUrl != null && newUrl != ""){
window.location.href = "<%=request.getContextPath()%>"+"/"+newUrl;
} else {
window.location.href = "<%=request.getContextPath()%>/user/zonglan";
}
}else{
window.wxc.xcConfirm(data.returnMsg, window.wxc.xcConfirm.typeEnum.error);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
if(textStatus == ‘timeout‘){
window.wxc.xcConfirm(‘请求超时‘, window.wxc.xcConfirm.typeEnum.error);
}else{
window.wxc.xcConfirm(‘连接异常‘, window.wxc.xcConfirm.typeEnum.error);
}
},
complete: function(xhr, ts){
}
});
}
</script>
<input type="text" placeholder="请输入手机号/邮箱" class="login_int" id="user_name" onblur="GetPwdAndChk()" >
<input type="password" placeholder="请输入密码" class="login_int" id="user_password">
<a href="javascript:void(0);" onclick="login();">立即登录</a>
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/a86852712/article/details/47318543