Authored by 毕凯

Merge branch 'feature/address4' into 'release/5.4.1'

去掉旧的地址加载



See merge request !241
... ... @@ -4,7 +4,6 @@
* @date: 2015/11/30
*/
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
tip = require('../plugin/tip'),
security = require('../plugin/security'),
loading = require('../plugin/loading');
... ... @@ -19,8 +18,7 @@ var $addressForm = $('.edit-address'),
navTitle = $navTitle.html(),
$area = $('.area'),
isSubmiting,
currentPage = 'edit',
newArea = [];
currentPage = 'edit';
var Vue = require('vue');
var vueAddressAct = require('home/address/address-act.vue');
... ... @@ -54,7 +52,6 @@ $backBtn.on('touchend', function(e) {
$addressListPage.hide();
$addressListPage.find('ul').hide().find('li').removeClass('highlight');
$addressListPage.children('ul').show().children('li').show();
newArea = [];
} else {
window.history.go(-1);
}
... ... @@ -138,75 +135,7 @@ $submit.on('touchend', function() {
$(this).removeClass('highlight');
});
function bindAddressListEvent(html) {
$addressListPage.html(html);
// 省市区
$area.on('touchend', function() {
addressVact.$children[0].show = true;
});
// touchend 在下滑的时候会触发
// 省市区联动
$addressListPage.find('.address').each(function(i, elem) {
var addressHammer = new Hammer(elem);
addressHammer.on('tap', function(e) {
var $this = $(e.target);
if (e.target.tagName.toLowerCase() !== 'li') {
$this = $this.parent('li');
}
newArea.push($this.children('.caption').text().trim());
$this.siblings().hide();
$this.children('ul').show().children('li').show();
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.text().trim());
$('[name="area"]').val(newArea.join(' '));
$('[name="area_code"]').val($this.data('id'));
$editAddressPage.show();
currentPage = 'edit';
$navTitle.html(navTitle);
// 恢复默认的三级选择
$addressListPage.hide();
$addressListPage.find('ul').hide().find('li').removeClass('highlight');
$addressListPage.children('ul').show().children('li').show();
newArea = [];
e.srcEvent.preventDefault();
e.srcEvent.stopPropagation();
});
});
$addressListPage.on('touchstart', 'li', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
}
// 省市区列表异步加载
$.ajax({
method: 'GET',
url: '/home/locationList',
timeout: 60000,
cache: true
}).then(function(html) {
bindAddressListEvent(html);
}).fail(function() {
tip.show('获取省市区列表失败');
// 省市区
$area.on('touchend', function() {
addressVact.$children[0].show = true;
});
... ...