authUser->id == 0) { $this->response->redirect(['for' => 'home.account.login']); return false; } return true; } public function initialize() { parent::initialize(); $authUser = $this->getAuthUser(false); $this->view->setVar('auth_user', $authUser); } /** * @Get("/", name="home.uc.index") */ public function indexAction() { $this->dispatcher->forward(['action' => 'courses']); } /** * @Get("/profile", name="home.uc.profile") */ public function profileAction() { $service = new ProfileInfoService(); $user = $service->handle(); $this->view->pick('user/console/profile'); $this->view->setVar('user', $user); } /** * @Get("/contact", name="home.uc.contact") */ public function contactAction() { $service = new ContactInfoService(); $contact = $service->handle(); $this->view->pick('user/console/contact'); $this->view->setVar('contact', $contact); } /** * @Get("/account", name="home.uc.account") */ public function accountAction() { $type = $this->request->getQuery('type', 'string', 'info'); $service = new AccountInfoService(); $captcha = $service->getSettings('captcha'); $account = $service->handle(); $service = new OAuthProviderService(); $oauthProvider = $service->handle(); $service = new ConnectListService(); $connects = $service->handle(); if ($type == 'info') { $this->view->pick('user/console/account_info'); } elseif ($type == 'phone') { $this->view->pick('user/console/account_phone'); } elseif ($type == 'email') { $this->view->pick('user/console/account_email'); } elseif ($type == 'password') { $this->view->pick('user/console/account_password'); } $this->view->setVar('oauth_provider', $oauthProvider); $this->view->setVar('connects', $connects); $this->view->setVar('captcha', $captcha); $this->view->setVar('account', $account); } /** * @Get("/courses", name="home.uc.courses") */ public function coursesAction() { $service = new CourseListService(); $pager = $service->handle(); $this->view->pick('user/console/courses'); $this->view->setVar('pager', $pager); } /** * @Get("/articles", name="home.uc.articles") */ public function articlesAction() { $service = new ArticleListService(); $pager = $service->handle(); $this->view->pick('user/console/articles'); $this->view->setVar('pager', $pager); } /** * @Get("/favorites", name="home.uc.favorites") */ public function favoritesAction() { $service = new FavoriteListService(); $pager = $service->handle(); $this->view->pick('user/console/favorites'); $this->view->setVar('pager', $pager); } /** * @Get("/consults", name="home.uc.consults") */ public function consultsAction() { $service = new ConsultListService(); $pager = $service->handle(); $this->view->pick('user/console/consults'); $this->view->setVar('pager', $pager); } /** * @Get("/reviews", name="home.uc.reviews") */ public function reviewsAction() { $service = new ReviewListService(); $pager = $service->handle(); $this->view->pick('user/console/reviews'); $this->view->setVar('pager', $pager); } /** * @Get("/orders", name="home.uc.orders") */ public function ordersAction() { $service = new OrderListService(); $pager = $service->handle(); $this->view->pick('user/console/orders'); $this->view->setVar('pager', $pager); } /** * @Get("/refunds", name="home.uc.refunds") */ public function refundsAction() { $service = new RefundListService(); $pager = $service->handle(); $this->view->pick('user/console/refunds'); $this->view->setVar('pager', $pager); } /** * @Get("/point/history", name="home.uc.point_history") */ public function pointHistoryAction() { $service = new PointHistoryService(); $pager = $service->handle(); $this->view->pick('user/console/point_history'); $this->view->setVar('pager', $pager); } /** * @Get("/point/redeems", name="home.uc.point_redeems") */ public function pointRedeemsAction() { $service = new PointRedeemListService(); $pager = $service->handle(); $this->view->pick('user/console/point_redeems'); $this->view->setVar('pager', $pager); } /** * @Get("/friends", name="home.uc.friends") */ public function friendsAction() { $service = new FriendListService(); $pager = $service->handle(); $this->view->pick('user/console/friends'); $this->view->setVar('pager', $pager); } /** * @Get("/groups", name="home.uc.groups") */ public function groupsAction() { $scope = $this->request->getQuery('scope', 'string', 'joined'); $service = new GroupListService(); $pager = $service->handle($scope); $this->view->pick('user/console/groups'); $this->view->setVar('scope', $scope); $this->view->setVar('pager', $pager); } /** * @Get("/subscribe", name="home.uc.subscribe") */ public function subscribeAction() { $subscribeRepo = new WeChatSubscribeRepo(); $subscribe = $subscribeRepo->findByUserId($this->authUser->id); $subscribed = $subscribe ? 1 : 0; $this->view->pick('user/console/subscribe'); $this->view->setVar('subscribed', $subscribed); } /** * @Post("/profile/update", name="home.uc.update_profile") */ public function updateProfileAction() { $service = new ProfileUpdateService(); $service->handle(); $location = $this->url->get(['for' => 'home.uc.profile']); $content = [ 'location' => $location, 'msg' => '更新资料成功', ]; return $this->jsonSuccess($content); } /** * @Post("/contact/update", name="home.uc.update_contact") */ public function updateContactAction() { $service = new ContactUpdateService(); $service->handle(); $content = ['msg' => '更新收货信息成功']; return $this->jsonSuccess($content); } /** * @Post("/connect/{id:[0-9]+}/delete", name="home.uc.unconnect") */ public function deleteConnectAction($id) { $service = new ConnectDeleteService(); $service->handle($id); $location = $this->url->get(['for' => 'home.uc.account']); $content = [ 'location' => $location, 'msg' => '解除登录绑定成功', ]; return $this->jsonSuccess($content); } }