...
|
...
|
@@ -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.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;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 拼接一条数据的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,6 +163,7 @@ $(function() { |
|
|
});
|
|
|
}
|
|
|
} else { // 修改
|
|
|
if (new RegExp(/^\d{3}[*]{4}\d{4}/).test(info.mobile)) {
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/me/address/update',
|
...
|
...
|
@@ -166,6 +181,28 @@ $(function() { |
|
|
}
|
|
|
}
|
|
|
});
|
|
|
} 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() {
|
|
|
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\'>' + tr.html() + '</tr>');
|
|
|
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');
|
|
|
|
|
|
});
|
|
|
}); |
...
|
...
|
|