541469799@qq.com hai 1 ano
pai
achega
dcf9f73eb6
Modificáronse 2 ficheiros con 76 adicións e 15 borrados
  1. 14 0
      app/index/controller/Captcha.php
  2. 62 15
      app/index/view/passport/logIn.html

+ 14 - 0
app/index/controller/Captcha.php

@@ -12,6 +12,7 @@ declare (strict_types=1);
 
 namespace app\index\controller;
 
+use app\index\service\passport\MailCaptcha;
 use think\response\Json;
 use app\api\service\passport\{Captcha as CaptchaService,
     MailCaptcha as MailCaptchaService,
@@ -62,4 +63,17 @@ class Captcha extends Controller
         }
         return $this->renderError($MailCaptchaService->getError() ?: '短信发送失败');
     }
+
+    public function checkEmailCaptcha(): Json
+    {
+        $code = $this->request->param('smsCode');
+        $mobile = $this->request->param('mobile');
+        $mailCaptcha = new MailCaptcha();
+        $flag = $mailCaptcha->checkCaptcha($code, $mobile);
+
+        if ($flag) {
+            return $this->renderSuccess('Sent Successful!Please check your new mails.');
+        }
+        return $this->renderError('not match');
+    }
 }

+ 62 - 15
app/index/view/passport/logIn.html

@@ -224,14 +224,39 @@
                 emailEle.focus();
                 return
             }
+
+            const dp = {
+                form: {
+                    mobile: email,
+                    smsCode: "hjhjhj",
+                    isParty: false,
+                    partyData: []
+                }
+            };
+
+            $.ajax({
+                url: "/index/captcha/sendEmailCaptcha",
+                headers: {platform: 'H5'},
+                dataType: 'json',
+                data: JSON.stringify(dp),
+                type: "POST",
+                contentType: 'application/json',
+                success: function (obj) {
+                    console.log(obj);
+                    //return false;
+                    //注册成功后进入
+                    if (obj.status === 200 || obj.status === '200') {
+                        const parentElement = $(this).parent();
+                        parentElement.hide(0)
+                        parentElement.siblings().hide(0)
+                        $("#emailVerifyModel").show(0)
+                        $("#emailAddress").text(email)
+                    }else {
+                        showToast('Please try again later.')
+                    }
+                }
+            })
             //验证成功后进入
-            if (true) {
-                const parentElement = $(this).parent();
-                parentElement.hide(0)
-                parentElement.siblings().hide(0)
-                $("#emailVerifyModel").show(0)
-                $("#emailAddress").text(email)
-            }
         });
 
         //验证电子邮箱(注册)
@@ -248,14 +273,36 @@
                 vcodeEle.focus();
                 return
             }
-            console.log("验证码", vcode)
-            //验证成功后进入
-            if (true) {
-                const parentElement = $(this).parent();
-                parentElement.hide(0)
-                parentElement.siblings().hide(0)
-                $("#setPasswordModel").show(0)
-            }
+            console.log("验证码", vcode)//checkEmailCaptcha
+            const emailEle = $("#email");
+            const email = emailEle.val()
+
+            const dp = {
+                    mobile: email,
+                    smsCode: vcode,
+            };
+
+            $.ajax({
+                url: "/index/captcha/checkEmailCaptcha",
+                headers: {platform: 'H5'},
+                dataType: 'json',
+                data: JSON.stringify(dp),
+                type: "POST",
+                contentType: 'application/json',
+                success: function (obj) {
+                    console.log(obj);
+                    //return false;
+                    //验证成功后进入
+                    if (obj.status === 200 || obj.status === '200') {
+                        const parentElement = $(this).parent();
+                        parentElement.hide(0)
+                        parentElement.siblings().hide(0)
+                        $("#setPasswordModel").show(0)
+                    }else {
+                        showToast('Please try again later.')
+                    }
+                }
+            })
         });
 
         //确认注册(注册)