|
@@ -21,6 +21,7 @@ var $addressForm = $('.edit-address'), |
|
@@ -21,6 +21,7 @@ var $addressForm = $('.edit-address'), |
21
|
isSubmiting,
|
21
|
isSubmiting,
|
22
|
currentPage = 'edit',
|
22
|
currentPage = 'edit',
|
23
|
newArea = [],
|
23
|
newArea = [],
|
|
|
24
|
+ chinaAddressList,
|
24
|
queryString = $.queryString();
|
25
|
queryString = $.queryString();
|
25
|
|
26
|
|
26
|
$($editAddressPage, $addressListPage).css('min-height', function() {
|
27
|
$($editAddressPage, $addressListPage).css('min-height', function() {
|
|
@@ -118,12 +119,7 @@ $submit.on('touchend', function() { |
|
@@ -118,12 +119,7 @@ $submit.on('touchend', function() { |
118
|
$(this).removeClass('highlight');
|
119
|
$(this).removeClass('highlight');
|
119
|
});
|
120
|
});
|
120
|
|
121
|
|
121
|
-// 省市区列表异步加载
|
|
|
122
|
-$.ajax({
|
|
|
123
|
- method: 'GET',
|
|
|
124
|
- url: '/home/locationList',
|
|
|
125
|
- timeout: 60000
|
|
|
126
|
-}).then(function(html) {
|
122
|
+function bindAddressListEvent(html) {
|
127
|
$addressListPage.html(html);
|
123
|
$addressListPage.html(html);
|
128
|
|
124
|
|
129
|
// 省市区
|
125
|
// 省市区
|
|
@@ -185,6 +181,27 @@ $.ajax({ |
|
@@ -185,6 +181,27 @@ $.ajax({ |
185
|
}).on('touchend touchcancel', 'li', function() {
|
181
|
}).on('touchend touchcancel', 'li', function() {
|
186
|
$(this).removeClass('highlight');
|
182
|
$(this).removeClass('highlight');
|
187
|
});
|
183
|
});
|
188
|
-}).fail(function() {
|
184
|
+}
|
|
|
185
|
+
|
|
|
186
|
+// 读取省市区列表缓存
|
|
|
187
|
+if (window.localStorage && window.localStorage.getItem) {
|
|
|
188
|
+ chinaAddressList = window.localStorage.getItem('chinaAddressList');
|
|
|
189
|
+}
|
|
|
190
|
+if (chinaAddressList) {
|
|
|
191
|
+ bindAddressListEvent(chinaAddressList);
|
|
|
192
|
+} else {
|
|
|
193
|
+
|
|
|
194
|
+ // 省市区列表异步加载
|
|
|
195
|
+ $.ajax({
|
|
|
196
|
+ method: 'GET',
|
|
|
197
|
+ url: '/home/locationList',
|
|
|
198
|
+ timeout: 60000
|
|
|
199
|
+ }).then(function(html) {
|
|
|
200
|
+ bindAddressListEvent(html);
|
|
|
201
|
+ if (window.localStorage && window.localStorage.setItem) {
|
|
|
202
|
+ window.localStorage.setItem('chinaAddressList', html);
|
|
|
203
|
+ }
|
|
|
204
|
+ }).fail(function() {
|
189
|
tip.show('获取省市区列表失败');
|
205
|
tip.show('获取省市区列表失败');
|
190
|
-}); |
206
|
+ });
|
|
|
207
|
+} |