cart2_wk.html
48.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
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
995
996
997
998
999
1000
1001
1002
1003
<!DOCTYPE html >
<html>
<head>
<meta charset="UTF-8">
<title>提交订单-{$tpshop_config['shop_info_store_title']}</title>
<meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}"/>
<meta name="description" content="{$tpshop_config['shop_info_store_desc']}"/>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="format-detection" content="email=no"/>
<meta name="format-detection" content="address=no;">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="default"/>
<link rel="stylesheet" href="__STATIC__/css/public.css">
<link rel="stylesheet" href="__STATIC__/css/style_jm.css">
<link rel="stylesheet" href="__STATIC__/css/user.css">
<link rel="stylesheet" href="__STATIC__/css/flow.css">
<script type="text/javascript" src="__STATIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/global.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<script src="__PUBLIC__/js/mobile_common.js?v=__CSSVERSION__"></script>
<script src="__STATIC__/js/common.js"></script>
<link rel="stylesheet" href="__STATIC__/css/login.css?v=20180717002">
<style type="text/css">
.addList li { border-bottom: 1px solid #ccc;}
.address_add { border: 0; padding: 0; padding-bottom: 10px;}
.address_add dl { border: 0; padding-left: 35px; }
.address_add dl dd { width: 80%;}
.addmone { padding: 0 10px 10px; }
.fu.close {
background: rgba(0, 0, 0, 0) url("__STATIC__/images/flow/close.png") no-repeat scroll center center / 20px 20px;
cursor: pointer; height: 20px;
position: absolute; right: 10px;
top: 10px; width: 30px;
}
#addrform li {
padding-left: 10px;
border-bottom: 1px solid #eeeeee;
position: relative
}
.grd { background: #e18b96}
.giveaway { position: absolute; left: 0; top: 0; z-index: 10; }
.c_checkbox_t {
width: 20px; height: 20px; margin-right: 10px;
background: url(__STATIC__/images/flow/c_checkbox_off.png) no-repeat center center;
background-image: url("__STATIC__/images/flow/c_checkbox_off.png");
background-size: auto auto; background-size: cover;
vertical-align: middle; display: inline-block;
*display: inline;*zoom: 1;
}
.c_checkbox_on {
background-image: url(__STATIC__/images/flow/c_checkbox_on.png);
}
</style>
</head>
<body style="background: rgb(235, 236, 237);position:relative;">
<!--<div class="tab_nav">-->
<!--<div class="header">-->
<!--<div class="h-left"><a class="sb-back" href="javascript:history.back(-1)" title="返回"></a></div>-->
<!--<div class="h-mid"> 确认订单</div>-->
<!--</div>-->
<!--</div>-->
<div class="screen-wrap fullscreen login">
<form name="cart2_form" id="cart2_form" method="post">
<input type="hidden" id="setadd" name="setadd" value="{$setadd}"/>
<input type="hidden" id="u_money" value="{$u_money}"/>
<input type="hidden" id="ordsn" name="ordsn" value="{$ordsn}"/>
<!--拼单有关-->
<input type="hidden" name="listno" value="{$listno}"/>
<input type="hidden" name="prom_id" value="{$prom_id}"/>
<section class="content" style="min-height: 294px;">
<div class="wrap">
<div class="active" style="min-height: 294px;">
<div class="content-buy">
<div class="wrap order-buy">
<!---当不是自提的时候--->
<if condition='$expty neq 1'>
<div id="fexp" class="<if condition='$expty eq 0'>dn</if>">
<div id="faddmone" class="addmone <eq name='setadd' value='0'>dn</eq>" onclick="addaddr(0)">
<div class="jia"></div>
<span class="addTxt">新增收货地址</span>
<img src="__STATIC__/images/category/leftTip.png" class="shop_arrow"/>
<p class="clear"></p>
</div>
<!--收货人-->
<section id="newadd" class="address address1 <eq name='setadd' value='1'>dn</eq>" onclick="addressList()">
<div id="faddrshow" class="address-info">
<p class="address-name">收货人:{$address.consignee}</p>
<p class="address-phone">手机:{$address.mobile}</p>
</div>
<div class="address-details">收货地址:{$address.more_address} {$address.address}</div>
<input id="address_id" type="hidden" value="{$address.address_id}" name="address_id"/>
</section>
</div>
</if>
<!--商品详细情况-->
<section class="order " id="order4">
<!--<div class="order-info" style="margin-top:0;">-->
<!--<h4 class="seller-name" > <img src="__STATIC__/images/flow/dingdan.png" width="28">
订单详情 <a class="modify" href="{:U('Cart/cart')}">修改</a></h4>-->
<!--</div>-->
<section class="order-info kuorder_list" style=" margin-top:0px;">
<div class="order-list">
<div class="goods-list-title">{$pick.pickup_name}</div>
<ul class="order-list-info">
<li class="item">
<div class="itemPay list-price-nums" id="itemPay17">
<p class="price">¥{$goods.goods_price}</p>
<p class="nums">x{$goods.goods_num}</p>
<if condition="$Think.request.is_pt gt 0"><input type="hidden" name="pdgoodsnum" value="{$goods.goods_num}"/></if>
<if condition="$goods.prom_type eq 2">
<input type="hidden" name="g_promid[{$v.pickup_id}-{$goods.prom_id}]" value="{$goods.goods_num}" />
</if>
</div>
<div class="itemInfo list-info" id="itemInfo12">
<div class="list-img ">
<a class="rel"
href="{:U('Mobile/Goods/goodsInfo',array('stoid'=>$Think.request.stoid,'id'=>$goods[goods_id]))}">
<img src="{:getimg($goods['original_img'],NOIMG,0,1)}">
</a>
</div>
<div class="list-cont">
<h5 class="goods-title">{$goods.goods_name} </h5>
<p class="godds-specification">
{$goods.guige}</p>
</div>
</div>
</li>
<li class="flow_youhui_no">
<switch name='$expty'>
<case value="0">
<a onclick="setexptype(this,1)"><span class="c_checkbox_t c_checkbox_on"></span>门店自提</a> <a onclick="setexptype(this,0)"><span class="c_checkbox_t"></span>快递邮寄</a><input class="exparr" type="hidden" name="exparr" value="1"/>
</case>
<case value="1">
<span class="c_checkbox_t c_checkbox_on"></span>门店自提
<input class="exparr" type="hidden" name="exparr" value="1"/>
</case>
<case value="2">
<span class="c_checkbox_t c_checkbox_on"></span>快递邮寄
<input class="exparr" type="hidden" name="exparr" value="0"/>
</case>
</switch>
</li>
<!---当是自选或者物流的时候的时候--->
<li class="flow_youhui_no fexp <if condition='$expty eq 0 or $expty eq 1'>dn</if>">
<label>
选择物流:
<if condition="count($shippingList) eq 1">
<select onChange="ajax_order_price();" class="vam ou-no fwuliu" name="shipping_code">
<option value="{$shippingList[0][shipping_code]}">{$shippingList[0][shipping_name]}</option>
</select>
<else/>
<select onChange="ajax_order_price();" class="vam ou-no fwuliu" name="shipping_code">
<foreach name="shippingList" item="v4" key="k4">
<option value="{$v4.shipping_code}">{$v4.shipping_name}</option>
</foreach>
</select>
</if>
</label>
</li>
</ul>
</div>
</section>
</section>
<section class="order-info">
<div class="order-list">
<div class="content ptop0">
<div class="panel panel-default info-box">
<div class="con-ct fo-con">
<ul class="ct-list order_total_ul" style="margin-bottom: 0">
<li>成团人数</if>
<span class="txt_right"><em class="price" id="cnum"></em>人</span>
<p class="clear"></p>
</li>
<li>成团单价
<span class="txt_right">¥<em class="price" id="tprice"></em></span>
<p class="clear"></p>
</li>
<li>支付定金
<span class="txt_right">¥<em class="price">{$order.order_amount+$order.user_money}</em></span>
<p class="clear"></p>
</li>
</ul>
</div>
</div>
</div>
</div>
</section>
<section class="order-info">
<div class="order-list">
<div class="content ptop0">
<div class="panel panel-default info-box">
<div class="con-ct fo-con">
<ul class="ct-list order_total_ul" style="margin-bottom: 0">
<li>尾款金额</if>
<span class="txt_right">¥<em class="price" id="wk_money"></em></span>
<p class="clear"></p>
</li>
<li>配送费用
<span class="txt_right">¥<em class="price" id="postFee">{$total_price.shipping_price}</em></span>
<p class="clear"></p>
</li>
</ul>
</div>
<div class="confirm">
<span class="confirm_text">支付合计:
<span class="price">
¥<strong class="price_total" id="payables">0</strong>
</span>
</span>
<span id="fsub_btn" class="confirm_btn" onclick="submit_order()">支付尾款</span>
<span id="fsubing" class="confirm_btn dn">支付中..</span>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
</section>
</form>
<input id="back_ordno" value="" type="hidden">
</div>
<!--弹窗-->
<div id="layeraddr" class="layermbox layermbox0_1 dn">
<div class="laymshade"></div>
<div class="layermmain">
<div class="section">
<div class="layermchild layermanim">
<p class="addTit">选择收货地址</p>
<div class="closed" style="top:8px"></div>
<p class="clear"></p>
<div class="layermcont">
<dl style="line-height: 40px; text-align: left; margin-bottom: 10px; border-bottom: #ccc solid 1px;background: url(__STATIC__/images/category/leftTip.png) no-repeat 98% center;background-size: 11px 20px; " id="btnwxaddress">
<img src="__STATIC__/images/user/wximg.png" style="width: 20px;height: 20px; padding-left: 5px;" />
<span>获取微信收货地址</span>
</dl>
<!--------------添加编辑优惠券------------->
<ul id="popaddressmone" class="addressmone dn">
<form id="addrform">
<input name="store_id" value="{$pstore_id}" type="hidden">
<input id="popseleaddid" name="address_id" type="hidden" value=""/>
<li style="padding-top: 0;">
<span>收货人</span>
<input name="consignee" id="consignee" type="text" value="" maxlength="12" placeholder="收货人姓名"/>
</li>
<li>
<span>手机</span>
<input type="tel" name="mobile" value="" id="mobile"
onpaste="this.value=this.value.replace(/[^\d-]/g,'')"
onKeyUp="this.value=this.value.replace(/[^\d-]/g,'')" maxlength="15" placeholder="手机号码"/>
</li>
<li onclick="show_addsele()">
<span>所在地区</span>
<input type="text" value="" id="showaddrQ" readonly placeholder="所在地区"/>
<input name='country' value='1' type="hidden">
<input id='inp_province' name='province' value='' type="hidden">
<input id='inp_city' name='city' value='' type="hidden">
<input id='inp_district' name='district' value='' type="hidden">
<input id='inp_twon' name='twon' value='' type="hidden">
<input id='more_address' name='more_address' value="" type="hidden">
</li>
<li>
<span>详细地址</span>
<input type="text" name="address" id="address" placeholder="详细地址" maxlength="100" value="{$address.address}"/>
</li>
<li>
<span>邮政编码</span>
<input id="zipcode" type="tel" name="zipcode" value="{$address.zipcode}"
onpaste="this.value=this.value.replace(/[^\d]/g,'')"
onKeyUp="this.value=this.value.replace(/[^\d]/g,'')"
maxlength="10" placeholder="邮政编码"/>
</li>
<li id="addrdelli" style="text-align: center;" onclick="deladdr()">
<a class="delAdd">删除地址</a>
</li>
</form>
</ul>
<!--------------地址列表------------->
<div id="popadddiv">
<ul id="popaddlist" class="addList">
<foreach name="addlist" item="v">
<li aid="{$v.address_id}"
<eq name="$v.is_default" value="1">isel="1"</eq>
onclick='selectto(this)'>
<div class="address_add">
<h2>
<eq name="$v.is_default" value="1">
<img src="__STATIC__/images/right.png">
<else/>
<img src="__STATIC__/images/flow/c_checkbox_off.png">
</eq>
</h2>
<dl class='popdata'>
<dt><font class="popconsignee">{$v.consignee}</font>,手机:<font class="popmobile">{$v.mobile}</font>
</dt>
<dd>收货地址:<font class="popaddstr">{$v.more_address} {$v.address}</font>
</dd>
</dl>
<img id="amend" onclick="editAddress(this,event)"
src="__STATIC__/images/amend.png"/>
</div>
</li>
</foreach>
</ul>
<div class="addmone" onclick="addaddr(0)">
<div class="jia"></div>
<span class="addTxt">新增收货地址</span>
<img src="__STATIC__/images/category/leftTip.png" class="shop_arrow"/>
<p class="clear"></p>
</div>
</div>
<div id="addbtn" class="twoBtn dn">
<div class="btnRed" style="width: 100%;margin-top: 20px;" onclick="updateaddr()">确定</div>
<!--<div class="btnWhile">取消</div>-->
</div>
<div id="quanbtn" class="twoBtn dn">
<div class="btnRed" style="width: 100%;margin-top: 20px;" onclick="selequanbtn()">确定</div>
<!--<div class="btnWhile">取消</div>-->
</div>
</div>
</div>
</div>
</div>
</div>
<include file="public/footer"/>
<include file="public/addrsele"/>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
var getstoid = "<?php echo I('stoid')?>";
var exptype = "{$expty}";
var addtype = 0;
var mobile = "{$user['mobile']}";
var erpvipid= "{$user['erpvipid']}";
$(function () {
if(erpvipid=="" && terpid!="") mobile="";
ajax_order_price(); // 计算订单价钱
//获取输入焦点时
$(".addressmone input").focus(function () {
$(".addressmone li").css("border-color", "#eee");
$(this).parents("li").css("border-color", "#C4182E");
});
//获取微信地址start
if(isWeiXin()){
$.ajax({
type : "POST",
url:"/index.php?m=Mobile&c=Index&a=ajaxGetWxConfig&stoid="+getstoid+"&t="+Math.random(),
data:{'askUrl':encodeURIComponent(location.href.split('#')[0])},
dataType:'JSON',
success: function(res)
{
wx.config({
debug: false,
appId: res.appId,
timestamp: res.timestamp,
nonceStr: res.nonceStr,
signature: res.signature,
jsApiList: ['openAddress'] // 功能列表,我们要使用JS-SDK的什么功能
});
$("#btnwxaddress").show();
wx.ready(function () {
$('#btnwxaddress').click(function(){
wx.openAddress({
success: function (res) {
var userName = res.userName; // 收货人姓名
var postalCode = res.postalCode; // 邮编
var provinceName = res.provinceName; // 国标收货地址第一级地址(省)
var cityName = res.cityName; // 国标收货地址第二级地址(市)
var countryName = res.countryName; // 国标收货地址第三级地址(国家)
var detailInfo = res.detailInfo; // 详细收货地址信息
var nationalCode = res.nationalCode; // 收货地址国家码
var telNumber = res.telNumber; // 收货人手机号码
var mobile = res.telNumber; // 收货人手机号码
var consignee=userName;
$("#showaddrQ").val(provinceName+"-"+cityName+"-"+countryName);
//
var mm=layer.open({content:'加载中',time:2});
$.ajax({
type: "POST",
url: '/index.php/Mobile/Cart/addwx_address/stoid/'+getstoid,
data: {'userName':userName,'postalCode':postalCode,'provinceName':provinceName,'cityName':cityName,'countryName':countryName,'detailInfo':detailInfo,'telNumber':telNumber},
dataType: "json",
success: function (data) {
layer.close(mm);
if (data.code == 1) {
$("#popaddlist").html(data.data);
if (data.fir == 0) {
$("#setadd").val(0);
$("#layeraddr").addClass("dn");
$("body").css("overflow", "auto");
var addr1 = $("#showaddrQ").val();
var htm = "<div id='faddrshow' class='address-info'><p class='address-name'>收货人:" + consignee + "</p><p class='address-phone'>手机:" + mobile + "</p></div><div class='address-details'>收货地址:" + addr1 + " " + detailInfo + "</div><input id='address_id' type='hidden' value='" + data.id + "' name='address_id'/>";
$("#newadd").html(htm);
$("#newadd").removeClass("dn");
$("#faddmone").addClass("dn");
ajax_order_price();
reg_mobile=mobile;
} else {
addressList();
/*---编辑OK之后,主页上的地址也要修改--*/
if ($("#address_id").val() == $("#popseleaddid").val()) {
var addr1 = $("#showaddrQ").val();
var htm = "<div id='faddrshow' class='address-info'><p class='address-name'>收货人:" + consignee + "</p><p class='address-phone'>手机:" + mobile + "</p></div><div class='address-details'>收货地址:" + addr1 + " " + detailInfo + "</div><input id='address_id' type='hidden' value='" + $("#popseleaddid").val()+ "' name='address_id'/>";
$("#newadd").html(htm);
ajax_order_price();
}
}
}
},
error: function () {
layer.close(mm);
layer.open({
content: '网络异常',
time: 2
});
}
});
//
}
});
});
});
},
error:function(){
return false;
}
});
}
//获取微信地址end
});
function isWeiXin(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
}else{
return false;
}
}
/*--------------------------地址管理----------------------------*/
//关闭弹窗
$(".closed").click(function () {
$("#layeraddr").addClass("dn");
$("body").css("overflow", "auto");
if ($(".addTit").text() == "编辑收货地址") {
addressList();
}
});
//地址列表
function addressList() {
$("#layeraddr").removeClass("dn");
$("body").css("overflow", "hidden");
$(".addTit").text("选择收货地址");
$("#popadddiv").removeClass("dn");
$(".addressmone").addClass("dn");
$(".twoBtn").addClass("dn");
$(".subbox_other").addClass("dn");
$("#popquanlist").addClass('dn');
}
//编辑地址
function editAddress(ob, e) {
forminit();
window.event ? window.event.cancelBubble = true : e.stopPropagation();
$("#layeraddr").removeClass("dn");
$("body").css("overflow", "hidden");
$(".addTit").text("编辑收货地址");
$("#popadddiv").addClass("dn");
$(".addressmone").removeClass("dn");
$("#quanbtn").addClass("dn");
$("#addbtn").removeClass("dn");
$(".subbox_other").addClass("dn");
var aid = $(ob).parent().parent().attr("aid");
var mi = layer.open({type: 2});
$.ajax({
type: "get",
url: '/index.php?m=Mobile&c=Cart&a=get_area&stoid=' + getstoid + "&aid=" + aid,
//data: $('#addrform').serialize(),
dataType: "json",
success: function (data) {
layer.close(mi);
if (data.code == 1) {
$("#popseleaddid").val(aid);
/*编辑ID*/
$("#consignee").val(data.data2.consignee);
$("#mobile").val(data.data2.mobile);
$("#address").val(data.data2.address);
$("#zipcode").val(data.data2.zipcode);
$("#showaddrQ").val(data.data2.addname);
$("#inp_province").val(data.data2.province);
$("#inp_city").val(data.data2.city);
$("#inp_district").val(data.data2.district);
$("#inp_twon").val(data.data2.twon);
set_getarea(data.data, data.data2);
$("#addrdelli").fadeIn(3);
} else {
layer.open({content: "未找到该地址", time: 2});
}
},
error: function () {
layer.open({
content: '网络异常',
time: 2
});
}
});
}
//增加收货地址
function addaddr(ty) {
addtype = ty;
$("#layeraddr").removeClass("dn");
$("body").css("overflow", "hidden");
$(".addTit").text("新增收货地址");
$("#popadddiv").addClass("dn");
$(".addressmone").removeClass("dn");
$("#quanbtn").addClass("dn");
$("#addbtn").removeClass("dn");
$(".subbox_other").addClass("dn");
$("#addrdelli").fadeOut(3);
$("#popquanlist").addClass("dn");
forminit();
$("#showaddrQ").val("");
$("#inp_province").val("");
$("#inp_city").val("");
$("#inp_district").val("");
$("#inp_twon").val("");
}
/*---表单初始化---*/
function forminit() {
$("#popseleaddid").val("");
$("#consignee").val("");
$("#mobile").val("");
$("#province").val("0");
$("#city").html("<option value='0'>请选择</option>");
$('#district').html("<option value='0'>请选择</option>");
$("#twon").css("display", "none");
$("#address").val("");
$("#zipcode").val("");
}
//新增,编辑收货地址提交
function updateaddr() {
var consignee = $("#consignee").val();
if (consignee == "") {
layer.open({content: "请输入收货人名字", time: 1});
return;
}
var mobile = $("#mobile").val();
if (mobile == "") {
layer.open({content: "请输入手机", time: 1});
return;
}
if (!checkMobile(mobile)) {
layer.open({content: "请输入正确的手机", time: 1});
return;
}
var province = $("#province").val();
if (province == "" || province == "0") {
layer.open({content: "请选择省份", time: 1});
return;
}
var city = $("#city").val();
if (city == "" || city == "0") {
layer.open({content: "请选择城市", time: 1});
return;
}
/*---
var district = $("#district").val();
if (district == "" || district == "0") {
layer.open({content: "请选择县,区", time: 1});
return;
}--*/
var address = $("#address").val();
if (address == "") {
layer.open({content: "请输入详细地址", time: 1});
return;
}
var zipcode = $("#zipcode").val();
// if (zipcode == "") {
// layer.open({content: "请输入邮编", time: 1});
// return;
// }
var id = $("#address_id").val();
var mi = layer.open({type: 2, shadeClose: false});
$.ajax({
type: "get",
url: '/index.php?m=Mobile&c=Cart&a=add_address&stoid=' + getstoid + "&seleid=" + id,
data: $('#addrform').serialize(),
dataType: "json",
success: function (data) {
layer.close(mi);
if (data.code == 1) {
$("#popaddlist").html(data.data);
if (data.fir == 0) {
$("#layeraddr").addClass("dn");
$("body").css("overflow", "auto");
var addr1 = $("#showaddrQ").val();
var htm = "<div id='faddrshow' class='address-info'><p class='address-name'>收货人:" + consignee + "</p><p class='address-phone'>手机:" + mobile + "</p></div><div class='address-details'>收货地址:" + addr1 + " " + address + "</div><input id='address_id' type='hidden' value='" + data.id + "' name='address_id'/>";
$("#newadd").html(htm);
$("#newadd").removeClass("dn");
$("#faddmone").addClass("dn");
ajax_order_price();
reg_mobile=mobile;
} else {
addressList();
/*---编辑OK之后,主页上的地址也要修改--*/
if ($("#address_id").val() == $("#popseleaddid").val()) {
var addr1 = $("#showaddrQ").val();
var htm = "<div id='faddrshow' class='address-info'><p class='address-name'>收货人:" + consignee + "</p><p class='address-phone'>手机:" + mobile + "</p></div><div class='address-details'>收货地址:" + addr1 + " " + address + "</div><input id='address_id' type='hidden' value='" + $("#popseleaddid").val()+ "' name='address_id'/>";
$("#newadd").html(htm);
ajax_order_price();
}
}
}
},
error: function () {
layer.open({
content: '网络异常',
time: 2
});
}
});
}
/*------设置要使用的地址------*/
function selectto(ob) {
var id = $(ob).attr("aid");
var consignee = $(ob).find(".address_add").find(".popdata").find(".popconsignee").text();
var mobile = $(ob).find(".address_add").find(".popdata").find(".popmobile").text();
var addrstr = $(ob).find(".address_add").find(".popdata").find(".popaddstr").text();
/*--列表中的勾选修改--*/
$(ob).parent().find('li').each(function () {
var aid = $(this).attr("aid");
if (id != aid) {
$(this).find(".address_add").find("h2").find("img").attr("src", "__STATIC__/images/flow/c_checkbox_off.png");
}
});
$(ob).find(".address_add").find("h2").find("img").attr("src", "__STATIC__/images/right.png");
var htm = "<div id='faddrshow' class='address-info'><p class='address-name'>收货人:" + consignee + "</p><p class='address-phone'>手机:" + mobile + "</p></div><div class='address-details'>收货地址:" + addrstr + "</div><input id='address_id' type='hidden' value='" + id + "' name='address_id'/>"
/*--填充--*/
$("#newadd").html(htm);
/*--关闭弹窗--*/
$("#layeraddr").addClass("dn");
$("body").css("overflow", "auto");
ajax_order_price();
}
/*--删除收货地址--*/
function deladdr() {
var id = $("#address_id").val();
var i = layer.open({
content: '确定要删除吗?!',
btn: ['确定', '取消'],
yes: function () {
layer.close(i);
var mm = layer.open({
type: 2
});
$.ajax({
type: "POST",
url: '/index.php?m=Mobile&c=Cart&a=del_address&stoid=' + getstoid + '&id=' + $("#popseleaddid").val() + "&seleid=" + id,
dataType: "json",
success: function (data) {
layer.close(mm);
if (data.code == 1) {
$("#popaddlist").html(data.data);
if (data.address2 != undefined && data.address2 != "") {
if ($("#address_id").val() == $("#popseleaddid").val()) {
var row = data.address2;
var htm = "<div id='faddrshow' class='address-info'><p class='address-name'>收货人:" + row.consignee + "</p><p class='address-phone'>手机:" + row.mobile + "</p></div><div class='address-details'>收货地址:" + row.addrstr + "</div><input id='address_id' type='hidden' value='" + row.id + "' name='address_id'/>";
$("#newadd").html(htm);
}
addressList();
} else {
$("#layeraddr").addClass("dn");
$("body").css("overflow", "auto");
$("#faddmone").removeClass("dn");
$("#newadd").addClass("dn");
$("#newadd").html("");
}
ajax_order_price();
} else {
layer.open({content: "删除失败", time: 2});
}
},
error: function () {
layer.open({
content: '网络异常',
time: 2
});
}
});
}, no: function () {
}
});
}
/*----------------------------------------------------------------------------------*/
// 获取订单价格
function ajax_order_price() {
//地址没添加的时候,取消所有的包邮券
if($("#address_id").length==0){
$("#is_set_by").val("0"); //已经设置包邮0
$("li.byq").remove();
$(".namespan").each(function () {
if ($(this).text() == '包邮券') {
$(this).text('');
$(this).prev().val('');
$(this).parent().next().attr('obsele', "");
}
});
}
var mm = layer.open({
type: 2,
shadeClose: false
});
$.ajax({
type: "POST",
url: '/index.php?m=Mobile&c=Cart&a=cart3_wk&stoid=' + getstoid + '&t=' + Math.random() + "&exptype=" + exptype,
data: $('#cart2_form').serialize(),
dataType: "json",
success: function (data) {
layer.close(mm);
if (data.code !=0) {
$("#fsub_btn").removeAttr('onclick');
$("#fsub_btn").css('background-color','gainsboro');
layer.open({
content: data.msg, time: 2
});
return false;
}
$("#wk_money").text(data.tmoney); // 物流费
$("#postFee").text(data.shipping_price); // 使用余额
$("#payables").text(data.all_money); // 应付尾款
$("#tprice").text(data.tprice); // 应付尾款
$("#cnum").text(data.cnum); // 应付尾款
},
error: function () {
layer.open({
content: '网络异常',
time: 2
});
}
});
}
// 提交订单
var ajax_return_status = 1; // 标识ajax 请求是否已经回来 可以进行下一次请求
function submit_order() {
//$("#fsub_btn").fadeOut(3);
//$("#fsubing").fadeIn(3);
var ordno = $("#back_ordno").val();
if ($.trim(ordno) != "") {
location.href = '/Mobile/Payment/getCode.html?orderno=' + data.result + '&stoid=' + getstoid;
return;
}
/*--确保收货人有--*/
if (exptype == 2) {
var setadd = $("#setadd").val();
if (setadd == "1") {
var name = $("#consignee").val();
if (name == "") {
layer.open({content: '请输入收货人姓名', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
name = $("#mobile").val();
if (name == "") {
layer.open({content: '请输入收货人手机', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
if (!checkMobile(name)) {
layer.open({content: '请输入正确格式的手机号码', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
name = $("#province").val();
if (name == "" || name == "0") {
layer.open({content: '请选择省份', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
name = $("#city").val();
if (name == "" || name == "0") {
layer.open({content: '请选择城市', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
name = $("#address").val();
if (name == "") {
layer.open({content: '请填写详细地址', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
} else {
var addid = $("input[name='address_id']").val();
if (addid == "" || addid == undefined || addid == null) {
layer.open({content: '未找到收货人', time: 1});
$("#fsub_btn").fadeIn(3);
$("#fsubing").fadeOut(3);
return;
}
}
}
//alert($('#cart2_form').serialize() + "&act=submit_order");
var ii = layer.open({
type: 2,
content: '提交中',
shadeClose: false
});
$.ajax({
type: "POST",
url: "{:U('Mobile/Cart/cart3_wk',array('stoid'=>$Think.request.stoid))}?"+$('#cart2_form').serialize() + "&act=submit_order&is_ajax=1",
dataType: "json",
success: function (data) {
var oid=$("#ordsn").val();
layer.close(ii);
if (data.code != 0) {
layer.open({content: data.msg, time: 2}); //执行有误
}else{
var fler=layer.open({
content: '支付尾款:¥'+data.all_money
,btn: ['微信支付', '余额支付']
,yes: function(index, layero){
window.location.href="/Mobile/Payment/getCode_pt.html?orderno=" + oid+ '&stoid=' + getstoid;
}
,no: function(index, layero){
layer.closeAll(fler);
var ii = layer.open({type: 2,shadeClose: false});
$.ajax({
type: "GET",
dataType: "json",
url: "/index.php?m=Mobile&c=team&a=tail_pay&ordsn=" +oid+"&stoid=" + getstoid,//+tab,
success: function (data) {
layer.closeAll(ii);
if (data.code ==1) {
layer.open({content:'支付成功',time:2});
setTimeout(function () {
window.location.href= "/index.php?m=Mobile&c=user&a=order_list&stoid=" + getstoid;
},2000);
}else{
layer.open({content:data.msg,time:2});
}
},
error:function () {
layer.closeAll(ii);
layer.open({content:'网络繁忙',time:2});
}
});
}
});
}
}
});
}
$(".input_class2 li").click(function () {
$(".input_class2 li").each(function(){
$(this).removeClass('active');
});
$(this).toggleClass('active');
$("#vertify").focus();
})
$(".input_class2 li").mouseover(function () {
$(".input_class2 li").each(function(){
$(this).removeClass('active');
});
$(this).toggleClass('active');
$("#vertify").focus();
})
$(".input_class2 li").mouseout(function () {
$(".input_class2 li").each(function(){
$(this).removeClass('active');
});
})
//设置物流方式
function setexptype(ob,ind){
$(ob).parent().find('a').each(function () {
$(this).find('span').removeClass('c_checkbox_on');
});
$(ob).find('span').addClass('c_checkbox_on');
$(ob).parent().find('input').val(ind);
//如果点击的是自提,就要取消包邮券
var obj = $(ob).parent().prev().find('div');
var txt= obj.find('.jmbag').find('.namespan').text();
if (txt== '包邮券' && ind==1) {
obj.find('.jmbag').find('input').val("");
obj.find('.jmbag').find('.namespan').text("");
obj.find('ul').attr("obsele", '');
obj.find('ul').find('.byq').remove();
}
if(ind==1) {
$(ob).parent().parent().find('.fexp').addClass('dn');
}
else {
$(ob).parent().parent().find('.fexp').removeClass('dn');
}
var isshow=0
$('.kuorder_list .order-list').each(function (){
isshow=0;
if(!$(this).find('ul').find('.fexp').hasClass('dn')){
isshow=1; return false;
}
})
if(isshow==1){ $("#fexp").removeClass("dn"); exptype=2;} //物流
else { $("#fexp").addClass("dn");exptype=1;} //自提
ajax_order_price();
}
</script>
</body>
</html>