|
|
<!DOCTYPE html>
|
|
|
<html lang="zh-CN">
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
<title>${uSystem.applicationName}登录页面</title>
|
|
|
<link rel="stylesheet" type="text/css" href="${ctxPath}/plugins/layui/css/layui.css?v=${jsVer}" media="all"/>
|
|
|
<link rel="stylesheet" media="screen" href="${ctxPath}/plugins/login/css/login.css">
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
<div class="layui-row" style="background-image: url('${ctxPath}/plugins/login/img/login_bg.png');position: fixed;width: 100%;height: 100%;background-size: 100% 100%;">
|
|
|
<!--#if(uSystem.subsystemIndexLogo == null || uSystem.subsystemIndexLogo == ''){-->
|
|
|
<img src="${ctxPath}/plugins/login/img/logo_mr.png" style="position: absolute;top: 40px;left: 40px;height: 5vh;">
|
|
|
<!--#}else{-->
|
|
|
<img src="${ctxPath}${uSystem.subsystemIndexLogo}" style="position: absolute;top: 40px;left: 40px;height: 5vh;">
|
|
|
<!--#}-->
|
|
|
<img src="${ctxPath}/plugins/login/img/BG-icon@2x.png" style="position: absolute;width: 40vw;top: 20%;left: 10%;">
|
|
|
<div class="layui-row" style="margin: 0 auto;max-width: 1920px;min-width: 1200px;position: relative;height: 600px;">
|
|
|
<div class="login" id="user_login">
|
|
|
<div class="layui-form-item name">
|
|
|
<h1 style="text-align: center;padding: 50px 0 30px;">用户登录</h1>
|
|
|
</div>
|
|
|
<div class="layui-form-item name">
|
|
|
<div class="layui-input-block code">
|
|
|
<i class="layui-icon layui-icon-username icon"></i>
|
|
|
<input type="text" name="code" placeholder="账号" autocomplete="off" class="layui-input n">
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-form-item name">
|
|
|
<div class="layui-input-block">
|
|
|
<i class="layui-icon layui-icon-password icon"></i>
|
|
|
<input type="password" name="password" placeholder="密码" autocomplete="off" class="layui-input w">
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-form-item dl" style="margin-top: 50px;">
|
|
|
<div class="layui-input-block">
|
|
|
<button type="button" class="layui-btn layui-btn-fluid buttonSubmit font-semibold">登 录</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<script type="text/javascript" src="${ctxPath}/plugins/jquery/jquery.min.js"></script>
|
|
|
<script src="${ctxPath}/plugins/layui/layui.js"></script>
|
|
|
<script>
|
|
|
var name = localStorage.getItem("code");//获取缓存中的用户名
|
|
|
if(!isEmpty(name)){
|
|
|
$(".login input[name=code]").val(name);
|
|
|
$(".login input[name=password]").focus();
|
|
|
}else {
|
|
|
$(".login input[name=code]").focus();
|
|
|
}
|
|
|
|
|
|
var layer;
|
|
|
layui.use('layer', function(){
|
|
|
layer = layui.layer;
|
|
|
});
|
|
|
|
|
|
$(document).keyup(function(event){
|
|
|
if(event.keyCode ==13){
|
|
|
var code = $(".login input[name=code]").val();
|
|
|
var password = $(".login input[name=password]").val();
|
|
|
if(!isEmpty(code) && !isEmpty(password)){
|
|
|
submitForm();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//绑定登录按钮
|
|
|
$(".font-semibold").click(function (){
|
|
|
submitForm();
|
|
|
});
|
|
|
|
|
|
//提交登录
|
|
|
function submitForm(){
|
|
|
var code = $(".login input[name=code]").val();
|
|
|
var password = $(".login input[name=password]").val();
|
|
|
var sign = getUrlParam("_sign");//获取地址参数 用于在之后请求中添加该数据
|
|
|
var type = getUrlParam("type");
|
|
|
var typeId = getUrlParam("typeId");
|
|
|
if(isEmpty(sign)){
|
|
|
sign = localStorage.getItem("_sign");
|
|
|
}
|
|
|
if(isEmpty(code)){
|
|
|
layer.msg("请输入用户名!");
|
|
|
$(".login input[name=code]").focus();
|
|
|
return;
|
|
|
}
|
|
|
if(isEmpty(password)){
|
|
|
layer.msg("请输入密码!");
|
|
|
$(".login input[name=password]").focus();
|
|
|
return;
|
|
|
}
|
|
|
$.ajax({
|
|
|
url: "${ctxPath}/login.json",
|
|
|
type: "POST",
|
|
|
dataType : "json",
|
|
|
data: {code:code,password:password,sign:sign,type:'${uSystem.type}',typeId:'${uSystem.typeId}'},
|
|
|
success:function (rsp) {
|
|
|
if(rsp.code == 0){
|
|
|
localStorage.setItem("code",code);//将用户名存入缓存中
|
|
|
|
|
|
// 默认清空,所有的sessionToken
|
|
|
for (let key of Object.keys(rsp.data)) {
|
|
|
// key 长得像 {}_{}_{}_TOKEN
|
|
|
//将用户名Token存入缓存中
|
|
|
if (key.toUpperCase().endsWith("_TOKEN")) {
|
|
|
sessionStorage.removeItem(key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var keyIdOrToken = '', tokenKey = ''
|
|
|
for (let key of Object.keys(rsp.data)) {
|
|
|
// key 长得像 {}_{}_{}_TOKEN
|
|
|
//将用户名Token存入缓存中
|
|
|
if (key.toUpperCase().endsWith("_TOKEN")) {
|
|
|
keyIdOrToken = rsp.data[key];
|
|
|
tokenKey = key;
|
|
|
sessionStorage.setItem(key, keyIdOrToken);
|
|
|
sessionStorage.setItem("TOKEN_KEY", tokenKey);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 跳转至PC端
|
|
|
window.location.href = "${ctxPath}/index.do?key_id=" + keyIdOrToken;
|
|
|
}else {
|
|
|
layer.msg(rsp.msg);
|
|
|
return;
|
|
|
}
|
|
|
},error:function({responseJSON: rsp}) {
|
|
|
layer.msg(rsp.msg || "网络连接失败");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//非空验证
|
|
|
function isEmpty(value) {
|
|
|
if(value == "" || value == undefined || value == "undefined" | value == "[]" || value == null || value == "null"){
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//判断是否是手机
|
|
|
function IsMobile() {
|
|
|
var isMobile = {
|
|
|
Android: function () {
|
|
|
return navigator.userAgent.match(/Android/i) ? true : false;
|
|
|
},
|
|
|
BlackBerry: function () {
|
|
|
return navigator.userAgent.match(/BlackBerry/i) ? true : false;
|
|
|
},
|
|
|
iOS: function () {
|
|
|
return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
|
|
|
},
|
|
|
Windows: function () {
|
|
|
return navigator.userAgent.match(/IEMobile/i) ? true : false;
|
|
|
},
|
|
|
any: function () {
|
|
|
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return isMobile.any(); //是移动设备
|
|
|
}
|
|
|
|
|
|
//获取url中的参数
|
|
|
function getUrlParam(name) {
|
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
|
|
var r = window.location.search.substr(1).match(reg); //匹配目标参数
|
|
|
if (r != null) return unescape(r[2]); return null; //返回参数值
|
|
|
}
|
|
|
|
|
|
//判断是否是IE并且IE版本
|
|
|
function IEVersion() {
|
|
|
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
|
|
|
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
|
|
|
var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
|
|
|
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
|
|
|
if(isIE) {
|
|
|
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
|
|
|
reIE.test(userAgent);
|
|
|
var fIEVersion = parseFloat(RegExp["$1"]);
|
|
|
if(fIEVersion == 7) {
|
|
|
return 7;
|
|
|
} else if(fIEVersion == 8) {
|
|
|
return 8;
|
|
|
} else if(fIEVersion == 9) {
|
|
|
return 9;
|
|
|
} else if(fIEVersion == 10) {
|
|
|
return 10;
|
|
|
} else {
|
|
|
return 6;//IE版本<=7
|
|
|
}
|
|
|
} else if(isEdge) {
|
|
|
return 'edge';//edge
|
|
|
} else if(isIE11) {
|
|
|
return 11; //IE11
|
|
|
}else{
|
|
|
return -1;//不是ie浏览器
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
</body>
|
|
|
</html> |