You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Api\CommonController;
  4. use Illuminate\Http\Request;
  5. use App\Common\ReturnData;
  6. use App\Common\Helper;
  7. use App\Http\Model\VerifyCode;
  8. class VerifyCodeController extends CommonController
  9. {
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. }
  14. //验证码校验
  15. public function verifyCodeCheck(Request $request)
  16. {
  17. $mobile = $request->input('mobile', null); //手机号码
  18. $verifyCode = $request->input('verifyCode', null); //手机验证码
  19. $type = $request->input('type', null); //验证码类型
  20. if ($mobile==null || $verifyCode==null || $type==null)
  21. {
  22. return ReturnData::create(ReturnData::PARAMS_ERROR);
  23. }
  24. if (!Helper::isValidMobile($mobile))
  25. {
  26. return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL);
  27. }
  28. $verifyCode = VerifyCode::isVerify($mobile, $verifyCode, $type);
  29. if(!$verifyCode)
  30. {
  31. return ReturnData::create(ReturnData::INVALID_VERIFYCODE);
  32. }
  33. return ReturnData::create(ReturnData::SUCCESS);
  34. }
  35. }