index.html
21.6 KB
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
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
<!DOCTYPE html>
<html lang="zh">
{include file="public/head"/}
<!--swiper引入-->
<link rel="stylesheet" href="__CDN__/assets/store/js/Swiper-3.4.2/css/swiper.min.css">
<script type="text/javascript" src="__CDN__/assets/store/js/Swiper-3.4.2/js/swiper.min.js"></script>
<style>
.content{
width: 100%;
font-size: 0;
background: rgba(249,249,249,1);
}
.content .bannerBox{
position: relative;
width: 100%;
height: 540px;
background: #1e9fff;
margin-bottom: 20px;
}
/*轮播图样式*/
.content .bannerBox .swiper-pagination-bullet{
background: rgba(255,255,255,1);
opacity: 1;
}
.content .bannerBox .swiper-pagination-bullet-active{
background: rgba(61,68,77,1);
}
/*悬浮导航一级样式*/
.content .bannerBox .suspensionNavBox{
position: absolute;
width: 284px;
height: 540px;
top: 0;
left: 360px;
z-index: 9;
background: rgba(255,255,255,1);
opacity: 0.9;
}
.content .bannerBox .suspensionNavBox ul{
width: 100%;
height: 100%;
}
.content .bannerBox .suspensionNavBox ul li{
list-style-type: none;
width: 100%;
height: 75px;
padding: 14px 12px;
cursor: pointer;
border-top: 1px solid rgba(238,238,238,1);
}
.content .bannerBox .suspensionNavBox ul li .typeBox p{
display: inline-block;
height: 22px;
margin-bottom: 5px;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
line-height: 22px;
color: rgba(61,68,77,1);
}
.content .bannerBox .suspensionNavBox ul li .typeBox .selectTypeName{
color: #009F8E;
}
.content .bannerBox .suspensionNavBox ul li .typeBox .arrow{
float: right;
}
.content .bannerBox .suspensionNavBox ul li .typeDetailBox p{
display: inline-block;
height: 20px;
margin-right: 15px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
line-height: 20px;
}
.content .bannerBox .suspensionNavBox ul li .typeDetailBox p a{
color: rgba(140,145,152,1);
}
/*悬浮导航二级样式*/
.content .bannerBox .secondLevelBox{
display: none;
position: absolute;
width: 133px;
height: 540px;
top: 0;
left: 644px;
z-index: 9;
background: rgba(249,249,249,1);
opacity: 0.9;
}
.content .bannerBox .secondLevelBox #secondLevelTitle{
width: 100%;
height: 62px;
line-height: 62px;
text-align: center;
border-bottom: 1px solid rgba(238,238,238,1);
font-size: 18px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(0,159,142,1)
}
.content .bannerBox .secondLevelBox #secondLevelList{
width: 100%;
height: 478px;
overflow: auto;
}
.content .bannerBox .secondLevelBox #secondLevelList li{
list-style-type: none;
cursor: pointer;
width: 100%;
height: 42px;
line-height: 42px;
text-align: center;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(6,18,30,1);
}
.content .bannerBox .secondLevelBox #secondLevelList li a{
color: rgba(6,18,30,1);
}
/*清仓列表部分样式*/
.content .clearanceBox{
width: 100%;
height: 351px;
margin-bottom: 12px;
background: rgba(255,255,255,1);
}
.content .clearanceBox .clearanceMain{
position: relative;
width: 1200px;
margin: 0 auto;
}
.content .clearanceBox .titleBox{
width: 1200px;
height: 62px;
line-height: 62px;
}
.content .clearanceBox .titleBox span:first-child{
display: inline-block;
float: left;
width: 6px;
height: 20px;
margin-top: 21px;
background: rgba(0,159,142,1);
border-radius: 2px;
}
.content .clearanceBox .titleBox span:last-child{
height: 22px;
line-height: 22px;
float: left;
margin-top: 20px;
padding-left: 12px;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(0,159,142,1);
}
.content .clearanceBox .clearanceList{
width: 100%;
height: 279px;
padding: 0 51px;
}
.content .clearanceBox .clearanceList .swiper-container .swiper-wrapper .swiper-slide .commodityTitle{
width: 168px;
/*height: 40px;*/
/*line-height: 20px;*/
text-align: left;
margin-top: 10px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(6,18,30,1);
}
.content .clearanceBox .clearanceList .swiper-container .swiper-wrapper .swiper-slide .priceBox{
width: 168px;
height: 20px;
}
.content .clearanceBox .clearanceList .swiper-container .swiper-wrapper .swiper-slide .priceBox .presentPrice{
font-size: 14px;
font-family: PingFang SC;
font-weight: 600;
line-height: 20px;
color: rgba(255,49,0,1);
float: left;
}
.content .clearanceBox .clearanceList .swiper-container .swiper-wrapper .swiper-slide .priceBox .originalPrice{
font-size: 12px;
font-family: PingFang SC;
font-weight: 400;
line-height: 17px;
color: rgba(189,196,206,1);
float: right;
text-decoration: line-through;
}
.content .clearanceBox .clearanceList .swiper-button-next, .content .clearanceBox .clearanceList .swiper-button-prev{
width: 26px;
height: 26px;
background-size: 26px;
-webkit-background-size: 26px;
}
.content .clearanceBox .clearanceList .swiper-button-next, .swiper-container-rtl .swiper-button-prev{
background-image: url("__CDN__/assets/store/images/right_icon.png");
}
.content .clearanceBox .clearanceList .swiper-button-prev, .swiper-container-rtl .swiper-button-next{
background-image: url("__CDN__/assets/store/images/left_icon.png");
}
/*产品热卖部分样式*/
.content .bestSellersBox{
width: 100%;
/*height: 981px;*/
background: rgba(255,255,255,1);
}
.content .bestSellersBox .bestSellersMain{
width: 1200px;
margin: 0 auto;
}
.content .bestSellersBox .bestSellersMain .titleBox{
width: 1200px;
height: 62px;
line-height: 62px;
}
.content .bestSellersBox .bestSellersMain .titleBox span:first-child{
display: inline-block;
float: left;
width: 6px;
height: 20px;
margin-top: 21px;
background: rgba(0,159,142,1);
border-radius: 2px;
}
.content .bestSellersBox .bestSellersMain .titleBox span:nth-child(2){
height: 22px;
line-height: 22px;
float: left;
margin-top: 20px;
padding-left: 12px;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(0,159,142,1);
}
.content .bestSellersBox .bestSellersMain .titleBox .moreBtn{
float: right;
height: 62px;
line-height: 62px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
color: rgba(140,145,152,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList{
width: 100%;
padding: 0 19px 0 29px;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox{
position: relative;
display: inline-block;
width: 182px;
height: 301px;
margin-right: 10px;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox a .insurance_icon{
position: absolute;
top: 0;
right: 0;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .imgBox{
position: relative;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .imgBox img{
width: 182px;
height: 182px;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .imgBox span{
display: block;
position: absolute;
top: 152px;
width: 100%;
height: 30px;
padding: 0 12px;
background: rgba(0,0,0,0.5);
border-radius: 0 0 4px 4px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 500;
line-height: 30px;
color: rgba(0,159,142,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .commodityPrice{
width: 100%;
height: 33px;
line-height: 40px;
margin: 0;
font-size: 14px;
font-family: PingFang SC;
font-weight: 600;
color: rgba(255,49,0,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .commodityName{
width: 100%;
/*height: 42px;*/
/*line-height: 21px;*/
margin: 0 0 4px 0;
text-align: left;
font-size: 14px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(6,18,30,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .labelBox span{
display: inline-block;
width: 70px;
height: 21px;
margin-right: 6px;
background: rgba(244,244,244,1);
border-radius: 2px;
font-size: 12px;
font-family: PingFang SC;
font-weight: 400;
line-height: 21px;
text-align: center;
color: rgba(0,0,0,1);
opacity: 0.85;
}
</style>
<body>
{include file="public/header"/}
<!--主要内容-->
<div class="content">
{include file="public/nav"}
<!--轮播图-->
<div class="bannerBox">
<div id="banner-container" class="swiper-container">
<div class="swiper-wrapper">
{foreach name="$slide" item="s"}
<div class="swiper-slide"><img src="{$s.thumbnail}" alt="img"></div>
{/foreach}
</div>
<!--分页器。如果放置在swiper-container外面,需要自定义样式。-->
<div class="swiper-pagination"></div>
</div>
<!--悬浮导航一级-->
<div class="suspensionNavBox">
<ul>
{foreach name="$goodstype_one" item="g_o"}
<li onmouseenter="openSecondLevelMenu(this)" >
<div class="typeBox">
<p class="typeName">{$g_o.name}</p>
<p class="arrow"><img src="__CDN__/assets/store/images/rightArrow.png" alt="img"></p>
</div>
<div class="typeDetailBox">
{foreach name="$g_o.goodstype_two" item="g_t"}
<p><a href="">{$g_t.name}</a></p>
{/foreach}
</div>
</li>
{/foreach}
</ul>
</div>
<!--悬浮导航二级-->
<div class="secondLevelBox" onmouseleave="closeSecondLevelMenu()">
<p id="secondLevelTitle">
低压配电
</p>
<ul id="secondLevelList">
<li>机械设备</li>
<li>机床设备</li>
</ul>
</div>
</div>
<!--特价清仓部分-->
<div class="clearanceBox">
<div class="clearanceMain">
<div class="titleBox">
<span></span>
<span>特价清仓</span>
</div>
<div class="clearanceList">
<div id="clearanceList-container" class="swiper-container">
<div class="swiper-wrapper clearance_goods_dom">
{foreach name="$clearance_goods" item="c_g"}
<div class="swiper-slide">
<a href="{:url('index/goods/detail',array('goods_id'=>$c_g.id))}">
<img src="{$c_g.thumbnail}" alt="img">
<p class="commodityTitle">{$c_g.goodsname}</p>
<div class="priceBox">
<p class="presentPrice">¥{$c_g.price}</p>
<p class="originalPrice">¥{$c_g.lineation}</p>
</div>
</a>
</div>
{/foreach}
</div>
</div>
<!-- 如果需要导航按钮 -->
<div id="clearanceList-button-prev" class="swiper-button-prev"></div>
<div id="clearanceList-button-next" class="swiper-button-next"></div>
</div>
</div>
</div>
<!--产品热卖部分-->
<div class="bestSellersBox">
<div class="bestSellersMain">
<div class="titleBox">
<span></span>
<span>产品热卖</span>
<a class="moreBtn" href="{:url('index/goods/goods_list')}">更多 ></a>
</div>
<div class="bestSellersList goods_dom">
{foreach name="$goods" item="g"}
<div class="commodityBox">
<a href="{:url('index/goods/detail',array('goods_id'=>$g.id))}" target="_blank">
<div class="imgBox">
<img src="{$g.thumbnail}" alt="img">
<span>{$g.store_name}</span>
</div>
<p class="commodityPrice">¥{$g.price}</p>
<p class="commodityName">{$g.goodsname}</p>
<div class="labelBox">
{foreach name="$g.property" item="g_p"}
<span>{$g_p}</span>
{/foreach}
</div>
<img class="insurance_icon" src="__CDN__/assets/store/images/insurance_icon.png" alt="img">
</a>
</div>
{/foreach}
</div>
</div>
</div>
</div>
{include file="public/footer"/}
{include file="public/js"/}
<script>
$(function () {
initBanner(); //初始化轮播图
initLocation();//获取定位信息
});
//定位当前位置
function initLocation(){
// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398,39.897445);
map.centerAndZoom(point,12);
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
if(this.getStatus() == BMAP_STATUS_SUCCESS){
var mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
//省份名称转换为id
$.ajax({
url:"{:url('index/sundry/get_province_id')}",
type:"POST",
data:{"province_name":r.address.province},
async:false,
success:function(res){
if(res.code == 1){
province_id = res.data.province_id;
lng = r.point.lng;
lat = r.point.lat;
//初始化清仓列表
initClearanceList();
//初始化产品热卖
initGoodsList();
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
});
} else {
toast('failed'+this.getStatus());
}
},{enableHighAccuracy: true})
}
//加载轮播图
function initBanner() {
var mySwiper = new Swiper('#banner-container', {
autoplay: 5000,//可选选项,自动滑动
pagination : '.swiper-pagination'
})
}
//加载清仓列表
function initClearanceList() {
$.ajax({
url:"{:url('index/goods/get_all')}",
type:"POST",
data:{"province_id":province_id,'is_clearance':1},
success:function(res){
console.log(res);
var clearance_goods_html = "";
$(res.data).each(function (key, vo) {
var str = "<div class=\"swiper-slide\">\n" +
" <a href=\"{:url('index/goods/detail',array('goods_id'=>'GOODS_ID'))}\" target='_blank'>\n" +
" <img src=\""+vo.thumbnail+"\" alt=\"img\">\n" +
" <p class=\"commodityTitle\">"+vo.goodsname+"</p>\n" +
" <div class=\"priceBox\">\n" +
" <p class=\"presentPrice\">¥"+vo.price+"</p>\n" +
" <p class=\"originalPrice\">¥"+vo.lineation+"</p>\n" +
" </div>\n" +
" </a>\n" +
" </div>";
clearance_goods_html += str.replace("GOODS_ID",vo.id);
});
$('.clearance_goods_dom').html(clearance_goods_html);
//初始化swiper
var myClearance = new Swiper('#clearanceList-container', {
loop: false,
slidesPerView: 6,
autoplay: 3000,
//前进后退按钮
nextButton: '#clearanceList-button-next',
prevButton: '#clearanceList-button-prev',
})
},
error:function(res){
toast('与服务器断开连接');
}
});
}
//初始化商品列表
function initGoodsList(){
$.ajax({
url:"{:url('index/goods/get_all')}",
type:"POST",
data:{"province_id":province_id},
success:function(res){
console.log(res);
var goods_html = "";
$(res.data).each(function (key1, vo) {
var property = "";
$(vo.property).each(function (key2, p) {
property += "<span>"+p+"</span>";
});
var insurance = "";
if(vo.insurance == '1'){
insurance = "<img class=\"insurance_icon\" src=\"__CDN__/assets/store/images/insurance_icon.png\" alt=\"img\">"
}
var str = "<div class=\"commodityBox\">\n" +
" <a href=\"{:url('index/goods/detail',array('goods_id'=>'GOODS_ID'))}\" target='_blank'>\n" +
" <div class=\"imgBox\">\n" +
" <img src=\""+vo.thumbnail+"\" alt=\"img\">\n" +
" <span>"+vo.store_name+"</span>\n" +
" </div>\n" +
" <p class=\"commodityPrice\">¥"+vo.price+"</p>\n" +
" <p class=\"commodityName\">"+vo.goodsname+"</p>\n" +
" <div class=\"labelBox\">\n" +
" "+property+"\n" +
" </div>\n" +
" "+insurance+"\n" +
" </a>\n" +
" </div>";
goods_html += str.replace("GOODS_ID",vo.id);
});
$('.goods_dom').html(goods_html);
},
error:function(res){
toast('与服务器断开连接');
}
});
}
//打开二级悬浮导航
function openSecondLevelMenu(obj) {
$('.typeName').removeClass('selectTypeName');
$('.suspensionNavBox ul li').css({'background': 'rgba(255,255,255,1)'});
$('.suspensionNavBox').find('img').attr('src','__CDN__/assets/store/images/rightArrow.png');
$(obj).css({'background': 'rgba(249,249,249,1)'});
$(obj).find('.typeName').addClass('selectTypeName');
$(obj).find('img').attr('src','__CDN__/assets/store/images/rightArrow_select.png');
$('#secondLevelTitle').html($(obj).find('.typeName').html());
var listVal = $(obj).find('.typeDetailBox').children('p');
var el = '';
for (var i=0; i<listVal.length; i++){
el += '<li>' + $(listVal[i]).html() + '</li>';
}
$('#secondLevelList').html(el);
$('.secondLevelBox').show();
}
//关闭二级悬浮导航
function closeSecondLevelMenu(obj) {
$('.typeName').removeClass('selectTypeName');
$('.suspensionNavBox ul li').css({'background': 'rgba(255,255,255,1)'});
$('.suspensionNavBox').find('img').attr('src','__CDN__/assets/store/images/rightArrow.png');
$('.secondLevelBox').hide();
}
// 搜索框
function search(val) {
var searchKey = $('#searchVal').val();
window.location.href = 'search.html?searchKey='+searchKey;
}
</script>
</body>
</html>