validated(); // 校验验证码 $sms = new SmsCodeModel(); if (!$sms->check($params['mobile'], $params['captcha'], $params['event'], 50)) { return AppResult::error($sms->getMessage()); } $UserModel = new UserModel(); if ($user = $UserModel->getByMobile($params['mobile'])){ if ($user['status'] != 1){ return AppResult::error('账号被锁定,无法登录'); } }else{ if (!$UserModel->register(mobile: $params['mobile'])){ return AppResult::error('注册失败'); } $user = $UserModel->getData(); } $token = (string)Str::uuid(); if (!TokenFast::set($token,$user['id'],2592000)){ return AppResult::error('获取token失败'); } $sms->flush($params['mobile'],$params['event']); return AppResult::success('登录成功',[ 'token' => $token ]); } }