search.html
34.5 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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
<!DOCTYPE html>
<html lang="zh">
{include file="public/head"/}
<!--表格插件引入-->
<link rel="stylesheet" href="__CDN__/assets/store/css/table.css">
<link rel="stylesheet" href="__CDN__/assets/store/css/uiduck.css">
<script type="text/javascript" src="__CDN__/assets/store/js/json2.js"></script>
<script type="text/javascript" src="__CDN__/assets/store/js/uiduck.js"></script>
<!--分页插件引入-->
<script type="text/javascript" src="__CDN__/assets/store/js/pagination/js/pagination.min.js"></script>
<link rel="stylesheet" href="__CDN__/assets/store/js/pagination/css/pagination.css">
<style>
.priceBtn{
position: relative;
}
.priceBtn img{
position: absolute;
left: 70px;
}
.priceBtn img:last-child{
top: 20px;
}
.content{
position: relative;
width: 100%;
font-size: 0;
background: rgba(255,255,255,1);
}
.content .contentMain{
width: 996px;
width:50%;
margin: 0 auto;
padding: 12px;
overflow: hidden;
}
.content .contentMain .contentMainTop{
width: 100%;
padding-top: 30px;
margin-bottom: 47px;
}
.content .contentMain .contentMainTop .locationBox{
margin-bottom: 18px;
}
.content .contentMain .contentMainTop .locationBox img{
display: block;
width: 24px;
height: 24px;
margin: 0px 10px 0 0;
float: left;
}
.content .contentMain .contentMainTop .locationBox p{
display: inline-block;
margin: 0;
font-size: 18px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(61,69,76,1);
}
.content .contentMain .contentMainTop .locationBox .title{
margin-right: 30px;
}
.content .contentMain .contentMainTop .searchBox{
width: 937px;
}
.content .contentMain .contentMainTop .searchBox input{
display: inline-block;
width: 825px;
height: 64px;
background: rgba(255,255,255,1);
box-shadow: 0 8px 16px rgba(24,36,36,0.09);
border-radius: 8px 0 0 8px;
}
.content .contentMain .contentMainTop .searchBox .input-group-btn{
width: 112px;
height: 64px;
float: right;
}
.content .contentMain .contentMainTop .searchBox .input-group-btn button{
width: 112px;
height: 64px;
background:rgba(255,148,23,1);
color: rgba(255,255,255,1);
border-radius: 0 8px 8px 0;
}
.content .contentMain #tableBox .tableButtons{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.content .contentMain #tableBox .tableButtons button{
width: 100px;
height: 36px;
margin-right: 12px;
border: 0;
border-radius: 0;
background: rgba(249, 249, 249, 1);
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
color: rgba(4, 17, 33, 1);
display: flex;
justify-content: space-between;
align-items: center;
}
.content .contentMain #tableBox .tableButtons .dropdown{
display: inline-block;
}
.content .contentMain #tableBox .tableButtons .dropdown button{
width: 120px;
}
.content .contentMain #tableBox .tableButtons .activeBtn{
color:rgba(255,255,255,1);
background: rgba(0, 159, 142, 1);
}
.content .contentMain #tableBox .tableButtons p{
height: 36px;
line-height: 36px;
float: right;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(61,69,76,1);
}
.content .contentMain #tableBox .tableButtons p span{
color: rgba(0, 159, 142, 1);
}
.content .contentMain #tableBox .tableContent{
width: 100%;
font-size:14px;
font-family:PingFangSC-Medium;
line-height:22px;
color:rgba(0,0,0,1);
}
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
.content .contentMain #tableBox .tableContent::-webkit-scrollbar
{
width: 12px;
height: 16px;
background-color: #F5F5F5;
}
/*定义滚动条轨道 内阴影+圆角*/
.content .contentMain #tableBox .tableContent::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #F5F5F5;
}
/*定义滑块 内阴影+圆角*/
.content .contentMain #tableBox .tableContent::-webkit-scrollbar-thumb
{
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
background-color: #ccc;
}
.content .contentMain #tableBox .tableContent table thead{
background:rgba(250,250,250,1);
border:1px solid rgba(238,238,238,1);
border-bottom: 0;
}
.content .contentMain #tableBox .tableContent table tr{
height: 60px;
text-align: center;
cursor: pointer;
}
.content .contentMain #tableBox .tableContent table tr .myLable{
display: inline-block;
background:rgba(244,244,244,1);
border-radius:2px;
width:50px;
height:14px;
font-size:10px;
font-family:PingFangSC-Medium;
line-height:15px;
color:rgba(0,0,0,1);
opacity:0.85;
}
.content .contentMain #tableBox .tableContent table .activeTr{
color:rgba(0,159,142,1);
}
.content .contentMain #tableBox .tableContent table .activeTr .myLable{
background: rgba(0,159,142,1);
color: rgba(255,255,255,1);
}
.content .contentMain #tableBox .tableContent table tr td{
text-align: center;
vertical-align: middle;
border:1px solid rgba(238,238,238,1);
}
.content .contentMain #tableBox .tableContent .pageBox{
width: 100%;
height: 100px;
text-align: center;
}
/*地图打开时无搜索结果提示*/
.content #mapShowNoResultsBox{
display: none;
width: 100%;
height: 757px;
margin: 0 auto;
overflow: hidden;
}
.content #mapShowNoResultsBox img{
display: block;
width: 307px;
height: 238px;
margin: 122px auto 43px;
}
.content #mapShowNoResultsBox p{
height: 20px;
line-height: 20px;
font-size: 14px;
font-family: PingFang SC;
text-align: center;
margin: 0 auto;
}
.content #mapShowNoResultsBox #mapShowTipsTitle{
width: 56px;
margin-bottom: 20px;
color: rgba(6,18,30,1);
}
.content #mapShowNoResultsBox #mapShowTipsText{
width: 100%;
margin-bottom: 22px;
font-weight: 400;
color: rgba(102,105,110,1);
}
.content #mapShowNoResultsBox a{
display: block;
width: 307px;
height: 52px;
line-height: 52px;
text-align: center;
margin: 0 auto;
background: rgba(0,159,142,1);
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(255,255,255,1);
}
/*地图区域样式*/
.content #mapBox{
position: absolute;
top: 0;
/* left: -900px; */
/* width: 900px; */
left:-50%;
width:50%;
height: 899px;
overflow: hidden;
background: #4cae4c;
}
.content #mapBox #mapDiv{
width: 100%;
height: 100%;
}
.content #mapBox #rangeSearchBox{
position: absolute;
top: 31px;
left: 31px;
width: 170px;
height: 32px;
z-index: 9;
}
.content #mapBox #rangeSearchBox button{
width: 100%;
height: 100%;
font-size: 12px;
font-family: PingFangSC-Regular;
line-height: 22px;
color: rgba(0,0,0,1);
border: 1px solid rgba(0,0,0,1);
border-radius: 4px;
}
/*打开地图按钮*/
.content .openMapBox{
position: absolute;
top: 378px;
left: 0;
width: 60px;
height: 140px;
background: rgba(0,159,142,1);
border-radius: 0 12px 12px 0;
cursor: pointer;
z-index: 9;
}
.content .openMapBox img{
display: block;
width: 32px;
height: 32px;
margin: 30px auto 14px;
}
.content .openMapBox p{
width: 32px;
height: 22px;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(255,255,255,1);
margin: 0 auto;
}
/*关闭地图按钮*/
.content #mapBox .takeBackMapBox{
position: absolute;
top: 380px;
right: 0;
width: 36px;
height: 140px;
background: rgba(0,159,142,1);
border-radius: 12px 0 0 12px;
cursor: pointer;
z-index: 8;
}
.content #mapBox .takeBackMapBox img{
display: block;
margin: 59px auto;
}
/*无搜索结果样式*/
.content #mapHideNoResultsBox{
display: none;
width: 1200px;
height: 757px;
margin: 0 auto;
overflow: hidden;
}
.content #mapHideNoResultsBox img{
display: block;
width: 307px;
height: 238px;
margin: 208px auto 43px;
}
.content #mapHideNoResultsBox p{
height: 20px;
line-height: 20px;
font-size: 14px;
font-family: PingFang SC;
text-align: center;
margin: 0 auto;
}
.content #mapHideNoResultsBox #tipsTitle{
width: 56px;
margin-bottom: 20px;
color: rgba(6,18,30,1);
}
.content #mapHideNoResultsBox #tipsText{
width: 126px;
font-weight: 400;
color: rgba(102,105,110,1);
}
</style>
<style>
/*重写百度地图城市选择样式*/
.BMap_CityListCtrl{
width: 276px!important;
right: 65px!important;
left: auto!important;
}
.BMap_CityListCtrl .ui_city_change_top{
height: 32px!important;
margin-bottom: 8px;
}
.BMap_CityListCtrl .ui_city_change a{
width: 96px;
height: 32px;
line-height: 32px;
border: 1px solid #ccc;
/* opacity: 0.9; */
border-radius:4px;
float: right!important;
}
.ui_city_change_top .ui_city_change_inner i, .ui_city_change_bottom .ui_city_change_inner i{
top: 13px;
}
.BMap_CityListCtrl .citylist_popup_main{
border: 0;
background: transparent;
box-shadow: none;
}
.BMap_CityListCtrl .citylist_popup_main .citylist_ctr_title{
width: 276px;
height: 46px;
line-height: 46px;
background: rgba(255,255,255,1);
opacity:1;
font-size: 16px;
font-family: PingFang SC;
/* font-weight: 600; */
color: rgba(6,18,30,1);
/*margin-bottom: 8px;*/
}
.citylist_popup_main .citylist_ctr_title{
border: 0;
}
.BMap_CityListCtrl .citylist_popup_main .citylist_ctr_content .city_content_top{
height: 8px;
border: none;
}
.BMap_CityListCtrl .citylist_popup_main .citylist_ctr_content .city_content_top #city_ctrl_form{
display: none;
}
.BMap_CityListCtrl .citylist_popup_main .citylist_ctr_content .city_content_top .cur_city_info{
position: absolute;
top: -30px;
right: 16px;
padding-left: 20px;
background: url("__CDN__/assets/store/images/location_fill_icon.png") no-repeat left;
}
.BMap_CityListCtrl .citylist_popup_main .citylist_ctr_content .city_content_medium{
background: rgba(255,255,255,1);
border: none;
margin: 0;
padding: 7px;
color:rgba(61,68,77,1);
}
.BMap_CityListCtrl .citylist_popup_main .city_content_bottom{
background: rgba(255,255,255,1);
border: none;
margin: 0;
padding: 7px;
color:rgba(61,68,77,1);
}
.BMap_CityListCtrl a{
color:rgba(61,68,77,1);
}
a:hover, a:focus{
color:rgba(61,68,77,1);
}
.sel_city_hotcity a{
color:rgba(61,68,77,1);
}
.sel_city_sf a{
color:rgba(61,68,77,1);
}
</style>
<style>
/*分页样式重写*/
.paginationMyOrder{
margin: 40px 120px;
}
#paginationGoodsCollect,#paginationStoreCollect{
padding: 20px 0 40px 240px;
}
.whj_jqueryPaginationCss-1 .whj_border{
font-size:14px;
font-family:PingFangSC-Regular;
color:rgba(0,0,0,0.65);
/*opacity:0.65;*/
border:1px solid rgba(0,0,0,0.15);
}
.whj_jqueryPaginationCss-1 .whj_padding{
margin: 0 4px;
width:32px;
height:32px;
line-height: 32px;
text-align: center;
border-radius:4px;
padding: 0;
}
.whj_jqueryPaginationCss-1 .whj_checked{
color: #fff;
border: 0;
background:rgba(0,159,142,1);
box-shadow:0px 6px 12px rgba(0,0,0,0.04);
}
.whj_jqueryPaginationCss-1 .whj_padding:hover{
color: #fff;
border: 0;
background:rgba(0,159,142,1);
box-shadow:0px 6px 12px rgba(0,0,0,0.04);
}
.whj_jqueryPaginationCss-1 select:hover{
color: #fff;
}
.whj_jqueryPaginationCss-1 select{
height:32px;
line-height: 32px;
text-align: center;
border-radius:4px;
margin: 0 4px 0 12px;
width:88px;
color:rgba(0,0,0,0.65)!important;
padding: 0 10px;
/*background: url("../images/selectIcon.png") no-repeat no-repeat 60px 8px !important;*/
}
.whj_jqueryPaginationCss-1 .whj_color{
background: transparent!important;
font-size:14px;
font-family:PingFangSC-Regular;
color:rgba(0,0,0,0.65)!important;
}
.whj_jqueryPaginationCss-1 input{
margin: 0 4px;
width:48px;
height:32px;
border:1px solid rgba(0,0,0,0.15)!important;
border-radius:4px!important;
}
</style>
<body>
{include file="public/header"/}
<!--主要内容-->
<div class="content">
<div class="contentMain">
<div class="contentMainTop">
<div class="locationBox">
<img src="__CDN__/assets/store/images/location_fill.png" alt="">
<p class="title">当前区域</p>
<p id="locationText"></p>
</div>
<!--搜索框-->
<div class="searchBox">
<input id="searchVal" type="text" class="search form-control" placeholder="请输入型号、参数查找元器件" value="{$keyword}"/>
<span class="input-group-btn">
<button class="btn" onclick="searchData()">
<img src="__CDN__/assets/store/images/search.png" alt="user">
搜索
</button>
</span>
</div>
</div>
<!--搜索结果表格-->
<div id="tableBox">
<div class="tableButtons">
<button class="btn" data-sort="1" onclick="sortSearch(this, 'salesVolume')">
<div>销量</div>
<div style="width: 18px;">
<img src="__CDN__/assets/store/images/dropDwon.png" alt="">
</div>
</button>
<button class="btn" data-sort="2" onclick="sortSearch(this, 'score')">
<div>评分</div>
<div style="width: 18px;"><img src="__CDN__/assets/store/images/dropDwon.png" alt=""></div>
</button>
<button class="btn" data-sort="3" onclick="sortSearch(this, 'releaseTime')">
<div>发布时间</div>
<div style="width: 18px;"><img src="__CDN__/assets/store/images/dropDwon.png" alt=""></div>
</button>
<button class="btn" data-sort="4" onclick="sortSearch(this, 'stock')">
<div>库存</div>
<div style="width: 18px;"><img src="__CDN__/assets/store/images/dropDwon.png" alt=""></div>
</button>
<button class="btn priceBtn" data-sort="0" onclick="sortSearch(this, 'price')">
<div>价格</div>
<div style="display: flex;flex-direction: column;align-items: center;height: 18px;width: 30px">
<img src="__CDN__/assets/store/images/dropDwon_up.png" alt="">
<img src="__CDN__/assets/store/images/dropDwon.png" alt="">
</div>
</button>
<div class="dropdown dropdownBtn">
<button class="btn btn-default dropdown-toggle activeBtn" data-sort="0" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<div><span class="distributorName">全部商家</span></div>
<div style="width: 18px;"><span class="caret"></span></div>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="#" data-sort="0" onclick="selectDistributor(this)">全部商家</a></li>
<li role="separator" class="divider"></li>
<li><a href="#" data-sort="7" onclick="selectDistributor(this)">供应商</a></li>
<li role="separator" class="divider"></li>
<li><a href="#" data-sort="8" onclick="selectDistributor(this)">一级代理</a></li>
<li role="separator" class="divider"></li>
<li><a href="#" data-sort="9" onclick="selectDistributor(this)">厂家直销</a></li>
</ul>
</div>
<p>
为你找到<span id="resultsNum">0件</span>相关商品
</p>
</div>
<div class="tableContent">
<!--以下为两个必须div元素-->
<!--<div id="ud-top" style="display: none;">
<h3>当前设置为微信字段,通过ud-keyWord属性指定相关列的key</h3>
<input id="search" ud-keyWord="wechat" class="uiduck-input" />
<button class="uiduck-btn" onClick=setData();>搜索</button>
</div>
<div id="table"></div>-->
<table id="searchTable" class="table table-hover">
<thead>
<tr>
<td width="54px">序号</td>
<td width="100px">商品图片</td>
<td width="180px">商品型号</td>
<td width="102px">商品库存</td>
<td width="102px">供应商</td>
<td width="140px">品牌</td>
<td width="128px">价格</td>
<td width="131px">店铺位置</td>
</tr>
</thead>
<tbody class="goods_dom">
<!--<tr>
<td>1</td>
<td><img src="__CDN__/assets/store/images/tableImg.png" alt=""></td>
<td>TOGIALED(统佳) TJ-L3FYTSARMFCSFLX2R-A5 发光二极管 DIP 红发红</td>
<td>80000</td>
<td>buerklin<span class="myLable">厂家直销</span></td>
<td>TOGIALED(统佳)</td>
<td>单价:¥0.0675</td>
<td>天津市河东区大直沽西路(10km)</td>
</tr>-->
</tbody>
</table>
<div class="pageBox">
<div class="paginationMyOrder" id="paginationAllOrder">
<div class="whj_jqueryPaginationCss-1">
</div>
</div>
</div>
</div>
</div>
<!--地图打开时空搜索结果-->
<div id="mapShowNoResultsBox">
<img src="__CDN__/assets/store/images/noResults.png" alt="img">
<p id="mapShowTipsTitle">温馨提示</p>
<p id="mapShowTipsText">抱歉,未找到与‘{$keyword}’相关的商品</p>
<a href="">帮买服务</a>
</div>
</div>
<!--地图区域-->
<div id="mapBox">
<div id="mapDiv"></div>
<!--收回地图按钮-->
<div class="takeBackMapBox" onclick="takeBackMap()">
<img src="__CDN__/assets/store/images/takeBackMap.png" alt="mapSearch">
</div>
<!--附近50公里搜索按钮-->
<div id="rangeSearchBox">
<button class="btn" onclick="rangeSearch50()">点击查询50KM内在售商品</button>
</div>
</div>
<!--打开地图按钮-->
<div class="openMapBox" onclick="openMap()">
<img src="__CDN__/assets/store/images/mapSearch.png" alt="mapSearch">
<p>地图</p>
<p>筛选</p>
</div>
<!--地图关闭时空搜索结果-->
<div id="mapHideNoResultsBox">
<img src="__CDN__/assets/store/images/noResults.png" alt="img">
<p id="tipsTitle">温馨提示</p>
<p id="tipsText">未搜索到,换个试试</p>
</div>
</div>
{include file="public/footer"/}
{include file="public/js"/}
<script>
var noResults = false;
var mapShow = false;
var mapObj;
var geoc;
var locationLng = 117.233;
var locationLat = 39.11365;
$(function () {
// showTableData();
// initMap();
tableClick();
// initPaging();
initLocation();//获取定位信息
});
//表格点击事件
function tableClick() {
$("#searchTable").on("click","tbody tr",function (e){
// $('#searchTable tbody tr').click(function (e) {
// console.log(e);
// console.log(this);
$('.activeTr').removeClass('activeTr');
$(this).addClass('activeTr');
})
}
//定位当前位置
function initLocation(){
// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398,39.897445);
map.centerAndZoom(point,10);
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
$('#locationText').html(r.address.province + "" + r.address.city);
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;
//初始化产品热卖
initGoodsList();
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
});
} else {
toast('failed'+this.getStatus());
}
},{enableHighAccuracy: true})
}
//初始化商品列表
function initGoodsList(page = 1, pageNum = 10){
//排序规则
var sort = $('.activeBtn').attr('data-sort');
//关键字
var keyword = $('#searchVal').val();
$.ajax({
url:"{:url('index/goods/get_all')}",
type:"POST",
data:{"province_id":province_id,"page":page,"pageNum":pageNum,'paginate':1,'sort':sort,'keyword':keyword,'lng':lng,'lat':lat},
success:function(res){
var goods_html = "";
$(res.data.data).each(function (key1, vo) {
var property = "";
$(vo.property).each(function (key2, p) {
property += "<span class=\"myLable\">"+p+"</span>";
});
var str = "<tr onclick=\"window.location.href='{:url('index/goods/detail',array('goods_id'=>'GOODS_ID'))}'\">\n" +
" <td>"+vo.id+"</td>\n" +
" <td><img src=\""+vo.thumbnail+"\" alt=\"\" style='width: 100px;height:100px'></td>\n" +
" <td>"+vo.goodsname+"</td>\n" +
" <td>"+vo.inventory+"</td>\n" +
" <td onclick=\"window.event.stopPropagation();window.location.href='{:url('index/shop/detail',array('store_id'=>'STORE_ID'))}'\">"+vo.store_name+property+"\n" +
" <td>"+vo.brand+"</td>\n" +
" <td>单价:¥"+vo.price+"</td>\n" +
" <td>"+vo.store_address+"("+vo.distance+"km)</td>\n" +
" </tr>";
goods_html += str.replace("GOODS_ID",vo.id).replace("STORE_ID",vo.store_id);
console.log(goods_html);
});
$('.goods_dom').html(goods_html);
$('#resultsNum').html(res.data.total+"件");
//初始化分页
var totalPage = Math.ceil(res.data.total/pageNum);
initPaging(res.data.total,res.data.current_page,totalPage,pageNum);
},
error:function(res){
toast('与服务器断开连接');
}
});
}
//初始化分页
function initPaging(totalSize = 0, current_page = 1, totalPage = 0, pageNum, showPageNum = 5) {
$("#paginationAllOrder").whjPaging({
//每页显示数据条数
pageNum: pageNum,
//当前页
current_page: current_page,
//可选,总条数
totalSize: totalSize,
//可选,总页数
totalPage: totalPage,
//可选,展示页码数量,默认5个页码数量
showPageNum: showPageNum,
//可选,css设置,可设置值:css-1,css-2,css-3,css-4,css-5,默认css-1,可自定义样式
css: 'css-1',
//可选,上一页按钮展示文本,默认显示文本为上一页
previousPage: "<span class=\"glyphicon glyphicon-menu-left\" aria-hidden=\"true\" style='opacity:0.65;font-size:12px;'></span>",
//可选,下一页按钮展示文本,默认显示文本为下一页
nextPage: "<span class=\"glyphicon glyphicon-menu-right\" aria-hidden=\"true\" style='opacity:0.65;font-size:12px;'></span>",
//可选,是否展示刷新,默认true
isShowRefresh: false,
//可选,是否展示首页与尾页,默认true
isShowFL: false,
//可选,是否展示共{}页,默认true
isShowTotalPage: false,
//可选,是否展示共{}条记录,默认true
isShowTotalSize: false,
//可选,是否需要重新设置当前页码、总页数及总条数,默认false,如果设为true,那么在请求服务器返回数据时,需要调用setPage方法
isResetPage: false,
//可选,跳至展示文本,默认显示文本为跳至
skip: "跳至",
//可选,确认按钮展示文本,默认显示文本为确认
confirm: "确认",
//必选,回掉函数,返回参数:第一个参数为页码,第二个参数为每页显示N条
callBack: function (currPage, pageSize) {
console.log('currPage:' + currPage + ' pageSize:' + pageSize);
initGoodsList(currPage, pageSize)
}
});
}
//切换经销商
function selectDistributor(obj) {
$(obj).closest('.dropdown').find('.distributorName').html($(obj).html());
$('#dropdownMenu1').attr('data-sort',$(obj).attr('data-sort'));
sortSearch($('#dropdownMenu1')[0], $(obj).html());
}
//查询数据
function searchData(val) {
/*var searchKey = $('#searchVal').val();
if(searchKey == ''){
toast('请输入要搜索的内容');
return;
}*/
initGoodsList();
//noResultsTips();
}
//排序查询
function sortSearch(obj, type) {
if(!$('.activeBtn').hasClass('priceBtn')){
$('.activeBtn img').attr('src', '__CDN__/assets/store/images/dropDwon.png');
}
$('.activeBtn').removeClass('activeBtn');
$(obj).addClass('activeBtn');
if(type != 'price'){
$(obj).find('img').attr('src', '__CDN__/assets/store/images/dropDwon_select.png');
$('.priceBtn').attr('data-sort',0);
$('.priceBtn').find('img').eq(0).attr('src', '__CDN__/assets/store/images/dropDwon_up.png');
$('.priceBtn').find('img').eq(1).attr('src', '__CDN__/assets/store/images/dropDwon.png');
}else{
if($.inArray($(obj).attr('data-sort'),['0','5']) != -1){
$(obj).find('img').eq(1).attr('src', '__CDN__/assets/store/images/dropDwon_select.png');
$(obj).find('img').eq(0).attr('src', '__CDN__/assets/store/images/dropDwon_up.png');
$(obj).attr('data-sort',6);
}else{
$(obj).find('img').eq(0).attr('src', '__CDN__/assets/store/images/dropDwon_up_select.png');
$(obj).find('img').eq(1).attr('src', '__CDN__/assets/store/images/dropDwon.png');
$(obj).attr('data-sort',5);
}
}
initGoodsList();
}
//无搜索结果提示
function noResultsTips() {
$('#mapHideNoResultsBox,#mapShowNoResultsBox').hide();
$('.contentMain').show();
if(noResults && !mapShow){
$('.contentMain').hide();
$('#mapHideNoResultsBox').show();
}else if(noResults && mapShow){
$('.tableBox').hide();
$('#mapShowNoResultsBox').show();
}
}
//打开地图
function openMap() {
$('.openMapBox').hide();
$("#mapBox").animate({left: "0px"});
$(".content .contentMain").css({
height:"899px",
width:"50%"
})
$('.content').css({'height': $('.contentMain').height()+20+'px'})
$('.contentMain').css({
position: 'absolute'
});
$(".content .contentMain #tableBox .tableContent").css({
height: "645px",
"overflow-y": "scroll"
})
$('.contentMain').animate({
top: '0',
right: '0'
})
mapShow = true;
noResultsTips();
initMap();
}
//收回地图
function takeBackMap() {
$('.content').css({'height': 'auto'})
// $("#mapBox").animate({left: "-900px"});
$("#mapBox").animate({left: "-50%"});
$('.openMapBox').show();
$('.contentMain').css({
position: 'static'
});
mapShow = false;
noResultsTips();
}
//初始化地图
function initMap() {
var point = new BMap.Point(locationLng, locationLat);
mapObj = new BMap.Map("mapDiv");
mapObj.centerAndZoom(point, 10);
mapObj.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
mapObj.setDefaultCursor('pointer');
addMarker(point, 999);
rangeSearch50();
var size = new BMap.Size(405, 43);
mapObj.addControl(new BMap.CityListControl({
anchor: BMAP_ANCHOR_TOP_LEFT,
offset: size
}));
geoc = new BMap.Geocoder();
mapObj.addEventListener("click", function(e){
var allOverlay = this.getOverlays();
for (var i=0; i<allOverlay.length; i++){
this.removeOverlay(allOverlay[i]);
}
locationLng = e.point.lng;
locationLat = e.point.lat;
geoc.getLocation(e.point, function(rs){
var addComp = rs.addressComponents;
$('#locationText').html(addComp.province + "" + addComp.city + "" + addComp.district + "" + addComp.street + "" + addComp.streetNumber);
//省份名称转换为id
$.ajax({
url:"{:url('index/sundry/get_province_id')}",
type:"POST",
data:{"province_name":addComp.province},
async:false,
success:function(res){
console.log(res);
if(res.code == 1){
province_id = res.data.province_id;
lng = locationLng;
lat = locationLat;
rangeSearch50();
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
});
});
var point = new BMap.Point(locationLng, locationLat);
addMarker(point, 999);
})
}
//添加标注点
function addMarker(point, index){ // 创建图标对象
var myIcon = new BMap.Icon("__CDN__/assets/store/images/mapPoint_icon.png", new BMap.Size(50, 50), {});
// 创建标注对象并添加到地图
var marker = new BMap.Marker(point, {icon: myIcon});
mapObj.addOverlay(marker);
}
//查询50KM范围内在售商品
function rangeSearch50(lng, lat) {
var allOverlay = mapObj.getOverlays();
for (var i=0; i<allOverlay.length; i++){
mapObj.removeOverlay(allOverlay[i]);
}
var point = new BMap.Point(locationLng, locationLat);
mapObj.centerAndZoom(point, 10);
addMarker(point);
var circle = new BMap.Circle(point,50000,{fillColor:"#00A998", strokeWeight: 1 ,fillOpacity: 0.2, strokeOpacity: 0.3});
mapObj.addOverlay(circle);
if (point != null) {
circle.addEventListener("lineupdate", function (e) {
console.log(circle.getRadius()); //返回圆形覆盖物的半径
});
}
initGoodsList();
}
</script>
</body>
</html>