diff --git a/public/themes/simpleboot3/cart/zj_cart/order_confirm.html b/public/themes/simpleboot3/cart/zj_cart/order_confirm.html index be5a955..ad58184 100644 --- a/public/themes/simpleboot3/cart/zj_cart/order_confirm.html +++ b/public/themes/simpleboot3/cart/zj_cart/order_confirm.html @@ -471,7 +471,8 @@ <input type="text" placeholder="请填写联系电话" class="detailplace"> </div> </div> - <div class="save">保存</div> + <div class="save newsave">保存</div> + <div class="save editsave" style="display:none">保存</div> </div> <!--选择地址--> <div class="addresswrapper" style="display:none"> @@ -757,8 +758,20 @@ }) $(".wrapper").click(function(){ $(this).css("display","none") + }); + + //新增收获地址 + $(".addplace").click(function(){ + $(".addpositionwrapper").css("display","block") + $(".newsave").css("display","block"); + $(".editsave").css("display","none") }) + $(".addressplus").click(function(){ + $(".addpositionwrapper").css("display","block") + $(".newsave").css("display","block"); + $(".editsave").css("display","none") + }) //选择地址 $(".people_info").click(function(){ $(".addresswrapper").css("display","block") @@ -803,13 +816,108 @@ //编辑地址 $(".edit").click(function(){ window.event.stopPropagation(); + $(".newsave").css("display","none"); + $(".editsave").css("display","block") $(".addresswrapper").css("display","none"); - $(".addpositionwrapper").css("display","block") + $(".addpositionwrapper").css("display","block"); + var data_id=$(this).children(".defauledi").attr("data-id"); + var url = 'address/Place/edit/'; + var params = { + id:data_id + }; + ajaxsend(url, params, function(res) { + console.log(res); + var data=res.data; + var cityval=data.province+" "+data.city +" "+ data.county; + console.log(cityval); + $("#end").val(cityval); + $("#place").val(data.place); + $("#name").val(data.name); + $("#phone").val(data.mobile); + }) + + + }); + //编辑地址(保存地址) + $(".editsave").click(function(){ + window.event.stopPropagation(); + // $(".addpositionwrapper").css("display","none"); + var name=$("#name").val(); + var phone=$("#phone").val(); + var place=$("#place").val(); + //省市区的id + var code=$("#end").attr("data-codes"); + //省市区 + var label=$("#end").val(); + + var url = 'address/Place/editDo'; + var params = { + name:name, + mobile:phone, + code:code, + label:label, + place:place, + uid:'{$uid}' + }; + ajaxsend(url, params, function(res) { + console.log(res); + if(res.code=="20000"){ + $(".addpositionwrapper").css("display","none") + }else{ + alert("保存失败") + } + }) }) - //保存地址 - $(".save").click(function(){ + //保存地址 (新增地址) + $(".newsave").click(function(){ window.event.stopPropagation(); - $(".addpositionwrapper").css("display","none") + // $(".addpositionwrapper").css("display","none"); + var name=$("#name").val(); + var phone=$("#phone").val(); + var place=$("#place").val(); + //省市区的id + var code=$("#end").attr("data-codes"); + //省市区 + var label=$("#end").val(); + if(label==""){ + alert("请选择省市区"); + return false; + } + if(place==""){ + alert("请选择详细地址"); + return false; + } + if(name==""){ + alert("请填写收获人姓名"); + return false; + } + if(phone==""){ + alert("请填写联系电话"); + return false; + } + var reg = /^1[34578]\d{9}$/; + if(!reg.test(phone)){ + alert("请输入正确的手机号"); + return false; + } + var url = 'address/Place/add'; + var params = { + name:name, + mobile:phone, + code:code, + label:label, + place:place, + uid:'{$uid}' + }; + ajaxsend(url, params, function(res) { + console.log(res); + if(res.code=="20000"){ + $(".addpositionwrapper").css("display","none") + }else{ + alert("保存失败") + } + }) + }) //选择地址 $(".people_info").click(function(){ @@ -817,17 +925,34 @@ $(".addresswrapper").css("display","block") }) //删除地址 + var del_id=""; $(".delect").click(function(){ window.event.stopPropagation(); + del_id=$(this).children(".defaultdel").attr("data-id") - $(".deletewrapper").show() - }) + $(".deletewrapper").show(); + + }); //删除确定 $(".sure").click(function(){ window.event.stopPropagation(); + var url = 'address/Place/del'; + var params = { + id:del_id + }; + ajaxsend(url, params, function(res) { + console.log(res); + if(res.code==20000){ + alert("删除成功"); + }else if(res.code==40000){ + alert("删除失败"); + } + + }) $(".deletewrapper").css("display","none") - }) + }); + $(".cancel").click(function(){ window.event.stopPropagation(); $(".addresswrapper").show()