request->param('code'); $iv = $this->request->param('iv'); $encryptedData = $this->request->param('encryptedData'); $loginService = new LoginService(); $user = $loginService->code2session($code, $iv, $encryptedData); return $this->buildSuccess($user); } catch (\Exception $e) { //错误消息 $e->getMessage() return $this->buildFailed($e->getCode() ?: 400,$e->getMessage()); } } /** * @title 登录 * @return \think\Response|void */ public function login(){ try { validate($this->valid)->scene('login')->check(Request::post()); $phone = $this->request->post('phone'); $openid = $this->request->post('openid'); $unionid = $this->request->post('unionid'); $loginService = new LoginService(); $user = $loginService->userLogin($phone, $openid, $unionid); return $this->buildSuccess($user); } catch (\Exception $e) { //错误消息 $e->getMessage() return $this->buildFailed($e->getCode() ?: 400,$e->getMessage()); } } public function userLogout() { } }