...
|
...
|
@@ -16,10 +16,33 @@ var $action = $('.action'), |
|
|
$area = $('.area'),
|
|
|
$footer = $('#yoho-footer'),
|
|
|
$confim = $('.confim-mask'),
|
|
|
$pageWrap = $('.page-wrap'),
|
|
|
$backBtn = $('.nav-back'),
|
|
|
isSubmiting,
|
|
|
deleteId,
|
|
|
currentPage = 'address',
|
|
|
newArea = [];
|
|
|
|
|
|
// 清除原有链接
|
|
|
$backBtn.attr('href', 'javascript:void(0);');
|
|
|
|
|
|
// 自定义事件
|
|
|
$backBtn.on('touchend', function(e) {
|
|
|
if (currentPage === 'edit') {
|
|
|
$pageWrap.hide();
|
|
|
$pageWrap.first().show();
|
|
|
e.preventDefault();
|
|
|
currentPage = 'address';
|
|
|
} else if (currentPage === 'list') {
|
|
|
$pageWrap.hide();
|
|
|
$editAddressPage.show();
|
|
|
e.preventDefault();
|
|
|
currentPage = 'edit';
|
|
|
} else {
|
|
|
window.history.go(-1);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
function editAddress(data) {
|
|
|
data = data || {};
|
|
|
$addressForm.find('[name="id"]').val(data.id || '');
|
...
|
...
|
@@ -28,10 +51,11 @@ function editAddress(data) { |
|
|
$addressForm.find('[name="area_code"]').val(data.areaCode || '');
|
|
|
$addressForm.find('[name="area"]').val(data.area || '');
|
|
|
$addressForm.find('[name="address"]').val(data.address || '');
|
|
|
$editAddressPage.show();
|
|
|
|
|
|
// $addressForm.find('[name="address"]').blur();
|
|
|
// $addressForm.find('[name="consignee"]').focus();
|
|
|
currentPage = 'edit';
|
|
|
$footer.hide();
|
|
|
$pageWrap.hide();
|
|
|
$editAddressPage.show();
|
|
|
}
|
|
|
|
|
|
$confim.on('touchend', '.cancel', function() {
|
...
|
...
|
@@ -130,11 +154,15 @@ $addressForm.on('submit', function() { |
|
|
// 省市区
|
|
|
$area.on('touchend', function() {
|
|
|
$footer.hide();
|
|
|
$pageWrap.hide();
|
|
|
$addressListPage.show();
|
|
|
currentPage = 'list';
|
|
|
});
|
|
|
|
|
|
$addressListPage.on('touchend', '.address', function() {
|
|
|
newArea.push($(this).children('.caption').text());
|
|
|
var caption = $(this).children('.caption').text();
|
|
|
|
|
|
newArea.push(caption);
|
|
|
$(this).siblings().hide();
|
|
|
$(this).children('ul').show();
|
|
|
return false;
|
...
|
...
|
@@ -145,11 +173,13 @@ $addressListPage.on('touchend', '.address', function() { |
|
|
$('[name="area"]').val(newArea.join(' '));
|
|
|
$('[name="area_code"]').val($(this).data('id'));
|
|
|
|
|
|
$editAddressPage.show();
|
|
|
currentPage = 'edit';
|
|
|
|
|
|
// 恢复默认的三级选择
|
|
|
$addressListPage.hide();
|
|
|
$addressListPage.find('ul').hide();
|
|
|
$addressListPage.children('ul').show().children('li').show();
|
|
|
$footer.show();
|
|
|
newArea = [];
|
|
|
return false;
|
|
|
}); |
...
|
...
|
|