feat : login

This commit is contained in:
2025-03-19 17:00:55 +08:00
parent ac1cd0725d
commit 22fef86d76
2 changed files with 10 additions and 10 deletions

View File

@@ -29,6 +29,7 @@ use App\Model\UserThird;
use App\Service\Api\BaseService; use App\Service\Api\BaseService;
use App\Service\ServiceTrait\Api\GetUserInfoTrait; use App\Service\ServiceTrait\Api\GetUserInfoTrait;
use App\Service\ServiceTrait\Common\UserTrait; use App\Service\ServiceTrait\Common\UserTrait;
use Exception;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
@@ -79,11 +80,11 @@ abstract class LoginBaseService extends BaseService
*/ */
protected string $lockKey; protected string $lockKey;
// /** /**
// * 登录code login_type = wx_login 必填 * 登录code login_type = wx_login 必填
// * @var string * @var string
// */ */
// protected string $jsCode = ''; protected string $jsCode = '';
/** /**
* 手机号 login_type = mobile_code 必填 * 手机号 login_type = mobile_code 必填
@@ -133,7 +134,7 @@ abstract class LoginBaseService extends BaseService
/** /**
* 返回值 * 返回值
* @return array * @return array
* @throws \Exception * @throws Exception
*/ */
protected function getReturn():array protected function getReturn():array
{ {

View File

@@ -33,16 +33,15 @@ class WxFastLoginService extends LoginBaseService
* @return array * @return array
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
* @throws RedisException
*/ */
public function handle(): array public function handle(): array
{ {
$jsCode = $this->request->input('js_code'); $this->jsCode = $this->request->input('js_code');
$phoneCode = $this->request->input('phone_code'); $phoneCode = $this->request->input('phone_code');
if (empty($jsCode) || empty($phoneCode)) throw new ErrException('登录参数错误'); if (empty($this->jsCode) || empty($phoneCode)) throw new ErrException('登录参数错误');
$wxInfo = $this->jsCodeGetOpenId($jsCode); $wxInfo = $this->jsCodeGetOpenId($this->jsCode);
$this->openId = $wxInfo['openid']; $this->openId = $wxInfo['openid'];
$this->unionId = $wxInfo['unionid'] ?? ''; $this->unionId = $wxInfo['unionid'] ?? '';