RewardHistory.cshtml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. @model LotteryWebApp.Models.RewardHistoryModel
  2. @using LotteryWebApp.Languages
  3. @{
  4. ViewData["Title"] = "Millions - Reward History";
  5. Layout = "~/Areas/Millions/Views/Shared/_Layout.cshtml";
  6. ViewData["ActiveTab"] = "More";
  7. }
  8. @section Styles {
  9. <script src="https://cdn.tailwindcss.com"></script>
  10. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  11. <link rel="stylesheet" href="/Millions/css/site.css" />
  12. <link rel="stylesheet" href="/Millions/css/results.css" />
  13. <link rel="stylesheet" href="/Millions/css/reward-history.css" />
  14. }
  15. <div class="main-container reward-history-container animate__animated animate__fadeIn pb-40 relative">
  16. <!-- Fixed Header -->
  17. <div class="fixed top-0 left-0 md:left-1/2 md:-translate-x-1/2 w-full md:max-w-[430px] z-[100] bg-[#0062FF]">
  18. <div class="results-top-header">
  19. <a href="/Millions/Home/More" class="back-btn">
  20. <i class="fa-solid fa-arrow-left"></i>
  21. </a>
  22. <h1 class="font-bricolage">Reward History</h1>
  23. </div>
  24. <!-- Spacer with rounded white top (matches History layout) -->
  25. <div class="bg-white rounded-t-[30px] h-[16px]"></div>
  26. </div>
  27. <!-- List container (spaced below fixed header) -->
  28. <div id="reward-list-container"
  29. class="reward-list-container bg-white rounded-t-[30px] px-4 pt-4 mt-[80px] pb-[120px] min-h-[calc(100vh-80px)] shadow-sm">
  30. <partial name="_RewardHistoryList" model="Model" />
  31. </div>
  32. <!-- Bottom Navbar -->
  33. <partial name="_BottomNavbar" />
  34. <!-- Notification Modal -->
  35. <div id="notificationModal" class="fixed inset-0 z-[300] flex items-center justify-center hidden px-6 font-bricolage" style="background: linear-gradient(135deg, rgba(26, 26, 46, 0.9) 0%, rgba(22, 33, 62, 0.9) 100%);">
  36. <div class="w-full max-w-[343px] min-h-[420px] bg-white rounded-[24px] overflow-hidden flex flex-col items-center p-8 animate__animated animate__zoomIn animate__faster shadow-2xl border border-white/50">
  37. <div class="w-full flex justify-center mb-8 mt-4">
  38. <img src="/Millions/img/modal/fail_icon.png" class="w-[160px] h-auto object-contain" alt="Notification icon" />
  39. </div>
  40. <div class="px-2 text-center mb-10 flex-1 flex items-center justify-center">
  41. <p id="notificationMessage" class="text-black font-[800] text-[20px] leading-snug"></p>
  42. </div>
  43. <div class="w-full">
  44. <button onclick="closeNotificationModal()" class="w-full bg-[#0062FF] text-white font-[800] text-[18px] py-[12px] rounded-[16px] shadow-lg active:scale-95 transition-all">
  45. @Lang.login
  46. </button>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. @section Scripts {
  52. <script>
  53. let currentSeqPage = parseInt('@Model.seqPage' || '1');
  54. let totalPages = parseInt('@Model.totalPage' || '1');
  55. let systemUpgrading = false;
  56. function changeRewardPage(page) {
  57. if (page < 1 || page > totalPages) return;
  58. currentSeqPage = page;
  59. loadRewardHistory();
  60. }
  61. function loadRewardHistory() {
  62. const container = document.getElementById("reward-list-container");
  63. container.style.opacity = "0.5";
  64. fetch(subDomain + `/Millions/Home/RewardHistoryPartial?seqPage=${currentSeqPage}`)
  65. .then(response => {
  66. if (!response.ok) throw new Error('Network response was not ok');
  67. return response.text();
  68. })
  69. .then(html => {
  70. try {
  71. const json = JSON.parse(html);
  72. if (json.responseCode === "-2" || (json.responseMessage && json.responseMessage.includes("System is upgrading"))) {
  73. showNotification(json.responseMessage || "System is upgrading", "-2");
  74. return;
  75. }
  76. } catch (e) {
  77. // Not JSON, HTML partial
  78. }
  79. container.innerHTML = html;
  80. container.style.opacity = "1";
  81. updatePaginationUI();
  82. })
  83. .catch(error => {
  84. console.error("Error loading reward history:", error);
  85. container.style.opacity = "1";
  86. if (error.message && (error.message.includes("System is upgrading") || error.message.includes("-2"))) {
  87. showNotification(error.message, "-2");
  88. }
  89. });
  90. }
  91. function updatePaginationUI() {
  92. const pageDisplay = document.getElementById("pageDisplay");
  93. const prevBtn = document.getElementById("prevPage");
  94. const nextBtn = document.getElementById("nextPage");
  95. if (pageDisplay) pageDisplay.innerText = `${currentSeqPage} / ${totalPages}`;
  96. if (prevBtn) prevBtn.disabled = currentSeqPage <= 1;
  97. if (nextBtn) nextBtn.disabled = currentSeqPage >= totalPages;
  98. }
  99. function showNotification(message, code) {
  100. $("#notificationMessage").text(message);
  101. const $btn = $("#notificationModal button");
  102. if (code === "-2" || (message && message.includes("System is upgrading"))) {
  103. systemUpgrading = true;
  104. $btn.text("@Lang.login");
  105. } else {
  106. systemUpgrading = false;
  107. $btn.text("OK");
  108. }
  109. $("#notificationModal").removeClass("hidden").addClass("flex");
  110. }
  111. function closeNotificationModal() {
  112. $("#notificationModal").addClass("hidden").removeClass("flex");
  113. if (systemUpgrading) {
  114. window.location.href = subDomain + "/Account/Login";
  115. }
  116. }
  117. </script>
  118. }