RewardHistory.cshtml 5.8 KB

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