You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.2 KiB
HTML

5 years ago
<extend name="Public/bases" />
<block name="body" >
<link href="__CSS__/user.css" rel="stylesheet" >
<body class="">
<header class="header">
<div class="">
<a href="{:U('Shop/useraddresslist',array('id'=>I('id'),'num'=>I('num')))}" class="hbtn back"><i class="iconfont icon-drop-left"></i></a>
<h1 class="caption">添加地址</h1>
<a href="javascript:;" class="hbtn addbtn jssubmit">保存</a>
</div>
</header>
<div class="occupy"></div>
<section class="trunker">
<section class="container">
<form id='form' action="" method="post" class="">
<div class="t-table user-auth-list">
<ul class="table clearfix">
<li class="table-row">
<span class="table-cell">收货人</span>
<span class="table-cell">
<input type="text" class="txt" id="name" name="name" value="" placeholder="请输入姓名">
</span>
</li>
<li class="table-row">
<span class="table-cell">手机</span>
<span class="table-cell">
<input type="text" class="txt" id="phone" name="phone" value="" placeholder="请输入手机号码">
</span>
</li>
<li class="table-row">
<span class="table-cell">省市区</span>
<span class="table-cell">
<input type="text" class="txt" id="city" name="city" value="" placeholder="请选择">
</span>
</li>
<li class="table-row">
<span class="table-cell">详细地址</span>
<span class="table-cell">
<input type="text" class="txt" id="address" name="address" value="" placeholder="请输入详细地址">
</span>
</li>
</ul>
</div>
<notempty name="userData">
<div class="t-table defaultset">
<div class="table">
<div class="table-row">
<span class="table-cell">设为默认地址</span>
<span class="table-cell">
<label class="input-checkbox">
<input type="checkbox" name="is_default" value="1" class="checkbox addr"><i class="iconfont icon-default"></i>
</label>
</span>
</div>
</div>
</div>
</notempty>
<input type="hidden" name="good_id" value="{:I('id')}">
<input type="hidden" name="num" value="{:I('num')}">
</form>
</section>
</section>
<div class="popmsg pop-dialog"></div>
<link rel="stylesheet" href="__CSS__/ydui.css?rev=@@hash">
<!-- <link rel="stylesheet" href="__CSS__/demo.css"> -->
<script type="text/javascript" src="__JS__/ydui.citys.js"></script>
<script type="text/javascript" src="__JS__/ydui.js"></script>
<script src="__JS__/pop.lwx.min.js"></script>
<script>
$(function() {
$('input[type=checkbox]').change(function() {
var that = $(this);
if (that.prop('checked')) {
that.addClass('on');
} else {that.removeClass('on');}
});
$('.jssubmit').click(function() {
var pmsg = $('.popmsg').pop();
if(validation()){
$.ajax({
cache:true,
type:'post',
url:"{:U('Shop/useraddressadd')}",
data:$('#form').serialize(),
dataType:'json',
success:function(result){
pmsg.msg(result.info);
if(result.url !=''){
setTimeout(function () {
window.location.href = result.url;
}, 2000);
}
},
error:function(){
alert("错误")
}
})
}
});
function validation(){
var pmsg = $('.popmsg').pop();
if($.trim($("#name").val()) == ''){
pmsg.msg('请输入姓名');
return false;
}
if($.trim($("#phone").val()) == ''){
pmsg.msg('请输入手机号');
return false;
}
var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
if(!myreg.test($("#phone").val())){
pmsg.msg('请输入有效的手机号码!');
return false;
}
if($.trim($("#city").val()) == ''){
pmsg.msg('请输入城市名称');
return false;
}
if($.trim($("#address").val()) == ''){
pmsg.msg('请输入详细地址');
return false;
}
return true;
}
var $target = $('#city');
$target.citySelect();
$target.on('click', function (event) {
event.stopPropagation();
$target.citySelect('open');
});
$target.on('done.ydui.cityselect', function (ret) {
$(this).val(ret.provance + ' ' + ret.city + ' ' + ret.area);
});
});
</script>
</body>
</block>