| Cỡ chữ:   
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body> <!-- ===================== HEADER ===================== --> <div class="restaurant-name"> <img id="logo" src="" /> <br>Vietpersie's Restaurant<br> <span id="table-badge" class="table-badge" onclick="showTablePopup()"></span> </div> <!-- ===================== MENU ===================== --> <div class="cat">Side Dishes</div> <div class="menu"> <div class="item"> <img src="https://lazi.vn/files/large/eaec0d5e27ce184" alt="side1"> <h3>Dragon Pass in Ocean</h3> <p>Crispy slices of seasoned russet potatoes, air-fried to perfection. Served with zesty sour cream for a delightful twist on a classic favorite.</p> <p><span>$10.99</span><span class="rightspan">Order</span></p> </div> <div class="item"> <img src="https://cdn.nguyenkimmall.com/images/companies/_1/Content/tin-tuc/gia-dung/top-10-mon-an-mua-dong-am-ap-kich-thich-vi-giac-h8.jpg" alt="Salad"> <h3>Warm Winter Day</h3> <p>Crisp cucumber and vibrant radishes, tossed in a tangy vinaigrette for a refreshing crunch.</p> <p><span>$5.99</span><span class="rightspan">Order</span></p> </div> </div> <div class="cat">Entreé</div> <div class="menu"> <div class="item"> <img src="https://assets.tmecosys.com/image/upload/t_web767x639/img/recipe/ras/Assets/102cf51c-9220-4278-8b63-2b9611ad275e/Derivates/3831dbe2-352e-4409-a2e2-fc87d11cab0a.jpg" alt="Burger"> <h3>Deluxe Burger</h3> <p>A juicy beef burger with lettuce, tomato, cheese, and special sauce.</p> <p><span>$10.99</span><span class="rightspan">Order</span></p> </div> <div class="item"> <img src="https://www.sidechef.com/recipe/48bc47bb-38ec-47e2-9e78-7bbed7552986.jpeg?d=1408x1120" alt="Pizza"> <h3>Pepperoni Pizza</h3> <p>Classic pizza topped with pepperoni, mozzarella cheese, and tomato sauce.</p> <p><span>$12.99</span><span class="rightspan">Order</span></p> </div> </div> <div class="cat">Desserts</div> <div class="menu"> <div class="item"> <img src="https://th.bing.com/th/id/OIP.21XG1xTLOPD5KUE5jbEtUQHaGU?pid=ImgDet&rs=1" alt="cheesecake"> <h3>Cheese Cake</h3> <p>Indulge in the timeless delight of our classic cheesecake. Creamy, rich, and velvety-smooth.</p> <p><span>$3.99</span><span class="rightspan">Order</span></p> </div> <div class="item"> <img src="https://www.theplazarestaurant.com/wp-content/uploads/2018/09/Fried-Icecream-1-300x200.jpg" alt="icecream"> <h3>Fried Ice Cream</h3> <p>A hot and crispy surprise that reveals a cold, sweet secret.</p> <p><span>$4.99</span><span class="rightspan">Order</span></p> </div> </div> <!-- ===================== POPUP NHẬP SỐ BÀN ===================== --> <div id="table-overlay" class="overlay"> <div class="popup-box"> <img class="popup-icon" src="uploads/4-20260429143810.png"> <h2 class="popup-title">Vietpersie's Restaurant</h2> <p class="popup-subtitle">Vui lòng nhập số bàn của bạn</p> <input id="table-input" class="table-input" type="number" min="1" max="50" placeholder="Số bàn (VD: 5)"> <button class="btn-dark btn-full" onclick="confirmTable()">Xác nhận</button> <p id="table-error" class="error-msg">Vui lòng nhập số bàn từ 1 đến 50!</p> </div> </div> <!-- ===================== NÚT GIỎ HÀNG NỔI ===================== --> <div id="cart-btn" class="cart-btn" onclick="toggleCart()"><img class="popup-icon" src="uploads/4-20260429143810.png"></div> <div id="cart-count" class="cart-count"></div> <!-- ===================== PANEL GIỎ HÀNG ===================== --> <div id="cart-panel" class="cart-panel"> <div class="cart-header"> <h3> Giỏ hàng của bạn</h3> <span onclick="toggleCart()" class="close-btn">×</span> </div> <div id="cart-items" class="cart-items"> <p class="empty-msg">Giỏ hàng trống️<br><small>Hãy chọn món bạn thích!</small></p> </div> <div id="cart-footer" class="cart-footer"> <div class="cart-total-row"> <span>Tổng cộng:</span> <span id="cart-total" class="price-red">$0.00</span> </div> <button class="btn-red btn-full" onclick="showOrderConfirm()"> Xác nhận & Gọi món</button> </div> </div> <!-- ===================== POPUP XÁC NHẬN ORDER ===================== --> <div id="confirm-overlay" class="overlay hidden"> <div class="popup-box popup-wide"> <h2 class="popup-title-left">Xác nhận đơn hàng</h2> <p id="confirm-table" class="text-muted"></p> <div id="confirm-items" class="confirm-items"></div> <div class="total-row"> <span>Tổng cộng:</span> <span id="confirm-total" class="price-red"></span> </div> <label class="note-label">Ghi chú đặc biệt (không bắt buộc):</label> <textarea id="order-note" class="note-input" placeholder="VD: Ít cay, không hành..."></textarea> <div class="btn-row"> <button class="btn-gray" onclick="document.getElementById('confirm-overlay').style.display='none'">Quay lại</button> <button class="btn-red btn-grow" onclick="sendOrder()">Gọi nhân viên & Đặt món</button> </div> </div> </div> <!-- ===================== POPUP ĐẶT THÀNH CÔNG ===================== --> <div id="success-overlay" class="overlay hidden"> <div class="popup-box"> <img class="popup-icon" src="uploads/4-20260429143810.png"> <h2 class="popup-title">Đặt món thành công!</h2> <p class="popup-subtitle">Nhân viên đã nhận được đơn của bạn</p> <div class="success-info"> <div class="info-row"> <span class="text-muted">Bàn số</span> <span class="text-bold" id="success-table"></span> </div> <div class="info-row"> <span class="text-muted">Số món</span> <span class="text-bold" id="success-items"></span> </div> </div> <button class="btn-dark btn-full" onclick="document.getElementById('success-overlay').style.display='none'">OK, tôi sẽ đợi!</button> </div> </div> <!-- ===================== TOAST THÔNG BÁO ===================== --> <div id="toast" class="toast"> <span id="toast-msg"></span> </div> <script src="script.js"></script> </body> </html>
/* ============================================= VIETPERSIE'S RESTAURANT - style.css ============================================= */ /* ===================== BASE ===================== */ body { font-family: 'Rubik', sans-serif; margin: 0; padding: 0; background-color: #f4f4f4; } /* ===================== HEADER ===================== */ .restaurant-name { font-family: 'Roboto Condensed', sans-serif; text-align: center; padding: 20px; background-color: darkslategrey; color: #fff; font-size: 2.5rem; } #logo { height: 35px; } .table-badge { display: none; background: #e74c3c; color: #fff; font-size: 0.9rem; padding: 6px 14px; border-radius: 20px; font-family: 'Rubik', sans-serif; cursor: pointer; } /* ===================== MENU ===================== */ .cat { font-family: 'Rubik', sans-serif; font-weight: bold; width: 180px; text-align: center; color: #ffffff; font-size: 25px; padding: 5px; border-radius: 25px; margin: 10px auto; background-color: #e74c3c; } .menu { display: flex; justify-content: center; align-items: flex-start; padding: 20px; } .item { width: 45%; background-color: #fff; margin: 10px; padding: 20px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .item img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; } .item h3 { margin-top: 10px; font-size: 1.9rem; } .item p { margin-top: 5px; font-size: 1rem; } .item span { font-weight: bold; font-size: 36px; color: #e74c3c; } .rightspan { float: right; background-color: darkslategrey; border-radius: 25px; font-size: 20px !important; padding: 10px !important; color: #ffffff !important; cursor: pointer; } .rightspan:hover { background-color: #e74c3c; color: #ffffff !important; } /* ===================== OVERLAY & POPUP ===================== */ .overlay { display: flex; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); align-items: center; justify-content: center; z-index: 9999; } .hidden { display: none; } .popup-box { background: #fff; border-radius: 16px; padding: 40px; text-align: center; max-width: 360px; width: 90%; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2); } .popup-wide { max-width: 400px; max-height: 90vh; overflow-y: auto; text-align: left; } .popup-icon { font-size: 48px; margin-bottom: 12px; width: 80px; height: 100px; } .popup-title { font-family: 'Roboto Condensed', sans-serif; font-size: 1.8rem; color: #2f4f4f; margin-bottom: 8px; } .popup-title-left { font-family: 'Roboto Condensed', sans-serif; font-size: 1.6rem; color: #2f4f4f; margin-bottom: 4px; } .popup-subtitle { color: #666; margin-bottom: 24px; } /* ===================== POPUP NHẬP BÀN ===================== */ .table-input { width: 100%; padding: 12px 16px; font-size: 1.2rem; border: 2px solid #ddd; border-radius: 8px; text-align: center; margin-bottom: 16px; outline: none; box-sizing: border-box; } .error-msg { color: #e74c3c; margin-top: 10px; display: none; } /* ===================== BUTTONS ===================== */ .btn-dark { background: #2f4f4f; color: #fff; border: none; border-radius: 8px; font-size: 1.1rem; padding: 14px; cursor: pointer; font-family: 'Rubik', sans-serif; } .btn-dark:hover { background: #e74c3c; } .btn-red { background: #e74c3c; color: #fff; border: none; border-radius: 8px; font-size: 1rem; padding: 14px; cursor: pointer; font-family: 'Rubik', sans-serif; font-weight: bold; } .btn-red:hover { background: #c0392b; } .btn-gray { flex: 1; padding: 12px; border: 1px solid #ddd; background: #f5f5f5; border-radius: 8px; cursor: pointer; font-family: 'Rubik', sans-serif; font-size: 0.95rem; } .btn-full { width: 100%; } .btn-grow { flex: 2; padding: 12px; } .btn-row { display: flex; gap: 10px; } /* ===================== NÚT GIỎ HÀNG NỔI ===================== */ .cart-btn { position: fixed; bottom: 30px; right: 30px; background: #2f4f4f; color: #fff; 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(0, 0, 0, 0.25); } .cart-btn:hover { background: #e74c3c; } .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Ỏ HÀNG ===================== */ .cart-panel { position: fixed; right: -400px; top: 0; bottom: 0; width: 360px; background: #fff; box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15); z-index: 2000; display: flex; flex-direction: column; transition: right 0.3s ease; font-family: 'Rubik', sans-serif; } .cart-header { background: #2f4f4f; color: #fff; padding: 20px; display: flex; justify-content: space-between; align-items: center; } .cart-header h3 { margin: 0; font-size: 1.2rem; } .close-btn { cursor: pointer; font-size: 22px; } .cart-items { flex: 1; overflow-y: auto; padding: 16px; } .empty-msg { text-align: center; color: #999; margin-top: 40px; } .cart-footer { padding: 16px; border-top: 1px solid #eee; display: none; } .cart-total-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 1.1rem; font-weight: bold; } /* ===================== POPUP XÁC NHẬN ===================== */ .confirm-items { margin-bottom: 16px; } .total-row { display: flex; justify-content: space-between; font-weight: bold; font-size: 1.1rem; margin-bottom: 20px; padding-top: 8px; } .note-label { display: block; margin-bottom: 6px; font-size: 0.9rem; color: #555; } .note-input { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.9rem; min-height: 80px; resize: none; font-family: 'Rubik', sans-serif; margin-bottom: 16px; box-sizing: border-box; } /* ===================== POPUP THÀNH CÔNG ===================== */ .success-info { background: #f9f9f9; border-radius: 12px; padding: 16px; margin-bottom: 20px; text-align: left; } .info-row { display: flex; justify-content: space-between; margin-bottom: 8px; } /* ===================== TOAST ===================== */ .toast { display: none; position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: #2f4f4f; color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 0.9rem; z-index: 9999; } /* ===================== UTILITY ===================== */ .price-red { color: #e74c3c; } .text-muted { color: #999; font-size: 0.9rem; margin-bottom: 16px; } .text-bold { font-weight: bold; }
// --- BIẾN TOÀN CỤC --- let cart = []; // Mảng lưu các món trong giỏ hàng let tableNumber = 0; // Số bàn của khách // ============================================= // 1. HIỂN THỊ POPUP NHẬP SỐ BÀN // ============================================= function showTablePopup() { let overlay = document.getElementById("table-overlay"); overlay.style.display = "flex"; document.getElementById("table-input").value = ""; document.getElementById("table-error").style.display = "none"; } function confirmTable() { let input = document.getElementById("table-input"); let val = parseInt(input.value); if (val < 1 || val > 50 || isNaN(val)) { document.getElementById("table-error").style.display = "block"; return; } tableNumber = val; document.getElementById("table-overlay").style.display = "none"; document.getElementById("table-badge").innerHTML = "Bàn số " + tableNumber; document.getElementById("table-badge").style.display = "inline-block"; } // ============================================= // 2. MỞ / ĐÓNG GIỎ HÀNG // ============================================= let panel = document.getElementById("cart-panel"); function toggleCart() { if (panel.style.right === "0px") { panel.style.right = "-400px"; } else { panel.style.right = "0px"; } } // ============================================= // 3. THÊM MÓN VÀO GIỎ HÀNG // ============================================= function addToCart(name, price) { if (tableNumber === 0) { showTablePopup(); return; } // Kiểm tra món đã có trong giỏ chưa let found = false; for (let i = 0; i < cart.length; i++) { if (cart[i].name === name) { cart[i].qty = cart[i].qty + 1; found = true; break; } } // Nếu chưa có thì thêm mới if (found === false) { cart.push({ name: name, price: price, qty: 1 }); } renderCart(); // Tự mở panel giỏ hàng document.getElementById("cart-panel").style.right = "0px"; // Hiện thông báo document.getElementById("toast-msg").innerHTML = "✅ Đã thêm: " + name; document.getElementById("toast").style.display = "block"; setTimeout(function () { document.getElementById("toast").style.display = "none"; }, 2000); } // ============================================= // 4. THAY ĐỔI SỐ LƯỢNG / XÓA MÓN // ============================================= function changeQty(index, amount) { cart[index].qty = cart[index].qty + amount; if (cart[index].qty <= 0) { cart.splice(index, 1); // Xóa khỏi mảng nếu số lượng = 0 } renderCart(); } // ============================================= // 5. HIỂN THỊ GIỎ HÀNG // ============================================= let container = document.getElementById("cart-items"); let footer = document.getElementById("cart-footer"); let countBadge = document.getElementById("cart-count"); function renderCart() { // 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ố lượng trên nút giỏ hàng 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 style='text-align:center; color:#999; margin-top:40px;'>Giỏ hàng trống ????️<br><small>Hãy chọn món bạn thích!</small></p>"; return; } // Hiển thị từng món trong giỏ footer.style.display = "block"; document.getElementById("cart-total").innerHTML = "$" + totalPrice.toFixed(2); 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 #f0f0f0;'>"; html += " <div style='flex:1'>"; html += " <div style='font-weight:bold;'>" + cart[i].name + "</div>"; html += " <div style='color:#e74c3c;'>$" + cart[i].price.toFixed(2) + " / món</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 #ddd;cursor:pointer;font-size:1rem;background:#f5f5f5;'>-</button>"; html += " <span style='font-weight:bold; min-width:20px; text-align:center;'>" + cart[i].qty + "</span>"; html += " <button onclick='changeQty(" + i + ", 1)' style='width:28px;height:28px;border-radius:50%;border:1px solid #ddd;cursor:pointer;font-size:1rem;background:#f5f5f5;'>+</button>"; html += " </div>"; html += "</div>"; } container.innerHTML = html; } // ============================================= // 6. XÁC NHẬN & GỬI ĐƠN HÀNG // ============================================= function showOrderConfirm() { 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:6px 0;border-bottom:1px solid #f0f0f0;'>"; itemsHTML += "<span>" + cart[i].name + " × " + cart[i].qty + "</span>"; itemsHTML += "<span style='color:#e74c3c;'>$" + (cart[i].price * cart[i].qty).toFixed(2) + "</span>"; itemsHTML += "</div>"; } document.getElementById("confirm-items").innerHTML = itemsHTML; document.getElementById("confirm-total").innerHTML = "$" + totalPrice.toFixed(2); document.getElementById("confirm-table").innerHTML = "Bàn số " + tableNumber; document.getElementById("confirm-overlay").style.display = "flex"; } function sendOrder() { document.getElementById("confirm-overlay").style.display = "none"; document.getElementById("cart-panel").style.right = "-400px"; // Hiển thị màn hình thành công document.getElementById("order-note").value = ""; document.getElementById("success-table").innerHTML = tableNumber; document.getElementById("success-items").innerHTML = cart.length + " loại món"; document.getElementById("success-overlay").style.display = "flex"; // Reset giỏ hàng cart = []; renderCart(); } // ============================================= // 7. GẮN SỰ KIỆN CHO TẤT CẢ NÚT "ORDER" // ============================================= window.addEventListener("DOMContentLoaded", function () { let items = document.querySelectorAll(".item"); for (let i = 0; i < items.length; i++) { let btn = items[i].querySelector(".rightspan"); let name = items[i].querySelector("h3").innerHTML; let priceText = items[i].querySelector("span").innerHTML; let price = parseFloat(priceText.replace("$", "")); btn.addEventListener("click", function () { addToCart(name, price); }); } // Hiện popup nhập bàn ngay khi tải trang showTablePopup(); });