Quellcode durchsuchen

获取手机号

shish vor 1 Jahr
Ursprung
Commit
1fd29bf8e8
2 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen
  1. 17 8
      app-hd/controllers/ApplyController.php
  2. 2 0
      app-hd/controllers/AuthController.php

+ 17 - 8
app-hd/controllers/ApplyController.php

@@ -163,6 +163,7 @@ class ApplyController extends BaseController
             $post['adminId'] = $this->adminId;
             $authCode = $post['authCode'] ?? '';
             $mobile = $post['mobile'] ?? '';
+            $fillMobile = $post['fillMobile'] ?? 1;
 
             //避免重复提交
             util::checkRepeatCommit($mobile, 10);
@@ -171,15 +172,23 @@ class ApplyController extends BaseController
             $cacheKey = 'register_mobile_code_' . $ptStyle . '_' . $mobile;
             $saveAuthCode = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
 
-            if ($authCode != 19640123) {
-                if (empty($saveAuthCode)) {
-                    util::fail('请填写验证码哦');
+            if($fillMobile == 1){
+                if ($authCode != 19640123) {
+                    if (empty($saveAuthCode)) {
+                        util::fail('请填写验证码哦');
+                    }
+                    if (empty($authCode)) {
+                        util::fail('请填写验证码');
+                    }
+                    if ($saveAuthCode != $authCode) {
+                        util::fail('验证码错误');
+                    }
                 }
-                if (empty($authCode)) {
-                    util::fail('请填写验证码');
-                }
-                if ($saveAuthCode != $authCode) {
-                    util::fail('验证码错误');
+            }else{
+                $cacheKey = 'getMobile_'.$mobile;
+                $hasGet = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                if(empty($hasGet)){
+                    util::fail('请获取手机');
                 }
             }
 

+ 2 - 0
app-hd/controllers/AuthController.php

@@ -65,6 +65,8 @@ class AuthController extends PublicController
             //noticeUtil::push($cacheKey . " 登录失败了!获取手机号失败", '15280215347');
             util::success(['hasNoOpenId' => 1], '登录失败了哦');
         }
+        $cacheKey = 'getMobile_'.$phoneNumber;
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 1]);
         util::success(['mobile' => $phoneNumber]);
     }