Authored by 毕凯

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

@@ -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,9 +125,13 @@ $area.on('touchend', function() { @@ -119,9 +125,13 @@ $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) { 128 +// 省市区列表异步加载
  129 +$.get('/home/locationList').then(function(html) {
  130 + $addressListPage.html(html);
  131 +
  132 + // touchend 在下滑的时候会触发
  133 + // 省市区联动
  134 + $addressListPage.find('.address').each(function(i, elem) {
125 var addressHammer = new Hammer(elem); 135 var addressHammer = new Hammer(elem);
126 136
127 addressHammer.on('tap', function(e) { 137 addressHammer.on('tap', function(e) {
@@ -134,9 +144,9 @@ $addressListPage.find('.address').each(function(i, elem) { @@ -134,9 +144,9 @@ $addressListPage.find('.address').each(function(i, elem) {
134 e.srcEvent.preventDefault(); 144 e.srcEvent.preventDefault();
135 e.srcEvent.stopPropagation(); 145 e.srcEvent.stopPropagation();
136 }); 146 });
137 -}); 147 + });
138 148
139 -$addressListPage.find('.address-last').each(function(i, elem) { 149 + $addressListPage.find('.address-last').each(function(i, elem) {
140 var addressLastHammer = new Hammer(elem); 150 var addressLastHammer = new Hammer(elem);
141 151
142 addressLastHammer.on('tap', function(e) { 152 addressLastHammer.on('tap', function(e) {
@@ -161,16 +171,13 @@ $addressListPage.find('.address-last').each(function(i, elem) { @@ -161,16 +171,13 @@ $addressListPage.find('.address-last').each(function(i, elem) {
161 e.srcEvent.preventDefault(); 171 e.srcEvent.preventDefault();
162 e.srcEvent.stopPropagation(); 172 e.srcEvent.stopPropagation();
163 }); 173 });
164 -}); 174 + });
165 175
166 -$addressListPage.on('touchstart', 'li', function() { 176 + $addressListPage.on('touchstart', 'li', function() {
167 $(this).addClass('highlight'); 177 $(this).addClass('highlight');
168 -}).on('touchend touchcancel', 'li', function() { 178 + }).on('touchend touchcancel', 'li', function() {
169 $(this).removeClass('highlight'); 179 $(this).removeClass('highlight');
170 -});  
171 -  
172 -$('input, textarea').on('focus', function() {  
173 - $footer.hide();  
174 -}).on('blur', function() {  
175 - $footer.show(); 180 + });
  181 +}).fail(function() {
  182 + tip.show('获取省市区列表失败');
176 }); 183 });
@@ -28,5 +28,7 @@ @@ -28,5 +28,7 @@
28 确认 28 确认
29 </div> 29 </div>
30 </div> 30 </div>
  31 + <div class="my-address-list-page page-wrap hide">
  32 + </div>
31 </div> 33 </div>
32 {{> layout/footer}} 34 {{> layout/footer}}
1 -<div class="my-address-list-page page-wrap hide">  
2 - <ul class="address-list">  
3 - {{# addressList}} 1 +<ul class="address-list">
  2 +{{# addressList}}
4 <li class="address"> 3 <li class="address">
5 <span class="caption">{{caption}}</span> 4 <span class="caption">{{caption}}</span>
6 <span class="iconfont">&#xe604;</span> 5 <span class="iconfont">&#xe604;</span>
@@ -20,6 +19,5 @@ @@ -20,6 +19,5 @@
20 {{/ sub}} 19 {{/ sub}}
21 </ul> 20 </ul>
22 </li> 21 </li>
23 - {{/ addressList}}  
24 - </ul>  
25 -</div>  
  22 +{{/ addressList}}
  23 +</ul>