demonaptien.html

6.00 KB • 24/12/2025 10:10:30 • HTML

Tải về
demonaptien.html
Html
<!DOCTYPE html>
<html lang="vi">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quy trình Check Hóa Đơn Tự Động</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f0f2f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .chat-container {
            width: 400px;
            background-color: white;
            border-radius: 15px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            height: 600px;
        }

        .header {
            background-color: #ffffff;
            padding: 15px;
            border-bottom: 1px solid #ddd;
            text-align: center;
            font-weight: bold;
            color: #333;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .status-dot {
            height: 10px;
            width: 10px;
            background-color: #4cd137;
            border-radius: 50%;
            display: inline-block;
        }

        .chat-area {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 10px;
            background-color: #e5ddd5; /* Màu nền kiểu WhatsApp */
        }

        .message {
            max-width: 75%;
            padding: 10px 15px;
            border-radius: 15px;
            font-size: 14px;
            line-height: 1.4;
            position: relative;
            animation: fadeIn 0.3s ease;
            box-shadow: 0 1px 2px rgba(0,0,0,0.1);
        }

        /* Bên trái: Hệ thống Hóa đơn */
        .left {
            align-self: flex-start;
            background-color: #ffffff;
            color: #333;
            border-top-left-radius: 0;
        }
        .left::before {
            content: "Hệ thống Hóa Đơn (Client)";
            position: absolute;
            top: -18px;
            left: 0;
            font-size: 10px;
            color: #666;
            font-weight: bold;
        }

        /* Bên phải: Hệ thống Soát lỗi Ngân hàng */
        .right {
            align-self: flex-end;
            background-color: #dcf8c6;
            color: #333;
            border-top-right-radius: 0;
        }
        .right::before {
            content: "Hệ thống Soát Lỗi (Server)";
            position: absolute;
            top: -18px;
            right: 0;
            font-size: 10px;
            color: #666;
            font-weight: bold;
        }

        .system-note {
            align-self: center;
            background-color: rgba(0,0,0,0.2);
            color: white;
            padding: 5px 10px;
            border-radius: 10px;
            font-size: 11px;
            margin: 10px 0;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* Nút chạy lại */
        .controls {
            padding: 10px;
            text-align: center;
            background: #fff;
        }
        button {
            padding: 8px 20px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover { background-color: #0056b3; }
    </style>
</head>
<body>

<div class="chat-container">
    <div class="header">
        <span>Giao thức kiểm tra tiền</span>
        <span class="status-dot"></span>
    </div>
    <div class="chat-area" id="chatBox">
        </div>
    <div class="controls">
        <button onclick="startSimulation()">Chạy lại mô phỏng</button>
    </div>
</div>

<script>
    const chatBox = document.getElementById('chatBox');

    const conversation = [
        { side: 'note', text: 'Khởi tạo đơn hàng #DH999...' },
        { side: 'left', text: '🔍 (Lần 1) Ê, có ai chuyển 50k nội dung "DH999" chưa?' },
        { side: 'right', text: '📂 Đang quét DB... Chưa thấy ai cả.' },
        { side: 'left', text: '⏳ Ok, tao đợi 3 giây...' },
        { side: 'note', text: '--- 3 giây trôi qua ---' },
        { side: 'left', text: '🔍 (Lần 2) Check lại hộ cái mã "DH999" xem?' },
        { side: 'right', text: '📂 Vẫn chưa thấy record nào.' },
        { side: 'note', text: '--- Khách hàng thực hiện chuyển khoản ---' },
        { side: 'note', text: '🔔 Ting Ting! Ngân hàng nhận 50k' },
        { side: 'left', text: '🔍 (Lần 3) Lâu quá, check lại lần nữa mã "DH999"!' },
        { side: 'right', text: '✅ CÓ RỒI! Tìm thấy 1 giao dịch: <br/><b>+50.000đ</b> | Nội dung: <b>"ck tien DH999"</b>' },
        { side: 'left', text: '🎉 Ngon! Khớp mã rồi. Đánh dấu là "Đã dùng" nhé!' },
        { side: 'right', text: '👌 Đã update trạng thái giao dịch -> DONE.' },
        { side: 'note', text: 'Giao dịch hoàn tất.' }
    ];

    function addMessage(msg) {
        const div = document.createElement('div');
        if (msg.side === 'note') {
            div.className = 'system-note';
            div.innerText = msg.text;
        } else {
            div.className = `message ${msg.side}`;
            div.innerHTML = msg.text;
        }
        chatBox.appendChild(div);
        chatBox.scrollTop = chatBox.scrollHeight; // Tự cuộn xuống dưới
    }

    async function startSimulation() {
        chatBox.innerHTML = ''; // Xóa cũ
        for (let i = 0; i < conversation.length; i++) {
            await new Promise(r => setTimeout(r, 1200)); // Đợi 1.2s mỗi tin nhắn
            addMessage(conversation[i]);
        }
    }

    // Tự chạy khi mở
    startSimulation();
</script>

</body>
</html>

Số dòng: 196