-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path首页显示热门商品.html
188 lines (171 loc) · 3.69 KB
/
首页显示热门商品.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
body {
background-color: #E4E4E4;
}
header {
width: 100%;
height: 40px;
margin: 0 auto;
background-color: #F0FFFF;
}
.load{
width: 120px;
height: 40px;
float: left;
margin-left: 30px;
}
.btn{
width: 50px;
height: 20px;
margin: 10px 5px;
background-color: #FF8C00;
border: 1px solid #848D94;
border-radius: 5px;
outline: none;
float: left;
color: #fff;
cursor: pointer;
}
ul {
width: 1200px;
height: 40px;
margin: 0 auto;
}
li {
float: left;
width: 110px;
height: 40px;
text-align: center;
line-height: 40px;
font-size: 20px;
list-style: none;
margin:0 5px 0;
background-color: #A5DC86;
color: white;
}
li:hover {
background-color: orange;
color: #000;
}
.shopcar{
width: 110px;
line-height: 38px;
text-align: center;
color: #fff;
background-color: #FD9720;
float: right;
margin-right: 30px;
border: 1px solid #f1f1f1;
border-radius: 15px;
}
a {
text-decoration: none;
color: red;
}
a:hover {
text-decoration: underline;
}
section #Box {
width: 1350px;
height: 840px;
margin: 0 auto;
}
.hot-top{
width: 300px;
line-height: 60px;
border-bottom: 2px solid #AAAAAA;
margin: 0 auto;
font-size: 35px;
text-align: center;
color: #FFD700;
}
.box {
width: 258px;
height: 400px;
margin: 10px 0 0 10px;
float: left;
border: 1px solid darkorange;
background-color: azure;
}
.goods_name {
width: 258px;
height: 70px;
}
.goods_desc {
width: 258px;
height: 45px;
font-size: 12px;
color: #FFA500;
}
.goods_img {
width: 258px;
height: 250px;
border-bottom: 10px solid darkorange;
}
.price {
width: 258px;
height: 20px;
color: red;
font-weight: 700;
margin-left: 10px;
}
img {
width: 258px;
height: 250px;
}
</style>
</head>
<body>
<header>
<div class="load">
<a href="注册.html"><input type="button" class="btn" value="注册" /></a>
<a href="登录.html"><input type="button" class="btn" value="登录" /></a>
</div>
<a href=""><div class="shopcar">购物车</div></a>
<ul></ul>
</header>
<section>
<div class="hot-top">热门商品</div>
<div id="Box"></div>
</section>
<script src="myajax.js" charset="UTF-8"></script>
<script>
var oh2 = document.querySelector('h2');
var oul = document.querySelector('ul');
var odiv = document.getElementById('Box');
console.log(odiv);
myajax.get('http://h6.duchengjiu.top/shop/api_cat.php', {}, function(error, responseText) {
var json = JSON.parse(responseText);
var data = json.data;
for(var i = 0; i < data.length; i++) {
var obj = data[i];
oul.innerHTML += `<li><a href="商品分类.html?cat_id=${obj.cat_id}">${obj.cat_name}</a></li>`;
}
});
myajax.get('http://h6.duchengjiu.top/shop/api_goods.php', {}, function(error, responseText) {
var json = JSON.parse(responseText);
var data = json.data;
for(var i = 0; i < data.length; i++) {
var obj = data[i];
odiv.innerHTML += `<div class="box">
<a href="商品详情.html?goods_id=${obj.goods_id}">
<div class="goods_img"><img src="${obj.goods_thumb}"></div>
<div class="goods_name">${obj.goods_name}</div>
<div class="goods_desc">${obj.goods_desc}</div>
<div class="price">\¥ ${obj.price}</div>
</a>
</div>`;
}
});
</script>
</body>
</html>