From d697a7bf97d2daaa7274141afd8dc6336cf2e1df Mon Sep 17 00:00:00 2001 From: koogua Date: Sat, 19 Feb 2022 18:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 + app/Http/Admin/Views/setting/captcha.volt | 32 ++++++-- .../Home/Views/account/forget_password.volt | 3 +- .../Home/Views/account/login_by_password.volt | 15 ++-- .../Home/Views/account/login_by_verify.volt | 5 +- app/Http/Home/Views/account/register.volt | 3 +- .../Home/Views/connect/bind_register.volt | 3 +- .../Views/user/console/account_email.volt | 3 +- .../Views/user/console/account_phone.volt | 3 +- app/Library/AppInfo.php | 2 +- public/static/home/js/captcha.verify.js | 79 +++++++++++-------- 11 files changed, 99 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4130dd6d..2c14648b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [v1.5.1](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.1)(2022-03-17) + +- 增加验证码开关 + ### [v1.5.0](https://gitee.com/koogua/course-tencent-cloud/releases/v1.5.0)(2022-02-17) - 调整对内部人员通知任务类型的前缀 diff --git a/app/Http/Admin/Views/setting/captcha.volt b/app/Http/Admin/Views/setting/captcha.volt index 1119fc25..1cc7e71b 100644 --- a/app/Http/Admin/Views/setting/captcha.volt +++ b/app/Http/Admin/Views/setting/captcha.volt @@ -2,20 +2,31 @@ {% block content %} + {% set captcha_display = captcha.enabled == 1 ? 'display:block' : 'display:none' %} +
验证码配置
- +
- + +
-
- -
- +
+
+ +
+ +
+
+
+ +
+ +
@@ -77,6 +88,15 @@ } ); + form.on('radio(captcha_enabled)', function (data) { + var block = $('#captcha-block'); + if (data.value === '1') { + block.show(); + } else { + block.hide(); + } + }); + form.on('submit(back_verify)', function (data) { $.ajax({ type: 'POST', diff --git a/app/Http/Home/Views/account/forget_password.volt b/app/Http/Home/Views/account/forget_password.volt index d95b541a..5683bf28 100644 --- a/app/Http/Home/Views/account/forget_password.volt +++ b/app/Http/Home/Views/account/forget_password.volt @@ -23,12 +23,13 @@
- +
+ diff --git a/app/Http/Home/Views/account/login_by_password.volt b/app/Http/Home/Views/account/login_by_password.volt index cded753e..b5a7e100 100644 --- a/app/Http/Home/Views/account/login_by_password.volt +++ b/app/Http/Home/Views/account/login_by_password.volt @@ -1,3 +1,6 @@ +{% set disabled_submit = captcha.enabled == 1 ? 'disabled="disabled"' : '' %} +{% set disabled_class = captcha.enabled == 1 ? 'layui-btn-disabled' : '' %} +
@@ -7,14 +10,16 @@
-
-
- + {% if captcha.enabled == 1 %} +
+
+ +
-
+ {% endif %}
- + diff --git a/app/Http/Home/Views/account/login_by_verify.volt b/app/Http/Home/Views/account/login_by_verify.volt index cb43f08e..41558f6b 100644 --- a/app/Http/Home/Views/account/login_by_verify.volt +++ b/app/Http/Home/Views/account/login_by_verify.volt @@ -9,14 +9,15 @@
- +
- + +
diff --git a/app/Http/Home/Views/account/register.volt b/app/Http/Home/Views/account/register.volt index 82787d53..06a11a06 100644 --- a/app/Http/Home/Views/account/register.volt +++ b/app/Http/Home/Views/account/register.volt @@ -38,13 +38,14 @@
- +
+ diff --git a/app/Http/Home/Views/connect/bind_register.volt b/app/Http/Home/Views/connect/bind_register.volt index 87208750..07e64e01 100644 --- a/app/Http/Home/Views/connect/bind_register.volt +++ b/app/Http/Home/Views/connect/bind_register.volt @@ -14,7 +14,7 @@
- +
@@ -24,6 +24,7 @@ + diff --git a/app/Http/Home/Views/user/console/account_email.volt b/app/Http/Home/Views/user/console/account_email.volt index 5f4dde35..18cd2115 100644 --- a/app/Http/Home/Views/user/console/account_email.volt +++ b/app/Http/Home/Views/user/console/account_email.volt @@ -28,12 +28,13 @@
- +
+ diff --git a/app/Http/Home/Views/user/console/account_phone.volt b/app/Http/Home/Views/user/console/account_phone.volt index 93459066..7c34aa58 100644 --- a/app/Http/Home/Views/user/console/account_phone.volt +++ b/app/Http/Home/Views/user/console/account_phone.volt @@ -28,12 +28,13 @@
- +
+ diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 8ae50148..a4dea0cb 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.5.0'; + protected $version = '1.5.1'; public function __get($name) { diff --git a/public/static/home/js/captcha.verify.js b/public/static/home/js/captcha.verify.js index 13fe91c3..2196ffdf 100644 --- a/public/static/home/js/captcha.verify.js +++ b/public/static/home/js/captcha.verify.js @@ -5,40 +5,26 @@ layui.use(['jquery', 'util'], function () { var timeCounting = false; var $account = $('#cv-account'); - var $emit = $('#cv-verify-emit'); + var $emit = $('#cv-emit-btn'); + var $submit = $('#cv-submit-btn'); - var captcha = new TencentCaptcha( - $emit[0], - $('#cv-app-id').val(), - function (res) { - if (res.ret === 0) { - $('#cv-ticket').val(res.ticket); - $('#cv-rand').val(res.randstr); - if (isEmail($account.val()) || isPhone($account.val())) { - var postUrl; - var postData = { - ticket: $('#cv-ticket').val(), - rand: $('#cv-rand').val(), - }; - if (isPhone($account.val())) { - postData.phone = $account.val(); - postUrl = '/verify/sms/code'; - } else if (isEmail($account.val())) { - postData.email = $account.val(); - postUrl = '/verify/mail/code'; - } - $.ajax({ - type: 'POST', - url: postUrl, - data: postData - }); - $('#cv-submit-btn').removeClass('layui-btn-disabled').removeAttr('disabled'); - $emit.addClass('layui-btn-disabled').attr('disabled', 'disabled'); - showCountDown($emit); + if ($('#cv-enabled').val() === '1') { + var captcha = new TencentCaptcha( + $emit[0], + $('#cv-app-id').val(), + function (res) { + if (res.ret === 0) { + $('#cv-ticket').val(res.ticket); + $('#cv-rand').val(res.randstr); + sendVerifyCode(); } } - } - ); + ); + } else { + $emit.on('click', function () { + sendVerifyCode(); + }); + } $account.on('keyup', function () { var accountOk; @@ -58,14 +44,39 @@ layui.use(['jquery', 'util'], function () { } }); - function showCountDown(obj) { + function sendVerifyCode() { + if (isEmail($account.val()) || isPhone($account.val())) { + var postUrl; + var postData = { + ticket: $('#cv-ticket').val(), + rand: $('#cv-rand').val(), + }; + if (isPhone($account.val())) { + postData.phone = $account.val(); + postUrl = '/verify/sms/code'; + } else if (isEmail($account.val())) { + postData.email = $account.val(); + postUrl = '/verify/mail/code'; + } + $.ajax({ + type: 'POST', + url: postUrl, + data: postData, + }); + $submit.removeClass('layui-btn-disabled').removeAttr('disabled'); + $emit.addClass('layui-btn-disabled').attr('disabled', 'disabled'); + showCountDown($emit); + } + } + + function showCountDown() { var serverTime = new Date().getTime(); var endTime = serverTime + 60 * 1000; util.countdown(endTime, serverTime, function (date, serverTime, timer) { var left = date[0] * 86400 + date[1] * 3600 + date[2] * 60 + date[3]; - obj.text(left + '秒'); + $emit.text(left + '秒'); if (left === 0) { - obj.removeClass('layui-btn-disabled').removeAttr('disabled').text('重新发送'); + $emit.removeClass('layui-btn-disabled').removeAttr('disabled').text('重新发送'); clearInterval(timer); timeCounting = false; }