add.html
33.1 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
<script src="__PUBLIC__/js/global.js"></script>
<include file="public/layout" />
<style>
#bside_left {
width: 260px;
height: 510px;
padding: 10px 0px 10px 10px;
float: left;
overflow: auto;
}
#bside_rgiht {
width: 603px;
height: 510px;
margin-left: 10px;
border-left: 1px solid #5688CB;
float: left;
font-size: 12px;
}
.info_list {
margin-bottom: 5px;
cleat: both;
cursor: pointer;
}
#container {
width: 603px;
height: 510px;
border: 5px solid #fff;
}
.explanation{ max-height: 60px;}
</style>
<body style="background-color: #FFF; overflow: auto;" onLoad="init()">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
<div class="fixed-bar">
<div class="item-title"><a class="back" href="{:urldecode(urldecode($url))}" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
<div class="subject">
<h3>门店管理 - 编辑和添加门店</h3>
<h5>系统门店管理</h5>
</div>
</div>
</div>
<!-- 操作说明 -->
<div class="explanation" id="explanation" >
<div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
<h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
<span id="explanationZoom" title="收起提示"></span></div>
<ul>
<li>新增时,必须在关键字搜索要添加的门店信息,才可实现门店线上线下同步</li>
</ul>
</div>
<form class="form-horizontal" id="handleForm" action="{:U('Admin/Pickup/add')}" method="post">
<input name="pickup_id" type="hidden" value="{$pickup['pickup_id']}" />
<div class="ncap-form-default">
<input type="hidden" maxlength="100" id="keyid"
name="keyid" value="{$pickup.keyid}" class="input-txt">
<input type="hidden" maxlength="100" id="oldurl"
name="oldurl" value="{$oldurl}" class="input-txt">
<if condition="(empty($pickup['pickup_id']) && $p_erpid)">
<dl class="row">
<dt class="tit">
<label for="fkeywords"><em>*</em>关键字搜索</label>
</dt>
<dd class="opt">
<input type="text" value=""
onkeydown="strkeydown(event, this, 'subbtn')"
id="fkeywords" class="input-txt"/>
<input id="subbtn" type="button" value="点击选择门店" onclick="searShop()"
class="input-btn" />
<span class="err cr"></span>
</dd>
</dl>
</if>
<dl class="row">
<dt class="tit">
<label>配送方式</label>
</dt>
<dd class="opt">
<input id="distr_type0" type="radio" name="distr_type" value="0"
<if condition="$pickup[distr_type] eq 0"> checked</if>
><label for="distr_type0">用户自选</label>
<input id="distr_type1" type="radio" name="distr_type" value="1"
<if condition="$pickup[distr_type] eq 1"> checked</if>
><label for="distr_type1">自提</label>
<input id="distr_type2" type="radio" name="distr_type" value="2"
<if condition="$pickup[distr_type] eq 2"> checked</if>
><label for="distr_type2">物流</label>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>门店分类</label>
</dt>
<dd class="opt">
<select name="category_id" id="category_id" onkeydown="strkeydown(event, this, 'sumbitbtn')">
<option value="0">请选择</option>
<volist name="category" id="p">
<option <if condition="$pickup['category_id'] eq $p['cat_id']">selected</if> value="{$p.cat_id}">{$p.cat_name}</option>
</volist>
</select>
<p class="notic"></p>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>门店名称</label>
</dt>
<dd class="opt">
<input type="text" maxlength="120" id="pickup_name"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
name="pickup_name" value="{$pickup.pickup_name}" class="input-txt">
<span class="err"></span>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>门店编号</label>
</dt>
<dd class="opt">
<input type="text" maxlength="120" <if condition="$p_erpid"> readonly="readonly" </if> id="pickup_no"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
name="pickup_no" value="{$pickup.pickup_no}" class="input-txt">
<p class="notic"></p>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>门店地址</label>
</dt>
<dd class="opt">
<select name="province_id" id="province"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
onChange="get_city(this);">
<option value="0">请选择</option>
<volist name="province" id="p">
<option <if condition="$pickup['province_id'] eq $p['id']">selected</if> value="{$p.id}">{$p.name}</option>
</volist>
</select>
<select name="city_id" id="city"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
onChange="get_area(this);showmap();">
<option value="0">请选择</option>
<volist name="city" id="p">
<option <if condition="$pickup['city_id'] eq $p['id']">selected</if> value="{$p.id}">{$p.name}</option>
</volist>
</select>
<select name="district_id" id="district" onkeydown="strkeydown(event, this, 'sumbitbtn')" onChange="showmap();">
<option value="0">请选择</option>
<volist name="district" id="p">
<option <if condition="$pickup['district_id'] eq $p['id']">selected</if> value="{$p.id}">{$p.name}</option>
</volist>
</select>
<input type="text" name="pickup_address" id="address"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
placeholder="详细地址" value="{$pickup.pickup_address}" class="input-txt" >
<input id="btn_search" type="button" value="搜索"
class="input-btn" />
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>经纬度</label>
</dt>
<dd class="opt">
<input id="lat" name="lat" type="text" value="{$pickup.lat}">
<input id="lon" name="lon" type="text" value="{$pickup.lon}">
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>地址定位</label>
</dt>
<dd class="opt">
<div id="bside_left">
<div id="txt_pannel">
<h3>功能简介:</h3>
<p>1、支持地址 精确/模糊 查询;</p>
<p>2、支持POI点坐标显示;</p>
<p>3、坐标鼠标跟随显示;</p>
<h3>使用说明:</h3>
<p>在搜索框搜索关键词后,地图上会显示相应poi点,同时左侧显示对应该点的信息,点击某点或某信息,右上角会显示相应该点的坐标和地址。</p>
</div>
</div>
<div id="bside_rgiht">
<div id="container"></div>
</div>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>联系人</label>
</dt>
<dd class="opt">
<input type="text" name="pickup_contact" maxlength="12" id="pickup_contact"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
placeholder="联系人" value="{$pickup.pickup_contact}" class="input-txt">
<p class="notic"></p>
</dd>
</dl>
<dl class="row">
<dt class="tit">
<label><em>*</em>电话</label>
</dt>
<dd class="opt">
<input type="text" name="pickup_phone" value="{$pickup.pickup_phone}"
onkeydown="strkeydown(event, this, 'sumbitbtn')"
class="input-txt">
<p class="notic"></p>
</dd>
</dl>
<dl class="row">
<dt class="tit">是否显示</dt>
<dd class="opt">
<div class="onoff">
<label for="order_shipping_sms_enable1" class="cb-enable <if condition='$pickup.isstop neq 1'>selected</if>">开启</label>
<label for="order_shipping_sms_enable0" class="cb-disable <if condition='$pickup.isstop neq 0'>selected</if>">关闭</label>
<input id="order_shipping_sms_enable1" name="isstop" onkeydown="strkeydown(event, this, 'sumbitbtn')" <if condition='$pickup.is_show eq 1'>selected</if> value="0" type="radio">
<input id="order_shipping_sms_enable0" name="isstop" onkeydown="strkeydown(event, this, 'sumbitbtn')"
<if condition='$pickup.is_show eq 0'>selected</if>
value="1" type="radio">
</div>
<p class="notic">选择门店时是否显示</p>
</dd>
</dl>
<input id="fulladdress" name="fulladdress" type="hidden" value="{$pickup.fulladdress}">
<div class="bot"><a id="sumbitbtn" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
</div>
<div class="poi" style="display: none">
<div class="poi_note">当前坐标:</div>
<input type="text" id="poi_cur">
<div class="poi_note">当前地址:</div>
<input type="text" id="addr_cur">
</div>
<span id="level" style="display: none;">当前缩放等级:10</span>
</form>
</div>
<input id="erpid" value="{:getERPId();}" type="hidden" />
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=MJVBZ-2BMR5-6S5I3-QQGIX-JCS6Q-NLFBK"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/valid.js"></script>
<script type="text/javascript">
function init() {
// if ($("#lat").val()!="" && $("#lon").val()!="") {
//
// var myLatlng = new qq.maps.LatLng($("#lat").val(), $("#lon").val());
// var myOptions = {
// zoom: 18,
// center: myLatlng
// };
// var map = new qq.maps.Map(document.getElementById("container"), myOptions);
// }
}
// showmap();
var container = document.getElementById("container");
var map = new qq.maps.Map(container, {
zoom: 16
}),
label = new qq.maps.Label({
map: map,
offset: new qq.maps.Size(15,-12),
draggable: false,
clickable: false
}),
markerArray = [],
curCity = document.getElementById("cur_city"),
btnSearch = document.getElementById("btn_search"),
bside = document.getElementById("bside_left"),
url, query_city,
cityservice = new qq.maps.CityService({
complete: function (result) {
if (result!=null) {
curCity.children[0].innerHTML = result.detail.name;
map.setCenter(result.detail.latLng);
}
}
});
cityservice.searchLocalCity();
map.setOptions({
draggableCursor: "crosshair"
});
$(container).mouseenter(function () {
label.setMap(map);
});
$(container).mouseleave(function () {
label.setMap(null);
});
qq.maps.event.addListener(map, "mousemove", function (e) {
var latlng = e.latLng;
label.setPosition(latlng);
label.setContent(latlng.getLat().toFixed(6) + "," + latlng.getLng().toFixed(6));
});
var url3;
qq.maps.event.addListener(map, "click", function (e) {
document.getElementById("poi_cur").value = e.latLng.getLat().toFixed(6) + "," + e.latLng.getLng().toFixed(6);
document.getElementById("lat").value= e.latLng.getLat().toFixed(6);
document.getElementById("lon").value=e.latLng.getLng().toFixed(6);
/*--url3 = encodeURI("https://apis.map.qq.=com/ws/geocoder/v1/?location=" + e.latLng.getLat() + "," + e.latLng.getLng() + "&key=MJVBZ-2BMR5-6S5I3-QQGIX-JCS6Q-NLFBK&output=jsonp&&callback=?");--*/
url3 = encodeURI("https://apis.map.qq.=com/ws/geocoder/v1/?location=" + e.latLng.getLat() + "," + e.latLng.getLng() + "&key=MJVBZ-2BMR5-6S5I3-QQGIX-JCS6Q-NLFBK&output=jsonp&&callback=?");
$.getJSON(url3, function (result) {
if(result.result!=undefined){
document.getElementById("addr_cur").value = result.result.address;
}else{
document.getElementById("addr_cur").value = "";
}
})
});
qq.maps.event.addListener(map, "zoom_changed", function () {
document.getElementById("level").innerHTML = "当前缩放等级:" + map.getZoom();
});
var listener_arr = [];
var isNoValue = false;
qq.maps.event.addDomListener(btnSearch, 'click', function () {
var province_id = $('select[name="province_id"]').find('option:selected').val();
var province_text = $('select[name="province_id"]').find('option:selected').text();
var city_id = $('select[name="city_id"]').find('option:selected').val();
var city_text = $('select[name="city_id"]').find('option:selected').text();
var district_id = $('select[name="district_id"]').find('option:selected').val();
var district_text = $('select[name="district_id"]').find('option:selected').text();
var pickup_address = $('input[name="pickup_address"]').val();
var error="";
if(province_id==0 || province_id==undefined || province_id==''){
error = '请选择省份 <br/>';
}
if(city_id==0 || city_id==undefined || city_id==''){
error += '请选择城市 <br/>';
}
if(district_id==0 || district_id==undefined || district_id==''){
error += '请选择区域 <br/>';
}
if(pickup_address == ''){
error += '请填写详细地址 <br/>';
}
if(error){
layer.alert(error, {icon: 2});
return false;
}
var value =$("#address").val();
var latlngBounds = new qq.maps.LatLngBounds();
for(var i= 0,l=listener_arr.length;i<l;i++){
qq.maps.event.removeListener(listener_arr[i]);
}
getcityname=city_text;
listener_arr.length = 0;
query_city = getcityname;
if (getcityname=="省属虚拟市" || getcityname=="县" || getcityname=="市辖区" )
{
query_city=district_text;
}
else
{
query_city=getcityname+district_text
}
query_city=province_text+query_city;
// alert(query_city);
url = encodeURI("https://apis.map.qq.com/ws/place/v1/search?keyword=" + value + "&boundary=region(" + query_city + ",0)&page_size=9&page_index=1&key=MJVBZ-2BMR5-6S5I3-QQGIX-JCS6Q-NLFBK&output=jsonp&&callback=?");//
// url=encodeURI("https://apis.map.qq.com/jsapi?qt=poi&wd=" + value + "&pn=0&rn=1000&rich_source=qipao&rich=web&nj=1&c=" + query_city + "&key=7JXBZ-W3Q3F-KI7JO-NDHMP-Q73S7-RGF47&output=jsonp&pf=jsapi&ref=jsapi&cb=?");
$.getJSON(url, function (result) {
if (result.count) {
isNoValue = false;
bside.innerHTML = "";
each(markerArray, function (n, ele) {
ele.setMap(null);
});
markerArray.length = 0;
each(result.data, function (n, ele) {
var latlng = new qq.maps.LatLng(ele.location.lat, ele.location.lng);
latlngBounds.extend(latlng);
var left = n * 27;
var marker = new qq.maps.Marker({
map: map,
position: latlng,
zIndex: 10
});
marker.index = n;
marker.isClicked = false;
setAnchor(marker, true);
markerArray.push(marker);
var listener1 = qq.maps.event.addDomListener(marker, "mouseover", function () {
var n = this.index;
setCurrent(markerArray, n, false);
setCurrent(markerArray, n, true);
label.setContent(this.position.getLat().toFixed(6) + "," + this.position.getLng().toFixed(6));
label.setPosition(this.position);
label.setOptions({
offset: new qq.maps.Size(15, -20)
})
});
listener_arr.push(listener1);
var listener2 = qq.maps.event.addDomListener(marker, "mouseout", function () {
var n = this.index;
setCurrent(markerArray, n, false);
setCurrent(markerArray, n, true);
label.setOptions({
offset: new qq.maps.Size(15, -12)
})
});
listener_arr.push(listener2);
var listener3 = qq.maps.event.addDomListener(marker, "click", function () {
var n = this.index;
setFlagClicked(markerArray, n);
setCurrent(markerArray, n, false);
setCurrent(markerArray, n, true);
document.getElementById("addr_cur").value = bside.childNodes[n].childNodes[1].childNodes[1].innerHTML.substring(3);
});
listener_arr.push(listener3);
// alert(latlngBounds);
// map.fitBounds(latlngBounds);
var div = document.createElement("div");
div.className = "info_list";
var order = document.createElement("div");
var leftn = -54 - 17 * n;
order.style.cssText = "width:17px;height:17px;margin:3px 3px 0px 0px;float:left;background:url(__PUBLIC__/static/images/marker_n.png) " + leftn + "px 0px";
div.appendChild(order);
var pannel = document.createElement("div");
pannel.style.cssText = "width:200px;float:left;";
div.appendChild(pannel);
var name = document.createElement("p");
name.style.cssText = "margin:0px;color:#0000CC";
name.innerHTML = ele.title;
pannel.appendChild(name);
var address = document.createElement("p");
address.style.cssText = "margin:0px;";
address.innerHTML = "地址:" + ele.address;
pannel.appendChild(address);
if (ele.tel != undefined) {
var phone = document.createElement("p");
phone.style.cssText = "margin:0px;";
phone.innerHTML = "电话:" + ele.tel;
pannel.appendChild(phone);
}
var position = document.createElement("p");
position.style.cssText = "margin:0px;";
position.innerHTML = "坐标:" + ele.location.lat.toFixed(6) + "," + ele.location.lng.toFixed(6);
pannel.appendChild(position);
bside.appendChild(div);
div.style.height = pannel.offsetHeight + "px";
div.isClicked = false;
div.index = n;
marker.div = div;
div.marker = marker;
//默认第一个
if (n==0) {
//
setFlagClicked(markerArray, n);
setCurrent(markerArray, n, false);
setCurrent(markerArray, n, true);
map.setCenter(markerArray[n].position);
//document.getElementById("addr_cur").value = this.childNodes[1].childNodes[1].innerHTML.substring(3);
}
});
$("#bside_left").delegate(".info_list", "mouseover", function (e) {
var n = this.index;
setCurrent(markerArray, n, false);
setCurrent(markerArray, n, true);
});
$("#bside_left").delegate(".info_list", "mouseout", function () {
each(markerArray, function (n, ele) {
if (!ele.isClicked) {
setAnchor(ele, true);
ele.div.style.background = "#fff";
}
})
});
$("#bside_left").delegate(".info_list", "click", function (e) {
var n = this.index;
setFlagClicked(markerArray, n);
setCurrent(markerArray, n, false);
setCurrent(markerArray, n, true);
map.setCenter(markerArray[n].position);
document.getElementById("addr_cur").value = this.childNodes[1].childNodes[1].innerHTML.substring(3);
});
} else {
bside.innerHTML = "";
each(markerArray, function (n, ele) {
ele.setMap(null);
});
markerArray.length = 0;
var novalue = document.createElement('div');
novalue.id = "no_value";
novalue.innerHTML = "对不起,没有搜索到您要找的结果!";
bside.appendChild(novalue);
isNoValue = true;
}
});
});
btnSearch.onmousedown = function () {
// this.className = "btn_active";
};
btnSearch.onmouseup = function () {
// this.className = "btn";
};
function setAnchor(marker, flag) {
var left = marker.index * 27;
if (flag == true) {
var anchor = new qq.maps.Point(10, 30),
origin = new qq.maps.Point(left, 0),
size = new qq.maps.Size(27, 33),
icon = new qq.maps.MarkerImage("__PUBLIC__/static/images/marker10.png", size, origin, anchor);
marker.setIcon(icon);
} else {
var anchor = new qq.maps.Point(10, 30),
origin = new qq.maps.Point(left, 35),
size = new qq.maps.Size(27, 33),
icon = new qq.maps.MarkerImage("__PUBLIC__/static/images/marker10.png", size, origin, anchor);
marker.setIcon(icon);
}
}
function setCurrent(arr, index, isMarker) {
if (isMarker) {
each(markerArray, function (n, ele) {
if (n == index) {
setAnchor(ele, false);
ele.setZIndex(10);
} else {
if (!ele.isClicked) {
setAnchor(ele, true);
ele.setZIndex(9);
}
}
});
} else {
each(markerArray, function (n, ele) {
if (n == index) {
ele.div.style.background = "#DBE4F2";
} else {
if (!ele.div.isClicked) {
ele.div.style.background = "#fff";
}
}
});
}
}
function setFlagClicked(arr, index) {
each(markerArray, function (n, ele) {
if (n == index) {
ele.isClicked = true;
ele.div.isClicked = true;
var str = '<div style="width:250px;">' + ele.div.children[1].innerHTML.toString() + '</div>';
var latLng = ele.getPosition();
document.getElementById("poi_cur").value = latLng.getLat().toFixed(6) + "," + latLng.getLng().toFixed(6);
document.getElementById("lat").value=latLng.getLat().toFixed(6)
document.getElementById("lon").value=latLng.getLng().toFixed(6);
} else {
ele.isClicked = false;
ele.div.isClicked = false;
}
});
}
var url2;
var getcityname;
var getdistrictname;
function showmap() {
getcityname=$("#city").find("option:selected").text();
getdistrictname=$("#district").find("option:selected").text();
var getfulladdress="";
getfulladdress=$("#province").find("option:selected").text();
var getaddress=getcityname+getdistrictname;
if (getcityname=="省属虚拟市" || getcityname=="县" || getcityname=="市辖区" )
{
getaddress=getdistrictname;
getfulladdress+=getdistrictname;
}
else
{
getfulladdress+=getcityname+getdistrictname;
}
getfulladdress+=$("#address").val();
$("#fulladdress").val(getfulladdress);
url2 = encodeURI("https://apis.map.qq.com/ws/geocoder/v1/?region=" + getaddress + "&address=" + getaddress + "&key=MJVBZ-2BMR5-6S5I3-QQGIX-JCS6Q-NLFBK&output=jsonp&&callback=?");
$.getJSON(url2, function (result) {
map.setCenter(new qq.maps.LatLng(result.result.location.lat, result.result.location.lng));
map.setZoom(16);
});
}
var url4;
$("#address").autocomplete({
source:function(request,response){
var getregion=getcityname+getdistrictname;
if (getcityname=="省属虚拟市" || getcityname=="县" || getcityname=="市辖区") {
getregion=getdistrictname;
}
url4 = encodeURI("https://apis.map.qq.com/ws/place/v1/suggestion/?keyword=" + request.term + "®ion=" + getregion + "&key=MJVBZ-2BMR5-6S5I3-QQGIX-JCS6Q-NLFBK&output=jsonp&&callback=?");
$.getJSON(url4,function(result){
response($.map(result.data,function(item){
return({
label:item.title
})
}));
});
}
});
function each(obj, fn) {
for (var n = 0, l = obj.length; n < l; n++) {
fn.call(obj[n], n, obj[n]);
}
}
//详细地址改变
$("#address").change(function () {
var fulladd1="";
getcityname=$("#city").find("option:selected").text();
getdistrictname=$("#district").find("option:selected").text();
var provincename=$("#province").find("option:selected").text();
fulladd1=provincename;
if (getcityname!="省属虚拟市" && getcityname!="县" && getcityname!="市辖区" )
{
fulladd1+=getcityname;
}
if (getdistrictname!="省属虚拟市" && getdistrictname!="县" && getdistrictname!="市辖区" )
{
fulladd1+=getdistrictname;
}
fulladd1+=$(this).val();
$("#fulladdress").val(fulladd1);
})
function checkForm(){
var keyid = $('input[name="keyid"]').val();
var pickup_name = $('input[name="pickup_name"]').val();
var pickup_no = $('input[name="pickup_no"]').val();
var province_id = $('select[name="province_id"]').find('option:selected').val();
var city_id = $('select[name="city_id"]').find('option:selected').val();
var district_id = $('select[name="district_id"]').find('option:selected').val();
var pickup_address = $('input[name="pickup_address"]').val();
var pickup_phone = $('input[name="pickup_phone"]').val();
var pickcat=$("#category_id").val();
var error = '';
var erpid=$("#erpid").val();
if(keyid == '' && erpid!=""){
$("#fkeywords").focus();
layer.alert("请在关键字搜索要添加的门店信息", {icon: 2});
return false;
}
if(pickup_no == ''){
error += '门店编号不能为空 <br/>';
}
if(pickup_name == ''){
error += '门店名称不能为空 <br/>';
}
if(province_id==0 || province_id==undefined || province_id==''){
error += '请选择省份 <br/>';
}
if(city_id==0 || city_id==undefined || city_id==''){
error += '请选择城市 <br/>';
}
if(district_id==0 || district_id==undefined || district_id==''){
error += '请选择区域 <br/>';
}
// if(pickcat==0 || pickcat==undefined || pickcat==''){
// error += '请选择门店分类 <br/>';
// }
if(pickup_address == ''){
error += '请填写详细地址 <br/>';
}
if(pickup_phone==""){
error += '请填固定电话或手机 <br/>';
}
// if(!isphone1(pickup_phone) && !isphone2(pickup_phone)){
// error += '请填写正确格式的固定电话或手机 <br/>';
// }
if(error){
//alert(error);
layer.alert(error, {icon: 2});
return false;
}
$('#handleForm').submit();
}
var seardata;
var count;
function getSearDate(){return seardata;}
function getCount(){return count;}
function searShop() {
var ky = $("#fkeywords").val();
if (ky == "") {
layer.msg("请输入关键字!", {icon: 2, time: 1000});
$("#fkeywords").focus();
$("#fkeywords").parent().find("span").text();
return;
}
var url="/index.php/admin/pickup/selectshop/key/"+ky;
var url2="/index.php/admin/pickup/search/key/"+ky;
layer.msg('努力中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '200px', time:100000}) ;
$.ajax({
type : "get", url : url,
dataType:"json",
error: function(request) {
layer.closeAll();
layer.msg("服务器繁忙, 请联系管理员!",{icon:2});return;
},
success: function(data) {
layer.closeAll();
if(data==""){
layer.msg("未找到数据",{icon:2,time:1000});
return;
}
count=data.data.total;
if(data.code="0" || data.code==0){
if(count==undefined || count<=0){
layer.msg("未找到数据",{icon:2,time:1000});
return;
}
seardata=data.data.pageData;
if(seardata.length==1){
m_call_back(seardata[0]);
}else{
layer.open({
type: 2,
title: '选择门店',
shadeClose: true,
shade: 0.2,
area: ['96%', '70%'],
content: url2,
});
}
}else{
layer.msg(data.msg,{icon:2,time:1000});
}
}
});
}
function m_call_back(data) {
$("#pickup_name").val(data.StorageName);
$("#pickup_no").val(data.StorageNo);
$("#pickup_contact").val(data.Manager);
var getaddress1= data.Address;
var geteditaddress1= data.editaddress;
$("#keyid").val(data.Id);
layer.closeAll('iframe');
//判断是否有存在keyid
var url="/index.php/admin/pickup/searchshop/keyid/"+ $("#keyid").val();
layer.msg('努力中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '200px', time:100000}) ;
$.ajax({
type : "get", url : url,
dataType:"json",
error: function(request) {
layer.closeAll();
layer.msg("服务器繁忙, 请联系管理员!",{icon:2});return;
},
success: function(data) {
layer.closeAll();
if(data.code=="1" || data.code==1){
var objdata=data.data;
layer.confirm("该门店已经存在门店列表,编号为"+objdata['pickup_no']+",请点击同步信息", {title:'温馨提示'
}, function(){
layer.closeAll();
}, function(){
});
}else{
getaddtoid(getaddress1,geteditaddress1);
}
}
});
}
function Cancle() {
layer.closeAll('iframe');
}
//
//getaddtoid("福建省\\泉州市\\丰泽区","泉州软件园");
function getaddtoid(addressname,editaddress) {
var url="/index.php/admin/pickup/getRegionId?addressname="+addressname;
layer.msg('努力中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '200px', time:100000}) ;
$.ajax({
type : "get", url : url,
dataType:"json",
error: function(request) {
layer.closeAll();
},
success: function(data) {
if(data.code==0){
var objdata=data.data;
$("#province").val(objdata['province_id']);
$("#province").trigger("change");
setTimeout(function () {
if (objdata['city_id']!=null)
{
$("#city").val(objdata['city_id']);
showmap();
$("#city").trigger("change");
setTimeout(function () {
if (objdata['district_id']!=null)
{
$("#district").val(objdata['district_id']);
$("#address").val(editaddress);
$("#btn_search").trigger("click");
showmap();
}
},100)
}
},100)
layer.closeAll();
//
}
else
{
layer.closeAll();
}
}
});
}
</script>
</body>
</html>