| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\api\validate;
- use app\common\validate\BaseValidate;
- /**
- * 短信验证
- * Class SmsValidate
- * @package app\api\validate
- */
- class SendSmsValidate extends BaseValidate
- {
- protected $rule = [
- 'mobile' => 'require|mobile',
- 'scene' => 'require',
- //'verifyCode' => 'require|checkVerifyCode',
- ];
- protected $message = [
- 'mobile.require' => '请输入手机号',
- 'mobile.mobile' => '请输入正确手机号',
- 'scene.require' => '请输入场景值',
- //'verifyCode.require' => '请输入图形验证码',
- ];
- /**
- * @notes 发送短信
- */
- public function sceneSendCode()
- {
- //return $this->only(['mobile','scene','verifyCode']);
- return $this->only(['mobile','scene']);
- }
- /**
- * @notes 图形验证码
- */
- public function sceneVerifyCode()
- {
- return $this->only(['mobile']);
- }
- /**
- * @notes 校验图形验证码
- */
- public function checkVerifyCode($scene, $rule, $data)
- {
- $captcha = cache('verifyCode_'.$data['mobile']);
- if (empty($captcha)) {
- return '图形验证码已失效,请重新获取';
- }
- if ($captcha != $data['verifyCode']) {
- return '图形验证码错误';
- }
- // 验证成功后删除验证码
- cache('verifyCode_'.$data['mobile'],null);
- return true;
- }
- }
|