feat : wx login

This commit is contained in:
2024-11-27 15:27:38 +08:00
parent 820b8d90dd
commit 237fed9fe6
3 changed files with 10 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middlewares; use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\Validation\Annotation\Scene; use Hyperf\Validation\Annotation\Scene;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
#[Controller(prefix: 'api/user')] #[Controller(prefix: 'api/user')]
#[Middlewares([ #[Middlewares([
@@ -18,6 +20,12 @@ use Hyperf\Validation\Annotation\Scene;
])] ])]
class UserController class UserController
{ {
/**
* @param UserRequest $request
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
#[RequestMapping(path: 'bind_phone/wx_code',methods: 'post')] #[RequestMapping(path: 'bind_phone/wx_code',methods: 'post')]
#[Scene(scene: 'bind_phone_wx')] #[Scene(scene: 'bind_phone_wx')]
public function bind_phone_by_wx_code(UserRequest $request) public function bind_phone_by_wx_code(UserRequest $request)

View File

@@ -22,7 +22,7 @@ class UserRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'code' => 'required|string', 'js_code' => 'required|string',
]; ];
} }
} }

View File

@@ -31,7 +31,7 @@ class BindPhoneByWxService extends BaseService
{ {
$this->checkBindPhone($this->userId); $this->checkBindPhone($this->userId);
$wxPhone = $this->jsCodeGetPhoneNumber($this->request->input('code')); $wxPhone = $this->jsCodeGetPhoneNumber($this->request->input('js_code'));
if (empty($wxPhone['phone_info']['purePhoneNumber'])) throw new ErrException('微信手机号查询失败,请联系人工客服处理'); if (empty($wxPhone['phone_info']['purePhoneNumber'])) throw new ErrException('微信手机号查询失败,请联系人工客服处理');