123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\common\controller;
- use app\BaseController;
- use app\common\model\MessageRecord;
- use think\Facade\Cache;
- class Auth extends BaseController
- {
- public function register(){
- $msg = "";
- if($this->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分钟内有效。若非本人操作请忽略。";
- }
- }
|