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>
|