diff --git a/Bootstrap.Admin/Views/Account/Login.cshtml b/Bootstrap.Admin/Views/Account/Login.cshtml
index 86fe8af3..f4000a6f 100644
--- a/Bootstrap.Admin/Views/Account/Login.cshtml
+++ b/Bootstrap.Admin/Views/Account/Login.cshtml
@@ -112,7 +112,7 @@
-
+
@@ -199,6 +206,13 @@
提交
+
diff --git a/Bootstrap.Admin/wwwroot/css/login-responsive.css b/Bootstrap.Admin/wwwroot/css/login-responsive.css
index 276c053e..2270eb48 100644
--- a/Bootstrap.Admin/wwwroot/css/login-responsive.css
+++ b/Bootstrap.Admin/wwwroot/css/login-responsive.css
@@ -38,6 +38,9 @@
.slidercaptcha {
top: -254px;
left: -15px;
+ }
+
+ .slidercaptcha, .slidercaptcha.forgot {
width: 310px;
height: 280px;
}
diff --git a/Bootstrap.Admin/wwwroot/css/login.css b/Bootstrap.Admin/wwwroot/css/login.css
index c5c37f3c..28328ef2 100644
--- a/Bootstrap.Admin/wwwroot/css/login.css
+++ b/Bootstrap.Admin/wwwroot/css/login.css
@@ -86,3 +86,17 @@
.slidercaptcha.card .card-header .close:hover {
color: #fff;
}
+
+.slidercaptcha.forgot {
+ position: absolute;
+ left: auto;
+ right: 14px;
+ bottom: 14px;
+ top: auto;
+ margin: 0;
+ width: 274px;
+}
+
+.slidercaptcha.reg {
+ bottom: 60px;
+}
\ No newline at end of file
diff --git a/Bootstrap.Admin/wwwroot/js/login.js b/Bootstrap.Admin/wwwroot/js/login.js
index aae019de..784b663e 100644
--- a/Bootstrap.Admin/wwwroot/js/login.js
+++ b/Bootstrap.Admin/wwwroot/js/login.js
@@ -13,43 +13,57 @@
}
});
- $.extend({
- captchaCheck: function (success) {
+ $.extend({
+ captchaCheck: function (captcha, success) {
$.bc({
url: "api/OnlineUsers",
method: "put",
callback: function (result) {
- if (result) $captcha.addClass('d-block');
+ if (result) captcha.addClass('d-block');
else success();
}
- });
+ });
+ },
+ capWidth: function () {
+ return $(window).width() < 768 ? 216 : 280;
+ },
+ capHeight: function () {
+ return $(window).width() < 768 ? 110 : 150;
+ },
+ capRegSuccess: function () {
+ $.bc({
+ url: "api/Register",
+ data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() },
+ modal: '#dialogNew',
+ method: "post",
+ callback: function (result) {
+ var title = result ? "提交成功
等待管理员审批" : "提交失败";
+ lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" });
+ }
+ });
+ },
+ capForgotSuccess: function () {
+ $.bc({
+ url: "api/Register",
+ data: { UserName: $('#f_userName').val(), DisplayName: $('#f_displayName').val(), Reason: $('#f_desc').val() },
+ modal: '#dialogForgot',
+ method: "put",
+ callback: function (result) {
+ var title = result ? "提交成功
等待管理员重置密码" : "提交失败";
+ lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" });
+ }
+ });
}
});
$('#btnSubmit').on('click', function () {
- $.bc({
- url: "api/Register",
- data: { UserName: $('#userName').val(), Password: $('#password').val(), DisplayName: $('#displayName').val(), Description: $('#description').val() },
- modal: '#dialogNew',
- method: "post",
- callback: function (result) {
- var title = result ? "提交成功
等待管理员审批" : "提交失败";
- lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" });
- }
- });
+ $.captchaCheck($('#dialogNew .slidercaptcha'), $.capRegSuccess);
+ return false;
});
$('#btnForgot').on('click', function () {
- $.bc({
- url: "api/Register",
- data: { UserName: $('#f_userName').val(), DisplayName: $('#f_displayName').val(), Reason: $('#f_desc').val() },
- modal: '#dialogForgot',
- method: "put",
- callback: function (result) {
- var title = result ? "提交成功
等待管理员重置密码" : "提交失败";
- lgbSwal({ timer: 1500, title: title, type: result ? "success" : "error" });
- }
- });
+ $.captchaCheck($('#dialogForgot .slidercaptcha'), $.capForgotSuccess);
+ return false;
});
$('.rememberPwd').on('click', function () {
@@ -65,26 +79,36 @@
}
});
- var $captcha = $('.slidercaptcha');
- $('.slidercaptcha .close').on('click', function () {
- $captcha.removeClass('d-block');
+ $('.slidercaptcha .close').on('click', function (e) {
+ $(this).parents('.slidercaptcha').removeClass('d-block');
+ return false;
});
$('button[type="submit"]').on('click', function (e) {
- $.captchaCheck(function () {
+ $.captchaCheck($('#login .slidercaptcha'), function () {
$('form').submit();
});
return false;
});
- $('#captcha').sliderCaptcha({
- width: $(window).width() < 768 ? 216 : 280,
- height: $(window).width() < 768 ? 110 : 150,
+ $('#captcha, #regcap, #forgotcap').sliderCaptcha({
+ width: $.capWidth(),
+ height: $.capHeight(),
setSrc: function () {
return 'http://pocoafrro.bkt.clouddn.com/Pic' + Math.round(Math.random() * 136) + '.jpg';
},
onSuccess: function () {
- $('form').submit();
+ var parent = this.$element.parents('.slidercaptcha').removeClass('d-block');
+ this.reset();
+ if (parent.hasClass('reg')) {
+ $.capRegSuccess();
+ }
+ else if (parent.hasClass('forgot')) {
+ $.capForgotSuccess();
+ }
+ else {
+ $('form').submit();
+ }
}
});
});
\ No newline at end of file
diff --git a/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js b/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js
index 43af4bba..107295a2 100644
--- a/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js
+++ b/Bootstrap.Admin/wwwroot/lib/captcha/longbow.slidercaptcha.js
@@ -185,7 +185,7 @@
$(this.refreshIcon).on('click', function () {
that.text.text(that.options.barText);
that.reset();
- if ($.isFunction(that.options.onRefresh)) that.options.onRefresh.call(that.$element);
+ if ($.isFunction(that.options.onRefresh)) that.options.onRefresh.call(that);
});
var originX, originY, trail = [],
@@ -226,10 +226,10 @@
} = that.verify()
if (spliced && verified) {
that.sliderContainer.addClass('sliderContainer_success');
- if ($.isFunction(that.options.onSuccess)) that.options.onSuccess.call(that.$element);
+ if ($.isFunction(that.options.onSuccess)) that.options.onSuccess.call(that);
} else {
that.sliderContainer.addClass('sliderContainer_fail');
- if ($.isFunction(that.options.onFail)) that.options.onFail.call(that.$element);
+ if ($.isFunction(that.options.onFail)) that.options.onFail.call(that);
setTimeout(() => {
that.text.text(that.options.failedText);
that.reset();