checkWebLogin(); I18n::init(); $db = new Database(); $userId = $this->getCurrentUserId(); $user = $db->get('users', ['id','username','balance'], ['id' => $userId]); $service = new FollowPlanService($db); $game = $db->get('games', '*', ['code' => 'pk10', 'status' => 1]); $gameId = $game['id'] ?? 0; $plans = $service->getActivePlans($gameId); $userFollows = $service->getUserFollowStatus($userId); $summary = $service->getUserSummary($userId); extract(compact('user', 'plans', 'userFollows', 'summary', 'game')); include __DIR__ . '/../../Views/Web/follow_plan.php'; } /** * 切换跟单状态 API */ public function toggleFollow() { $this->checkWebLogin(); header('Content-Type: application/json'); $db = new Database(); $data = json_decode(file_get_contents('php://input'), true); $planId = intval($data['plan_id'] ?? 0); $service = new FollowPlanService($db); $result = $service->toggleFollow($this->getCurrentUserId(), $planId); echo json_encode($result); } }