-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
596 lines (534 loc) · 19.2 KB
/
index.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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>爱吃多多线购物平台 - 首页</title>
<link rel="shortcut icon" href="img/foodie.ico"/>
<link href="AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
<link href="AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css" />
<link href="css/demo.css" rel="stylesheet" type="text/css" />
<link href="css/hmstyle.css" rel="stylesheet" type="text/css" />
<link href="css/skin.css" rel="stylesheet" type="text/css" />
<link href="css/lee.css" rel="stylesheet" type="text/css" />
<script src="AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
<!-- <script src="AmazeUI-2.4.2/assets/js/amazeui.js"></script> -->
<script src="AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div class="attention">本电商购物平台为演示网站,仅供学习和交流。所有交易金额均为0.01元,并且不会真实发货!</div>
<!-- <div id="index" @scroll="handleScroll"> -->
<div id="index">
<div class="hmtop">
<!--顶部导航条 -->
<div class="am-container header">
<ul class="message-l">
<div class="topMessage">
<div class="menu-hd" v-show="!userIsLogin">
<a href="login.html" target="_top" class="h">亲,请登录</a>
<a href="register.html" target="_top">免费注册</a>
</div>
<div class="menu-hd" v-show="userIsLogin">
<span style="color: #d2364c">欢迎,{{userInfo.username}}</span>
</div>
</div>
</ul>
<ul class="message-r">
<div class="topMessage home">
<div class="menu-hd"><a href="index.html" target="_top" class="h">商城首页</a></div>
</div>
<div class="topMessage my-shangcheng">
<div class="menu-hd MyShangcheng"><a href="javascript:void(0);" @click="goUserCenter">
<i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
</div>
</ul>
</div>
<!--悬浮搜索框-->
<div class="nav white">
<div class="logoBig">
<li><img src="img/logobig.png" /></li>
</div>
<div class="search-bar pr">
<a name="index_none_header_sysc" href="#"></a>
<form>
<input id="searchInput" v-model="keywords" name="index_none_header_sysc" type="text"
placeholder="搜索" autocomplete="off">
<input id="ai-topsearch" @click="doSearch" class="submit am-btn" value="搜索" index="1">
</form>
</div>
</div>
<div class="clear"></div>
</div>
<div id="index444">
<div class="banner" style="top: 213px;">
<!--轮播 -->
<div class="am-slider am-slider-default scoll" data-am-flexslider id="demo-slider-0">
<ul class="am-slides">
<li class="banner1"><a></a></li>
</ul>
</div>
<div class="clear"></div>
</div>
<div class="shopNav">
<div class="slideall">
<div class="long-title"><span class="all-goods">全部分类</span></div>
<div class="nav-cont">
<ul>
<li class="index"><a href="index.html">首页</a></li>
</ul>
</div>
<!--侧边导航 -->
<div id="nav" class="navfull">
<div class="area clearfix">
<div class="category-content" id="guide_2">
<div class="category">
<ul class="category-list" id="js_climit_li"></ul>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="shopMainbg">
<div class="shopMain" id="shopmain">
<div class="am-g am-g-fixed recommendation">
<div class="clock am-u-sm-3">
<!-- <img src="img/course/2020.jpg" style="margin-top: 36px;"></img> -->
<p style="font-weight: bold;">个人相关</p>
</div>
<div class="am-u-sm-4 am-u-lg-3 ">
<div class="info ">
<h3>Github</h3>
<h4>个人Github主页</h4>
</div>
<div class="recommendationMain one">
<a href="https://github.com/dsying" target="_blank">
<img src="img/course/github.png"></img>
</a>
</div>
</div>
<div class="am-u-sm-4 am-u-lg-3 ">
<div class="info ">
<h3>掘金</h3>
<h4>个人掘金主页</h4>
</div>
<div class="recommendationMain two">
<a href="https://juejin.im/user/5b0e60f6f265da08f0339162" target="_blank">
<img src="img/course/juejin.jpg"></img>
</a>
</div>
</div>
<!-- <div class="am-u-sm-4 am-u-lg-3 ">-->
<!-- <div class="info ">-->
<!-- <h3>分布式协调中间件</h3>-->
<!-- <h4>Zookeeper入门</h4>-->
<!-- </div>-->
<!-- <div class="recommendationMain three">-->
<!-- <a href="https://coding.imooc.com/class/201.html" target="_blank">-->
<!-- <img src="img/course/zk.jpg"></img>-->
<!-- </a>-->
<!-- </div>-->
<!-- </div>-->
</div>
<div class="clear "></div>
<!--热门活动 -->
<div v-for="(rootCat, rootIndex) in sixNewItemsList">
<!--甜点-->
<div class="am-container ">
<div class="shopTitle ">
<h4>{{rootCat.rootCatName}}</h4>
<h3>{{rootCat.slogan}}</h3>
</div>
</div>
<!-- 展示最新的6款商品 -->
<div class="am-g am-g-fixed floodFour">
<div class="am-u-sm-5 am-u-md-4 text-one list" :style="'background-color:' + rootCat.bgColor">
<a href="javascript:void(0);">
<img :src="rootCat.catImage"/>
</a>
<div class="triangle-topright"></div>
</div>
<div class="am-u-sm-7 am-u-md-4 text-two sug">
<div class="outer-con ">
<div class="title ">
{{rootCat.simpleItemList[0].itemName}}
</div>
</div>
<a :href="'item.html?itemId=' + rootCat.simpleItemList[0].itemId" target="_blank"><img :src="rootCat.simpleItemList[0].itemUrl" style="width: 170px; height: 170px;"/></a>
</div>
<div class="am-u-sm-7 am-u-md-4 text-two">
<div class="outer-con ">
<div class="title ">
{{rootCat.simpleItemList[1].itemName}}
</div>
</div>
<a :href="'item.html?itemId=' + rootCat.simpleItemList[1].itemId" target="_blank"><img :src="rootCat.simpleItemList[1].itemUrl" style="width: 170px; height: 170px;"/></a>
</div>
<div class="am-u-sm-3 am-u-md-2 text-three big" >
<div class="outer-con " >
<div class="title ">
{{rootCat.simpleItemList[2].itemName}}
</div>
</div>
<a :href="'item.html?itemId=' + rootCat.simpleItemList[2].itemId" target="_blank"><img :src="rootCat.simpleItemList[2].itemUrl" style="width: 170px; height: 170px;"/></a>
</div>
<div class="am-u-sm-3 am-u-md-2 text-three sug">
<div class="outer-con ">
<div class="title ">
{{rootCat.simpleItemList[3].itemName}}
</div>
</div>
<a :href="'item.html?itemId=' + rootCat.simpleItemList[3].itemId" target="_blank"><img :src="rootCat.simpleItemList[3].itemUrl" style="width: 170px; height: 170px;"/></a>
</div>
<div class="am-u-sm-3 am-u-md-2 text-three ">
<div class="outer-con ">
<div class="title ">
{{rootCat.simpleItemList[4].itemName}}
</div>
</div>
<a :href="'item.html?itemId=' + rootCat.simpleItemList[4].itemId" target="_blank"><img :src="rootCat.simpleItemList[4].itemUrl" style="width: 170px; height: 170px;"/></a>
</div>
<div class="am-u-sm-3 am-u-md-2 text-three last big ">
<div class="outer-con ">
<div class="title ">
{{rootCat.simpleItemList[5].itemName}}
</div>
</div>
<a :href="'item.html?itemId=' + rootCat.simpleItemList[5].itemId" target="_blank"><img :src="rootCat.simpleItemList[5].itemUrl" style="width: 170px; height: 170px;"/></a>
</div>
</div>
<div class="clear "></div>
</div>
<div class="footer ">
<div class="footer-hd ">
<p>
<a href="https://github.com/dsying" target="_blank">Github</a>
<b>|</b>
<a href="https://juejin.im/user/5b0e60f6f265da08f0339162" target="_blank">掘金社区</a>
</p>
</div>
<div class="footer-bd ">
<p>
<em></em>
</p>
</div>
</div>
</div>
</div>
<!--菜单 -->
<div class="tip">
<div id="sidebar">
<div id="wrap">
<div id="prof" class="item ">
<a href="# ">
<span class="setting "></span>
</a>
<div class="ibar_login_box status_login " style="height: 150px">
<div class="avatar_box ">
<p class="avatar_imgbox ">
<img v-show="userIsLogin" :src="userInfo.face"/>
<img v-show="!userIsLogin" src="img/default-face.png"/>
</p>
<ul class="user_info ">
<li v-show="!userIsLogin">用户未登录</li>
<li v-show="userIsLogin">用户昵称:{{userInfo.nickname}}</li>
<li v-show="userIsLogin" @click="logout">退出登录</li>
</ul>
</div>
<i class="icon_arrow_white "></i>
</div>
</div>
<div id="shopCart " class="item " @click="goToShopcart">
<a href="# ">
<span class="message "></span>
</a>
<p>购物车</p>
<p class="cart_num ">{{shopcartItemCounts}}</p>
</div>
<div class="quick_toggle ">
<li class="qtitem ">
<a href="#top " class="return_top "><span class="top "></span></a>
</li>
</div>
<!--回到顶部 -->
<div id="quick_links_pop " class="quick_links_pop hide "></div>
</div>
</div>
<div id="prof-content " class="nav-content ">
<div class="nav-con-close ">
<i class="am-icon-angle-right am-icon-fw "></i>
</div>
<div>
我
</div>
</div>
<div id="shopCart-content " class="nav-content ">
<div class="nav-con-close ">
<i class="am-icon-angle-right am-icon-fw "></i>
</div>
<div>
购物车
</div>
</div>
</div>
</div>
<script type="text/javascript " src="js/quick_links.js"></script>
<script type="text/javascript " src="js/app.js"></script>
<script type="text/javascript">
function showPage(type, catOrItemId) {
if(type == 1) {
window.open("item.html?itemId=" + catOrItemId);
} else if (type == 2) {
window.open("catItems.html?searchType=catItems&catId=" + catOrItemId);
}
}
</script>
<script type="text/javascript">
var index = new Vue({
el: "#index",
data: {
carouselList: [],
categoryList: [],
sixNewItemsList: [],
userIsLogin: false,
userInfo: {},
keywords: null,
catIndex: 0, // 用于懒加载判断每次的幅度
isScrolling: true,
shopcartItemCounts: 0, // 购物车中商品的数量
},
created() {
// var me = this;
// 用户cookie操作
app.judgeUserLoginStatus(this)
// 渲染轮播图
this.renderCarousel();
// 渲染分类
this.renderCategorys();
// 渲染分类下最新商品
this.renderSixNewItems();
// 从购物车中拿到商品的数量
this.shopcartItemCounts = app.getShopcartItemCounts();
},
methods: {
// 跳转用户中心页面
goUserCenter() {
// 判断用户是否登录
var userIsLogin = this.userIsLogin;
if (!userIsLogin) {
// 用户未登录,则跳转
window.location.href = "login.html?returnUrl=" + app.centerServerUrl;
} else {
window.location.href = app.centerServerUrl;
}
},
// 跳转购物车页面
goToShopcart() {
window.location.href = "shopcart.html";
},
// 搜索
doSearch() {
var keywords = this.keywords;
// console.log(keywords);
if (keywords == null || keywords == undefined || keywords == '') {
alert("搜索内容不能为空");
return;
}
window.open("catItems.html?searchType=searchItems&keywords=" + keywords);
},
// 渲染首页分类下的最新六款商品
renderSixNewItems() {
var serverUrl = app.serverUrl;
var categoryList = this.categoryList;
var catIndex = this.catIndex;
var rootCat = categoryList[catIndex];
if (rootCat == undefined || rootCat == null || rootCat == '') {
return;
}
var rootCatId = rootCat.id;
catIndex++;
this.catIndex = catIndex;
// 获得各个分类下的最新6个商品
axios.get(
serverUrl + '/index/sixNewItems/' + rootCatId, {})
.then(res => {
if (res.data.status == 200) {
var sixNewItemsListTemp = res.data.data
var sixNewItemsList = this.sixNewItemsList;
sixNewItemsList.push(sixNewItemsListTemp[0]);
this.sixNewItemsList = sixNewItemsList;
this.isScrolling = false; // 加载完毕以后表示下次可以继续滚动加载
}
});
},
// 渲染轮播图
renderCarousel() {
var serverUrl = app.serverUrl;
// 获得轮播图
axios.get(
serverUrl + '/index/carousel', {})
.then(res => {
if (res.data.status == 200) {
var carouselList = res.data.data
this.carouselList = carouselList;
// 循环渲染轮播图
var $slider = $('#demo-slider-0');
for (var i = 0; i < carouselList.length; i++) {
var type = carouselList[i].type;
var catId = carouselList[i].catId;
var itemId = carouselList[i].itemId;
var catOrItemId = "";
if (type == 1) {
catOrItemId = itemId;
}
if (type == 2) {
catOrItemId = catId;
}
catOrItemId = encodeURI(catOrItemId);
var cal = '<li class="" style="background: ' + carouselList[i].backgroundColor +
';">' +
'<a href=javascript:showPage(' + type + ',\"'+catOrItemId+'\");><img src="' + carouselList[i].imageUrl + '" /></a>' +
+'</li>';
$slider.flexslider('addSlide', cal);
}
$slider.flexslider('removeSlide', 0);
}
});
},
// 渲染分类
renderCategorys() {
var serverUrl = app.serverUrl;
// 获得商品分类 - 大分类
axios.get(
serverUrl + '/index/cats', {})
.then(res => {
if (res.data.status == 200) {
var categoryList = res.data.data
this.categoryList = categoryList;
var rootCatHtml = "";
for (var i = 0; i < categoryList.length; i++) {
var cat = categoryList[i];
rootCatHtml += '' +
'<li class="appliance js_toggle relative">' +
'<div class="category-info">' +
'<h3 class="category-name b-category-name">' +
'<i><img src="' + cat.logo + '"></i>' +
'<a class="ml-22" title="' + cat.name + '">' + cat.name + '</a>' +
'</h3>' +
'<em>></em></div>' +
'<div class="menu-item menu-in top">' +
'<div class="area-in">' +
'<div class="area-bg">' +
'<div class="menu-srot">' +
'<div class="sort-side" rootCatId="' + cat.id + '"></div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<b class="arrow"></b>' +
'</li>';
}
var $leftNav = $('#js_climit_li');
$leftNav.html(rootCatHtml);
$("li").hover(function () {
// debugger;
$(".category-content .category-list li.first .menu-in").css("display",
"none");
$(".category-content .category-list li.first").removeClass("hover");
var meLi = $(this);
var subWapper = $(this).children("div.menu-in").children("div.area-in")
.children("div.area-bg").children("div.menu-srot").children(
"div.sort-side");
// console.log(subWapper.html());
var subCatHtml = subWapper.html();
var rootCatId = subWapper.attr("rootCatId");
// console.log(rootCatId);
// 如果该节点下没有内容,则发起请求查询子分类并且渲染到页面,如果有的话就不查询了(懒加载模式)
if (subCatHtml == null || subCatHtml == '' || subCatHtml == undefined) {
if (rootCatId != undefined && rootCatId != null && rootCatId != '') {
// 根据root分类id查询该分类下的所有子分类
axios.get(
serverUrl + '/index/subCat/' + rootCatId, {})
.then(res => {
if (res.data.status == 200) {
var catList = res.data.data
// this.catList = catList;
// debugger;
var subRenderHtml = '';
for (var i = 0; i < catList.length; i++) {
var cat = catList[i];
subRenderHtml += '' +
'<dl class="dl-sort">' +
'<dt><span title="' + cat.name + '">' +
cat.name + '</span></dt>';
// 拼接第三级分类
var subCatList = cat.subCatList;
for (var j = 0; j < subCatList.length; j++) {
var subCat = subCatList[j];
subRenderHtml += '<dd><a title="' + subCat
.subName + '" href="catItems.html?searchType=catItems&catId='+ subCat.subId +'" target="_blank"><span>' +
subCat.subName + '</span></a></dd>'
}
subRenderHtml += '</dl>';
}
subWapper.html(subRenderHtml);
meLi.addClass("hover");
meLi.children("div.menu-in").css("display",
"block");
}
});
}
} else {
$(this).addClass("hover");
$(this).children("div.menu-in").css("display", "block");
}
}, function () {
$(this).removeClass("hover")
$(this).children("div.menu-in").css("display", "none")
});
this.renderSixNewItems();
}
});
},
// 退出登录
logout() {
var userId = this.userInfo.id;
var serverUrl = app.serverUrl;
axios.defaults.withCredentials = true;
axios.get(serverUrl + '/user/logout?userId=' + userId, {})
.then(res => {
if (res.data.status == 200) {
window.location.href = "index.html";
} else if (res.data.status == 500) {
alert(res.data.msg);
return;
}
});
}
}
});
</script>
<script type="text/javascript">
$(window).scroll(
function() {
// scrollTop为滚动条在Y轴上的滚动距离。
// clientHeight为内容可视区域的高度。
// scrollHeight为内容可视区域的高度加上溢出(滚动)的距离。
var scrollTop = $(this).scrollTop();
var scrollHeight = $(document).height();
var windowHeight = $(this).height();
if (scrollTop + windowHeight > (scrollHeight - 50) ) {
// 此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
// console.log("123");
index.renderSixNewItems();
}
});
</script>
</body>
</html>