<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>CRM用户登录</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="<%=basePath%>resource/js/CheckForm.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
var errori ='<%=request.getParameter("error")%>'
if(errori=='yes'){
alert("用户或密码错误!请重新输入!");
}
</script>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #016aa9;
overflow:hidden;
}
.STYLE1 {
color: #000000;
font-size: 12px;
}
#in1{
background-image: url('<%=basePath%>resource/images/dl.gif');
height:18px;
width:49px;
border: 0px;
}
</style>
<script type="text/javascript">
//function isNumberOrLetter( s ){//判断是否是数字或字母
//var regu = "^[0-9a-zA-Z]+$";
//var re = new RegExp(regu);
//if (re.test(s)) {
// return true;
//}else{ q
// alert("账号只能是字母或数字!");
//return false;
//}
//}
</script>
<script language="JavaScript" type="text/javascript" src="<%=basePath%>resource/js/FormValid.js"></script>
</head>
<body οnlοad="checkCookie()">
<form name="from1" method ="post" οnsubmit="return validator(this)" >
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="962" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="235" background="<%=basePath%>resource/images/login_03.gif"> </td>
</tr>
<tr>
<td height="53"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="394" height="53" background="<%=basePath%>resource/images/login_05.gif"> </td>
<td width="206" background="<%=basePath%>resource/images/login_06.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="16%" height="25"><div align="right"><span class="STYLE1">用户</span></div></td>
<td width="57%" height="25">
<div align="center">
<input type="text" id="userNum" name="userNum" valid="required|regexp" regexp="^[A-Za-z0-9]+$"
errmsg="用户名不能为空!|账号只能由字母和数字组成!" style="width:105px; height:17px; background-color:#292929;
border:solid 1px #7dbad7; font-size:12px; color:#6cd0ff"
placeholder="请输入用户名"
>
</div>
</td>
<td width="27%" height="25"> </td>
</tr>
<tr>
<td height="25"><div align="right"><span class="STYLE1">密码</span></div></td>
<td height="25">
<div align="center">
<input type="password" id="userPwd" name="userPw" valid="required" errmsg="密码不能为空!"
style="width:105px; height:17px; background-color:#292929; border:solid 1px #7dbad7; font-size:12px; color:#6cd0ff"
placeholder="请输入密码"
>
</div>
</td>
<td height="25"><div align="left"><input type="submit" id="in1" value="" οnclick="login()"/></div></td>
</tr>
<tr>
<td height="25"><div align="right"><span class="STYLE1"></span></div></td>
<td height="25" >
<div align="right" style="font-size:10px;height:17px;width:100px" >
<input type="checkbox" id="rembInfo" style="font-size:10px;height:17px;" οnclick="saneInfo()" checked="true" /> 记住我
</div>
</td>
<td>
<input type="reset" value="重置" />
</td>
</tr>
</table>
</td>
<td width="362" background="<%=basePath%>resource/images/login_07.gif"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="213" background="<%=basePath%>resource/images/login_08.gif"></td>
</tr>
</table></td>
</tr>
</table>
</form>
<script type="text/javascript">
//login
function login(){
alert("login");
var userName=$("#userName").val();
var userPwd=$("#userPwd").val();
//$("#userNum").val(getCookie("username"));
//setCookie('username','jun',"userPwd",'1',new Date().getTime()+30*60*1000);
setCookie('userInfo',userName+";userPwd="+userPwd,new Date().getTime()+30*60*1000);
}
//
function getCookie(userInfo)
{
alert('getCookie:'+c_name);
//方法一:
if (document.cookie.length>0)
{
alert('cookie is not null');
c_start=document.cookie.indexOf(userInfo + "=");
if (c_start!=-1)
{
alert('getCookie2.');
c_start=c_start + userInfo.length+1;
c_end=document.cookie.indexOf(";",c_start);
}
if (c_end==-1) {
alert('getCookie3.');
c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
/*//方法二:
var cookieList=document.cookies.split(";");
//解析名/值
for(var i=0;i<cookieList.length;i++){
var arr=cookieList.split("=");
if(arr[0]=c_name){
return decodeURIComponent(arr[1]);
}
}
*/
alert('cookie is null');
return ""
}
function setCookie(userInfo,value,expiredays)
{
alert('setCookie.');
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=userInfo+ "=" +escape(value) +
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
function checkCookie()
{
alert('加载中。。。')
username=getCookie('username');
alert("username:"+username);
if (username!=null && username!="")
{
alert('欢迎 '+username+' 再次登录!')
//设置用户信息
$("#userNum").val(getCookie("userName")[2]);
$("#userPwd").val(getCookie("userPwd")[4]);
}
else
{
username=prompt('Please enter your name:',"");
//setCookie('username','jun',new Date().getTime()+30*60*1000);
}
}
</script>
</body>
</html>