Authored by ccbikai

地址选择使用 hammer

... ... @@ -5,6 +5,7 @@
*/
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
... ... @@ -185,30 +186,48 @@ $area.on('touchend', function() {
currentPage = 'list';
});
// touchend 在下滑的时候会触发
// 省市区联动
$addressListPage.on('touchend', '.address', function() {
newArea.push($(this).children('.caption').text());
$(this).siblings().hide();
$(this).children('ul').show();
return false;
}).on('touchend', '.address-last', function() {
$addressListPage.find('.address').each(function(i, elem) {
var addressHammer = new Hammer(elem);
// 填结果到 html
newArea.push($(this).children('.caption').text());
$('[name="area"]').val(newArea.join(' '));
$('[name="area_code"]').val($(this).data('id'));
addressHammer.on('tap', function(e) {
var $this = $(e.target);
$editAddressPage.show();
currentPage = 'edit';
$navTitle.html('修改地址');
$footer.show();
newArea.push($this.children('.caption').text());
$this.siblings().hide();
$this.children('ul').show().children('li').show();
// 恢复默认的三级选择
$addressListPage.hide();
$addressListPage.find('ul').hide();
$addressListPage.children('ul').show().children('li').show();
newArea = [];
return false;
e.srcEvent.preventDefault();
e.srcEvent.stopPropagation();
});
});
$addressListPage.find('.address-last').each(function(i, elem) {
var addressLastHammer = new Hammer(elem);
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'));
$editAddressPage.show();
currentPage = 'edit';
$navTitle.html('修改地址');
$footer.show();
// 恢复默认的三级选择
$addressListPage.hide();
$addressListPage.find('ul').hide();
$addressListPage.children('ul').show().children('li').show();
newArea = [];
e.srcEvent.preventDefault();
e.srcEvent.stopPropagation();
});
});
$($editAddressPage, $addressListPage).css('min-height', function() {
... ...