feat : wx login
This commit is contained in:
@@ -14,16 +14,31 @@ use App\Exception\ErrException;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Api\GetUserInfoTrait;
|
||||
use App\Service\ServiceTrait\Api\WxMiniTrait;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class BindPhoneByWxService extends BaseService
|
||||
{
|
||||
use GetUserInfoTrait,WxMiniTrait;
|
||||
use GetUserInfoTrait,
|
||||
WxMiniTrait;
|
||||
|
||||
public function handle()
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
$this->checkBindPhone($this->userId);
|
||||
|
||||
$wxPhone = $this->jsCodeGetPhoneNumber($this->request->input('code'));
|
||||
|
||||
if (empty($wxPhone['phone_info']['purePhoneNumber'])) throw new ErrException('微信手机号查询失败,请联系人工客服处理');
|
||||
|
||||
$userInfo = $this->getUserInfo($this->userId);
|
||||
|
||||
$userInfo->phone = $wxPhone['phone_info']['purePhoneNumber'];
|
||||
if (!$userInfo->save()) throw new ErrException('绑定手机号失败,请联系人工客服处理');
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user