Selaa lähdekoodia

篮球预测记录

charles_c 5 kuukautta sitten
vanhempi
commit
e4a0e33777
1 muutettua tiedostoa jossa 108 lisäystä ja 60 poistoa
  1. 108 60
      src/app/personal-center/page.jsx

+ 108 - 60
src/app/personal-center/page.jsx

@@ -157,6 +157,28 @@ const PersonalCenter = () => {
     router.push("/exchange-points");
   };
 
+  const getResultColor = (result) => {
+    switch (result) {
+      case "correct":
+        return "text-green-600";
+      case "incorrect":
+        return "text-red-600";
+      default:
+        return "text-gray-600";
+    }
+  };
+
+  const getResultText = (result, score) => {
+    switch (result) {
+      case "correct":
+        return "正确";
+      case "incorrect":
+        return score || "错误";
+      default:
+        return "待定";
+    }
+  };
+
   if (isLoading) {
     return (
       <div className="bg-blue-600 text-white min-h-screen p-4">Loading...</div>
@@ -257,6 +279,9 @@ const PersonalCenter = () => {
               >
                 <p className="font-bold text-blue-700 mb-2">
                   {prediction.matchInfo}
+                  <span className="ml-2 text-sm text-gray-500">
+                    [{prediction.type === "football" ? "足球" : "篮球"}]
+                  </span>
                 </p>
                 <p className="text-gray-600 mb-2">
                   比赛时间:{" "}
@@ -265,104 +290,127 @@ const PersonalCenter = () => {
                   </span>
                 </p>
                 <div className="grid grid-cols-2 gap-2">
+                  {/* 胜负预测 */}
                   <p>
                     胜负预测:{" "}
                     <span
                       className={`font-medium ${
-                        prediction.whoWillWin === "home"
+                        prediction.type === "football"
+                          ? prediction.football?.whoWillWin?.prediction ===
+                            "home"
+                            ? "text-red-600"
+                            : prediction.football?.whoWillWin?.prediction ===
+                              "away"
+                            ? "text-green-600"
+                            : "text-yellow-600"
+                          : prediction.basketball?.whoWillWin?.prediction ===
+                            "home"
                           ? "text-red-600"
-                          : prediction.whoWillWin === "away"
-                          ? "text-green-600"
-                          : "text-yellow-600"
+                          : "text-green-600"
                       }`}
                     >
-                      {prediction.whoWillWin === "home"
+                      {prediction.type === "football"
+                        ? prediction.football?.whoWillWin?.prediction === "home"
+                          ? "主胜"
+                          : prediction.football?.whoWillWin?.prediction ===
+                            "away"
+                          ? "客胜"
+                          : "平局"
+                        : prediction.basketball?.whoWillWin?.prediction ===
+                          "home"
                         ? "主胜"
-                        : prediction.whoWillWin === "away"
-                        ? "客胜"
-                        : "平局"}
+                        : "客胜"}
                     </span>
                   </p>
                   <p>
                     结果:{" "}
                     <span
-                      className={`font-medium ${
-                        prediction.whoWillWinResult === "correct"
-                          ? "text-green-600"
-                          : prediction.whoWillWinResult === "incorrect"
-                          ? "text-red-600"
-                          : "text-gray-600"
-                      }`}
+                      className={`font-medium ${getResultColor(
+                        prediction.type === "football"
+                          ? prediction.football?.whoWillWin?.result
+                          : prediction.basketball?.whoWillWin?.result
+                      )}`}
                     >
-                      {prediction.whoWillWinResult === "correct"
-                        ? "正确"
-                        : prediction.whoWillWinResult === "incorrect"
-                        ? prediction.whoWillWin === "home"
-                          ? "客胜"
-                          : "主胜"
-                        : "待定"}
+                      {getResultText(
+                        prediction.type === "football"
+                          ? prediction.football?.whoWillWin?.result
+                          : prediction.basketball?.whoWillWin?.result
+                      )}
                     </span>
                   </p>
+
+                  {/* 让分/首先得分预测 */}
                   <p>
-                    首先得分:{" "}
+                    {prediction.type === "football" ? "首先得分" : "让分预测"}:{" "}
                     <span
                       className={`font-medium ${
-                        prediction.firstTeamToScore === "home"
+                        prediction.type === "football"
+                          ? prediction.football?.firstTeamToScore
+                              ?.prediction === "home"
+                            ? "text-red-600"
+                            : "text-green-600"
+                          : prediction.basketball?.spread?.prediction === "home"
                           ? "text-red-600"
-                          : prediction.firstTeamToScore === "away"
-                          ? "text-green-600"
-                          : "text-gray-600"
+                          : "text-green-600"
                       }`}
                     >
-                      {prediction.firstTeamToScore === "home"
-                        ? "主队"
-                        : prediction.firstTeamToScore === "away"
-                        ? "客队"
-                        : "无进球"}
+                      {prediction.type === "football"
+                        ? prediction.football?.firstTeamToScore?.prediction ===
+                          "home"
+                          ? "主队"
+                          : prediction.football?.firstTeamToScore
+                              ?.prediction === "away"
+                          ? "客队"
+                          : "无进球"
+                        : prediction.basketball?.spread?.prediction === "home"
+                        ? "主队赢盘"
+                        : "客队赢盘"}
                     </span>
                   </p>
                   <p>
                     结果:{" "}
                     <span
-                      className={`font-medium ${
-                        prediction.firstTeamToScoreResult === "correct"
-                          ? "text-green-600"
-                          : prediction.firstTeamToScoreResult === "incorrect"
-                          ? "text-red-600"
-                          : "text-gray-600"
-                      }`}
+                      className={`font-medium ${getResultColor(
+                        prediction.type === "football"
+                          ? prediction.football?.firstTeamToScore?.result
+                          : prediction.basketball?.spread?.result
+                      )}`}
                     >
-                      {prediction.firstTeamToScoreResult === "correct"
-                        ? "正确"
-                        : prediction.firstTeamToScoreResult === "incorrect"
-                        ? prediction.firstTeamToScore === "home"
-                          ? "客队"
-                          : "主队"
-                        : "待定"}
+                      {getResultText(
+                        prediction.type === "football"
+                          ? prediction.football?.firstTeamToScore?.result
+                          : prediction.basketball?.spread?.result
+                      )}
                     </span>
                   </p>
+
+                  {/* 总分/进球预测 */}
                   <p>
-                    总进球数:{" "}
+                    {prediction.type === "football" ? "总进球数" : "总分预测"}:{" "}
                     <span className="font-medium text-purple-600">
-                      {prediction.totalGoals}
+                      {prediction.type === "football"
+                        ? prediction.football?.totalGoals?.prediction
+                        : prediction.basketball?.totalPoints?.prediction ===
+                          "over"
+                        ? "大分"
+                        : "小分"}
                     </span>
                   </p>
                   <p>
                     结果:{" "}
                     <span
-                      className={`font-medium ${
-                        prediction.totalGoalsResult === "correct"
-                          ? "text-green-600"
-                          : prediction.totalGoalsResult === "incorrect"
-                          ? "text-red-600"
-                          : "text-gray-600"
-                      }`}
+                      className={`font-medium ${getResultColor(
+                        prediction.type === "football"
+                          ? prediction.football?.totalGoals?.result
+                          : prediction.basketball?.totalPoints?.result
+                      )}`}
                     >
-                      {prediction.totalGoalsResult === "correct"
-                        ? "正确"
-                        : prediction.totalGoalsResult === "incorrect"
-                        ? prediction.score
-                        : "待定"}
+                      {getResultText(
+                        prediction.type === "football"
+                          ? prediction.football?.totalGoals?.result
+                          : prediction.basketball?.totalPoints?.result,
+                        prediction.score
+                      )}
                     </span>
                   </p>
                 </div>