فهرست منبع

注册邮件倒计时

zhangdehua 9 ماه پیش
والد
کامیت
8245f6837c
3فایلهای تغییر یافته به همراه32 افزوده شده و 5 حذف شده
  1. 1 1
      app/index/controller/Captcha.php
  2. 3 2
      app/index/service/passport/MailCaptcha.php
  3. 28 2
      app/index/view/passport/logIn.html

+ 1 - 1
app/index/controller/Captcha.php

@@ -136,7 +136,7 @@ class Captcha extends Controller
             return $this->renderSuccess('Sent Successful!Please check your new mails.');
         }
         log_record($smtp->getError(), 'error');
-        return $this->renderError('Failed to send code. Please try again later');
+        return $this->renderError($smtp->getError());
 
 
 //        $MailCaptchaService = new MailCaptchaService;

+ 3 - 2
app/index/service/passport/MailCaptcha.php

@@ -35,7 +35,7 @@ class MailCaptcha extends BaseService
     // 发送限制间隔时间,默认24小时
     protected int $safeTime = 86400;
     //验证码过期时间
-    protected int $expireTime = 300;
+    protected int $expireTime = 900;
     //可重复使用次数
     protected int $checkTimes = 5;
 
@@ -51,6 +51,7 @@ class MailCaptcha extends BaseService
         $this->validate($data);
         // 执行发送短信
         if (!$this->sendCaptcha($data['mobile'])) {
+            $this->error = 'Invalid email address.';
             return false;
         }
         return true;
@@ -117,7 +118,7 @@ class MailCaptcha extends BaseService
             //Content
             //$mail->isHTML(true);                                  //Set email format to HTML
             $mail->Subject = 'Code';
-            $mail->Body = 'Your code is ' . $smsCaptcha . '.Please use it in 15 minutes';
+            $mail->Body = 'Your code is ' . $smsCaptcha . '. Please use it in 15 minutes';
             $mail->AltBody = 'This is the Your Code for FreeShippingV';
 
             $mail->send();

+ 28 - 2
app/index/view/passport/logIn.html

@@ -221,10 +221,18 @@
             })
         });
 
+        let countdown = 60;
+        let countdownTimer;
+
         //继续(注册)
         $("#continueButton").on(tap, function (event) {
             event.preventDefault();
             console.log(2)
+
+            if (countdownTimer) {
+                return;
+            }
+
             const emailEle = $("#email");
             //输入框不存在
             if (!emailEle) {
@@ -237,6 +245,11 @@
                 return
             }
 
+            // 点击后立即执行一次倒计时
+            countdown = 60
+            $(this).text(countdown + 's');
+            countdown--;
+
             const dp = {
                 form: {
                     mobile: email,
@@ -246,6 +259,19 @@
                 }
             };
 
+            // 开始倒计时
+            countdownTimer = setInterval(() => {
+                if (countdown <= 0) {
+                    clearInterval(countdownTimer);
+                    countdownTimer = null;
+                    // 倒计时结束后恢复按钮状态
+                    $(this).text('Get code');
+                } else {
+                    $(this).text(countdown + 's');
+                    countdown--;
+                }
+            }, 1000);
+
             $.ajax({
                 url: "/index/captcha/sendEmailCaptcha",
                 headers: {platform: 'H5'},
@@ -258,7 +284,7 @@
                     //return false;
                     //注册成功后进入
                     if (obj.status === 200 || obj.status === '200') {
-                        showToast('Code has been sent!Please check your new mails.')
+                        showToast('Code has been sent! Please check your new mails.')
                         const parentElement = $(this).parent();
                         //parentElement.hide(0)
                         //parentElement.siblings().hide(0)
@@ -380,4 +406,4 @@
     })
 </script>
 
-</html>
+</html>