BuyTicket.cshtml 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. @model LotteryWebApp.Models.HomeIndex_ViewModel
  2. @{
  3. ViewData["Title"] = "LotteryV2 - Buy Ticket";
  4. Layout = "~/Areas/LotteryV2/Views/Shared/_Layout.cshtml";
  5. var currentTerm = Model.listTerm?.FirstOrDefault();
  6. }
  7. @using LotteryWebApp.Languages;
  8. @using LotteryWebApp.Common;
  9. <link rel="stylesheet" href="/LotteryV2/css/buy-ticket.css" />
  10. <link rel="stylesheet" href="/LotteryV2/css/buy-ticket.css" />
  11. @if (Model.termType == Constants.PIC10_BIGSMALL_CODE || Model.termType == Constants.PIC10_ODDEVEN_CODE)
  12. {
  13. var isBigSmall = Model.termType == Constants.PIC10_BIGSMALL_CODE;
  14. var themeColor = isBigSmall ? "#0A9800" : "#AA3DC8";
  15. var gameTitle = isBigSmall ? Lang.v2_big_small : Lang.v2_odd_even;
  16. var prizeAmount = isBigSmall ? "100" : "200";
  17. <!-- ==================== CARD SELECTION GAME UI (BIG/SMALL or ODD/EVEN) ==================== -->
  18. <div class="main-container animate__animated animate__fadeIn bg-[#F5F5F5] h-screen flex flex-col font-bricolage overflow-hidden max-w-[414px] mx-auto relative">
  19. <!-- Header -->
  20. <div class="w-full py-3 px-4 text-white flex items-center justify-between sticky top-0 z-[60]" style="background: @themeColor;">
  21. <button onclick="location.href='@Url.Action("GameHome", "Home")'" class="w-10 h-10 flex items-center justify-center -ml-2 rounded-full active:bg-white/20 transition-all">
  22. <i class="fa-solid fa-arrow-left text-[20px]"></i>
  23. </button>
  24. <span class="font-[800] text-[18px] absolute left-1/2 -translate-x-1/2 whitespace-nowrap">
  25. @gameTitle
  26. </span>
  27. <div class="w-8"></div>
  28. </div>
  29. <!-- Sticky Term Info sub-header -->
  30. <div class="p-4 py-2.5 bg-white flex items-center justify-between shadow-sm sticky top-[52px] z-50">
  31. <div class="flex items-center gap-2 border border-[#E5E7EB] rounded-lg px-3 py-1.5 bg-gray-50">
  32. <i class="fa-regular fa-calendar text-[[@themeColor]] text-sm" style="color: @themeColor"></i>
  33. <span class="text-[12px] font-bold text-gray-700">@DateTime.Now.ToString("dddd, MMM dd, yyyy", System.Globalization.CultureInfo.InvariantCulture)</span>
  34. </div>
  35. <div class="flex items-center gap-1 ml-4 flex-1 justify-end">
  36. <span class="text-[12px] font-bold text-gray-400">@Lang.v2_round</span>
  37. <span class="text-[18px] font-black text-brown-main">#@(currentTerm?.id ?? "123")</span>
  38. </div>
  39. </div>
  40. <!-- Scrollable Content Area -->
  41. <div class="flex-1 overflow-y-auto bg-white pb-40" id="bsContent">
  42. <!-- Results for the last 5 days -->
  43. <div class="px-5 pt-4 pb-2">
  44. <h3 class="text-[17px] font-bold text-black text-center mb-3">Results for the last 5 days</h3>
  45. <div id="last5Results" class="flex justify-between gap-1.5 px-1">
  46. @* Mock data for results *@
  47. @for(int r=0; r<5; r++) {
  48. var resTitle = isBigSmall ? (r % 2 == 0 ? "Big" : "Small") : (r % 2 == 0 ? "Odd" : "Even");
  49. var resColor = isBigSmall ? (resTitle == "Big" ? "#A2FF00" : "#FF4157") : (resTitle == "Odd" ? "#FFC700" : "#B33BD0");
  50. <div class="flex flex-col items-center justify-center min-h-[56px] flex-1 rounded-lg py-1.5 border border-gray-200" style="background: linear-gradient(136deg, #FFFAE6 0%, #FFE588 100%);">
  51. <span class="text-[10px] font-bold text-black whitespace-nowrap opacity-70">Mar @(16+r)</span>
  52. <span class="text-[18px] font-black leading-tight" style="-webkit-text-stroke: 0.5px #000; color: @resColor;">@resTitle</span>
  53. </div>
  54. }
  55. </div>
  56. </div>
  57. <!-- Selection Cards -->
  58. <!-- Selection Cards -->
  59. <div class="px-5 pt-4 flex gap-3 h-[245px]">
  60. <!-- Card 1 (Big or Odd) -->
  61. <div id="cardBig" onclick="selectBigSmall('big')" class="bigsmall-card flex-1 rounded-2xl relative cursor-pointer transition-all duration-300 active:scale-[0.97] border-2 border-transparent overflow-hidden flex flex-col" style="background: linear-gradient(180deg, #FFF7DB 0%, #FFEEB3 100%);">
  62. <img src="/LotteryV2/img/bigsmall/light_effect_1.png" class="absolute top-0 left-0 w-full opacity-60 pointer-events-none" alt="" />
  63. <img src="/LotteryV2/img/bigsmall/light_effect_2.png" class="absolute bottom-12 left-0 w-full opacity-60 pointer-events-none" alt="" />
  64. <div class="flex flex-col items-center pt-4 pb-3 px-3 relative z-10 h-full justify-between">
  65. <div class="flex flex-col items-center w-full">
  66. <div class="h-[34px] flex items-center justify-center">
  67. <div class="text-[30px] font-[800] leading-none" style="-webkit-text-stroke: 1px #000; text-shadow: 1px 2px 2px rgba(0,0,0,0.15); color: @(isBigSmall ? "#A2FF00" : "#FFC700");">@(isBigSmall ? "Big" : "Odd")</div>
  68. </div>
  69. <div class="text-[11px] font-medium text-gray-500 mt-1 h-[28px] text-center leading-tight">
  70. @(isBigSmall ? "13 number from" : "Odd numbers") <br/> <b>@(isBigSmall ? "41-80" : "1, 3, 5, 7, 9")</b>
  71. </div>
  72. </div>
  73. <div class="flex items-center justify-center -space-x-2 my-2">
  74. @if (isBigSmall) {
  75. <img src="/LotteryV2/img/bigsmall/ball_42_dark.png" class="w-12 h-12 relative z-[1]" alt="42" />
  76. <img src="/LotteryV2/img/bigsmall/ball_88_big.png" class="w-16 h-16 relative z-[2]" alt="88" />
  77. <img src="/LotteryV2/img/bigsmall/ball_54_dark.png" class="w-12 h-12 relative z-[1]" alt="54" />
  78. } else {
  79. <img src="/LotteryV2/img/oddeven/ball_3.png" class="w-12 h-12 relative z-[1]" alt="3" />
  80. <img src="/LotteryV2/img/oddeven/ball_1.png" class="w-16 h-16 relative z-[2]" alt="1" />
  81. <img src="/LotteryV2/img/oddeven/ball_19.png" class="w-12 h-12 relative z-[1]" alt="19" />
  82. }
  83. </div>
  84. <button class="bigsmall-btn w-full py-2.5 rounded-xl font-black text-[15px] transition-all shadow-md" style="background: @themeColor; color: white;">@Lang.v2_select</button>
  85. </div>
  86. </div>
  87. <!-- Card 2 (Small or Even) -->
  88. <div id="cardSmall" onclick="selectBigSmall('small')" class="bigsmall-card flex-1 rounded-2xl relative cursor-pointer transition-all duration-300 active:scale-[0.97] border-2 border-transparent overflow-hidden flex flex-col" style="background: linear-gradient(180deg, #FFF7DB 0%, #FFEEB3 100%);">
  89. <img src="/LotteryV2/img/bigsmall/light_effect_1.png" class="absolute top-0 left-0 w-full opacity-60 pointer-events-none" alt="" />
  90. <img src="/LotteryV2/img/bigsmall/light_effect_2.png" class="absolute bottom-12 left-0 w-full opacity-60 pointer-events-none" alt="" />
  91. <div class="flex flex-col items-center pt-4 pb-3 px-3 relative z-10 h-full justify-between">
  92. <div class="flex flex-col items-center w-full">
  93. <div class="h-[34px] flex items-center justify-center">
  94. <div class="text-[22px] font-[800] leading-none italic" style="-webkit-text-stroke: 1px #000; text-shadow: 1px 2px 2px rgba(0,0,0,0.15); color: @(isBigSmall ? "#FF4157" : "#B33BD0");">@(isBigSmall ? "Small" : "Even")</div>
  95. </div>
  96. <div class="text-[11px] font-medium text-gray-500 mt-1 h-[28px] text-center leading-tight">
  97. @(isBigSmall ? "13 number from" : "Even numbers") <br/> <b>@(isBigSmall ? "01-40" : "0, 2, 4, 6, 8")</b>
  98. </div>
  99. </div>
  100. <div class="flex items-center justify-center -space-x-2 my-2">
  101. @if (isBigSmall) {
  102. <img src="/LotteryV2/img/bigsmall/ball_5_blue.png" class="w-12 h-12 relative z-[1]" alt="5" />
  103. <img src="/LotteryV2/img/bigsmall/ball_1_big.png" class="w-16 h-16 relative z-[2]" alt="1" />
  104. <img src="/LotteryV2/img/bigsmall/ball_8_pink.png" class="w-12 h-12 relative z-[1]" alt="8" />
  105. } else {
  106. <img src="/LotteryV2/img/oddeven/ball_66.png" class="w-12 h-12 relative z-[1]" alt="66" />
  107. <img src="/LotteryV2/img/oddeven/ball_68.png" class="w-16 h-16 relative z-[2]" alt="68" />
  108. <img src="/LotteryV2/img/oddeven/ball_88.png" class="w-12 h-12 relative z-[1]" alt="88" />
  109. }
  110. </div>
  111. <button class="bigsmall-btn w-full py-2.5 rounded-xl font-black text-[15px] transition-all shadow-md"
  112. style="background: @themeColor; color: white;">@Lang.v2_select</button>
  113. </div>
  114. </div>
  115. </div>
  116. <!-- You Choose + Prize Section -->
  117. <div class="px-5 pt-6 flex flex-col items-center gap-4">
  118. <div class="flex flex-col items-center">
  119. <span class="text-[12px] font-medium text-gray-500">@Lang.v2_you_choose</span>
  120. <span id="choiceDisplay" class="text-[32px] font-[800] leading-tight" style="-webkit-text-stroke: 1px #000;">—</span>
  121. </div>
  122. <div class="flex flex-col items-center">
  123. <span class="text-[12px] font-medium text-gray-500">@Lang.v2_prize_if_win</span>
  124. <div class="flex items-baseline gap-1">
  125. <span class="text-[28px] font-black text-black">@prizeAmount</span>
  126. <span class="text-[14px] font-black text-[#E56B23]">HTG</span>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- Bottom Action Bar -->
  132. <div class="p-4 bg-white border-t border-gray-200 z-[70] shadow-[0px_-4px_10px_rgba(0,0,0,0.03)] absolute bottom-0 w-full left-0">
  133. <div class="flex items-center justify-between">
  134. <div class="flex flex-col">
  135. <span class="text-[12px] text-gray-500 font-bold uppercase">@Lang.v2_estimated_ticket_price</span>
  136. <div class="flex items-baseline gap-1">
  137. <span id="bsTotalPrice" class="text-[28px] font-black text-black">50</span>
  138. <span class="text-[13px] font-black" style="color: @themeColor">HTG</span>
  139. </div>
  140. </div>
  141. <button id="bsPaymentBtn" onclick="bsShowPayment()" class="text-white text-[20px] font-black px-10 py-3.5 rounded-xl shadow-lg active:scale-95 transition-all" style="background: @themeColor;">
  142. @Lang.v2_payment
  143. </button>
  144. </div>
  145. </div>
  146. </div>
  147. }
  148. else
  149. {
  150. <!-- ==================== CLASSIC PICK 10 / ODD-EVEN GAME UI ==================== -->
  151. <div class="main-container animate__animated animate__fadeIn bg-[#F5F5F5] h-screen flex flex-col font-bricolage overflow-hidden max-w-[414px] mx-auto relative">
  152. <!-- Header -->
  153. <div class="w-full bg-[#EE0033] py-3 px-4 text-white flex items-center justify-between sticky top-0 z-[60]">
  154. <button onclick="location.href='@Url.Action("GameHome", "Home")'" class="w-10 h-10 flex items-center justify-center -ml-2 rounded-full active:bg-white/20 transition-all">
  155. <i class="fa-solid fa-arrow-left text-[20px]"></i>
  156. </button>
  157. <span class="font-[800] text-[18px] absolute left-1/2 -translate-x-1/2 whitespace-nowrap">
  158. @if (Model.termType == Constants.PIC10_BASIC_CODE) { @Lang.v2_buy_classic_pick_10 }
  159. else { @Lang.v2_odd_even }
  160. </span>
  161. <div class="w-8"></div>
  162. </div>
  163. <!-- Sticky Term Info sub-header -->
  164. <div class="p-4 py-2.5 bg-white flex items-center justify-between shadow-sm sticky top-[52px] z-50">
  165. <div class="flex items-center gap-2 border border-[#E5E7EB] rounded-lg px-3 py-1.5 bg-gray-50">
  166. <i class="fa-regular fa-calendar text-[#EE0033] text-sm"></i>
  167. <span class="text-[12px] font-bold text-gray-700">@DateTime.Now.ToString("dddd, MMM dd, yyyy", System.Globalization.CultureInfo.InvariantCulture)</span>
  168. </div>
  169. <div class="flex items-center gap-1 ml-4 flex-1 justify-end">
  170. <span class="text-[12px] font-bold text-gray-400">@Lang.v2_round</span>
  171. <span class="text-[18px] font-black text-brown-main">#@(currentTerm?.id ?? "12459")</span>
  172. </div>
  173. </div>
  174. <!-- Ticket Scrollable List Area -->
  175. <div id="ticketContainer" class="p-4 flex flex-col gap-6 flex-1 overflow-y-auto bg-[#F5F5F5]">
  176. @for (int i = 1; i <= 2; i++)
  177. {
  178. <div class="ticket-card relative group active:bg-gray-50 transition-colors cursor-pointer animate__animated animate__fadeIn">
  179. <button onclick="removeEntry(this)" class="absolute -right-2 top-2 w-7 h-7 bg-[#999] text-white rounded-full flex items-center justify-center text-[11px] shadow-sm z-[10] hover:bg-red-500 transition-all border-2 border-white">
  180. <i class="fa-solid fa-xmark"></i>
  181. </button>
  182. <div class="absolute left-2 top-4 w-9 h-9 rounded-full bg-[#EE0033] border-[3px] border-white flex items-center justify-center text-white font-black text-sm shadow-md ticket-index">@i</div>
  183. <div class="flex flex-col gap-1 pl-8">
  184. <span class="text-[16px] font-extrabold text-[#333]">@Lang.v2_select_10_lucky_numbers</span>
  185. <div class="flex items-start gap-4">
  186. <div class="grid grid-cols-5 gap-y-1 gap-x-2 flex-1">
  187. @for (int j = 0; j < (Model.termType == Constants.PIC10_BASIC_CODE ? 10 : 15); j++)
  188. {
  189. <div class="ball-circle ball-empty"></div>
  190. }
  191. </div>
  192. <div class="w-20 action-area flex flex-col gap-2">
  193. <button onclick="randomizeTicket(this)" class="rand-btn bg-green-main text-white flex items-center justify-center gap-2 w-20 py-2 rounded-xl font-extrabold text-[11px] shadow-sm active:scale-95 transition-all">
  194. <i class="fa-solid fa-arrows-rotate text-[10px]"></i> @Lang.Random
  195. </button>
  196. <div class="edit-delete-group hidden flex flex-col gap-2">
  197. <button onclick="editFullTicket(this)" class="bg-[#2B83F2] text-white flex items-center justify-center gap-2 w-20 py-1.5 rounded-lg font-bold text-[12px] shadow-sm active:scale-95 transition-all">
  198. <i class="fa-solid fa-pen text-[10px]"></i> @Lang.v2_edit
  199. </button>
  200. <button onclick="clearTicket(this)" class="bg-[#EE0033] text-white flex items-center justify-center gap-2 w-20 py-1.5 rounded-lg font-bold text-[12px] shadow-sm active:scale-95 transition-all">
  201. <i class="fa-solid fa-trash-can text-[10px]"></i> @Lang.v2_delete
  202. </button>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. }
  209. <div class="w-full pt-2" id="addButtonWrapper">
  210. <button onclick="addNewTicket()" class="w-fit min-w-[220px] mx-auto bg-green-main text-white font-black text-md py-2.5 px-6 rounded-xl shadow-md border-b-[4px] border-[#129A30] active:translate-y-[1px] active:border-b-[1px] transition-all flex items-center justify-center gap-2">
  211. @Lang.v2_add_more_ticket
  212. </button>
  213. </div>
  214. <div class="h-4"></div>
  215. </div>
  216. <!-- Bottom Action Bar -->
  217. <div class="p-4 bg-white border-t border-gray-200 z-[70] shadow-[0px_-4px_10px_rgba(0,0,0,0.03)]">
  218. <div class="flex items-center justify-between">
  219. <div class="flex flex-col">
  220. <span class="text-[12px] text-gray-500 font-bold uppercase">@Lang.v2_estimated_ticket_price</span>
  221. <div class="flex items-baseline gap-1">
  222. <span id="totalPrice" class="text-[28px] font-black text-black">0</span>
  223. <span class="text-[13px] font-black text-[#EE0033]">HTG</span>
  224. </div>
  225. </div>
  226. <button onclick="preparePayment()" class="bg-[#EE0033] text-white text-[20px] font-black px-10 py-3.5 rounded-xl shadow-[0px_6px_15px_rgba(238,0,51,0.25)] active:scale-95 transition-all">
  227. @Lang.v2_payment
  228. </button>
  229. </div>
  230. </div>
  231. </div>
  232. }
  233. <!-- Order Summary Screen (from Figma) -->
  234. <div id="orderSummaryModal" class="hidden fixed inset-0 z-[150] bg-black/60 flex items-center justify-center p-0 font-bricolage backdrop-blur-[2px]">
  235. <div class="w-full max-w-[414px] h-full bg-white flex flex-col animate__animated animate__fadeInRight animate__faster border-x shadow-2xl relative">
  236. <!-- Header đồng bộ tuyệt đối -->
  237. <div class="w-full bg-[#EE0033] py-3 px-4 text-white flex items-center justify-between sticky top-0 z-[60]">
  238. <button onclick="hideOrderSummary()" class="w-10 h-10 flex items-center justify-center -ml-2 rounded-full active:bg-white/20 transition-all">
  239. <i class="fa-solid fa-arrow-left text-[20px]"></i>
  240. </button>
  241. <span class="font-[800] text-[18px] absolute left-1/2 -translate-x-1/2 whitespace-nowrap">
  242. @if (Model.termType == Constants.PIC10_BASIC_CODE) { @Lang.v2_buy_classic_pick_10 }
  243. else if (Model.termType == Constants.PIC10_BIGSMALL_CODE) { @Lang.v2_big_small }
  244. else { @Lang.v2_odd_even }
  245. </span>
  246. <div class="w-8"></div>
  247. </div>
  248. <!-- Content Area -->
  249. <div class="flex-1 overflow-y-auto p-5 space-y-5 bg-gray-50 pb-72">
  250. <!-- Phần Round Info từ Model -->
  251. <div class="flex items-center justify-end gap-1 mb-2 px-1">
  252. <span class="text-[12px] font-bold text-gray-400">@Lang.v2_round</span>
  253. <span class="text-[16px] font-black text-brown-main">#@(currentTerm?.id ?? "12459")</span>
  254. </div>
  255. <div class="flex justify-between items-center px-1">
  256. <span class="text-[14px] font-bold text-gray-800">Selected Tickets</span>
  257. <span class="text-[14px] font-bold text-gray-800">@Lang.price</span>
  258. </div>
  259. <!-- Ticket List List -->
  260. <div id="summaryTicketList" class="flex flex-col gap-4">
  261. <!-- Populated dynamically via JS -->
  262. </div>
  263. <!-- Dates Section -->
  264. <div class="grid grid-cols-2 gap-4 mt-8 pt-6 border-t border-dashed border-gray-300">
  265. <div class="space-y-1">
  266. <span class="text-[11px] font-black text-[#EE0033] block text-center uppercase tracking-tight">@Lang.date_purchase</span>
  267. <div class="bg-white border border-gray-100 rounded-xl py-2.5 px-2 text-center font-black text-[11px] text-gray-700 shadow-sm">
  268. @DateTime.Now.ToString("dddd MMM dd, yyyy", System.Globalization.CultureInfo.InvariantCulture)
  269. </div>
  270. </div>
  271. <div class="space-y-1">
  272. <span class="text-[11px] font-black text-[#EE0033] block text-center uppercase tracking-tight">@Lang.draw_date</span>
  273. <div class="bg-white border border-gray-100 rounded-xl py-2.5 px-2 text-center font-black text-[11px] text-gray-700 shadow-sm" id="summaryResultDate">
  274. @{
  275. DateTime drawDate;
  276. bool isValidDate = DateTime.TryParse(currentTerm?.date_start, out drawDate);
  277. if (isValidDate) {
  278. @drawDate.ToString("dddd MMM dd, yyyy", System.Globalization.CultureInfo.InvariantCulture)
  279. } else {
  280. @:N/A
  281. }
  282. }
  283. </div>
  284. </div>
  285. </div>
  286. <!-- Totals Section -->
  287. <div class="mt-10 px-2 space-y-2">
  288. <div class="flex justify-between items-center">
  289. <span class="text-[14px] font-bold text-gray-400">@Lang.total_ticket</span>
  290. <span id="summaryTotalCount" class="text-[16px] font-black text-black">0</span>
  291. </div>
  292. <div class="flex justify-between items-center">
  293. <span class="text-[14px] font-bold text-gray-400">@Lang.total_money</span>
  294. <div class="flex items-baseline gap-1">
  295. <span id="summaryTotalAmount" class="text-[32px] font-black text-black">0</span>
  296. <span class="text-[16px] font-black text-[#EE0033]">HTG</span>
  297. </div>
  298. </div>
  299. </div>
  300. <!-- Scalloped edge visual separator filler -->
  301. <div class="w-full h-8 flex overflow-hidden opacity-5 mt-4">
  302. @for(int i=0; i<30; i++) {
  303. <div class="w-4 h-4 rounded-full bg-black -mt-2 shrink-0"></div>
  304. }
  305. </div>
  306. </div>
  307. <div class="p-4 bg-white border-t border-gray-100 grid grid-cols-2 gap-4 pb-8 shadow-[0px_-4px_20px_rgba(0,0,0,0.05)] absolute bottom-0 w-full left-0 z-[70]">
  308. <button onclick="hideOrderSummary()" class="bg-[#FFB000] text-white py-2.5 rounded-2xl font-black text-[18px] shadow-lg shadow-orange-200 active:scale-95 transition-all uppercase tracking-wide">
  309. @Lang.reorder
  310. </button>
  311. <button id="finalPaymentBtn" onclick="confirmCheckout(this)" class="bg-[#EE0033] text-white py-2.5 rounded-2xl font-black text-[18px] shadow-lg shadow-red-200 active:scale-95 transition-all uppercase tracking-wide">
  312. @Lang.v2_payment
  313. </button>
  314. </div>
  315. </div>
  316. </div>
  317. <!-- OTP Verification Modal (V2 Design Overhaul - Matching Figma) -->
  318. <div id="otpModal" class="fixed inset-0 bg-black/80 backdrop-blur-sm z-[200] hidden items-center justify-center p-4">
  319. <!-- Outer container to hold the modal + external overflowing elements (like stars/glitter) -->
  320. <div class="relative w-full max-w-[360px] mt-6 animate__animated animate__zoomIn animate__faster">
  321. <!-- Glitter effect (external to the white box) -->
  322. <div class="absolute -top-[100px] -left-[10px] w-[380px] h-[160px] mix-blend-screen pointer-events-none z-0 overflow-visible opacity-90" style="background: url('/LotteryV2/img/modal/otp_glitter.png') no-repeat center center; background-size: contain;"></div>
  323. <!-- The White Box -->
  324. <div class="bg-white rounded-[32px] w-full relative z-10 shadow-[0px_0px_30px_rgba(255,255,255,0.15)] pb-5 border border-yellow-500/20">
  325. <!-- Floating Coins from Figma -->
  326. <div class="absolute -top-[40px] -right-[10px] z-[80] w-[120px] pointer-events-none drop-shadow-2xl">
  327. <img src="/LotteryV2/img/modal/otp_coins.png" class="w-full object-contain" />
  328. </div>
  329. <!-- Red Header Section -->
  330. <div class="relative w-full pt-4 pb-4 bg-[#EE0033] rounded-t-[32px] flex flex-col items-center justify-center z-20" style="border-bottom-left-radius: 50% 20px; border-bottom-right-radius: 50% 20px;">
  331. <h2 class="text-white text-[17px] sm:text-[20px] font-[900] uppercase tracking-wide relative z-10 font-bricolage drop-shadow-md text-center px-4 leading-tight w-[80%] mr-auto">@Lang.v2_confirm_purchase</h2>
  332. </div>
  333. <!-- Modal Body Content -->
  334. <div class="relative px-6 pt-3 flex flex-col items-center gap-3 z-10">
  335. <!-- Shield Icon: mix-blend-mode multiply to remove the white square background -->
  336. <div class="relative w-full flex justify-center mb-0 mt-1">
  337. <img src="/LotteryV2/img/modal/otp_shield.png" alt="Success" class="w-[90px] object-contain" style="mix-blend-mode: multiply;">
  338. </div>
  339. <!-- Info Rows (Aligned exactly like screenshot) -->
  340. <div class="w-full flex flex-col gap-2 items-center mt-0">
  341. <!-- Ticket Info -->
  342. <div class="grid grid-cols-[90px_auto] items-center gap-3 w-full justify-center">
  343. <span class="text-[15px] font-bold text-[#555] text-right font-bricolage">@Lang.v2_ticket</span>
  344. <div id="otpTicketTypeContainer" class="flex justify-start">
  345. <img id="otpTicketTypeImg" src="/LotteryV2/img/even_text.png" class="h-6 object-contain drop-shadow-sm" />
  346. </div>
  347. </div>
  348. <!-- Amount Info -->
  349. <div class="grid grid-cols-[90px_auto] items-center gap-3 w-full justify-center">
  350. <span class="text-[15px] font-bold text-[#555] text-right font-bricolage">@Lang.v2_amount</span>
  351. <div class="flex items-baseline gap-1.5 justify-start">
  352. <span id="otpTotalAmount" class="text-[22px] font-[900] text-black leading-none tracking-tight">1.000</span>
  353. <span class="text-[15px] font-[900] text-[#F37021] font-bricolage">HTG</span>
  354. </div>
  355. </div>
  356. </div>
  357. <p class="text-[14px] font-bold text-[#555] text-center px-4 leading-snug mt-0 font-bricolage">@Lang.v2_otp_instruction</p>
  358. <!-- 6-Slots OTP Grid (Large Gray Blocks) -->
  359. <div class="flex items-center justify-center gap-2 w-full mt-1 px-2" id="otpInputs">
  360. @for (int i = 1; i <= 6; i++)
  361. {
  362. <input type="tel" maxlength="1" id="otp@(i)"
  363. oninput="moveToNext(this, '@(i < 6 ? "otp" + (i + 1) : "")')"
  364. class="w-[42px] h-[48px] bg-[#757575] rounded-[10px] text-white text-[26px] font-bold text-center appearance-none focus:bg-[#555] focus:scale-[1.03] focus:ring-2 focus:ring-[#EE0033]/50 transition-all outline-none shadow-inner otp-slot"
  365. placeholder="-">
  366. }
  367. </div>
  368. <!-- Timer & Resend -->
  369. <div class="flex flex-col items-center gap-1 mt-0">
  370. <span id="otpTimer" class="text-[15px] font-black text-[#EE0033] font-bricolage">60s</span>
  371. <button id="resendOtpBtn" onclick="sendOtpRequest()" disabled class="text-[14px] font-black text-[#0A9800] underline decoration-solid underline-offset-[3px] transition-all hover:text-[#087a00] disabled:opacity-40 disabled:no-underline font-bricolage">@Lang.v2_request_new_otp</button>
  372. </div>
  373. <!-- Action Buttons: Cancel / Confirm -->
  374. <div class="grid grid-cols-2 gap-3 w-full mt-2">
  375. <button onclick="hideOtpModal()" class="bg-[#FF0000] text-white py-[12px] rounded-[16px] font-[900] text-[17px] shadow-[0_8px_15px_rgba(255,0,0,0.2)] active:scale-95 transition-all tracking-wide">@Lang.v2_cancel</button>
  376. <button onclick="finalizePurchase(this)" class="bg-[#0A9800] text-white py-[12px] rounded-[16px] font-[900] text-[17px] shadow-[0_8px_15px_rgba(10,152,0,0.2)] active:scale-95 transition-all tracking-wide">@Lang.v2_confirm</button>
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. @section Scripts {
  383. <script>
  384. const maxBalls = @(Model.termType == Constants.PIC10_BASIC_CODE ? 10 : (Model.termType == Constants.PIC10_BIGSMALL_CODE ? 13 : 15));
  385. function reindexTickets() {
  386. $(".ticket-card").each(function(index) {
  387. $(this).find(".ticket-index").text(index + 1);
  388. });
  389. }
  390. function removeEntry(btn) {
  391. var card = $(btn).closest('.ticket-card');
  392. card.addClass('animate__animated animate__fadeOutRight animate__faster');
  393. setTimeout(function() {
  394. card.remove();
  395. reindexTickets();
  396. updateTotalPrice();
  397. }, 300);
  398. }
  399. function randomizeTicket(btn) {
  400. var icon = $(btn).find('i');
  401. icon.addClass('fa-spin');
  402. var card = $(btn).closest('.ticket-card');
  403. var balls = card.find('.ball-circle');
  404. // Generate unique random numbers 1-80
  405. var numbers = [];
  406. while(numbers.length < maxBalls){
  407. var r = Math.floor(Math.random() * 80) + 1;
  408. if(numbers.indexOf(r) === -1) numbers.push(r);
  409. }
  410. numbers.sort((a, b) => a - b);
  411. // Update balls with staggered animation
  412. balls.each(function(index) {
  413. var ball = $(this);
  414. setTimeout(function() {
  415. var formattedNum = numbers[index].toString().padStart(2, '0');
  416. ball.removeClass('ball-empty').addClass('ball-filled').text(formattedNum);
  417. ball.addClass('animate__animated animate__flipInY');
  418. if(index === maxBalls - 1) {
  419. setTimeout(() => {
  420. icon.removeClass('fa-spin');
  421. // Replace button with Edit/Delete group
  422. $(btn).hide();
  423. card.find('.edit-delete-group').removeClass('hidden').addClass('animate__animated animate__fadeInRight animate__faster');
  424. updateTotalPrice();
  425. }, 300);
  426. }
  427. }, index * 40);
  428. });
  429. }
  430. function clearTicket(btn) {
  431. var card = $(btn).closest('.ticket-card');
  432. var balls = card.find('.ball-circle');
  433. balls.removeClass('ball-filled animate__animated animate__flipInY shadow-inner').addClass('ball-empty').text('');
  434. // Hide Edit/Delete group and show Rand button
  435. card.find('.edit-delete-group').addClass('hidden');
  436. card.find('.rand-btn').show().addClass('animate__animated animate__fadeInLeft animate__faster');
  437. updateTotalPrice();
  438. }
  439. // Open Number Picker Modal
  440. var activeBall = null;
  441. var activeTicketCard = null;
  442. var selectedNumbers = [];
  443. function editFullTicket(btn) {
  444. activeTicketCard = $(btn).closest('.ticket-card');
  445. activeBall = null;
  446. selectedNumbers = [];
  447. activeTicketCard.find('.ball-filled').each(function() {
  448. var num = $(this).text().trim();
  449. if(num) selectedNumbers.push(num);
  450. });
  451. openNumberPicker(true);
  452. }
  453. function openNumberPicker(isMulti) {
  454. var modal = $("#numberPickerModal");
  455. var grid = $("#numberGrid");
  456. var title = $("#modalTitle");
  457. var countArea = $(".selection-count-area");
  458. var confirmBtn = $("#confirmBtn");
  459. grid.empty();
  460. if (isMulti) {
  461. title.text("Edit Ticket");
  462. countArea.removeClass('hidden');
  463. confirmBtn.removeClass('hidden').text("@Lang.confirm");
  464. updateSelectionCount();
  465. } else {
  466. title.text("Pick Number");
  467. countArea.addClass('hidden');
  468. confirmBtn.removeClass('hidden').text("@Lang.confirm");
  469. selectedNumbers = [activeBall.text().trim()];
  470. updateSelectionCount();
  471. }
  472. for (var i = 1; i <= 80; i++) {
  473. var formatted = i.toString().padStart(2, '0');
  474. var isSelected = selectedNumbers.includes(formatted);
  475. var btnClass = isSelected
  476. ? 'bg-[#EE0033] text-white shadow-md scale-105'
  477. : 'bg-white text-gray-700 hover:bg-gray-100 border border-gray-100';
  478. var btn = $(`<button class="num-btn h-10 rounded-lg font-black text-sm transition-all focus:outline-none ${btnClass}">${formatted}</button>`);
  479. btn.click(function(e) {
  480. e.preventDefault();
  481. var picked = $(this).text().trim();
  482. if (isMulti) {
  483. if (selectedNumbers.includes(picked)) {
  484. selectedNumbers = selectedNumbers.filter(n => n !== picked);
  485. $(this).removeClass('bg-[#EE0033] text-white shadow-md scale-105').addClass('bg-white text-gray-700 border border-gray-100');
  486. } else if (selectedNumbers.length < maxBalls) {
  487. selectedNumbers.push(picked);
  488. $(this).addClass('bg-[#EE0033] text-white shadow-md scale-105').removeClass('bg-white text-gray-700 border border-gray-100');
  489. }
  490. } else {
  491. grid.find('.num-btn').removeClass('bg-[#EE0033] text-white shadow-md scale-105').addClass('bg-white text-gray-700 border border-gray-100');
  492. selectedNumbers = [picked];
  493. $(this).addClass('bg-[#EE0033] text-white shadow-md scale-105').removeClass('bg-white text-gray-700 border border-gray-100');
  494. }
  495. updateSelectionCount();
  496. });
  497. grid.append(btn);
  498. }
  499. modal.removeClass('hidden').addClass('flex');
  500. modal.find('.modal-content').removeClass('animate__zoomOut').addClass('animate__zoomIn');
  501. }
  502. function updateSelectionCount() {
  503. var count = selectedNumbers.length;
  504. $("#selectionCount").text(count);
  505. $("#maxSelectionCount").text(maxBalls);
  506. var isValid = activeTicketCard ? (count === maxBalls) : (count === 1);
  507. if (isValid) {
  508. $("#confirmBtn").prop('disabled', false).removeClass('opacity-50 cursor-not-allowed').addClass('cursor-pointer');
  509. } else {
  510. $("#confirmBtn").prop('disabled', true).addClass('opacity-50 cursor-not-allowed').removeClass('cursor-pointer');
  511. }
  512. }
  513. // All immediate jQuery event bindings must wait for DOM + jQuery to be ready
  514. document.addEventListener("DOMContentLoaded", function() {
  515. // Click on a filled ball to edit single number
  516. $(document).on('click', '.ball-filled', function() {
  517. activeBall = $(this);
  518. activeTicketCard = null;
  519. openNumberPicker(false);
  520. });
  521. // Confirm button handler
  522. $(document).off('click', '#confirmBtn').on('click', '#confirmBtn', function(e) {
  523. e.preventDefault();
  524. if (selectedNumbers.length === 0) return;
  525. if (activeTicketCard && activeTicketCard.length > 0) {
  526. // Multi mode: Update the entire ticket card
  527. selectedNumbers.sort((a, b) => parseInt(a) - parseInt(b));
  528. var balls = activeTicketCard.find('.ball-circle, .ball-empty, .ball-filled');
  529. balls.each(function(index) {
  530. if (index < selectedNumbers.length) {
  531. $(this).removeClass('ball-empty').addClass('ball-filled').text(selectedNumbers[index]);
  532. $(this).addClass('animate__animated animate__pulse');
  533. setTimeout(() => $(this).removeClass('animate__animated animate__pulse'), 500);
  534. }
  535. });
  536. activeTicketCard.find('.rand-btn').hide();
  537. activeTicketCard.find('.edit-delete-group').removeClass('hidden').show();
  538. updateTotalPrice();
  539. } else if (activeBall && activeBall.length > 0) {
  540. // Single mode: Update only the active ball
  541. activeBall.text(selectedNumbers[0]).removeClass('ball-empty').addClass('ball-filled');
  542. activeBall.addClass('animate__animated animate__pulse');
  543. setTimeout(() => activeBall.removeClass('animate__animated animate__pulse'), 500);
  544. }
  545. closeNumberPicker();
  546. });
  547. });
  548. function closeNumberPicker() {
  549. var modal = $("#numberPickerModal");
  550. modal.find('.modal-content').removeClass('animate__zoomIn').addClass('animate__zoomOut');
  551. setTimeout(() => {
  552. modal.removeClass('flex').addClass('hidden');
  553. // Reset state
  554. activeBall = null;
  555. activeTicketCard = null;
  556. }, 200);
  557. }
  558. function updateTotalPrice() {
  559. var filledTickets = 0;
  560. $(".ticket-card").each(function() {
  561. if ($(this).find(".ball-filled").length === maxBalls) {
  562. filledTickets++;
  563. }
  564. });
  565. const pricePerTicket = @(Model.termType == Constants.PIC10_BASIC_CODE ? "10" : "50");
  566. $("#totalPrice").text(filledTickets * pricePerTicket);
  567. }
  568. function addNewTicket() {
  569. var container = $("#ticketContainer");
  570. var wrapper = $("#addButtonWrapper");
  571. var currentIndex = $(".ticket-card").length + 1;
  572. var ballsHtml = '';
  573. for (var i = 0; i < maxBalls; i++) {
  574. ballsHtml += '<div class="ball-circle ball-empty"></div>';
  575. }
  576. var ticketHtml = `
  577. <div class="ticket-card relative group active:bg-gray-50 transition-colors cursor-pointer animate__animated animate__fadeInUp animate__faster">
  578. <button onclick="removeEntry(this)" class="absolute -right-2 top-1 w-7 h-7 bg-[#999] text-white rounded-full flex items-center justify-center text-[11px] shadow-sm z-[10] hover:bg-red-500 transition-all border-2 border-white">
  579. <i class="fa-solid fa-xmark"></i>
  580. </button>
  581. <div class="absolute left-2 top-4 w-9 h-9 rounded-full bg-[#EE0033] border-[3px] border-white flex items-center justify-center text-white font-black text-sm shadow-md ticket-index">${currentIndex}</div>
  582. <div class="flex flex-col gap-1 pl-8">
  583. <span class="text-[16px] font-extrabold text-[#333]">@Lang.v2_select_10_lucky_numbers</span>
  584. <div class="flex items-start gap-4">
  585. <div class="grid grid-cols-5 gap-y-1 gap-x-2 flex-1">
  586. ${ballsHtml}
  587. </div>
  588. <div class="w-20 action-area flex flex-col gap-2">
  589. <button onclick="randomizeTicket(this)" class="rand-btn bg-green-main text-white flex items-center justify-center gap-2 w-20 py-2 rounded-xl font-extrabold text-[11px] shadow-sm active:scale-95 transition-all">
  590. <i class="fa-solid fa-arrows-rotate text-[10px]"></i> @Lang.Random
  591. </button>
  592. <div class="edit-delete-group hidden flex flex-col gap-2">
  593. <button onclick="editFullTicket(this)" class="bg-[#2B83F2] text-white flex items-center justify-center gap-2 w-20 py-1.5 rounded-lg font-bold text-[12px] shadow-sm active:scale-95 transition-all">
  594. <i class="fa-solid fa-pen text-[10px]"></i> @Lang.v2_edit
  595. </button>
  596. <button onclick="clearTicket(this)" class="bg-[#EE0033] text-white flex items-center justify-center gap-2 w-20 py-1.5 rounded-lg font-bold text-[12px] shadow-sm active:scale-95 transition-all">
  597. <i class="fa-solid fa-trash-can text-[10px]"></i> @Lang.v2_delete
  598. </button>
  599. </div>
  600. </div>
  601. </div>
  602. </div>
  603. </div>
  604. `;
  605. $(ticketHtml).insertBefore(wrapper);
  606. container.animate({ scrollTop: container.prop("scrollHeight") }, 300);
  607. }
  608. // --- Order Summary Modal Logic ---
  609. // --- Payment Preparation & Order Summary Logic ---
  610. function preparePayment(event) {
  611. const isBSMode = @(Model.termType == Constants.PIC10_BIGSMALL_CODE || Model.termType == Constants.PIC10_ODDEVEN_CODE ? "true" : "false");
  612. const tickets = [];
  613. if (isBSMode) {
  614. if (!bsChoice) {
  615. showNotification("Please select a choice first.", "warning");
  616. return;
  617. }
  618. let bsCode = "";
  619. if ('@Model.termType' === '@Constants.PIC10_BIGSMALL_CODE') {
  620. bsCode = (bsChoice === 'big') ? "B" : "S";
  621. } else {
  622. bsCode = (bsChoice === 'big') ? "O" : "E"; // Odd = O, Even = E
  623. }
  624. tickets.push({
  625. code: bsCode,
  626. money: "50"
  627. });
  628. } else {
  629. $(".ticket-card").each(function() {
  630. const balls = $(this).find(".ball-filled");
  631. if (balls.length === maxBalls) {
  632. const selectedNumbers = [];
  633. balls.each(function() { selectedNumbers.push($(this).text().trim()); });
  634. const itemPrice = "@(Model.termType == Constants.PIC10_BASIC_CODE ? "10" : "50")";
  635. tickets.push({
  636. code: selectedNumbers.join(','),
  637. money: itemPrice
  638. });
  639. }
  640. });
  641. if (tickets.length === 0) {
  642. showNotification("@Lang.v2_ticket_not_valid", "warning");
  643. return;
  644. }
  645. }
  646. const requestData = {
  647. gameId: "@Model.termType",
  648. ticket: tickets
  649. };
  650. const btn = event ? event.currentTarget : null;
  651. const originalText = btn ? btn.innerHTML : "@Lang.v2_payment";
  652. if (btn) {
  653. btn.innerHTML = '<i class="fa-solid fa-circle-notch fa-spin"></i> Loading...';
  654. btn.disabled = true;
  655. }
  656. // Gọi ConfirmTicketData API (giống nhau cho tất cả loại game)
  657. // Pick 10: code = "21,26,40,47,48,52,67,69,71,74"
  658. // Big/Small: code = "B" hoặc "S"
  659. // Odd/Even: code = "O" hoặc "E"
  660. console.log("[DEBUG] ConfirmTicketData request:", JSON.stringify(requestData));
  661. $.ajax({
  662. url: subDomain + '@Url.Action("ConfirmTicketData", "Home")',
  663. type: 'POST',
  664. contentType: 'application/json',
  665. data: JSON.stringify(requestData),
  666. success: function(data) {
  667. console.log("[DEBUG] ConfirmTicketData response:", JSON.stringify(data));
  668. if (btn) {
  669. btn.innerHTML = originalText;
  670. btn.disabled = false;
  671. }
  672. if (data.responseCode === "0") {
  673. showOrderSummary(data, tickets);
  674. } else {
  675. showNotification(data.responseMessage || "Confirmation failed", "warning");
  676. }
  677. },
  678. error: function(err) {
  679. console.error("[DEBUG] ConfirmTicketData AJAX Error:", err);
  680. if (btn) {
  681. btn.innerHTML = originalText;
  682. btn.disabled = false;
  683. }
  684. console.error("AJAX Error:", err);
  685. showNotification("Network error occurred.", "warning");
  686. }
  687. });
  688. }
  689. let currentTransId = null;
  690. function showOrderSummary(apiData, localTickets) {
  691. currentTransId = apiData.transId;
  692. const summaryModal = $("#orderSummaryModal");
  693. const summaryList = $("#summaryTicketList");
  694. summaryList.empty();
  695. const displayTickets = (apiData && apiData.ticket) ? apiData.ticket : (localTickets || []);
  696. if (!displayTickets || !Array.isArray(displayTickets)) {
  697. console.warn("No tickets found to display in summary.");
  698. return;
  699. }
  700. displayTickets.forEach((t, index) => {
  701. const numbers = t.code.split(',');
  702. let contentHtml = '';
  703. if (numbers.length > 1) {
  704. let numbersBalls = '';
  705. numbers.forEach(n => {
  706. numbersBalls += `<div class="w-7 h-7 rounded-full flex items-center justify-center text-white text-[11px] font-black shadow-lg" style="background: radial-gradient(circle at 30% 30%, #444, #000);">${n.trim()}</div>`;
  707. });
  708. contentHtml = `<div class="grid grid-cols-5 gap-y-2 relative z-10 px-2 justify-items-center">${numbersBalls}</div>`;
  709. } else {
  710. const isBS = @(Model.termType == Constants.PIC10_BIGSMALL_CODE ? "true" : "false");
  711. const isFirstChoice = (numbers[0] === 'B' || numbers[0] === 'O');
  712. const label = isFirstChoice ? (isBS ? "Big" : "Odd") : (isBS ? "Small" : "Even");
  713. const color = isFirstChoice ? (isBS ? "#A2FF00" : "#FFC700") : (isBS ? "#FF4157" : "#B33BD0");
  714. contentHtml = `<div class="w-full flex justify-center"><span class="text-[28px] font-black italic uppercase" style="-webkit-text-stroke: 1px #000; color: ${color};">${label}</span></div>`;
  715. }
  716. const itemHtml = `
  717. <div class="flex items-center gap-3">
  718. <div class="flex-1 rounded-2xl p-3 relative overflow-hidden flex flex-col gap-2 min-h-[80px] justify-center"
  719. style="background: linear-gradient(90deg, #EE0033 0%, rgba(238, 0, 51, 0.4) 70%, rgba(238, 0, 51, 0.05) 100%); border: 1px solid rgba(238, 0, 51, 0.1);">
  720. ${contentHtml}
  721. </div>
  722. <div class="w-24 shrink-0 bg-white border border-gray-200 rounded-2xl p-2.5 flex items-center justify-between shadow-sm">
  723. <div class="flex items-baseline gap-0.5">
  724. <span class="text-[16px] font-black text-black">${t.money}</span>
  725. <span class="text-[10px] font-black text-[#EE0033]">HTG</span>
  726. </div>
  727. </div>
  728. </div>
  729. `;
  730. summaryList.append(itemHtml);
  731. });
  732. $("#summaryTotalCount").text(displayTickets.length);
  733. const totalMoney = apiData.totalMoneyPayment || apiData.totalMoney || "0";
  734. $("#summaryTotalAmount").text(parseFloat(totalMoney).toLocaleString('en-US'));
  735. summaryModal.removeClass("hidden").addClass("flex");
  736. }
  737. function hideOrderSummary() {
  738. $("#orderSummaryModal").removeClass("flex").addClass("hidden");
  739. }
  740. function confirmCheckout(btn) {
  741. const originalText = $(btn).html();
  742. $(btn).prop('disabled', true).html('<i class="fa-solid fa-spinner fa-spin mr-2"></i>Processing...');
  743. // Trigger SendOTP API
  744. $.ajax({
  745. url: subDomain + '@Url.Action("SendOTP", "Home")',
  746. type: 'POST',
  747. success: function(data) {
  748. $(btn).prop('disabled', false).html(originalText);
  749. if (data.responseCode === "0") {
  750. showOtpModal();
  751. } else {
  752. showNotification(data.responseMessage || "Failed to send OTP", "warning");
  753. }
  754. },
  755. error: function() {
  756. $(btn).prop('disabled', false).html(originalText);
  757. showNotification("Network error occurred.", "warning");
  758. }
  759. });
  760. }
  761. let otpInterval;
  762. function showOtpModal() {
  763. hideOrderSummary();
  764. $("#otpModal").removeClass("hidden").addClass("flex");
  765. $("#otpInputs input").val("");
  766. $("#otp1").focus();
  767. // Map game type to readable name & image
  768. let gameTypeStr = "@Model.termType";
  769. let displayName = "Classic Pick 10";
  770. let imgSrc = "";
  771. if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE") {
  772. displayName = "Big / Small";
  773. // Detect if current selection is Big or Small from summary
  774. let firstTicket = $("#summaryTicketList .flex.items-center span.font-black").first().text().trim();
  775. if (firstTicket.toLowerCase().includes("big")) imgSrc = "/LotteryV2/img/big_text.png";
  776. else if (firstTicket.toLowerCase().includes("small")) imgSrc = "/LotteryV2/img/small_text.png";
  777. } else if (gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") {
  778. displayName = "Odd / Even";
  779. let firstTicket = $("#summaryTicketList .flex.items-center span.font-black").first().text().trim();
  780. if (firstTicket.toLowerCase().includes("odd")) imgSrc = "/LotteryV2/img/odd_text.png";
  781. else if (firstTicket.toLowerCase().includes("even")) imgSrc = "/LotteryV2/img/even_text.png";
  782. }
  783. $("#otpTicketTypeContainer").find("span").remove();
  784. if (imgSrc) {
  785. $("#otpTicketTypeImg").attr("src", imgSrc).show();
  786. } else {
  787. $("#otpTicketTypeImg").hide();
  788. if ($("#otpTicketTypeContainer").find("span").length === 0) {
  789. $("#otpTicketTypeContainer").append(`<span class='text-[17px] font-[900] text-purple-700 italic'>${displayName}</span>`);
  790. }
  791. }
  792. $("#otpTotalAmount").text($("#summaryTotalAmount").text());
  793. startOtpTimer(60);
  794. }
  795. // Add backspace support for OTP inputs
  796. $("#otpInputs input").on("keydown", function(e) {
  797. if (e.key === "Backspace" && this.value.length === 0) {
  798. $(this).prev('input').focus();
  799. }
  800. });
  801. function hideOtpModal() {
  802. $("#otpModal").removeClass("flex").addClass("hidden");
  803. clearInterval(otpInterval);
  804. }
  805. function startOtpTimer(seconds) {
  806. let timeLeft = seconds;
  807. $("#resendOtpBtn").prop("disabled", true);
  808. clearInterval(otpInterval);
  809. otpInterval = setInterval(() => {
  810. timeLeft--;
  811. $("#otpTimer").text(timeLeft + "s");
  812. if (timeLeft <= 0) {
  813. clearInterval(otpInterval);
  814. $("#resendOtpBtn").prop("disabled", false);
  815. $("#otpTimer").text("");
  816. }
  817. }, 1000);
  818. }
  819. function moveToNext(el, nextId) {
  820. if (el.value.length >= 1) {
  821. if (nextId) document.getElementById(nextId).focus();
  822. }
  823. }
  824. function sendOtpRequest() {
  825. // Re-trigger SendOTP
  826. $.ajax({
  827. url: subDomain + '@Url.Action("SendOTP", "Home")',
  828. type: 'POST',
  829. success: function(data) {
  830. if (data.responseCode === "0") {
  831. startOtpTimer(60);
  832. showNotification("OTP has been resent.", "success");
  833. } else {
  834. showNotification(data.responseMessage || "Failed to resend OTP", "warning");
  835. }
  836. }
  837. });
  838. }
  839. function showReceiptSuccess(transId, amount, phone) {
  840. // Setup data dynamically
  841. $("#receiptAmount").text(amount + " HTG");
  842. if(phone) $("#receiptPhone").text(phone);
  843. let gameTypeStr = "@Model.termType";
  844. let displayName = "@Lang.v2_classic_pick_10";
  845. if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE") displayName = "@Lang.v2_big_small";
  846. else if (gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") displayName = "@Lang.v2_odd_even";
  847. $("#receiptGameType").text("@Lang.buy " + displayName);
  848. $("#receiptTicketCode").text("#" + transId);
  849. let choiceText = "-";
  850. if (gameTypeStr === "@Constants.PIC10_BIGSMALL_CODE" || gameTypeStr === "@Constants.PIC10_ODDEVEN_CODE") {
  851. choiceText = $("#summaryTicketList .flex.items-center span.font-black").first().text().trim();
  852. } else {
  853. choiceText = "PICK 10";
  854. }
  855. $("#receiptChoice").text(choiceText);
  856. // Format current date "dd/MM/yyyy - HH:mm:ss"
  857. let now = new Date();
  858. let ds = now.getDate().toString().padStart(2, '0') + '/' + (now.getMonth() + 1).toString().padStart(2, '0') + '/' + now.getFullYear() + ' - ' + now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0') + ':' + now.getSeconds().toString().padStart(2, '0');
  859. $("#receiptTime").text(ds);
  860. hideOtpModal();
  861. $("#receiptSuccessModal").removeClass("hidden").addClass("flex");
  862. }
  863. function finalizePurchase(btn) {
  864. let otpCode = "";
  865. $("#otpInputs input").each(function() {
  866. otpCode += $(this).val();
  867. });
  868. if (otpCode.length < 6) {
  869. showNotification("Please enter full 6-digit OTP", "warning");
  870. return;
  871. }
  872. const originalText = $(btn).html();
  873. $(btn).prop('disabled', true).html('<i class="fa-solid fa-spinner fa-spin mr-2"></i> ...');
  874. const finalData = {
  875. transIdByTicket: currentTransId,
  876. paymentCode: otpCode
  877. };
  878. // STEP 1: Confirm OTP API
  879. $.ajax({
  880. url: subDomain + '@Url.Action("ConfirmOTP", "Home")',
  881. type: 'POST',
  882. contentType: 'application/json',
  883. data: JSON.stringify({ otp: otpCode }),
  884. success: function(otpResp) {
  885. // Check if OTP validation succeeds
  886. if (otpResp.responseCode === "0" || otpResp.responseCode === 200 || otpResp.responseCode === "0000") {
  887. // STEP 2: Confirm Buying Ticket API
  888. $.ajax({
  889. url: subDomain + '@Url.Action("ConfirmBuyingTicket", "Home")',
  890. type: 'POST',
  891. contentType: 'application/json',
  892. data: JSON.stringify(finalData),
  893. success: function(buyResp) {
  894. $(btn).prop('disabled', false).html(originalText);
  895. if (buyResp.responseCode === "0" || buyResp.responseCode === "0000") {
  896. // Open Figma styled success modal!
  897. showReceiptSuccess(buyResp.transId || currentTransId, $("#summaryTotalAmount").text(), "@(Model.userStatus?.msisdn ?? "-")");
  898. } else {
  899. showNotification(buyResp.responseMessage || "Payment failed", "warning");
  900. }
  901. },
  902. error: function() {
  903. $(btn).prop('disabled', false).html(originalText);
  904. showNotification("Network error occurred during payment completion.", "warning");
  905. }
  906. });
  907. } else {
  908. $(btn).prop('disabled', false).html(originalText);
  909. showNotification(otpResp.responseMessage || "Invalid OTP code", "warning");
  910. }
  911. },
  912. error: function() {
  913. $(btn).prop('disabled', false).html(originalText);
  914. showNotification("Network error while validating OTP.", "warning");
  915. }
  916. });
  917. }
  918. function showNotification(message, type = 'success') {
  919. const msgEl = $("#notificationMessage");
  920. const iconEl = $("#notificationModal img");
  921. msgEl.text(message);
  922. // Toggle icon based on type (warning or success)
  923. const warningIcon = '/LotteryV2/img/modal/warning_icon.png';
  924. const successIcon = '/LotteryV2/img/modal/success_icon.png';
  925. const fallbackWarning = 'https://cdn-icons-png.flaticon.com/512/564/564619.png';
  926. const fallbackSuccess = 'https://cdn-icons-png.flaticon.com/512/190/190411.png';
  927. if (type === 'warning' || type === 'error') {
  928. iconEl.attr('src', warningIcon);
  929. iconEl.attr('onerror', `this.src='${fallbackWarning}'`);
  930. } else {
  931. iconEl.attr('src', successIcon);
  932. iconEl.attr('onerror', `this.src='${fallbackSuccess}'`);
  933. }
  934. $("#notificationModal").removeClass("hidden").addClass("flex");
  935. }
  936. function closeNotificationModal() {
  937. $("#notificationModal").addClass("hidden").removeClass("flex");
  938. }
  939. // ==================== CARD SELECTION GAME LOGIC (BIG/SMALL / ODD/EVEN) ====================
  940. var bsChoice = null; // 'big' or 'small' (reused as 'odd' or 'even')
  941. const isBigSmall = @(Model.termType == Constants.PIC10_BIGSMALL_CODE ? "true" : "false");
  942. const themeColor = isBigSmall ? "#0A9800" : "#AA3DC8";
  943. const labelBig = isBigSmall ? "Big" : "Odd";
  944. const labelSmall = isBigSmall ? "Small" : "Even";
  945. const colorBig = isBigSmall ? "#A2FF00" : "#FFC700";
  946. const colorSmall = isBigSmall ? "#FF4157" : "#B33BD0";
  947. // Loclized text from resources
  948. const langSelect = "@Lang.v2_select";
  949. const langSelected = "@Lang.v2_selected";
  950. function selectBigSmall(choice) {
  951. bsChoice = choice;
  952. var cardBig = document.getElementById('cardBig');
  953. var cardSmall = document.getElementById('cardSmall');
  954. var choiceDisplay = document.getElementById('choiceDisplay');
  955. if (!cardBig || !cardSmall) return;
  956. if (choice === 'big') {
  957. // Highlight Big/Odd card with theme glow
  958. cardBig.style.border = '2px solid ' + themeColor;
  959. cardBig.style.boxShadow = '0px 0px 12px 0px ' + (isBigSmall ? 'rgba(162, 255, 0, 1)' : 'rgba(179, 59, 208, 0.6)');
  960. cardBig.querySelector('.bigsmall-btn').textContent = langSelected;
  961. cardBig.querySelector('.bigsmall-btn').style.background = '#333';
  962. // Reset Small/Even card
  963. cardSmall.style.border = '2px solid transparent';
  964. cardSmall.style.boxShadow = 'none';
  965. cardSmall.querySelector('.bigsmall-btn').textContent = langSelect;
  966. cardSmall.querySelector('.bigsmall-btn').style.background = themeColor;
  967. // Update display
  968. if (choiceDisplay) {
  969. choiceDisplay.textContent = labelBig;
  970. choiceDisplay.style.color = colorBig;
  971. choiceDisplay.style.webkitTextStroke = '1px #000';
  972. }
  973. } else {
  974. // Highlight Small/Even card with theme glow
  975. cardSmall.style.border = '2px solid ' + themeColor;
  976. cardSmall.style.boxShadow = '0px 0px 12px 0px ' + (isBigSmall ? 'rgba(162, 255, 0, 1)' : 'rgba(179, 59, 208, 0.6)');
  977. cardSmall.querySelector('.bigsmall-btn').textContent = langSelected;
  978. cardSmall.querySelector('.bigsmall-btn').style.background = '#333';
  979. // Reset Big/Odd card
  980. cardBig.style.border = '2px solid transparent';
  981. cardBig.style.boxShadow = 'none';
  982. cardBig.querySelector('.bigsmall-btn').textContent = langSelect;
  983. cardBig.querySelector('.bigsmall-btn').style.background = themeColor;
  984. // Update display
  985. if (choiceDisplay) {
  986. choiceDisplay.textContent = labelSmall;
  987. choiceDisplay.style.color = colorSmall;
  988. choiceDisplay.style.webkitTextStroke = '1px #000';
  989. }
  990. }
  991. }
  992. function bsShowPayment(e) {
  993. preparePayment(e);
  994. }
  995. </script>
  996. <!-- Number Picker Modal (Premium Design) -->
  997. <div id="numberPickerModal" class="fixed inset-0 bg-black/60 z-[200] hidden items-center justify-center p-4 backdrop-blur-sm transition-all">
  998. <div class="modal-content bg-white w-full max-w-[360px] rounded-3xl overflow-hidden shadow-2xl animate__animated animate__zoomIn animate__faster">
  999. <div class="p-5 bg-[#EE0033] text-white flex justify-between items-center">
  1000. <div class="flex items-center gap-3">
  1001. <div class="w-8 h-8 rounded-lg bg-white/20 flex items-center justify-center">
  1002. <i class="fa-solid fa-hashtag text-sm"></i>
  1003. </div>
  1004. <h3 class="font-black text-lg uppercase tracking-tight" id="modalTitle">Pick Number</h3>
  1005. </div>
  1006. <button onclick="closeNumberPicker()" class="w-8 h-8 flex items-center justify-center rounded-full hover:bg-white/20 transition-all">
  1007. <i class="fa-solid fa-xmark text-xl"></i>
  1008. </button>
  1009. </div>
  1010. <div class="p-3 bg-gray-50 flex items-center justify-center border-b selection-count-area hidden">
  1011. <span class="text-[12px] font-bold text-gray-500 uppercase">Selected: <span id="selectionCount" class="text-[#EE0033]">0</span>/<span id="maxSelectionCount">10</span></span>
  1012. </div>
  1013. <div class="p-4 grid grid-cols-6 gap-2 max-h-[450px] overflow-y-auto bg-gray-50" id="numberGrid">
  1014. <!-- 1-80 populated via JS -->
  1015. </div>
  1016. <div class="p-4 bg-white border-t flex flex-col gap-2">
  1017. <button id="confirmBtn" class="hidden w-full py-3 bg-[#EE0033] text-white rounded-xl font-black text-md active:bg-[#CC002D] transition-all uppercase tracking-wide shadow-lg">
  1018. @Lang.confirm
  1019. </button>
  1020. <button onclick="closeNumberPicker()" class="w-full py-3 bg-gray-100 text-gray-700 rounded-xl font-black text-[14px] active:bg-gray-200 transition-all uppercase tracking-wide">
  1021. @Lang.v2_back
  1022. </button>
  1023. </div>
  1024. </div>
  1025. </div>
  1026. <div id="notificationModal" class="fixed inset-0 z-[300] bg-black/60 flex items-center justify-center hidden px-4 font-bricolage backdrop-blur-sm">
  1027. <div class="w-full max-w-[360px] bg-white rounded-[32px] overflow-hidden flex flex-col items-center px-6 pt-5 pb-6 animate__animated animate__zoomIn animate__faster shadow-2xl relative border border-white/50">
  1028. <!-- Alert Icon -->
  1029. <div class="w-full flex justify-center mb-3 mt-1">
  1030. <img src="/LotteryV2/img/modal/success_icon.png" class="w-[100px] h-auto object-contain" alt="Notificaton icon" onerror="this.src='https://cdn-icons-png.flaticon.com/512/190/190411.png'" />
  1031. </div>
  1032. <!-- Message Area -->
  1033. <div class="px-2 text-center mb-5">
  1034. <p id="notificationMessage" class="text-black font-[800] text-[17px] leading-snug">
  1035. <!-- Message content -->
  1036. </p>
  1037. </div>
  1038. <!-- Action Button -->
  1039. <div class="w-full">
  1040. <button onclick="closeNotificationModal()" class="w-full bg-[#EE0033] text-white font-[900] text-[18px] py-[13px] rounded-[18px] shadow-[0_8px_20px_rgba(238,0,51,0.25)] active:scale-95 transition-all uppercase tracking-wide">
  1041. OK
  1042. </button>
  1043. </div>
  1044. </div>
  1045. </div>
  1046. <!-- Beautiful Success Receipt Modal (Matches Figma 161:3722) -->
  1047. <div id="receiptSuccessModal" class="fixed inset-0 z-[300] bg-black/80 hidden items-center justify-center px-4 font-bricolage backdrop-blur-md">
  1048. <div class="w-full max-w-[360px] bg-[#F9F9F9] rounded-[32px] overflow-hidden flex flex-col items-center px-6 pt-4 pb-5 shadow-2xl relative animate__animated animate__zoomIn animate__faster border border-white/50">
  1049. <!-- Confetti/Celebration background effect (Subtle) -->
  1050. <div class="absolute top-0 inset-x-0 h-[150px] pointer-events-none opacity-40 mix-blend-multiply" style="background: url('/LotteryV2/img/modal/otp_glitter.png') no-repeat top center; background-size: cover;"></div>
  1051. <h2 class="text-[#534A4A] font-[800] text-[19px] tracking-tight relative z-10 w-full text-center mt-1">@Lang.v2_payment_successfully</h2>
  1052. <!-- Ticket / Success Graphic -->
  1053. <div class="relative w-full flex justify-center mt-2 mb-0 z-10">
  1054. <div class="relative w-[100px] flex items-center justify-center">
  1055. <div class="absolute inset-0 bg-green-400 blur-2xl opacity-20 rounded-full scale-125"></div>
  1056. <img src="/LotteryV2/img/modal/otp_shield.png" alt="Success" class="w-full drop-shadow-xl z-20" style="mix-blend-mode: multiply;" />
  1057. </div>
  1058. </div>
  1059. <h3 class="text-[#0A9800] font-[900] text-[20px] uppercase tracking-wide relative z-10">@Lang.success</h3>
  1060. <div class="w-full h-px border-t-[2px] border-dashed border-gray-300 my-3 relative z-10"></div>
  1061. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1062. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.number</span>
  1063. <span class="font-black text-[14px] text-gray-800" id="receiptPhone">-</span>
  1064. </div>
  1065. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1066. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.v2_your_choice</span>
  1067. <span class="text-[#EE0033] font-[900] text-[15px] uppercase" id="receiptChoice">-</span>
  1068. </div>
  1069. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1070. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.ticket_code</span>
  1071. <span class="font-black text-[13px] text-gray-800" id="receiptTicketCode">#</span>
  1072. </div>
  1073. <div class="w-full flex justify-between items-center mb-1 relative z-10 px-1">
  1074. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.payment</span>
  1075. <span class="text-[#EE0033] font-[900] text-[15px]" id="receiptAmount">0 HTG</span>
  1076. </div>
  1077. <div class="w-full h-px border-t-[2px] border-dashed border-gray-300 my-3 relative z-10"></div>
  1078. <div class="w-full flex justify-between items-center mb-2 relative z-10 px-1">
  1079. <span class="text-[#534A4A] font-bold text-[14px]">@Lang.time</span>
  1080. <span class="font-bold text-[13px] text-gray-600" id="receiptTime">00:00:00</span>
  1081. </div>
  1082. <div class="w-full flex justify-start items-center relative z-10 px-1 mt-1">
  1083. <span class="text-[#534A4A] font-bold text-[13px] italic text-gray-500" id="receiptGameType">@Lang.v2_buy_ticket_label</span>
  1084. </div>
  1085. <div class="text-[#534A4A] font-[900] text-[18px] relative z-10 text-center mt-3">@Lang.thank_you <span class="text-[#EE0033]">♥️</span></div>
  1086. <!-- Action Button -->
  1087. <button onclick="location.href='@Url.Action("GameHome", "Home", new { termType = Model.termType })'" class="w-full bg-[#EE0033] text-white font-[900] text-[18px] py-[13px] rounded-[18px] shadow-[0_8px_20px_rgba(238,0,51,0.25)] active:scale-95 transition-all mt-4 relative z-10 uppercase tracking-wide">
  1088. @Lang.back_to_homepage
  1089. </button>
  1090. </div>
  1091. </div>
  1092. }