|
@@ -13,11 +13,11 @@ var $addressForm = $('.edit-address'), |
|
@@ -13,11 +13,11 @@ var $addressForm = $('.edit-address'), |
13
|
$submit = $('.submit'),
|
13
|
$submit = $('.submit'),
|
14
|
$editAddressPage = $('.my-edit-address-page'),
|
14
|
$editAddressPage = $('.my-edit-address-page'),
|
15
|
$addressListPage = $('.my-address-list-page'),
|
15
|
$addressListPage = $('.my-address-list-page'),
|
16
|
- $area = $('.area'),
|
|
|
17
|
$footer = $('#yoho-footer'),
|
16
|
$footer = $('#yoho-footer'),
|
18
|
$backBtn = $('.nav-back'),
|
17
|
$backBtn = $('.nav-back'),
|
19
|
$navTitle = $('.nav-title'),
|
18
|
$navTitle = $('.nav-title'),
|
20
|
navTitle = $navTitle.html(),
|
19
|
navTitle = $navTitle.html(),
|
|
|
20
|
+ $area = $('.area'),
|
21
|
isSubmiting,
|
21
|
isSubmiting,
|
22
|
currentPage = 'edit',
|
22
|
currentPage = 'edit',
|
23
|
newArea = [];
|
23
|
newArea = [];
|
|
@@ -109,6 +109,12 @@ $submit.on('touchend', function() { |
|
@@ -109,6 +109,12 @@ $submit.on('touchend', function() { |
109
|
$(this).removeClass('highlight');
|
109
|
$(this).removeClass('highlight');
|
110
|
});
|
110
|
});
|
111
|
|
111
|
|
|
|
112
|
+$('input, textarea').on('focus', function() {
|
|
|
113
|
+ $footer.hide();
|
|
|
114
|
+}).on('blur', function() {
|
|
|
115
|
+ $footer.show();
|
|
|
116
|
+});
|
|
|
117
|
+
|
112
|
// 省市区
|
118
|
// 省市区
|
113
|
$area.on('touchend', function() {
|
119
|
$area.on('touchend', function() {
|
114
|
$editAddressPage.hide();
|
120
|
$editAddressPage.hide();
|
|
@@ -119,58 +125,59 @@ $area.on('touchend', function() { |
|
@@ -119,58 +125,59 @@ $area.on('touchend', function() { |
119
|
$navTitle.html('地区选择');
|
125
|
$navTitle.html('地区选择');
|
120
|
});
|
126
|
});
|
121
|
|
127
|
|
122
|
-// touchend 在下滑的时候会触发
|
|
|
123
|
-// 省市区联动
|
|
|
124
|
-$addressListPage.find('.address').each(function(i, elem) {
|
|
|
125
|
- var addressHammer = new Hammer(elem);
|
128
|
+// 省市区列表异步加载
|
|
|
129
|
+$.get('/home/locationList').then(function(html) {
|
|
|
130
|
+ $addressListPage.html(html);
|
|
|
131
|
+
|
|
|
132
|
+ // touchend 在下滑的时候会触发
|
|
|
133
|
+ // 省市区联动
|
|
|
134
|
+ $addressListPage.find('.address').each(function(i, elem) {
|
|
|
135
|
+ var addressHammer = new Hammer(elem);
|
126
|
|
136
|
|
127
|
- addressHammer.on('tap', function(e) {
|
|
|
128
|
- var $this = $(e.target);
|
137
|
+ addressHammer.on('tap', function(e) {
|
|
|
138
|
+ var $this = $(e.target);
|
129
|
|
139
|
|
130
|
- newArea.push($this.children('.caption').text());
|
|
|
131
|
- $this.siblings().hide();
|
|
|
132
|
- $this.children('ul').show().children('li').show();
|
140
|
+ newArea.push($this.children('.caption').text());
|
|
|
141
|
+ $this.siblings().hide();
|
|
|
142
|
+ $this.children('ul').show().children('li').show();
|
133
|
|
143
|
|
134
|
- e.srcEvent.preventDefault();
|
|
|
135
|
- e.srcEvent.stopPropagation();
|
144
|
+ e.srcEvent.preventDefault();
|
|
|
145
|
+ e.srcEvent.stopPropagation();
|
|
|
146
|
+ });
|
136
|
});
|
147
|
});
|
137
|
-});
|
|
|
138
|
|
148
|
|
139
|
-$addressListPage.find('.address-last').each(function(i, elem) {
|
|
|
140
|
- var addressLastHammer = new Hammer(elem);
|
149
|
+ $addressListPage.find('.address-last').each(function(i, elem) {
|
|
|
150
|
+ var addressLastHammer = new Hammer(elem);
|
141
|
|
151
|
|
142
|
- addressLastHammer.on('tap', function(e) {
|
|
|
143
|
- var $this = $(e.target);
|
152
|
+ addressLastHammer.on('tap', function(e) {
|
|
|
153
|
+ var $this = $(e.target);
|
144
|
|
154
|
|
145
|
- // 填结果到 html
|
|
|
146
|
- newArea.push($this.children('.caption').text());
|
|
|
147
|
- $('[name="area"]').val(newArea.join(' '));
|
|
|
148
|
- $('[name="area_code"]').val($this.data('id'));
|
155
|
+ // 填结果到 html
|
|
|
156
|
+ newArea.push($this.children('.caption').text());
|
|
|
157
|
+ $('[name="area"]').val(newArea.join(' '));
|
|
|
158
|
+ $('[name="area_code"]').val($this.data('id'));
|
149
|
|
159
|
|
150
|
- $editAddressPage.show();
|
|
|
151
|
- currentPage = 'edit';
|
|
|
152
|
- $navTitle.html(navTitle);
|
|
|
153
|
- $footer.show();
|
160
|
+ $editAddressPage.show();
|
|
|
161
|
+ currentPage = 'edit';
|
|
|
162
|
+ $navTitle.html(navTitle);
|
|
|
163
|
+ $footer.show();
|
154
|
|
164
|
|
155
|
- // 恢复默认的三级选择
|
|
|
156
|
- $addressListPage.hide();
|
|
|
157
|
- $addressListPage.find('ul').hide().find('li').removeClass('highlight');
|
|
|
158
|
- $addressListPage.children('ul').show().children('li').show();
|
|
|
159
|
- newArea = [];
|
165
|
+ // 恢复默认的三级选择
|
|
|
166
|
+ $addressListPage.hide();
|
|
|
167
|
+ $addressListPage.find('ul').hide().find('li').removeClass('highlight');
|
|
|
168
|
+ $addressListPage.children('ul').show().children('li').show();
|
|
|
169
|
+ newArea = [];
|
160
|
|
170
|
|
161
|
- e.srcEvent.preventDefault();
|
|
|
162
|
- e.srcEvent.stopPropagation();
|
171
|
+ e.srcEvent.preventDefault();
|
|
|
172
|
+ e.srcEvent.stopPropagation();
|
|
|
173
|
+ });
|
163
|
});
|
174
|
});
|
164
|
-});
|
|
|
165
|
-
|
|
|
166
|
-$addressListPage.on('touchstart', 'li', function() {
|
|
|
167
|
- $(this).addClass('highlight');
|
|
|
168
|
-}).on('touchend touchcancel', 'li', function() {
|
|
|
169
|
- $(this).removeClass('highlight');
|
|
|
170
|
-});
|
|
|
171
|
|
175
|
|
172
|
-$('input, textarea').on('focus', function() {
|
|
|
173
|
- $footer.hide();
|
|
|
174
|
-}).on('blur', function() {
|
|
|
175
|
- $footer.show();
|
176
|
+ $addressListPage.on('touchstart', 'li', function() {
|
|
|
177
|
+ $(this).addClass('highlight');
|
|
|
178
|
+ }).on('touchend touchcancel', 'li', function() {
|
|
|
179
|
+ $(this).removeClass('highlight');
|
|
|
180
|
+ });
|
|
|
181
|
+}).fail(function() {
|
|
|
182
|
+ tip.show('获取省市区列表失败');
|
176
|
}); |
183
|
}); |