...
|
...
|
@@ -13,11 +13,11 @@ var $addressForm = $('.edit-address'), |
|
|
$submit = $('.submit'),
|
|
|
$editAddressPage = $('.my-edit-address-page'),
|
|
|
$addressListPage = $('.my-address-list-page'),
|
|
|
$area = $('.area'),
|
|
|
$footer = $('#yoho-footer'),
|
|
|
$backBtn = $('.nav-back'),
|
|
|
$navTitle = $('.nav-title'),
|
|
|
navTitle = $navTitle.html(),
|
|
|
$area = $('.area'),
|
|
|
isSubmiting,
|
|
|
currentPage = 'edit',
|
|
|
newArea = [];
|
...
|
...
|
@@ -109,6 +109,12 @@ $submit.on('touchend', function() { |
|
|
$(this).removeClass('highlight');
|
|
|
});
|
|
|
|
|
|
$('input, textarea').on('focus', function() {
|
|
|
$footer.hide();
|
|
|
}).on('blur', function() {
|
|
|
$footer.show();
|
|
|
});
|
|
|
|
|
|
// 省市区
|
|
|
$area.on('touchend', function() {
|
|
|
$editAddressPage.hide();
|
...
|
...
|
@@ -119,58 +125,59 @@ $area.on('touchend', function() { |
|
|
$navTitle.html('地区选择');
|
|
|
});
|
|
|
|
|
|
// touchend 在下滑的时候会触发
|
|
|
// 省市区联动
|
|
|
$addressListPage.find('.address').each(function(i, elem) {
|
|
|
var addressHammer = new Hammer(elem);
|
|
|
// 省市区列表异步加载
|
|
|
$.get('/home/locationList').then(function(html) {
|
|
|
$addressListPage.html(html);
|
|
|
|
|
|
// touchend 在下滑的时候会触发
|
|
|
// 省市区联动
|
|
|
$addressListPage.find('.address').each(function(i, elem) {
|
|
|
var addressHammer = new Hammer(elem);
|
|
|
|
|
|
addressHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target);
|
|
|
addressHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target);
|
|
|
|
|
|
newArea.push($this.children('.caption').text());
|
|
|
$this.siblings().hide();
|
|
|
$this.children('ul').show().children('li').show();
|
|
|
newArea.push($this.children('.caption').text());
|
|
|
$this.siblings().hide();
|
|
|
$this.children('ul').show().children('li').show();
|
|
|
|
|
|
e.srcEvent.preventDefault();
|
|
|
e.srcEvent.stopPropagation();
|
|
|
e.srcEvent.preventDefault();
|
|
|
e.srcEvent.stopPropagation();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$addressListPage.find('.address-last').each(function(i, elem) {
|
|
|
var addressLastHammer = new Hammer(elem);
|
|
|
$addressListPage.find('.address-last').each(function(i, elem) {
|
|
|
var addressLastHammer = new Hammer(elem);
|
|
|
|
|
|
addressLastHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target);
|
|
|
addressLastHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target);
|
|
|
|
|
|
// 填结果到 html
|
|
|
newArea.push($this.children('.caption').text());
|
|
|
$('[name="area"]').val(newArea.join(' '));
|
|
|
$('[name="area_code"]').val($this.data('id'));
|
|
|
// 填结果到 html
|
|
|
newArea.push($this.children('.caption').text());
|
|
|
$('[name="area"]').val(newArea.join(' '));
|
|
|
$('[name="area_code"]').val($this.data('id'));
|
|
|
|
|
|
$editAddressPage.show();
|
|
|
currentPage = 'edit';
|
|
|
$navTitle.html(navTitle);
|
|
|
$footer.show();
|
|
|
$editAddressPage.show();
|
|
|
currentPage = 'edit';
|
|
|
$navTitle.html(navTitle);
|
|
|
$footer.show();
|
|
|
|
|
|
// 恢复默认的三级选择
|
|
|
$addressListPage.hide();
|
|
|
$addressListPage.find('ul').hide().find('li').removeClass('highlight');
|
|
|
$addressListPage.children('ul').show().children('li').show();
|
|
|
newArea = [];
|
|
|
// 恢复默认的三级选择
|
|
|
$addressListPage.hide();
|
|
|
$addressListPage.find('ul').hide().find('li').removeClass('highlight');
|
|
|
$addressListPage.children('ul').show().children('li').show();
|
|
|
newArea = [];
|
|
|
|
|
|
e.srcEvent.preventDefault();
|
|
|
e.srcEvent.stopPropagation();
|
|
|
e.srcEvent.preventDefault();
|
|
|
e.srcEvent.stopPropagation();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$addressListPage.on('touchstart', 'li', function() {
|
|
|
$(this).addClass('highlight');
|
|
|
}).on('touchend touchcancel', 'li', function() {
|
|
|
$(this).removeClass('highlight');
|
|
|
});
|
|
|
|
|
|
$('input, textarea').on('focus', function() {
|
|
|
$footer.hide();
|
|
|
}).on('blur', function() {
|
|
|
$footer.show();
|
|
|
$addressListPage.on('touchstart', 'li', function() {
|
|
|
$(this).addClass('highlight');
|
|
|
}).on('touchend touchcancel', 'li', function() {
|
|
|
$(this).removeClass('highlight');
|
|
|
});
|
|
|
}).fail(function() {
|
|
|
tip.show('获取省市区列表失败');
|
|
|
}); |
...
|
...
|
|