request->isPost()){ } return view("", ["msg" => $msg]); } public function verificationCode() { $phone = $this->request["phone"]; $type = $this->request["type"]; //校验手机号码是否为空 if(\StrUtil::isEmpOrNull($phone)) { return json(["msg" => "请填写手机号码!"],500); } if (\StrUtil::isEmpOrNull($type)) { return json(["msg" => "请填写手机号码!"],500); } //校验手机号码格式是否正确 if(\StrUtil::isMoblePhone($phone)) { return json(["msg" => "请填写正确的手机号码!"],500); } $record = Cache::get("verify_{$type}_{$phone}"); if($record){ $time = time(); if($time - $record <= 60){ return json(["msg" => "一分钟内请勿频繁发送短信!"],500); } } $code = ''; for ($i = 1;$i <= 6;$i++){ $code .= rand(0,9); } $template = "【晋江市人才服务平台】尊敬的用户,您的短信验证码为{$code},5分钟内有效。若非本人操作请忽略。"; } }