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.

43 lines
1.1 KiB

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