<!DOCTYPE html>
|
<html lang="en">
|
<head>
|
<meta charset="UTF-8">
|
<title>系统登录</title>
|
<link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
|
<link rel="icon" type="image/x-icon" href="../static/images/wcs_logo.png" />
|
<link rel="stylesheet" href="../static/css/animate.min.css">
|
<script type="text/javascript" src="../static/layui/layui.js"></script>
|
<script type="text/javascript" src="../static/js/common.js"></script>
|
<style>
|
html{
|
height: 100%;
|
}
|
body.login-bg {
|
color: #777;
|
height: 100%;
|
/*background-image: linear-gradient(to right, #ff9569 0%, #e92758 100%);*/
|
/*background-image: linear-gradient(-90deg, #a2e7f3 0%, #98baee 100%);*/
|
background-image: url("../static/images/login.png");
|
/*background: -webkit-linear-gradient(red, blue); !* Safari 5.1 - 6.0 *!;*/
|
/*background-image: url("../static/image/login_bg.jpg");*/
|
/*background-repeat: no-repeat;*/
|
/*background-size: cover;*/
|
/*background-position: top center;*/
|
}
|
|
#login-wrapper {
|
box-sizing:border-box;
|
background: #fff;
|
position: absolute;
|
top: 45%;
|
left: 50%;
|
margin-top: -210px;
|
margin-left: -220px;
|
width: 400px;
|
min-height: 380px;
|
padding: 50px;
|
text-align: center;
|
border-radius: 5px;
|
box-shadow: 0px 0px 10px rgb(168, 165, 165);
|
transform-origin: 50% 50%;
|
/*animation: loading 1s 0s forwards;*/
|
transform: rotateX(0deg);
|
}
|
|
#login-wrapper h2 {
|
color: rgba(64,158,255,0.9);
|
font-size: 26px;
|
font-weight: bold;
|
margin-bottom: 30px;
|
}
|
|
.layadmin-user-login-body .layui-form-item {
|
margin-bottom: 20px;
|
position: relative;
|
}
|
.layadmin-user-login-body .layui-form-item .layui-input {
|
height: 42px;
|
padding-left: 40px;
|
font-size: 16px;
|
border: 1px solid #c8cccf;
|
color: inherit;
|
}
|
.login-submit {
|
margin-top: 30px;
|
}
|
.layadmin-user-login-icon {
|
position: absolute;
|
left: 1px;
|
top: 1px;
|
width: 38px;
|
line-height: 40px;
|
text-align: center;
|
color: #B2B2B2;
|
font-size: 18px;
|
}
|
.layui-btn-normal {
|
background-color: rgba(64,158,255,0.9);
|
font-size: 20px;
|
border-radius: 4px;
|
height: 52px;
|
}
|
.login-lang {
|
position: fixed;
|
top: 20px;
|
right: 24px;
|
z-index: 2;
|
}
|
.login-lang select {
|
min-width: 140px;
|
height: 34px;
|
padding: 0 10px;
|
border: 1px solid #d6dbe6;
|
border-radius: 17px;
|
background: rgba(255, 255, 255, 0.92);
|
color: #3b4a5a;
|
outline: none;
|
}
|
</style>
|
</head>
|
<body class="login-bg animsition">
|
|
<div class="login-lang">
|
<select id="lang-switch" aria-label="Language"></select>
|
</div>
|
<div id="login-wrapper" class="animate__animated animate__bounceInDown">
|
<header>
|
<h2 id="login-title" data-i18n-key="login.title" style="cursor: pointer; user-select: none;">WCS系统V3.0</h2>
|
</header>
|
<div class="layui-form layadmin-user-login-body">
|
<div class="layui-form-item">
|
<label class="layui-icon layui-icon-cellphone layadmin-user-login-icon"></label>
|
<input id="mobile" class="layui-input" type="text" name="mobile" lay-verify="mobile" data-i18n-placeholder-key="login.username" placeholder="账号">
|
</div>
|
<div class="layui-form-item">
|
<label class="layui-icon layui-icon-password layadmin-user-login-icon"></label>
|
<input id="password" class="layui-input" type="password" name="password" lay-verify="password" data-i18n-placeholder-key="login.password" placeholder="密码">
|
</div>
|
</div>
|
<div class="layui-form-item login-submit">
|
<button id="login-button" data-i18n-key="login.submit" class="layui-btn layui-btn-fluid layui-btn-normal" lay-submit="" lay-filter="login">登     录</button>
|
</div>
|
</div>
|
<div id="system-tools-panel" style="display: none; padding: 20px;">
|
<div style="margin-bottom: 18px;">
|
<div data-i18n-key="login.tools.recommended" style="margin-bottom: 10px; color: #666; font-weight: 600;">推荐操作</div>
|
<div style="display: flex; flex-wrap: wrap; gap: 12px;">
|
<button data-i18n-key="login.tools.requestCode" class="layui-btn layui-btn-normal layui-btn-sm" id="btn-request-code">获取请求码</button>
|
<button data-i18n-key="login.tools.activate" class="layui-btn layui-btn-normal layui-btn-sm" id="btn-activate">一键激活</button>
|
</div>
|
<div data-i18n-key="login.tools.recommendedDesc" style="margin-top: 8px; color: #999; font-size: 12px;">优先使用“获取请求码”和“一键激活”完成许可证申请与激活。</div>
|
</div>
|
<div>
|
<div data-i18n-key="login.tools.others" style="margin-bottom: 10px; color: #666; font-weight: 600;">其他工具</div>
|
<div style="display: flex; flex-wrap: wrap; gap: 12px;">
|
<button data-i18n-key="login.tools.projectName" class="layui-btn layui-btn-primary layui-btn-sm" id="btn-project-name">获取项目名称</button>
|
<button data-i18n-key="login.tools.serverInfo" class="layui-btn layui-btn-primary layui-btn-sm" id="btn-server-info">获取系统配置</button>
|
<button data-i18n-key="login.tools.uploadLicense" class="layui-btn layui-btn-primary layui-btn-sm" id="btn-upload-license">录入许可证</button>
|
</div>
|
</div>
|
</div>
|
|
</body>
|
<script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
|
<script type="text/javascript" src="../static/js/tools/md5.js"></script>
|
<script type="text/javascript">
|
|
layui.use(['form','layer'],function () {
|
var form = layui.form,
|
layer = layui.layer,
|
$ = layui.jquery;
|
|
function initLanguageSwitch() {
|
WCS_I18N.onReady(function (i18n) {
|
var select = document.getElementById('lang-switch');
|
var options = i18n.getLocaleOptions();
|
var current = i18n.getLocale();
|
var html = '';
|
var i;
|
for (i = 0; i < options.length; i++) {
|
html += '<option value="' + options[i].tag + '"' + (options[i].tag === current ? ' selected' : '') + '>' + options[i].label + '</option>';
|
}
|
select.innerHTML = html;
|
select.onchange = function () {
|
i18n.setLocale(this.value);
|
};
|
document.title = i18n.t('login.title');
|
});
|
}
|
|
initLanguageSwitch();
|
|
// 连续点击三次标题显示隐藏功能
|
var titleClickCount = 0;
|
var titleClickTimer = null;
|
$('#login-title').click(function() {
|
titleClickCount++;
|
if (titleClickTimer) {
|
clearTimeout(titleClickTimer);
|
}
|
if (titleClickCount >= 3) {
|
titleClickCount = 0;
|
openSystemToolsDialog();
|
} else {
|
titleClickTimer = setTimeout(function() {
|
titleClickCount = 0;
|
}, 500);
|
}
|
});
|
|
function openSystemToolsDialog() {
|
layer.open({
|
type: 1,
|
title: '系统工具',
|
area: ['560px', '300px'],
|
shadeClose: true,
|
content: $('#system-tools-panel'),
|
end: function () {
|
$('#system-tools-panel').hide();
|
}
|
});
|
}
|
|
function fallbackCopy(text) {
|
try {
|
var textarea = document.createElement('textarea');
|
textarea.value = text;
|
textarea.style.position = 'fixed';
|
textarea.style.opacity = '0';
|
document.body.appendChild(textarea);
|
textarea.select();
|
document.execCommand('copy');
|
document.body.removeChild(textarea);
|
layer.msg('已复制到剪贴板');
|
} catch (err) {
|
layer.msg('复制失败');
|
}
|
}
|
|
function openTextDialog(title, label, text, tip) {
|
var html = ''
|
+ '<div style="padding:15px 20px 5px 20px;">'
|
+ '<div style="font-weight:600;margin-bottom:8px;">' + label + '</div>'
|
+ (tip ? '<div style="color:#999;margin-bottom:8px;">' + tip + '</div>' : '')
|
+ '<textarea id="dialog-text" readonly style="width:100%;min-height:220px;background:#f7f7f7;border:1px solid #e6e6e6;border-radius:6px;padding:12px;line-height:1.6;resize:none;">'
|
+ text
|
+ '</textarea>'
|
+ '<div class="layui-btn-container" style="text-align:right;margin-top:10px;">'
|
+ '<button class="layui-btn layui-btn-primary" id="copy-dialog-text">复制</button>'
|
+ '</div>'
|
+ '</div>';
|
layer.open({
|
type: 1,
|
title: title,
|
area: ['720px','460px'],
|
shadeClose: true,
|
content: html,
|
success: function (layero) {
|
layero.find('#copy-dialog-text').on('click', function () {
|
var value = layero.find('#dialog-text').val();
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
navigator.clipboard.writeText(value).then(function () {
|
layer.msg('已复制到剪贴板');
|
}).catch(function () {
|
fallbackCopy(value);
|
});
|
} else {
|
fallbackCopy(value);
|
}
|
});
|
}
|
});
|
}
|
|
// 获取请求码
|
$('#btn-request-code').click(function() {
|
$.ajax({
|
url: baseUrl + "/license/getRequestCode",
|
method: 'GET',
|
success: function (res) {
|
if (res.code === 200){
|
openTextDialog('获取请求码', '请求码', res.msg || '', '请求码中已包含项目名称,直接发给许可证服务端即可。');
|
} else {
|
layer.msg(res.msg || '获取请求码失败');
|
}
|
},
|
error: function () {
|
layer.msg('获取请求码失败');
|
}
|
});
|
return false;
|
});
|
|
// 获取系统配置
|
$('#btn-server-info').click(function() {
|
$.ajax({
|
url: baseUrl + "/license/getServerInfos",
|
method: 'GET',
|
success: function (res) {
|
var pretty = '';
|
try {
|
pretty = JSON.stringify(res, null, 2);
|
} catch (e) {
|
pretty = res;
|
}
|
openTextDialog('获取系统配置', '系统配置信息', pretty, '老项目仍可继续使用这份硬件信息 JSON 申请许可证。');
|
},
|
error: function () {
|
layer.msg('获取系统配置信息失败');
|
}
|
});
|
return false;
|
});
|
|
// 录入许可证
|
$('#btn-upload-license').click(function () {
|
layer.open({
|
type: 1,
|
title: '录入许可证',
|
area: ['760px', '420px'],
|
shadeClose: true,
|
content: ''
|
+ '<div style="padding:15px 20px 5px 20px;">'
|
+ '<div style="font-weight:600;margin-bottom:8px;">许可证 Base64</div>'
|
+ '<div style="color:#999;margin-bottom:8px;">将许可证服务端返回的 license 字段完整粘贴到这里。</div>'
|
+ '<textarea id="license-base64-input" style="width:100%;min-height:240px;background:#fff;border:1px solid #e6e6e6;border-radius:6px;padding:12px;line-height:1.6;resize:none;"></textarea>'
|
+ '</div>',
|
btn: ['提交', '取消'],
|
yes: function (index, layero) {
|
var license = $.trim(layero.find('#license-base64-input').val());
|
if (!license) {
|
layer.msg('许可证内容不能为空');
|
return;
|
}
|
$.ajax({
|
url: baseUrl + '/license/updateLicense',
|
method: 'POST',
|
contentType: 'application/json;charset=UTF-8',
|
data: JSON.stringify({license: license}),
|
success: function (res) {
|
if (res.code === 200) {
|
layer.close(index);
|
layer.msg('许可证更新成功');
|
} else {
|
layer.msg(res.msg || '许可证更新失败');
|
}
|
},
|
error: function () {
|
layer.msg('许可证录入失败');
|
}
|
});
|
}
|
});
|
return false;
|
});
|
|
// 一键激活
|
$('#btn-activate').click(function() {
|
layer.confirm('确定执行一键激活吗', function(index){
|
layer.close(index);
|
$.ajax({
|
url: baseUrl + "/license/activate",
|
method: 'POST',
|
success: function (res) {
|
if (res.code === 200){
|
layer.msg('激活成功');
|
} else {
|
layer.msg(res.msg)
|
}
|
},
|
error: function () {
|
layer.msg('激活失败');
|
}
|
});
|
});
|
return false;
|
});
|
|
// 获取项目名称
|
$('#btn-project-name').click(function() {
|
$.ajax({
|
url: baseUrl + "/license/getProjectName",
|
method: 'GET',
|
success: function (res) {
|
if (res.code === 200){
|
layer.alert(res.msg);
|
} else {
|
layer.msg(res.msg)
|
}
|
},
|
error: function () {
|
layer.msg('获取项目名称失败');
|
}
|
});
|
return false;
|
});
|
|
form.on('submit(login)', function (data) {
|
var mobile = $("#mobile").val();
|
if (mobile === "") {
|
layer.msg("请输入账号", {offset: '150px'});
|
return;
|
}
|
var password = $("#password").val();
|
if (password === "") {
|
layer.msg("请输入密码", {offset: '150px'});
|
return;
|
}
|
|
var user = {
|
mobile: mobile,
|
password: hex_md5(password)
|
};
|
$.ajax({
|
url: baseUrl+"/login.action",
|
data: user,
|
method: 'POST',
|
success: function (res) {
|
if (res.code === 200){
|
localStorage.setItem("token", res.data.token);
|
localStorage.setItem("username", res.data.username);
|
window.location.href = "index.html";
|
} else {
|
layer.msg(res.msg, {offset: '150px'});
|
}
|
}
|
});
|
return false;
|
});
|
|
$('body').keydown(function () {
|
if (event.keyCode === 13) {
|
$("#login-button").click();
|
}
|
});
|
|
});
|
</script>
|
<script type></script>
|
</html>
|