| Cỡ chữ:   
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <!-- ===================== HEADER ===================== --> <div class="header"> <div class="header-title">???? StarCinema</div> <span id="user-badge" class="user-badge" onclick="showNamePopup()"></span> </div> <!-- ===================== DANH SÁCH PHIM ===================== --> <div class="section-title">Phim đang chiếu</div> <div class="movie-grid"> <div class="movie-card"> <img src="https://m.media-amazon.com/images/I/71niXI3lxlL._AC_SY679_.jpg" alt="Spider-Man"> <div class="movie-info"> <h3>Spider-Man: No Way Home</h3> <p>Hành động • 148 phút</p> <div class="movie-footer"> <span class="price">120.000 ₫</span> <span class="btn-order" onclick="addTicket('Spider-Man: No Way Home', 120000)">???? Đặt vé</span> </div> </div> </div> <div class="movie-card"> <img src="https://m.media-amazon.com/images/I/71kF1U9XBML._AC_SY679_.jpg" alt="Frozen 2"> <div class="movie-info"> <h3>Frozen II</h3> <p>Hoạt hình • 103 phút</p> <div class="movie-footer"> <span class="price">90.000 ₫</span> <span class="btn-order" onclick="addTicket('Frozen II', 90000)">???? Đặt vé</span> </div> </div> </div> <div class="movie-card"> <img src="https://m.media-amazon.com/images/I/81JdJVgEpOL._AC_SY679_.jpg" alt="Interstellar"> <div class="movie-info"> <h3>Interstellar</h3> <p>Khoa học viễn tưởng • 169 phút</p> <div class="movie-footer"> <span class="price">130.000 ₫</span> <span class="btn-order" onclick="addTicket('Interstellar', 130000)">???? Đặt vé</span> </div> </div> </div> <div class="movie-card"> <img src="https://m.media-amazon.com/images/I/51UOVJuSLxL._AC_.jpg" alt="Inside Out 2"> <div class="movie-info"> <h3>Inside Out 2</h3> <p>Hoạt hình • 100 phút</p> <div class="movie-footer"> <span class="price">95.000 ₫</span> <span class="btn-order" onclick="addTicket('Inside Out 2', 95000)">???? Đặt vé</span> </div> </div> </div> </div> <!-- ===================== POPUP NHẬP TÊN ===================== --> <div id="name-overlay" class="overlay"> <div class="popup-box"> <div class="popup-icon">????</div> <h2 class="popup-title">StarCinema</h2> <p class="popup-subtitle">Nhập tên của bạn để bắt đầu đặt vé</p> <input id="name-input" class="popup-input" type="text" placeholder="VD: Nguyễn Văn A" maxlength="30"> <p id="name-error" class="error-msg">Vui lòng nhập tên của bạn!</p> <button class="btn-primary btn-full" onclick="confirmName()">Bắt đầu →</button> </div> </div> <!-- ===================== NÚT GIỎ VÉ NỔI ===================== --> <div id="cart-btn" class="cart-btn" onclick="toggleCart()">????</div> <div id="cart-count" class="cart-count"></div> <!-- ===================== PANEL GIỎ VÉ ===================== --> <div id="cart-panel" class="cart-panel"> <div class="cart-header"> <h3>???? Vé của bạn</h3> <span class="close-btn" onclick="toggleCart()">×</span> </div> <div id="cart-items" class="cart-items"> <p class="empty-msg">Chưa có vé nào<br><small>Hãy chọn phim bạn thích!</small></p> </div> <div id="cart-footer" class="cart-footer"> <div class="cart-total-row"> <span>Tổng tiền:</span> <span id="cart-total" class="price-yellow">0 ₫</span> </div> <button class="btn-primary btn-full" onclick="showConfirm()">Xác nhận đặt vé</button> </div> </div> <!-- ===================== POPUP XÁC NHẬN ===================== --> <div id="confirm-overlay" class="overlay hidden"> <div class="popup-box popup-wide"> <h2 class="popup-title">Xác nhận đơn vé</h2> <p id="confirm-name" class="popup-subtitle"></p> <div id="confirm-items"></div> <div class="total-row"> <span>Tổng cộng:</span> <span id="confirm-total" class="price-yellow"></span> </div> <div class="btn-row"> <button class="btn-gray" onclick="closeConfirm()">Quay lại</button> <button class="btn-primary btn-grow" onclick="sendOrder()">✅ Xác nhận mua vé</button> </div> </div> </div> <!-- ===================== POPUP THÀNH CÔNG ===================== --> <div id="success-overlay" class="overlay hidden"> <div class="popup-box"> <div class="popup-icon">????</div> <h2 class="popup-title">Đặt vé thành công!</h2> <p class="popup-subtitle">Chúc bạn xem phim vui vẻ</p> <div class="success-info"> <div class="info-row"> <span class="label">Khách hàng</span> <span id="success-name" class="value"></span> </div> <div class="info-row"> <span class="label">Số loại phim</span> <span id="success-count" class="value"></span> </div> <div class="info-row"> <span class="label">Tổng tiền</span> <span id="success-total" class="value price-yellow"></span> </div> </div> <button class="btn-primary btn-full" onclick="closeSuccess()">OK!</button> </div> </div> <!-- ===================== TOAST ===================== --> <div id="toast" class="toast"><span id="toast-msg"></span></div> <script src="script.js"></script> </body> </html>
/* ============================================= STARCINEMA - style.css ============================================= */ /* ===================== BASE ===================== */ body { font-family: 'Nunito', sans-serif; margin: 0; padding: 0; background-color: #0d0d0d; color: #f0f0f0; min-height: 100vh; } /* ===================== HEADER ===================== */ .header { display: flex; align-items: center; justify-content: space-between; padding: 16px 30px; background-color: #1a1a1a; border-bottom: 2px solid #f5c518; } .header-title { font-family: 'Bebas Neue', sans-serif; font-size: 2rem; color: #f5c518; letter-spacing: 2px; } .user-badge { display: none; background: #f5c518; color: #0d0d0d; font-weight: 700; font-size: 0.9rem; padding: 6px 16px; border-radius: 20px; cursor: pointer; } /* ===================== DANH SÁCH PHIM ===================== */ .section-title { font-family: 'Bebas Neue', sans-serif; font-size: 1.6rem; color: #f5c518; letter-spacing: 2px; padding: 24px 30px 10px; } .movie-grid { display: flex; flex-wrap: wrap; gap: 20px; padding: 10px 30px 100px; justify-content: center; } .movie-card { background: #1a1a1a; border-radius: 12px; overflow: hidden; width: 260px; box-shadow: 0 4px 20px rgba(0,0,0,0.5); transition: transform 0.2s; } .movie-card:hover { transform: translateY(-4px); } .movie-card img { width: 100%; height: 340px; object-fit: cover; } .movie-info { padding: 14px; } .movie-info h3 { margin: 0 0 6px; font-size: 1.1rem; color: #fff; } .movie-info p { margin: 0 0 12px; color: #888; font-size: 0.9rem; } .movie-footer { display: flex; align-items: center; justify-content: space-between; } .price { font-weight: 700; font-size: 1.1rem; color: #f5c518; } .btn-order { background: #f5c518; color: #0d0d0d; font-weight: 700; font-size: 0.85rem; padding: 8px 14px; border-radius: 20px; cursor: pointer; transition: background 0.2s; } .btn-order:hover { background: #e6b800; } /* ===================== OVERLAY & POPUP ===================== */ .overlay { display: flex; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); align-items: center; justify-content: center; z-index: 9999; } .hidden { display: none; } .popup-box { background: #1a1a1a; border-radius: 16px; padding: 36px; text-align: center; max-width: 340px; width: 90%; border: 1px solid #333; } .popup-wide { max-width: 380px; text-align: left; } .popup-icon { font-size: 48px; margin-bottom: 12px; } .popup-title { font-family: 'Bebas Neue', sans-serif; font-size: 1.8rem; color: #f5c518; letter-spacing: 1px; margin: 0 0 8px; } .popup-subtitle { color: #888; margin: 0 0 20px; font-size: 0.95rem; } .popup-input { width: 100%; padding: 12px 16px; font-size: 1rem; background: #0d0d0d; border: 2px solid #333; border-radius: 8px; color: #fff; margin-bottom: 12px; box-sizing: border-box; font-family: 'Nunito', sans-serif; outline: none; } .popup-input:focus { border-color: #f5c518; } .error-msg { color: #e74c3c; font-size: 0.9rem; margin: 0 0 12px; display: none; } /* ===================== BUTTONS ===================== */ .btn-primary { background: #f5c518; color: #0d0d0d; border: none; border-radius: 8px; font-size: 1rem; padding: 13px; cursor: pointer; font-family: 'Nunito', sans-serif; font-weight: 700; } .btn-primary:hover { background: #e6b800; } .btn-gray { flex: 1; padding: 12px; border: 1px solid #444; background: #2a2a2a; color: #ccc; border-radius: 8px; cursor: pointer; font-family: 'Nunito', sans-serif; font-size: 0.95rem; } .btn-full { width: 100%; } .btn-grow { flex: 2; padding: 12px; } .btn-row { display: flex; gap: 10px; margin-top: 8px; } /* ===================== NÚT GIỎ NỔI ===================== */ .cart-btn { position: fixed; bottom: 30px; right: 30px; background: #f5c518; color: #0d0d0d; border-radius: 50%; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1000; font-size: 26px; box-shadow: 0 4px 16px rgba(245,197,24,0.4); } .cart-btn:hover { background: #e6b800; } .cart-count { position: fixed; bottom: 62px; right: 22px; background: #e74c3c; color: #fff; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; font-weight: bold; display: none; align-items: center; justify-content: center; z-index: 1001; } /* ===================== PANEL GIỎ ===================== */ .cart-panel { position: fixed; right: -400px; top: 0; bottom: 0; width: 340px; background: #1a1a1a; border-left: 1px solid #333; z-index: 2000; display: flex; flex-direction: column; transition: right 0.3s ease; font-family: 'Nunito', sans-serif; } .cart-header { background: #111; color: #f5c518; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #333; } .cart-header h3 { margin: 0; font-size: 1.1rem; } .close-btn { cursor: pointer; font-size: 22px; color: #888; } .cart-items { flex: 1; overflow-y: auto; padding: 16px; } .empty-msg { text-align: center; color: #666; margin-top: 40px; line-height: 1.8; } .cart-footer { padding: 16px; border-top: 1px solid #333; display: none; } .cart-total-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 1rem; font-weight: 700; } /* ===================== POPUP XÁC NHẬN ===================== */ .total-row { display: flex; justify-content: space-between; font-weight: bold; font-size: 1rem; padding: 10px 0; border-top: 1px solid #333; margin-bottom: 16px; } /* ===================== POPUP THÀNH CÔNG ===================== */ .success-info { background: #111; border-radius: 10px; padding: 16px; margin-bottom: 20px; text-align: left; border: 1px solid #333; } .info-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.95rem; } .label { color: #888; } .value { font-weight: 700; color: #fff; } /* ===================== TOAST ===================== */ .toast { display: none; position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: #f5c518; color: #0d0d0d; padding: 10px 22px; border-radius: 20px; font-size: 0.9rem; font-weight: 700; z-index: 9999; } /* ===================== UTILITY ===================== */ .price-yellow { color: #f5c518; font-weight: 700; }
// ============================================= // STARCINEMA - script.js // ============================================= // --- BIẾN TOÀN CỤC --- let cart = []; // Mảng lưu vé đã chọn let userName = ""; // Tên khách hàng // ============================================= // 1. POPUP NHẬP TÊN // ============================================= function showNamePopup() { document.getElementById("name-overlay").style.display = "flex"; document.getElementById("name-input").value = ""; document.getElementById("name-error").style.display = "none"; } function confirmName() { let input = document.getElementById("name-input"); let val = input.value.trim(); if (val === "") { document.getElementById("name-error").style.display = "block"; return; } userName = val; document.getElementById("name-overlay").style.display = "none"; let badge = document.getElementById("user-badge"); badge.innerHTML = "???? " + userName; badge.style.display = "inline-block"; } // ============================================= // 2. MỞ / ĐÓNG GIỎ VÉ // ============================================= function toggleCart() { let panel = document.getElementById("cart-panel"); if (panel.style.right === "0px") { panel.style.right = "-400px"; } else { panel.style.right = "0px"; } } // ============================================= // 3. THÊM VÉ VÀO GIỎ // ============================================= function addTicket(movieName, price) { // Nếu chưa có tên thì yêu cầu nhập if (userName === "") { showNamePopup(); return; } // Kiểm tra phim đã có trong giỏ chưa let found = false; for (let i = 0; i < cart.length; i++) { if (cart[i].name === movieName) { cart[i].qty = cart[i].qty + 1; found = true; break; } } // Nếu chưa có thì thêm mới vào mảng if (found === false) { cart.push({ name: movieName, price: price, qty: 1 }); } renderCart(); // Tự mở panel giỏ vé document.getElementById("cart-panel").style.right = "0px"; // Hiện thông báo toast document.getElementById("toast-msg").innerHTML = "???? Đã thêm: " + movieName; document.getElementById("toast").style.display = "block"; setTimeout(function () { document.getElementById("toast").style.display = "none"; }, 2000); } // ============================================= // 4. THAY ĐỔI SỐ LƯỢNG VÉ // ============================================= function changeQty(index, amount) { cart[index].qty = cart[index].qty + amount; // Nếu số lượng = 0 thì xóa khỏi giỏ if (cart[index].qty <= 0) { cart.splice(index, 1); } renderCart(); } // ============================================= // 5. HIỂN THỊ GIỎ VÉ // ============================================= function renderCart() { let container = document.getElementById("cart-items"); let footer = document.getElementById("cart-footer"); let countBadge = document.getElementById("cart-count"); // Tính tổng số lượng và tổng tiền let totalQty = 0; let totalPrice = 0; for (let i = 0; i < cart.length; i++) { totalQty = totalQty + cart[i].qty; totalPrice = totalPrice + cart[i].price * cart[i].qty; } // Cập nhật badge số vé trên nút nổi if (totalQty > 0) { countBadge.style.display = "flex"; countBadge.innerHTML = totalQty; } else { countBadge.style.display = "none"; } // Nếu giỏ trống if (cart.length === 0) { footer.style.display = "none"; container.innerHTML = "<p class='empty-msg'>Chưa có vé nào<br><small>Hãy chọn phim bạn thích!</small></p>"; return; } // Hiển thị từng loại vé trong giỏ footer.style.display = "block"; document.getElementById("cart-total").innerHTML = totalPrice.toLocaleString("vi-VN") + " ₫"; let html = ""; for (let i = 0; i < cart.length; i++) { html += "<div style='display:flex; align-items:center; justify-content:space-between; padding:12px 0; border-bottom:1px solid #2a2a2a;'>"; html += " <div style='flex:1'>"; html += " <div style='font-weight:700; color:#fff;'>" + cart[i].name + "</div>"; html += " <div style='color:#f5c518; font-size:0.9rem;'>" + cart[i].price.toLocaleString("vi-VN") + " ₫ / vé</div>"; html += " </div>"; html += " <div style='display:flex; align-items:center; gap:8px;'>"; html += " <button onclick='changeQty(" + i + ", -1)' style='width:28px;height:28px;border-radius:50%;border:1px solid #444;cursor:pointer;background:#2a2a2a;color:#fff;font-size:1rem;'>-</button>"; html += " <span style='font-weight:bold; min-width:20px; text-align:center; color:#fff;'>" + cart[i].qty + "</span>"; html += " <button onclick='changeQty(" + i + ", 1)' style='width:28px;height:28px;border-radius:50%;border:1px solid #444;cursor:pointer;background:#2a2a2a;color:#fff;font-size:1rem;'>+</button>"; html += " </div>"; html += "</div>"; } container.innerHTML = html; } // ============================================= // 6. HIỂN THỊ POPUP XÁC NHẬN // ============================================= function showConfirm() { if (cart.length === 0) return; let totalPrice = 0; for (let i = 0; i < cart.length; i++) { totalPrice = totalPrice + cart[i].price * cart[i].qty; } let itemsHTML = ""; for (let i = 0; i < cart.length; i++) { itemsHTML += "<div style='display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid #2a2a2a; color:#ccc;'>"; itemsHTML += "<span>" + cart[i].name + " × " + cart[i].qty + "</span>"; itemsHTML += "<span style='color:#f5c518;'>" + (cart[i].price * cart[i].qty).toLocaleString("vi-VN") + " ₫</span>"; itemsHTML += "</div>"; } document.getElementById("confirm-items").innerHTML = itemsHTML; document.getElementById("confirm-total").innerHTML = totalPrice.toLocaleString("vi-VN") + " ₫"; document.getElementById("confirm-name").innerHTML = "Khách hàng: " + userName; document.getElementById("confirm-overlay").style.display = "flex"; } function closeConfirm() { document.getElementById("confirm-overlay").style.display = "none"; } // ============================================= // 7. GỬI ĐƠN & HIỆN THÀNH CÔNG // ============================================= function sendOrder() { let totalPrice = 0; for (let i = 0; i < cart.length; i++) { totalPrice = totalPrice + cart[i].price * cart[i].qty; } // Điền thông tin vào popup thành công document.getElementById("success-name").innerHTML = userName; document.getElementById("success-count").innerHTML = cart.length + " loại phim"; document.getElementById("success-total").innerHTML = totalPrice.toLocaleString("vi-VN") + " ₫"; // Đóng các panel document.getElementById("confirm-overlay").style.display = "none"; document.getElementById("cart-panel").style.right = "-400px"; // Hiện thành công document.getElementById("success-overlay").style.display = "flex"; // Reset giỏ vé cart = []; renderCart(); } function closeSuccess() { document.getElementById("success-overlay").style.display = "none"; } // ============================================= // 8. CHẠY KHI TRANG TẢI XONG // ============================================= window.addEventListener("DOMContentLoaded", function () { showNamePopup(); });