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.

140 lines
5.0 KiB
HTML

<extend name="Public/bases" />
<block name="body" >
<link href="__CSS__/user.css" rel="stylesheet" >
<body class="">
<header class="header">
<div class="">
<a href="{:U('User/useraddresslist')}" 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 class="txt" readonly 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>
<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" style="width:100%;height:100px;"><i class="iconfont icon-default"></i>
</label>
</span>
</div>
</div>
</div>
</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]').click(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('User/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>