Thứ Ba, 8 tháng 9, 2026

JS Thời Gian Đếm Ngược


 ĐẾM NGƯỢC ( 10S )

if (empty($client) || !isset($_SESSION["client"])) {

    include("header.php");

    ?>

    <style type="text/css">

        .cart-empty-box {

            max-width: 550px;

            margin: 60px auto;

            padding: 40px 30px;

            background: #ffffff;

            border-radius: 16px;

            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);

            text-align: center;

            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;

        }

        .cart-empty-box h2 {

            color: #2c3e50;

            font-size: 22px;

            margin-bottom: 12px;

            font-weight: 700;

        }

        .cart-empty-box p {

            color: #666;

            font-size: 15px;

            margin-bottom: 24px;

        }

        .timer-wrapper {

            display: inline-block;

            background: #f0fdf4;

            border: 1px solid #bbf7d0;

            border-radius: 50px;

            padding: 8px 20px;

            margin-bottom: 25px;

        }

        .timer-count {

            color: #16a34a;

            font-weight: 800;

            font-size: 20px;

        }

        .btn-redirect {

            display: inline-block;

            padding: 12px 28px;

            background-color: #16a34a;

            color: #ffffff !important;

            border-radius: 30px;

            text-decoration: none;

            font-weight: 600;

            font-size: 14px;

            box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);

            transition: all 0.3s ease;

        }

        .btn-redirect:hover {

            background-color: #15803d;

            box-shadow: 0 6px 16px rgba(22, 163, 74, 0.35);

        }

    </style>

    <div class="cart-empty-box">

        <h2>Đơn hàng đã được xử lý hoặc giỏ hàng rỗng!</h2>

        <p>Bạn đã hoàn tất đặt hàng hoặc chưa chọn sản phẩm mới.</p>

        <div class="timer-wrapper">

            Đang quay về trang chủ sau <span id="countdown" class="timer-count">10</span> giây

        </div>

        <div>

            <a href="<?php echo $site_live; ?>" class="btn-redirect">Quay về trang chủ ngay</a>

        </div>

    </div>

    <script type="text/javascript">

        (function() {

            var timeLeft = 10;

            var timerElement = document.getElementById('countdown');

            var countdownTimer = setInterval(function() {

                timeLeft--;

                if (timerElement) {

                    timerElement.textContent = timeLeft;

                }

                if (timeLeft <= 0) {

                    clearInterval(countdownTimer);

                    window.location.href = "<?php echo $site_live; ?>";

                }

            }, 1000);

        })();

    </script>

    <?php

    include("footer.php");

    exit();

}

Không có nhận xét nào:

Đăng nhận xét