...
|
...
|
@@ -37,10 +37,12 @@ $(function() { |
|
|
|
|
|
return {
|
|
|
id: $addressId.val(),
|
|
|
aid: $('#tr_' + $addressId.val()).data('addressid'),
|
|
|
consignee: $consignee.val(),
|
|
|
address: $address.val(),
|
|
|
mobile: $mobile.val(),
|
|
|
phone: $phone.val()
|
|
|
phone: $phone.val(),
|
|
|
default: $('#tr_' + $addressId.val()).data('default') === 'true'
|
|
|
};
|
|
|
},
|
|
|
|
...
|
...
|
@@ -87,16 +89,20 @@ $(function() { |
|
|
getHtml: function(info) {
|
|
|
var html = '<tr class="table-body">';
|
|
|
|
|
|
html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' +
|
|
|
html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id +
|
|
|
'" data-addressid="' + info.aid + '">' +
|
|
|
'<input type="hidden" id="tr_' + info.area_code + '" value="' + info.area_code + '">' +
|
|
|
'<td class=\'width-name\'>' + info.consignee + '</td>' +
|
|
|
'<td class=\'width-address\'>' + info.area + '</td>' +
|
|
|
'<td class=\'width-fulladdress\'>' + info.address + '</td>' +
|
|
|
'<td class=\'width-mobile\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' +
|
|
|
'<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 set\' data-id=\'' + info.address_id + '\'>设为默认</span>' +
|
|
|
info.address_id + '\'>修改</span>\n<em class="op-sep">|</em>\n';
|
|
|
if (!info.default) {
|
|
|
html += '<span class=\'blue opreation del-address\' data-id=\'' + info.aid + '\'>删除</span>\n';
|
|
|
}
|
|
|
|
|
|
html += '<span class=\'btn set-default opreation set\' data-id=\'' + info.aid + '\'>设为默认</span>' +
|
|
|
'</div></td>';
|
|
|
html += '</tr>';
|
|
|
return html;
|
...
|
...
|
@@ -123,7 +129,7 @@ $(function() { |
|
|
$(document).on('click', '#save-address', function() {
|
|
|
var info,
|
|
|
area,
|
|
|
areaInfo;
|
|
|
areaInfo, info2;
|
|
|
|
|
|
info = Bll.getInfo();
|
|
|
area = address.getAreaIds();
|
...
|
...
|
@@ -132,8 +138,14 @@ $(function() { |
|
|
info.area_code = area.split(',')[2];
|
|
|
info.area = areaInfo.split(',').join(' ');
|
|
|
|
|
|
info2 = $.extend({}, info);
|
|
|
info2.id = info.aid;
|
|
|
delete info2.aid;
|
|
|
|
|
|
if (Bll.check(info) === true) {
|
|
|
|
|
|
console.log(info.id);
|
|
|
|
|
|
// 新增
|
|
|
if (info.id === '') {
|
|
|
if (currentLength >= 7) {
|
...
|
...
|
@@ -146,16 +158,8 @@ $(function() { |
|
|
dataType: 'json',
|
|
|
data: info,
|
|
|
success: function(data) {
|
|
|
var html;
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
html = Bll.getHtml(data.data);
|
|
|
|
|
|
currentLength++;
|
|
|
leftLength--;
|
|
|
$('tbody').append(html);
|
|
|
Bll.setTableTile();
|
|
|
Bll.clearInput();
|
|
|
location.reload();
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
}
|
...
|
...
|
@@ -168,14 +172,10 @@ $(function() { |
|
|
type: 'POST',
|
|
|
url: '/me/address/update',
|
|
|
dataType: 'json',
|
|
|
data: info,
|
|
|
data: info2,
|
|
|
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).parents('tr').before(Bll.getHtml(info)).remove();
|
|
|
Bll.clearInput();
|
|
|
$('.tip em').html('新增地址');
|
|
|
location.reload();
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
}
|
...
|
...
|
@@ -187,14 +187,10 @@ $(function() { |
|
|
type: 'POST',
|
|
|
url: '/me/address/update',
|
|
|
dataType: 'json',
|
|
|
data: info,
|
|
|
data: info2,
|
|
|
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).parents('tr').before(Bll.getHtml(info)).remove();
|
|
|
Bll.clearInput();
|
|
|
$('.tip em').html('新增地址');
|
|
|
location.reload();
|
|
|
} else {
|
|
|
new _alert(data.message).show();
|
|
|
}
|
...
|
...
|
@@ -206,8 +202,6 @@ $(function() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
$('#address_id').val('');
|
|
|
|
|
|
});
|
|
|
|
|
|
// 修改收货地址
|
...
|
...
|
|