|
|
@ -6,6 +6,7 @@ use plugin\piadmin\app\base\BaseService; |
|
|
use plugin\piadmin\app\dao\UserDao; |
|
|
use plugin\piadmin\app\dao\UserDao; |
|
|
use plugin\piadmin\app\exception\ApiException; |
|
|
use plugin\piadmin\app\exception\ApiException; |
|
|
use plugin\piadmin\app\utils\CacheUtils; |
|
|
use plugin\piadmin\app\utils\CacheUtils; |
|
|
|
|
|
use plugin\piadmin\app\utils\Captcha; |
|
|
use plugin\piadmin\app\utils\JwtUtils; |
|
|
use plugin\piadmin\app\utils\JwtUtils; |
|
|
|
|
|
|
|
|
class UserService extends BaseService |
|
|
class UserService extends BaseService |
|
|
@ -33,6 +34,25 @@ class UserService extends BaseService |
|
|
return $tokenInfo; |
|
|
return $tokenInfo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function mobileLogin($params) |
|
|
|
|
|
{ |
|
|
|
|
|
$user = $this->dao->getModel()->where(function ($query) use ($params){ |
|
|
|
|
|
$query->where('phone', '=', $params['phone']); |
|
|
|
|
|
})->find(); |
|
|
|
|
|
//验证码验证
|
|
|
|
|
|
if(env('APP_DEBUG') != true){ |
|
|
|
|
|
$captcha = new Captcha(); |
|
|
|
|
|
$res = $captcha->verify($params['phone'],$params['code'],"login"); |
|
|
|
|
|
if($res['code'] != 200){ |
|
|
|
|
|
throw new ApiException($res['msg']); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
$tokenInfo = $this->commonLogin($user, $params); |
|
|
|
|
|
$tokenInfo['user'] = $user->toArray(); |
|
|
|
|
|
$tokenInfo['expire_time'] = $tokenInfo['expire'] + time(); |
|
|
|
|
|
return $tokenInfo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// ============================================================ 私有方法 ===============================================
|
|
|
// ============================================================ 私有方法 ===============================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|