|
@@ -16,10 +16,34 @@ var $action = $('.action'), |
|
@@ -16,10 +16,34 @@ var $action = $('.action'), |
16
|
$area = $('.area'),
|
16
|
$area = $('.area'),
|
17
|
$footer = $('#yoho-footer'),
|
17
|
$footer = $('#yoho-footer'),
|
18
|
$confim = $('.confim-mask'),
|
18
|
$confim = $('.confim-mask'),
|
|
|
19
|
+ $pageWrap = $('.page-wrap'),
|
|
|
20
|
+ $backBtn = $('.nav-back'),
|
19
|
isSubmiting,
|
21
|
isSubmiting,
|
20
|
deleteId,
|
22
|
deleteId,
|
|
|
23
|
+ currentPage = 'address',
|
21
|
newArea = [];
|
24
|
newArea = [];
|
22
|
|
25
|
|
|
|
26
|
+// 清除原有链接
|
|
|
27
|
+$backBtn.attr('href', 'javascript:void(0);');
|
|
|
28
|
+
|
|
|
29
|
+// 自定义事件
|
|
|
30
|
+$backBtn.on('touchend', function(e) {
|
|
|
31
|
+ console.log(currentPage);
|
|
|
32
|
+ if (currentPage === 'edit') {
|
|
|
33
|
+ $pageWrap.hide();
|
|
|
34
|
+ $pageWrap.first().show();
|
|
|
35
|
+ e.preventDefault();
|
|
|
36
|
+ currentPage = 'address';
|
|
|
37
|
+ } else if (currentPage === 'list') {
|
|
|
38
|
+ $pageWrap.hide();
|
|
|
39
|
+ $editAddressPage.show();
|
|
|
40
|
+ e.preventDefault();
|
|
|
41
|
+ currentPage = 'edit';
|
|
|
42
|
+ } else {
|
|
|
43
|
+ window.history.go(-1);
|
|
|
44
|
+ }
|
|
|
45
|
+});
|
|
|
46
|
+
|
23
|
function editAddress(data) {
|
47
|
function editAddress(data) {
|
24
|
data = data || {};
|
48
|
data = data || {};
|
25
|
$addressForm.find('[name="id"]').val(data.id || '');
|
49
|
$addressForm.find('[name="id"]').val(data.id || '');
|
|
@@ -28,7 +52,10 @@ function editAddress(data) { |
|
@@ -28,7 +52,10 @@ function editAddress(data) { |
28
|
$addressForm.find('[name="area_code"]').val(data.areaCode || '');
|
52
|
$addressForm.find('[name="area_code"]').val(data.areaCode || '');
|
29
|
$addressForm.find('[name="area"]').val(data.area || '');
|
53
|
$addressForm.find('[name="area"]').val(data.area || '');
|
30
|
$addressForm.find('[name="address"]').val(data.address || '');
|
54
|
$addressForm.find('[name="address"]').val(data.address || '');
|
|
|
55
|
+
|
|
|
56
|
+ currentPage = 'edit';
|
31
|
$footer.hide();
|
57
|
$footer.hide();
|
|
|
58
|
+ $pageWrap.hide();
|
32
|
$editAddressPage.show();
|
59
|
$editAddressPage.show();
|
33
|
}
|
60
|
}
|
34
|
|
61
|
|
|
@@ -128,11 +155,15 @@ $addressForm.on('submit', function() { |
|
@@ -128,11 +155,15 @@ $addressForm.on('submit', function() { |
128
|
// 省市区
|
155
|
// 省市区
|
129
|
$area.on('touchend', function() {
|
156
|
$area.on('touchend', function() {
|
130
|
$footer.hide();
|
157
|
$footer.hide();
|
|
|
158
|
+ $pageWrap.hide();
|
131
|
$addressListPage.show();
|
159
|
$addressListPage.show();
|
|
|
160
|
+ currentPage = 'list';
|
132
|
});
|
161
|
});
|
133
|
|
162
|
|
134
|
$addressListPage.on('touchend', '.address', function() {
|
163
|
$addressListPage.on('touchend', '.address', function() {
|
135
|
- newArea.push($(this).children('.caption').text());
|
164
|
+ var caption = $(this).children('.caption').text();
|
|
|
165
|
+
|
|
|
166
|
+ newArea.push(caption);
|
136
|
$(this).siblings().hide();
|
167
|
$(this).siblings().hide();
|
137
|
$(this).children('ul').show();
|
168
|
$(this).children('ul').show();
|
138
|
return false;
|
169
|
return false;
|
|
@@ -143,11 +174,13 @@ $addressListPage.on('touchend', '.address', function() { |
|
@@ -143,11 +174,13 @@ $addressListPage.on('touchend', '.address', function() { |
143
|
$('[name="area"]').val(newArea.join(' '));
|
174
|
$('[name="area"]').val(newArea.join(' '));
|
144
|
$('[name="area_code"]').val($(this).data('id'));
|
175
|
$('[name="area_code"]').val($(this).data('id'));
|
145
|
|
176
|
|
|
|
177
|
+ $editAddressPage.show();
|
|
|
178
|
+ currentPage = 'edit';
|
|
|
179
|
+
|
146
|
// 恢复默认的三级选择
|
180
|
// 恢复默认的三级选择
|
147
|
$addressListPage.hide();
|
181
|
$addressListPage.hide();
|
148
|
$addressListPage.find('ul').hide();
|
182
|
$addressListPage.find('ul').hide();
|
149
|
$addressListPage.children('ul').show().children('li').show();
|
183
|
$addressListPage.children('ul').show().children('li').show();
|
150
|
- $footer.show();
|
|
|
151
|
newArea = [];
|
184
|
newArea = [];
|
152
|
return false;
|
185
|
return false;
|
153
|
}); |
186
|
}); |