diff --git a/app/api/validate/RegisterValidate.php b/app/api/validate/RegisterValidate.php index 803c2d1c..c775957f 100644 --- a/app/api/validate/RegisterValidate.php +++ b/app/api/validate/RegisterValidate.php @@ -16,6 +16,7 @@ namespace app\api\validate; use app\common\enum\notice\NoticeEnum; use app\common\model\user\User; +use app\common\service\JsonService; use app\common\service\sms\SmsDriver; use app\common\validate\BaseValidate; @@ -48,4 +49,31 @@ class RegisterValidate extends BaseValidate 'password_confirm.require' => '请确认密码', 'password_confirm.confirm' => '两次输入的密码不一致' ]; + + public function goCheck($scene = null, array $validateData = []): array + { + //接收参数 + if ($this->method == 'GET') { + $params = request()->get(); + } else { + $params = request()->post(); + } + //合并验证参数 + $params = array_merge($params, $validateData); + + //场景 + if ($scene) { + $result = $this->scene($scene)->check($params); + } else { + $result = $this->check($params); + } + + if (!$result) { + $exception = is_array($this->error) ? implode(';', $this->error) : $this->error; + $data = $exception == '手机号已存在' ? ['has_register'=>1] : []; + JsonService::throw($exception,$data); + } + // 3.成功返回数据 + return $params; + } } \ No newline at end of file