Spaces:
No application file

File size: 3,692 Bytes
acfcded
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>๊ฒฐ์ œ ํŽ˜์ด์ง€</title>
<style>

    :root {

        --main-color: #6cdce4;      /* ๋ฏผํŠธ */

        --secondary-color: #447790; /* ๋ณด์กฐ์ƒ‰ */

    }



    body {

        margin: 0;

        font-family: 'Noto Sans KR', sans-serif;

        background-color: #f9f9f9;

        color: #333;

    }



    header {

        background-color: var(--secondary-color);

        color: var(--main-color);

        padding: 15px 30px;

        text-align: center;

        font-size: 24px;

    }



    .container {

        max-width: 600px;

        margin: 30px auto;

        padding: 20px;

        background-color: #fff;

        border-radius: 8px;

        box-shadow: 0 2px 6px rgba(0,0,0,0.1);

    }



    h2 {

        color: var(--secondary-color);

        margin-bottom: 15px;

    }



    .cart-summary {

        margin-bottom: 20px;

    }



    .cart-summary div {

        display: flex;

        justify-content: space-between;

        margin-bottom: 5px;

    }



    label {

        display: block;

        margin: 10px 0 5px;

    }



    input {

        width: 100%;

        padding: 8px;

        font-size: 14px;

        border-radius: 5px;

        border: 1px solid #ccc;

        margin-bottom: 10px;

    }



    button {

        width: 100%;

        padding: 10px;

        background-color: var(--main-color);

        color: #fff;

        font-size: 16px;

        border: none;

        border-radius: 5px;

        cursor: pointer;

    }



    button:hover {

        background-color: var(--secondary-color);

    }

</style>
</head>
<body>
<header>๊ฒฐ์ œ ํŽ˜์ด์ง€</header>

<div class="container">
    <h2>์žฅ๋ฐ”๊ตฌ๋‹ˆ ํ™•์ธ</h2>
    <div class="cart-summary" id="cart-summary">
        <!-- ์žฅ๋ฐ”๊ตฌ๋‹ˆ ์ƒํ’ˆ ๋ชฉ๋ก ํ‘œ์‹œ -->
    </div>

    <h2>๊ฒฐ์ œ ์ •๋ณด ์ž…๋ ฅ</h2>
    <form id="payment-form">
        <label for="name">์ด๋ฆ„</label>
        <input type="text" id="name" required placeholder="ํ™๊ธธ๋™">

        <label for="card">์นด๋“œ ๋ฒˆํ˜ธ</label>
        <input type="text" id="card" required placeholder="0000-0000-0000-0000">

        <label for="expiry">์œ ํšจ๊ธฐ๊ฐ„</label>
        <input type="text" id="expiry" required placeholder="MM/YY">

        <button type="submit">๊ฒฐ์ œ ์™„๋ฃŒ</button>
    </form>
</div>

<script>

    // localStorage์—์„œ ์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ

    let cart = JSON.parse(localStorage.getItem('cartData')) || [];



    const cartSummary = document.getElementById('cart-summary');



    function renderCartSummary(){

        cartSummary.innerHTML = '';

        let total = 0;

        cart.forEach(item => {

            total += item.price;

            const div = document.createElement('div');

            div.innerHTML = `<span>${item.name}</span><span>โ‚ฉ${item.price}</span>`;

            cartSummary.appendChild(div);

        });

        const totalDiv = document.createElement('div');

        totalDiv.style.fontWeight = 'bold';

        totalDiv.innerHTML = `<span>ํ•ฉ๊ณ„</span><span>โ‚ฉ${total}</span>`;

        cartSummary.appendChild(totalDiv);

    }



    renderCartSummary();



    const form = document.getElementById('payment-form');

    form.addEventListener('submit', function(e){

        e.preventDefault();

        alert('๊ฒฐ์ œ๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!');

        localStorage.removeItem('cartData'); // ๊ฒฐ์ œ ํ›„ ์žฅ๋ฐ”๊ตฌ๋‹ˆ ์ดˆ๊ธฐํ™”

        window.location.href = 'index.html'; // ๋ฉ”์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™

    });

</script>
</body>
</html>