Authored by 毕凯

地址修改 省市区列表异步加载

... ... @@ -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,9 +125,13 @@ $area.on('touchend', function() {
$navTitle.html('地区选择');
});
// touchend 在下滑的时候会触发
// 省市区联动
$addressListPage.find('.address').each(function(i, 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) {
... ... @@ -134,9 +144,9 @@ $addressListPage.find('.address').each(function(i, elem) {
e.srcEvent.preventDefault();
e.srcEvent.stopPropagation();
});
});
});
$addressListPage.find('.address-last').each(function(i, elem) {
$addressListPage.find('.address-last').each(function(i, elem) {
var addressLastHammer = new Hammer(elem);
addressLastHammer.on('tap', function(e) {
... ... @@ -161,16 +171,13 @@ $addressListPage.find('.address-last').each(function(i, elem) {
e.srcEvent.preventDefault();
e.srcEvent.stopPropagation();
});
});
});
$addressListPage.on('touchstart', 'li', function() {
$addressListPage.on('touchstart', 'li', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$('input, textarea').on('focus', function() {
$footer.hide();
}).on('blur', function() {
$footer.show();
});
}).fail(function() {
tip.show('获取省市区列表失败');
});
... ...
... ... @@ -28,5 +28,7 @@
确认
</div>
</div>
<div class="my-address-list-page page-wrap hide">
</div>
</div>
{{> layout/footer}}
... ...
<div class="my-address-list-page page-wrap hide">
<ul class="address-list">
{{# addressList}}
<ul class="address-list">
{{# addressList}}
<li class="address">
<span class="caption">{{caption}}</span>
<span class="iconfont">&#xe604;</span>
... ... @@ -20,6 +19,5 @@
{{/ sub}}
</ul>
</li>
{{/ addressList}}
</ul>
</div>
\ No newline at end of file
{{/ addressList}}
</ul>
... ...