feat : login

This commit is contained in:
2025-03-19 16:56:38 +08:00
parent 307c0ec930
commit ac1cd0725d
3 changed files with 30 additions and 9 deletions

View File

@@ -37,25 +37,45 @@ class WxFastLoginService extends LoginBaseService
*/
public function handle(): array
{
$this->jsCode = $this->request->input('js_code');
$jsCode = $this->request->input('js_code');
$phoneCode = $this->request->input('phone_code');
if (empty($this->jsCode)) throw new ErrException('登录参数错误');
if (empty($jsCode) || empty($phoneCode)) throw new ErrException('登录参数错误');
$wxInfo = $this->jsCodeGetOpenId($this->jsCode);
$wxInfo = $this->jsCodeGetOpenId($jsCode);
$this->openId = $wxInfo['openid'];
$this->unionId = $wxInfo['unionid'] ?? '';
$this->jsCodeGetPhoneNumber($phoneCode);
$this->mobile = $wxPhone['phone_info']['purePhoneNumber'] ?? '';
$this->checkLock(self::LOGIN_TYPE);
$this->register();
$this->login();
$this->updateMobile();
$this->redis->delLock($this->lockKey);
return $this->getReturn();
}
/**
* @return void
*/
private function updateMobile(): void
{
if (empty($this->mobile)) return;
if ($this->userInfo->mobile == $this->mobile) return;
$this->userInfo->mobile = $this->mobile;
if (!$this->userInfo->save()) throw new ErrException('更新手机号失败');
}
/**
* 注册
* @return void