...
|
...
|
@@ -16,10 +16,34 @@ 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) {
|
|
|
console.log(currentPage);
|
|
|
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,7 +52,10 @@ 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 || '');
|
|
|
|
|
|
currentPage = 'edit';
|
|
|
$footer.hide();
|
|
|
$pageWrap.hide();
|
|
|
$editAddressPage.show();
|
|
|
}
|
|
|
|
...
|
...
|
@@ -128,11 +155,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;
|
...
|
...
|
@@ -143,11 +174,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;
|
|
|
}); |
...
|
...
|
|