...
|
...
|
@@ -59,16 +59,28 @@ $(function() { |
|
|
|
|
|
info.consignee === '' ? $consignee.next().show() : $consignee.next().hide();
|
|
|
info.address === '' ? $address.next().show() : $address.next().hide();
|
|
|
info.mobile === '' ? $mobile.next().show() :
|
|
|
(!reg.test(info.mobile) ? $mobile.next().html('手机号码格式不对').show() : $mobile.next().hide());
|
|
|
typeof (info.area_code) === 'undefined' ?
|
|
|
addressForm.css('margin-bottom', '20px').find('.error-tips').show() :
|
|
|
addressForm.css('margin-bottom', '70px').find('.error-tips').hide();
|
|
|
if (info.consignee === '' || info.address === '' || info.mobile === '' || !reg.test(info.mobile) ||
|
|
|
typeof (info.area_code) === 'undefined') {
|
|
|
flag = false;
|
|
|
if (info.id) {
|
|
|
info.mobile === '' ? $mobile.next().show() : $mobile.next().hide();
|
|
|
|
|
|
if (info.consignee === '' || info.address === '' || info.mobile === '' ||
|
|
|
typeof (info.area_code) === 'undefined') {
|
|
|
flag = false;
|
|
|
}
|
|
|
return flag;
|
|
|
} else {
|
|
|
info.mobile === '' ? $mobile.next().show() :
|
|
|
(!reg.test(info.mobile) ? $mobile.next().html('手机号码格式不对').show() : $mobile.next().hide());
|
|
|
|
|
|
if (info.consignee === '' || info.address === '' || info.mobile === '' || !reg.test(info.mobile) ||
|
|
|
typeof (info.area_code) === 'undefined') {
|
|
|
flag = false;
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
return flag;
|
|
|
|
|
|
},
|
|
|
|
|
|
// 拼接一条数据的html
|
...
|
...
|
@@ -84,7 +96,8 @@ $(function() { |
|
|
'<td class=\'width-opearte\'><div><span class=\'blue opreation update-address\' data-id=\'' +
|
|
|
info.address_id + '\'>修改</span>\n<em class="op-sep">|</em>\n' +
|
|
|
'<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' +
|
|
|
'<span class=\'btn set-default opreation \' data-id=\'' + info.address_id + '\'>设为默认</span></div></td>';
|
|
|
'<span class=\'btn set-default opreation \' data-id=\'' + info.address_id + '\'>设为默认</span>'+
|
|
|
'</div></td>';
|
|
|
html += '</tr>';
|
|
|
return html;
|
|
|
},
|
...
|
...
|
@@ -118,6 +131,7 @@ $(function() { |
|
|
|
|
|
info.area_code = area.split(',')[2];
|
|
|
info.area = areaInfo.split(',').join(' ');
|
|
|
|
|
|
if (Bll.check(info) === true) {
|
|
|
|
|
|
// 新增
|
...
|
...
|
@@ -149,23 +163,46 @@ $(function() { |
|
|
});
|
|
|
}
|
|
|
} else { // 修改
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/me/address/update',
|
|
|
dataType: 'json',
|
|
|
data: info,
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
|
|
|
info.address_id = info.id;
|
|
|
$('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
|
|
|
Bll.clearInput();
|
|
|
$('.tip em').html('新增地址');
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
if (new RegExp(/^\d{3}[*]{4}\d{4}/).test(info.mobile)) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/me/address/update',
|
|
|
dataType: 'json',
|
|
|
data: info,
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
|
|
|
info.address_id = info.id;
|
|
|
$('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
|
|
|
Bll.clearInput();
|
|
|
$('.tip em').html('新增地址');
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
} else if (reg.test(info.mobile)) {
|
|
|
$mobile.next().hide();
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/me/address/update',
|
|
|
dataType: 'json',
|
|
|
data: info,
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
|
|
|
info.address_id = info.id;
|
|
|
$('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
|
|
|
Bll.clearInput();
|
|
|
$('.tip em').html('新增地址');
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
$mobile.next().html('手机号码格式不对').show();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -227,12 +264,29 @@ $(function() { |
|
|
data: {
|
|
|
id: id
|
|
|
},
|
|
|
success: function() {
|
|
|
$('.current-default').removeClass('current-default').text('设为默认');
|
|
|
$(self).addClass('current-default').text('默认地址');
|
|
|
tbody.find('.table-body').eq(0).before('<tr class=\'table-body\'>' + tr.html() + '</tr>');
|
|
|
tr.remove();
|
|
|
success: function(data) {
|
|
|
if (data.code === 200) {
|
|
|
$('.current-default').removeClass('current-default').text('设为默认');
|
|
|
$(self).addClass('current-default').text('默认地址');
|
|
|
tbody.find('.table-body').eq(0).before('<tr class=\'table-body select-row\'>' + tr.html()+
|
|
|
'</tr>');
|
|
|
tr.remove();
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
// 选中某一行
|
|
|
$(document).on('click', '.table-body', function() {
|
|
|
$('.table-body').removeClass('select-row');
|
|
|
$(this).addClass('select-row');
|
|
|
|
|
|
$('.set-default').hide();
|
|
|
$(this).find('.set-default').css('display', 'inline-block');
|
|
|
|
|
|
});
|
|
|
}); |
...
|
...
|
|