-
Notifications
You must be signed in to change notification settings - Fork 0
/
detail-product.html
379 lines (294 loc) · 13.6 KB
/
detail-product.html
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chi tiết sản phẩm</title>
<link rel="stylesheet" href="assets/css/product-detail.css">
<link rel="stylesheet" href="assets/css/radio.css">
<link rel="stylesheet" href="assets/css/footer.css">
<link rel="shortcut icon" type="image" href="assets/img/logo2.png">
<link rel="stylesheet" href="assets/css/styleP.css">
<link href="https://fonts.googleapis.com/css?family=Poppins:600&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/a81368914c.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;1,200;1,300;1,400&display=swap" rel="stylesheet">
</head>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(function(){
$("header").load("header.html");
$("footer").load("footer.html");
});
</script>
<header>
</header>
<body>
<div class="wrapper">
<div class="top-content">
<ul class="breadcrumb">
<li><a href="#">Trang chủ</a></li>
<li><a href="#">Sản phẩm</a></li>
<li>Bán chạy nhất</li>
</ul>
</div>
<div class="left-content">
<div class="left-content-img">
<img id="mainImage" src="assets/img/shoes/1.png">
</div>
<div class="left-content-slider">
<div class="left-content-slider-content">
<div class="arrow-left-background">
</div>
<img class="arrow-left" id="slideLeft" src="assets/img/left_arrow.svg">
<div class="arrow-right-background">
</div>
<img class="arrow-right" id="slideRight" src="assets/img/right_arrow.svg">
<div class="left-content-slider-more-img" id="slider">
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/1.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/2.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/3.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/4.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/5.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/6.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/3.png">
</div>
<div class="item">
<img class="thumb" src="assets/img/detail_img_shoes/2.png">
</div>
</div>
</div>
</div>
</div>
<div class="right-content">
<div class="right-content-pa">
<div class="name">
<p1 id="productName">Nike Air Force 1 Low Triple White</p1>
</div>
<div class="gender-price">
<p2 id="productGender">Giày nam</p2>
<br/>
<p3 id="productPrice">2.649.000đ</p3>
</div>
<div class="masanpham-thuonghieu">
<p5>Mã sản phẩm: </p5>
<p4>DD8959-100</p4>
<br/>
<p5>Thương hiệu: </p5>
<p4>Nike</p4>
</div>
<div class="size">
<p6>Chọn size giày:</p6>
<div class ="content-size-detail">
<input type="radio" class="chk-size" name="rad" id="s35">
<label for = "s35">35</label>
<input type="radio" class="chk-size" name="rad" id="s35.5">
<label for = "s35.5">35.5</label>
<input type="radio" class="chk-size" name="rad" id="s36">
<label for = "s36">36</label>
<input type="radio" class="chk-size" name="rad" id="s37">
<label for = "s37">37</label>
<input type="radio" class="chk-size" name="rad" id="s38.5">
<label for = "s38.5">38.5</label>
</div>
<div class ="content-size-detail">
<input type="radio" class="chk-size" name="rad" id="s39">
<label for = "s39">39</label>
<input type="radio" class="chk-size" name="rad" id="s40">
<label for = "s40">40</label>
<input type="radio" class="chk-size" name="rad" id="s42.5">
<label for = "s42.5">42.5</label>
<input type="radio" class="chk-size" name="rad" id="s43">
<label for = "s43">43</label>
<input type="radio" class="chk-size" name="rad" id="s45">
<label for = "s45">45</label>
</div>
</div>
<div class="add-to-cart" id="btnAddToCart">
<div class="button-add-to-cart">
<img src="assets/img/ic_cart.svg">
<div>Thêm vào giỏ hàng</div>
</div>
</div>
<div class="mota-sanpham">
<p6>Mô tả sản phẩm:</p6>
<p id="productDes">
Ra mắt vào năm 1982, AF-1 là đôi giày bóng rổ đầu tiên của Nike Air, đã cách mạng hóa trò chơi trong khi nhanh chóng thu hút được sức hút trên khắp thế giới. Ngày nay, Air Force 1 vẫn đúng với nguồn gốc của nó với cùng một lớp đệm mềm mại và có độ đàn hồi đã thay đổi lịch sử giày thể thao.
</p>
</div>
<div class="chinhsach">
<div class="bottom-left"></div>
<div class="head-left">
<p6>Chính sách</p6>
<img class="img-title" src="assets/img/down_arrow.svg">
</div>
<div>
<ul>
<li><p>Cam kết chính hãng 100%: Giày nhập từ thị trường US, UK, JP</p></li>
<li><p>Miễn phí vận chuyển cho đơn hàng trên 5.000.000đ</p></li>
<li><p>Đổi trả nhanh chóng: hỗ trợ đổi hàng miễn phí trong vòng 7 ngày</p></li>
</ul>
</div>
</div>
<div class="danhgia">
<div class="bottom-left"></div>
<div class="head-left">
<p6>Đánh giá</p6>
<img class="img-title" src="assets/img/down_arrow.svg">
<img class="img-title2" src="assets/img/ic_5_stars.svg">
</div>
<div class="danhgia-chu">
<div class="danhgia-vote">
<img src="assets/img/ic_5_stars.svg">
<p>5/5 Sao</p>
</div>
<div class="viet-danhgia">
<p6>Viết đánh giá</p6>
<p>Sản phẩm hiện tại chưa có đánh giá, hãy là người đầu tiên đánh giá...</p>
</div>
</div>
</div>
</div>
</div>
<div class="bottom-content">
<div class="bottom-left"></div>
<div class="top">
<p6 class="may-love">
CÓ THỂ BẠN SẼ THÍCH
</p6>
</div>
<div class="offer" id="offerProduct">
</div>
</div>
</div>
<script>
let btnAdd = document.getElementById('btnAddToCart');
btnAdd.addEventListener('click',()=>{
cartStore();
totalCost();
})
function cartStore(){
let productNumber = localStorage.getItem("cartNumbers");
productNumber = parseInt(productNumber);
if(productNumber){
localStorage.setItem('cartNumbers',productNumber + 1);
}
else{
localStorage.setItem('cartNumbers',1);
}
location.reload();
alert("Thêm vào giỏ hàng thành công");
setItem();
}
function setItem(){
let product = JSON.parse(localStorage.getItem("data"));
let cartItem = JSON.parse(localStorage.getItem("productInCart"));
if(cartItem!=null){
if(cartItem[product.name] == undefined){
cartItem = {
...cartItem,
[product.name]: product
}
}
cartItem[product.name].incart +=1;
}
else{
product.incart = 1;
cartItem = {
[product.name]:product
}
}
localStorage.setItem('productInCart',JSON.stringify(cartItem));
}
function totalCost(){
let product = JSON.parse(localStorage.getItem("data"));
let cartCost = localStorage.getItem('totalCost');
if(cartCost != null){
cartCost = parseInt(cartCost);
localStorage.setItem('totalCost', cartCost + product.aft_price);
}else{
localStorage.setItem('totalCost',product.aft_price);
}
}
</script>
<script>
var x = JSON.parse(localStorage.getItem("data"));
x.aft_price = x.aft_price.toLocaleString('it-IT', {style : 'currency', currency : 'VND'});
x.aft_price = x.aft_price.replace("VND", "₫");
x.aft_price = x.aft_price.replace(/\s+/g, '');
document.getElementById('productName').innerHTML = x.name;
document.getElementById('productPrice').innerHTML = x.aft_price;
document.getElementById('mainImage').src = x.thumb;
document.getElementById('productGender').innerHTML = x.gender;
document.getElementById('productDes').innerHTML = x.descript;
</script>
<script>
var thumb = document.getElementsByClassName('thumb');
for(var i =0; i<thumb.length;i++){
thumb[i].addEventListener("click", function(){
// if(active.length>0){
// active[0].classList.remove('active');
// }
document.getElementById("mainImage").src = this.src;
})
}
var slideLeft = document.getElementById("slideLeft");
var slideRight = document.getElementById("slideRight");
slideLeft.addEventListener("click", function(){
document.getElementById("slider").scrollLeft -= 105;
})
slideRight.addEventListener("click", function(){
document.getElementById("slider").scrollLeft += 105;
})
</script>
<script>
var xhttp = new XMLHttpRequest();
var html = "";
var i;
let myArr;
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myArr = JSON.parse(this.responseText);
myFunction(myArr);
}
};
xhttp.open("GET","assets/json/db_product.json", true);
xhttp.send();
function myFunction(arr) {
html = "<div class='offer' id='offerProduct'>";
for (i = 0; i <6; i++) {
var sp = arr.product[i];
sp.aft_price = sp.aft_price.toLocaleString('it-IT', {style : 'currency', currency : 'VND'});
sp.aft_price = sp.aft_price.replace("VND", "₫");
sp.aft_price = sp.aft_price.replace(/\s+/g, '');
html += "<div class='item'> <div class='img'> <img onclick = openDetail(" + i + ") src=" + sp.thumb +"> <div class='xemnhanh'></div> <div class='xemnhanh-content'>Xem nhanh</div> </div> <div class='text'> <div class='title'>"+sp.title+"</div> <div class='name'>" + sp.name+"</div> <div class='gender'>"+sp.gender+"</div> <div class='price'> <div class='aft-price'>"+sp.aft_price+"</div> </div> </div> </div> "
}
html += " </div>";
document.getElementById("offerProduct").innerHTML = html;
}
function openDetail(i){
var sp = myArr.product[i];
localStorage.setItem("data",JSON.stringify(sp));
location.href = "detail-product.html";
console.log(i);
}
</script>
</body>
<footer>
</footer>
</html>