修复登陆弹窗多次触发问题
This commit is contained in:
parent
8d6a68ee8e
commit
41086c1353
|
|
@ -746,6 +746,8 @@ body::before {
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Enhanced login functionality with remember password
|
// Enhanced login functionality with remember password
|
||||||
|
let isLoginInProgress = false; // 添加登录状态标志
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// 页面加载时检查是否有保存的用户名
|
// 页面加载时检查是否有保存的用户名
|
||||||
loadRememberedCredentials();
|
loadRememberedCredentials();
|
||||||
|
|
@ -779,19 +781,114 @@ body::before {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Login button click handler
|
// 重写原有的登录按钮点击事件,添加防重复点击保护
|
||||||
$('#loginBtn').on('click', function() {
|
$('#loginBtn').off('click').on('click', function(e) {
|
||||||
if (validateForm()) {
|
e.preventDefault();
|
||||||
performLogin();
|
if (isLoginInProgress) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清除之前的错误消息
|
||||||
|
errorclean();
|
||||||
|
|
||||||
|
// 检查用户协议
|
||||||
|
if (!$('#agreementCheckbox').prop('checked')) {
|
||||||
|
layui.use('layer', function(){
|
||||||
|
var layer = layui.layer;
|
||||||
|
layer.msg('请阅读并同意用户协议');
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证用户名
|
||||||
|
if($("#accountNameId").val() == '') {
|
||||||
|
$("#usererror").append("登录名不能为空");
|
||||||
|
return false;
|
||||||
|
} else if($("#passwordId").val() == '') {
|
||||||
|
$("#passworderror").append("密码不能为空");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// 设置登录进行中状态
|
||||||
|
isLoginInProgress = true;
|
||||||
|
|
||||||
|
// 保存记住密码的凭据
|
||||||
|
const username = $('#accountNameId').val().trim();
|
||||||
|
const password = $('#passwordId').val();
|
||||||
|
const remember = $('#rememberCheckbox').is(':checked');
|
||||||
|
if (remember) {
|
||||||
|
saveCredentials(username, password, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行原有的登录逻辑
|
||||||
|
dialogloading();
|
||||||
|
var loginname = $("#accountNameId").val();
|
||||||
|
var password = $("#passwordId").val();
|
||||||
|
|
||||||
|
loginname = encodeURI(encodeURI(loginname));
|
||||||
|
password = encodeURI(encodeURI(password));
|
||||||
|
localStorage.setItem("pwd", $.md5(password));
|
||||||
|
localStorage.setItem("uname", loginname);
|
||||||
|
|
||||||
|
var verifyCode = null;
|
||||||
|
var code = loginname + ",jy," + $.md5(password) + ",jy," + verifyCode;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: bonuspath + '/system_login',
|
||||||
|
data: {
|
||||||
|
KEYDATA: code,
|
||||||
|
tm: new Date().getTime(),
|
||||||
|
uuId: uuid()
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data, textStatus) {
|
||||||
|
dialogloadingClose();
|
||||||
|
|
||||||
|
// 重置登录状态(防重复提交保护)
|
||||||
|
isLoginInProgress = false;
|
||||||
|
|
||||||
|
const result = data.result;
|
||||||
|
if ("success" == result) {
|
||||||
|
sessionStorage.setItem("token", data.token);
|
||||||
|
dialogloadingClose();
|
||||||
|
clearLoginForm();
|
||||||
|
loginAlert(result);
|
||||||
|
window.location.href = bonuspath + "/backstage/index";
|
||||||
|
} else {
|
||||||
|
clearLoginForm();
|
||||||
|
loginAlert(result);
|
||||||
|
const errInfo = " ";
|
||||||
|
data.result = " ";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
dialogloadingClose();
|
||||||
|
|
||||||
|
// 重置登录状态(防重复提交保护)
|
||||||
|
isLoginInProgress = false;
|
||||||
|
|
||||||
|
// 处理网络错误
|
||||||
|
loginAlert("error");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Enter key support
|
// Enter key support - 修复重复触发问题
|
||||||
$('#loginForm').on('keypress', function(e) {
|
$('#loginForm').on('keypress', function(e) {
|
||||||
if (e.which === 13) {
|
if (e.which === 13) {
|
||||||
$('#loginBtn').click();
|
e.preventDefault();
|
||||||
|
if (!isLoginInProgress) {
|
||||||
|
$('#loginBtn').trigger('click');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 防止表单默认提交
|
||||||
|
$('#loginForm').on('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 加载记住的凭据
|
// 加载记住的凭据
|
||||||
|
|
@ -908,32 +1005,81 @@ body::before {
|
||||||
element.closest('.form-group').removeClass('error');
|
element.closest('.form-group').removeClass('error');
|
||||||
}
|
}
|
||||||
|
|
||||||
function performLogin() {
|
|
||||||
const loginBtn = $('#loginBtn');
|
|
||||||
const username = $('#accountNameId').val().trim();
|
// 清除所有错误消息
|
||||||
const password = $('#passwordId').val();
|
function hideAllErrors() {
|
||||||
const remember = $('#rememberCheckbox').is(':checked');
|
$('.error-message').removeClass('show');
|
||||||
|
$('.form-group').removeClass('error');
|
||||||
loginBtn.addClass('loading').prop('disabled', true).text('登录中...');
|
}
|
||||||
|
|
||||||
// 保存凭据(如果勾选了记住密码)
|
// 添加原有登录逻辑中需要的工具函数
|
||||||
saveCredentials(username, password, remember);
|
function uuid() {
|
||||||
|
var s = [];
|
||||||
// Here you would call your actual login function
|
var hexDigits = "0123456789abcdef";
|
||||||
// For now, we'll simulate the login process
|
for (var i = 0; i < 32; i++) {
|
||||||
setTimeout(function() {
|
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
||||||
loginBtn.removeClass('loading').prop('disabled', false).text('登录');
|
}
|
||||||
|
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
||||||
// 这里应该调用实际的登录逻辑
|
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||||||
// 成功登录后可以显示成功消息
|
s[8] = s[13] = s[18] = s[23];
|
||||||
layui.use('layer', function(){
|
var uuid = s.join("");
|
||||||
var layer = layui.layer;
|
return uuid;
|
||||||
layer.msg('登录成功!', {icon: 1, time: 2000}, function(){
|
}
|
||||||
// 登录成功后的跳转逻辑
|
|
||||||
// window.location.href = 'your_success_page_url';
|
function errorclean() {
|
||||||
});
|
$("#usererror").empty();
|
||||||
|
$("#passworderror").empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearLoginForm() {
|
||||||
|
$("#verifyCodeId").val("");
|
||||||
|
$("#passwordId").val("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function loginAlert(msg) {
|
||||||
|
if("codeerror" == msg){
|
||||||
|
$("#verifyCodeId").tips({side : 3,msg : "验证码不正确!",bg : '#FF2D2D',time : 2});
|
||||||
|
$("#verifyCodeId").focus();
|
||||||
|
} else if("nullup" == msg){
|
||||||
|
$("#accountNameId").tips({side : 3,msg : "用户名或密码不能为空!",bg : '#FF2D2D',time : 2});
|
||||||
|
$("#accountNameId").focus();
|
||||||
|
} else if("nullcode" == msg){
|
||||||
|
$("#verifyCodeId").tips({side : 3,msg : "验证码不能为空!",bg : '#FF2D2D',time : 2});
|
||||||
|
$("#verifyCodeId").focus();
|
||||||
|
} else if("usererror" == msg){
|
||||||
|
$("#accountNameId").tips({side : 3,msg : "用户名或密码有误!",bg : '#FF2D2D',time : 2});
|
||||||
|
$("#accountNameId").focus();
|
||||||
|
} else if("attemptserror" == msg){
|
||||||
|
dialogerror("错误次数过多!");
|
||||||
|
} else if("error" == msg){
|
||||||
|
dialogerror("输入有误!");
|
||||||
|
} else if("inactive" == msg){
|
||||||
|
dialogerror("未激活!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dialogerror(Str) {
|
||||||
|
layui.use('layer', function(){
|
||||||
|
var layer = layui.layer;
|
||||||
|
layer.msg(Str, {icon: 5, time: 3000});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dialogloading() {
|
||||||
|
layui.use('layer', function(){
|
||||||
|
var layer = layui.layer;
|
||||||
|
layer.load(1, {
|
||||||
|
shade: [0.1,'#fff']
|
||||||
});
|
});
|
||||||
}, 2000);
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dialogloadingClose() {
|
||||||
|
layui.use('layer', function(){
|
||||||
|
var layer = layui.layer;
|
||||||
|
layer.closeAll('loading');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忘记密码功能
|
// 忘记密码功能
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ function rowFunction(id,deviceCode,isFixedAssets,typeId) {
|
||||||
h += "<a href='#' title='查看' onclick='check('"+id+"','"+typeId+"')' class='aBtnNoTD' ><i class='icon-zoom-in color-p bigger-140'></i></a>";
|
h += "<a href='#' title='查看' onclick='check('"+id+"','"+typeId+"')' class='aBtnNoTD' ><i class='icon-zoom-in color-p bigger-140'></i></a>";
|
||||||
h += "<a href='#' title='机具生命周期' onclick='receive('" + deviceCode + "')' class='aBtnNoTD' ><i class='icon-list-alt color-p bigger-140'></i></a></li>";
|
h += "<a href='#' title='机具生命周期' onclick='receive('" + deviceCode + "')' class='aBtnNoTD' ><i class='icon-list-alt color-p bigger-140'></i></a></li>";
|
||||||
// h += "<a href='#' title='修改' onclick='edit('"+id+"')' class='aBtnNoTD' ><i class='icon-edit color-blue bigger-140'></i></a>";
|
// h += "<a href='#' title='修改' onclick='edit('"+id+"')' class='aBtnNoTD' ><i class='icon-edit color-blue bigger-140'></i></a>";
|
||||||
h += "<a href='#' title='报废' onclick='scrapping('"+id+"')' class='aBtnNoTD' ><i class='icon-edit color-blue bigger-140'></i></a>";
|
// h += "<a href='#' title='报废' onclick='scrapping('"+id+"')' class='aBtnNoTD' ><i class='icon-edit color-blue bigger-140'></i></a>";
|
||||||
|
|
||||||
h += "</div>";
|
h += "</div>";
|
||||||
h += "</td>";
|
h += "</td>";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
//JavaScript Document
|
//JavaScript Document
|
||||||
var box_view_btn="loginBtn";//初始化按钮值
|
let box_view_btn = "loginBtn";//初始化按钮值
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
errorclean();
|
errorclean();
|
||||||
|
|
@ -7,46 +7,37 @@ $(function () {
|
||||||
//监听docuemnt的onkeydown事件看是不是按了回车键
|
//监听docuemnt的onkeydown事件看是不是按了回车键
|
||||||
$(document).keydown(function(event){
|
$(document).keydown(function(event){
|
||||||
event = event ? event : window.event;
|
event = event ? event : window.event;
|
||||||
if (event.keyCode === 13){
|
if (event.keyCode === 13) {
|
||||||
$("#"+box_view_btn).trigger("click");
|
$("#"+box_view_btn).trigger("click");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//登录
|
//登录
|
||||||
|
$("#loginBtn").click(function () {
|
||||||
|
|
||||||
$("#loginBtn").click(function () {
|
|
||||||
errorclean();
|
errorclean();
|
||||||
|
|
||||||
|
|
||||||
if (!$('#agreementCheckbox').prop('checked')) {
|
if (!$('#agreementCheckbox').prop('checked')) {
|
||||||
layui.use('layer', function(){
|
layui.use('layer', function(){
|
||||||
var layer = layui.layer;
|
const layer = layui.layer;
|
||||||
layer.msg('请阅读并同意用户协议');
|
layer.msg('请阅读并同意用户协议');
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// alert($("#accountNameId").val());
|
if($("#accountNameId").val()==''){
|
||||||
|
|
||||||
if($("#accountNameId").val()==''){
|
|
||||||
/*$("#accountNameId").tips({side : 3,msg : "用户名不能为空!",bg : '#FF2D2D',time : 2});*/
|
/*$("#accountNameId").tips({side : 3,msg : "用户名不能为空!",bg : '#FF2D2D',time : 2});*/
|
||||||
$("#usererror").append("登录名不能为空");
|
$("#usererror").append("登录名不能为空");
|
||||||
// $("#accountNameId").focus();
|
// $("#accountNameId").focus();
|
||||||
|
|
||||||
}else if( $("#passwordId").val()==''){
|
} else if ( $("#passwordId").val()==''){
|
||||||
$("#passworderror").append("密码不能为空");
|
$("#passworderror").append("密码不能为空");
|
||||||
// $("#passwordId").tips({side : 3,msg : "密码不能为空!",bg : '#FF2D2D',time : 2});
|
// $("#passwordId").tips({side : 3,msg : "密码不能为空!",bg : '#FF2D2D',time : 2});
|
||||||
// $("#passwordId").focus();
|
// $("#passwordId").focus();
|
||||||
|
|
||||||
}/*else if("" == $("#verifyCodeId").val()){
|
} else {
|
||||||
$("#verifyCodeId").tips({side : 3,msg : "验证码不能为空!",bg : '#FF2D2D',time : 2});
|
|
||||||
$("#verifyCodeId").focus();
|
|
||||||
} */ else{
|
|
||||||
// alert("else");
|
|
||||||
dialogloading();
|
dialogloading();
|
||||||
var loginname = $("#accountNameId").val();
|
let loginname = $("#accountNameId").val();
|
||||||
var password = $("#passwordId").val();
|
let password = $("#passwordId").val();
|
||||||
|
|
||||||
console.log("loginname="+typeof(loginname));
|
console.log("loginname="+typeof(loginname));
|
||||||
console.log("password="+typeof(password));
|
console.log("password="+typeof(password));
|
||||||
|
|
||||||
|
|
@ -61,30 +52,23 @@ $(function () {
|
||||||
|
|
||||||
typeof(code);
|
typeof(code);
|
||||||
console.log("code="+typeof(code));
|
console.log("code="+typeof(code));
|
||||||
$.ajax({type:'POST',url:bonuspath +'/system_login',data:{KEYDATA:code,tm:new Date().getTime(),uuId:uuid()},
|
$.ajax({type:'POST',url:bonuspath +'/system_login',data:{KEYDATA:code,tm:new Date().getTime(),uuId:uuid()},
|
||||||
dataType:'json',success:function(data, textStatus){
|
dataType:'json',success:function(data, textStatus){
|
||||||
dialogloadingClose();
|
dialogloadingClose();
|
||||||
var result=data.result;
|
const result = data.result;
|
||||||
// alert(JSON.stringify(result));
|
if ("success" == result){ //如果登录不成功,则再次刷新验证码
|
||||||
if ("success" == result){ //如果登录不成功,则再次刷新验证码
|
|
||||||
sessionStorage.setItem("token",data.token);
|
sessionStorage.setItem("token",data.token);
|
||||||
// alert(result);
|
dialogloadingClose();
|
||||||
dialogloadingClose();
|
clearLoginForm();//清除信息
|
||||||
clearLoginForm();//清除信息
|
loginAlert(result);
|
||||||
loginAlert(result);
|
window.location.href=bonuspath+"/backstage/index";
|
||||||
// alert(result);
|
//window.location.href=bonuspath+"/backstage/rm/taskRecord/show";
|
||||||
window.location.href=bonuspath+"/backstage/index";
|
} else {
|
||||||
|
clearLoginForm();
|
||||||
//window.location.href=bonuspath+"/backstage/rm/taskRecord/show";
|
loginAlert(result);
|
||||||
|
// window.location.href=bonuspath+"/backstage/index";
|
||||||
}else{
|
const errInfo = " ";
|
||||||
clearLoginForm();
|
data.result=" ";
|
||||||
loginAlert(result);
|
|
||||||
//alert("success11");
|
|
||||||
// window.location.href=bonuspath+"/backstage/index";
|
|
||||||
|
|
||||||
var errInfo=" ";
|
|
||||||
data.result=" ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -105,7 +89,6 @@ $(function () {
|
||||||
});
|
});
|
||||||
function clean(){
|
function clean(){
|
||||||
errorclean();
|
errorclean();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -118,21 +101,17 @@ function uuid() {
|
||||||
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
||||||
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||||||
s[8] = s[13] = s[18] = s[23];
|
s[8] = s[13] = s[18] = s[23];
|
||||||
var uuid = s.join("");
|
return s.join("");
|
||||||
return uuid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//自定义错误提示staart
|
//自定义错误提示staart
|
||||||
function errorclean(){
|
function errorclean(){
|
||||||
$("#usererror").empty();
|
$("#usererror").empty();
|
||||||
$("#passworderror").empty();
|
$("#passworderror").empty();
|
||||||
}
|
}
|
||||||
//自定义结束end
|
//自定义结束end
|
||||||
|
function clearLoginForm(){
|
||||||
|
|
||||||
|
|
||||||
function clearLoginForm(){
|
|
||||||
$("#verifyCodeId").val("");
|
$("#verifyCodeId").val("");
|
||||||
$("#passwordId").val("");
|
$("#passwordId").val("");
|
||||||
getVerifyCode();
|
getVerifyCode();
|
||||||
|
|
@ -146,7 +125,6 @@ function show_box(id) {
|
||||||
jQuery('#'+id).addClass('visible');
|
jQuery('#'+id).addClass('visible');
|
||||||
}
|
}
|
||||||
//刷新验证码
|
//刷新验证码
|
||||||
|
|
||||||
function getVerifyCode() {
|
function getVerifyCode() {
|
||||||
$("#vimg").attr("src", "verifyCode/slogin.do?random=" + Math.random());
|
$("#vimg").attr("src", "verifyCode/slogin.do?random=" + Math.random());
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +170,7 @@ function dialogerror(Str){
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
function dialogloading(){
|
function dialogloading(){
|
||||||
$("#jyLoadingStr").empty().append("正在登录 , 请稍后 ...");
|
$("#jyLoadingStr").empty().append("正在登录 , 请稍后 ...");
|
||||||
|
|
@ -203,8 +181,8 @@ function dialogloading(){
|
||||||
modal: true,
|
modal: true,
|
||||||
show:{effect:"fade"},hide:{effect:"fade"}
|
show:{effect:"fade"},hide:{effect:"fade"}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
function dialogloadingClose(){
|
function dialogloadingClose(){
|
||||||
$("#jyLoading").dialog("close");
|
$("#jyLoading").dialog("close");
|
||||||
};
|
}
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
</context:component-scan>
|
</context:component-scan>
|
||||||
|
|
||||||
<!-- 对静态资源文件的访问 restful -->
|
<!-- 对静态资源文件的访问 restful -->
|
||||||
<mvc:resources mapping="/static/**" location="/,/static/" />
|
<mvc:resources mapping="/static/**" location="/,/static/" cache-period="0" />
|
||||||
<mvc:resources mapping="/filePath/**" location="file:/data/gzimt/"/>
|
<mvc:resources mapping="/filePath/**" location="file:/data/gzimt/"/>
|
||||||
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||||
<property name="viewClass"
|
<property name="viewClass"
|
||||||
|
|
|
||||||
|
|
@ -50,19 +50,16 @@ public class AreaTypeServiceImp extends BaseServiceImp<AreaTypeBean> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AreaTypeBean> findma(AreaTypeBean o) {
|
public List<AreaTypeBean> findma(AreaTypeBean o) {
|
||||||
|
|
||||||
return dao.findma(o);
|
return dao.findma(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AreaTypeBean> findmt(AreaTypeBean o) {
|
public List<AreaTypeBean> findmt(AreaTypeBean o) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return dao.findmt(o);
|
return dao.findmt(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ZNode> orgTree() {
|
public List<ZNode> orgTree() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return dao.orgTree(null);
|
return dao.orgTree(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue