History.cshtml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. @model LotteryWebApp.Models.UserTicketHistoryModel
  2. @using LotteryWebApp.Languages
  3. @using LotteryWebApp.Common
  4. @{
  5. ViewData["Title"] = "LotteryV2 - History";
  6. Layout = "~/Areas/LotteryV2/Views/Shared/_Layout.cshtml";
  7. ViewData["ActiveTab"] = "History";
  8. }
  9. @section Styles {
  10. <script src="https://cdn.tailwindcss.com"></script>
  11. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  12. <link rel="stylesheet" href="/LotteryV2/css/site.css" />
  13. <link rel="stylesheet" href="/LotteryV2/css/results.css" />
  14. <link rel="stylesheet" href="/LotteryV2/css/history.css" />
  15. }
  16. <div class="main-container results-container animate__animated animate__fadeIn pb-40 relative">
  17. <!-- Header Group: Fixed at Top -->
  18. <div class="fixed top-0 left-0 md:left-1/2 md:-translate-x-1/2 w-full md:max-w-[414px] z-[100] bg-[#F3F4F6] pb-2 shadow-md">
  19. <!-- Header -->
  20. <div class="results-top-header">
  21. <a href="/LotteryV2/Home/GameHome" class="back-btn">
  22. <i class="fas fa-arrow-left"></i>
  23. </a>
  24. <h1 class="font-bricolage">@Lang.history</h1>
  25. </div>
  26. <!-- Game Tabs -->
  27. <div class="history-game-tabs !mt-0 pt-3 scale-95 origin-top">
  28. <div class="game-tab @(Model.termType == Constants.PIC10_BASIC_CODE ? "active" : "")"
  29. onclick="changeGame('@Constants.PIC10_BASIC_CODE', this)">@Lang.v2_classic_pick_10</div>
  30. <div class="game-tab @(Model.termType == Constants.PIC10_BIGSMALL_CODE ? "active" : "")"
  31. onclick="changeGame('@Constants.PIC10_BIGSMALL_CODE', this)">@Lang.v2_big_small</div>
  32. <div class="game-tab @(Model.termType == Constants.PIC10_ODDEVEN_CODE ? "active" : "")"
  33. onclick="changeGame('@Constants.PIC10_ODDEVEN_CODE', this)">@Lang.v2_odd_even</div>
  34. </div>
  35. <!-- Status Filters -->
  36. <div class="status-filters !mt-1">
  37. <div class="status-filter @(Model.status == Constants.ALL_DATA ? "active" : "")"
  38. onclick="changeStatus('@Constants.ALL_DATA', this)">@Lang.v2_all</div>
  39. <div class="status-filter @(Model.status == Constants.NOT_DRAW_CODE ? "active" : "")"
  40. onclick="changeStatus('@Constants.NOT_DRAW_CODE', this)">@Lang.v2_waiting</div>
  41. <div class="status-filter @(Model.status == Constants.WIN_CODE ? "active" : "")"
  42. onclick="changeStatus('@Constants.WIN_CODE', this)">@Lang.v2_win</div>
  43. <div class="status-filter @(Model.status == Constants.DRAWN_CODE ? "active" : "")"
  44. onclick="changeStatus('@Constants.DRAWN_CODE', this)">@Lang.v2_not_win</div>
  45. </div>
  46. </div>
  47. <!-- Spacer to push content down below fixed header (~160px) -->
  48. <div class="h-[160px]"></div>
  49. <!-- Ticket List Container -->
  50. <div id="history-list-container" class="history-items-list px-4 mt-2">
  51. <partial name="_TermUserTicketHistory" model="Model" />
  52. </div>
  53. <!-- Pagination (Optional but good to have if supported) -->
  54. @if (Model.totalPage != null && int.Parse(Model.totalPage) > 1) {
  55. <div class="flex justify-center gap-4 pb-40">
  56. <button onclick="changePage(currentSeqPage - 1)" class="p-2 px-4 bg-white rounded-lg shadow-sm font-bold text-gray-500 disabled:opacity-30" id="prevPage">Prev</button>
  57. <span class="p-2 font-bold text-[#EE0033]" id="pageDisplay">@Model.seqPage / @Model.totalPage</span>
  58. <button onclick="changePage(currentSeqPage + 1)" class="p-2 px-4 bg-white rounded-lg shadow-sm font-bold text-gray-500 disabled:opacity-30" id="nextPage">Next</button>
  59. </div>
  60. }
  61. <!-- Shared Bottom Navbar -->
  62. <partial name="_BottomNavbar" />
  63. </div>
  64. @section Scripts {
  65. <script>
  66. let currentTermType = '@Model.termType';
  67. let currentStatus = '@Model.status';
  68. let currentSeqPage = parseInt('@Model.seqPage');
  69. let totalPages = parseInt('@Model.totalPage' || '1');
  70. function changeGame(type, el) {
  71. if (currentTermType === type) return;
  72. currentTermType = type;
  73. currentSeqPage = 1;
  74. document.querySelectorAll('.game-tab').forEach(t => t.classList.remove('active'));
  75. el.classList.add('active');
  76. loadHistory();
  77. }
  78. function changeStatus(status, el) {
  79. if (currentStatus === status) return;
  80. currentStatus = status;
  81. currentSeqPage = 1;
  82. document.querySelectorAll('.status-filter').forEach(t => t.classList.remove('active'));
  83. el.classList.add('active');
  84. loadHistory();
  85. }
  86. function changePage(page) {
  87. if (page < 1 || page > totalPages) return;
  88. currentSeqPage = page;
  89. loadHistory();
  90. }
  91. function loadHistory() {
  92. const container = document.getElementById("history-list-container");
  93. container.style.opacity = "0.5";
  94. fetch(subDomain + `/LotteryV2/Home/TermUserTicketHistory?termType=${currentTermType}&status=${currentStatus}&seqPage=${currentSeqPage}`)
  95. .then(response => response.text())
  96. .then(html => {
  97. container.innerHTML = html;
  98. container.style.opacity = "1";
  99. updatePaginationUI();
  100. })
  101. .catch(error => {
  102. container.style.opacity = "1";
  103. });
  104. }
  105. function updatePaginationUI() {
  106. const pageDisplay = document.getElementById("pageDisplay");
  107. const prevBtn = document.getElementById("prevPage");
  108. const nextBtn = document.getElementById("nextPage");
  109. if (pageDisplay) {
  110. // Total pages might have changed after filter
  111. // We'd need to get it from the partial view or another API call
  112. // For now, assume it's stable or handled by the server
  113. pageDisplay.innerText = `${currentSeqPage} / ${totalPages}`;
  114. }
  115. if (prevBtn) prevBtn.disabled = currentSeqPage <= 1;
  116. if (nextBtn) nextBtn.disabled = currentSeqPage >= totalPages;
  117. }
  118. </script>
  119. }