|
@@ -4,9 +4,9 @@ |
|
@@ -4,9 +4,9 @@ |
4
|
* @date: 2016/07/05
|
4
|
* @date: 2016/07/05
|
5
|
*/
|
5
|
*/
|
6
|
|
6
|
|
7
|
-
|
|
|
8
|
var cascadingAddress = require('../plugins/cascading-address');
|
7
|
var cascadingAddress = require('../plugins/cascading-address');
|
9
|
var dialog = require('../plugins/dialog');
|
8
|
var dialog = require('../plugins/dialog');
|
|
|
9
|
+var _alert = dialog.Alert;
|
10
|
var _confirm = dialog.Confirm;
|
10
|
var _confirm = dialog.Confirm;
|
11
|
var $addressId = $('#address_id');
|
11
|
var $addressId = $('#address_id');
|
12
|
var $consignee = $('#consignee');
|
12
|
var $consignee = $('#consignee');
|
|
@@ -15,84 +15,7 @@ var $mobile = $('#mobile'); |
|
@@ -15,84 +15,7 @@ var $mobile = $('#mobile'); |
15
|
var $phone = $('#phone');
|
15
|
var $phone = $('#phone');
|
16
|
var currentLength = $('.a-table').find('tr').length - 1;// 当前地址条数
|
16
|
var currentLength = $('.a-table').find('tr').length - 1;// 当前地址条数
|
17
|
var leftLength = 20 - currentLength;// 还剩地址条数
|
17
|
var leftLength = 20 - currentLength;// 还剩地址条数
|
18
|
-
|
|
|
19
|
-var Bll = {
|
|
|
20
|
- // 获取输入框输入的值
|
|
|
21
|
- getInfo() {
|
|
|
22
|
- // todo uid
|
|
|
23
|
- var uid = '123456';
|
|
|
24
|
-
|
|
|
25
|
- return {
|
|
|
26
|
- id: $addressId.val(),
|
|
|
27
|
- uid: uid,
|
|
|
28
|
- consignee: $consignee.val(),
|
|
|
29
|
-
|
|
|
30
|
- // todo 地址码
|
|
|
31
|
- address: $address.val(),
|
|
|
32
|
- mobile: $mobile.val(),
|
|
|
33
|
- phone: $phone.val()
|
|
|
34
|
-
|
|
|
35
|
- // todo 设置默认值
|
|
|
36
|
- };
|
|
|
37
|
- },
|
|
|
38
|
-
|
|
|
39
|
- // 清空输入框
|
|
|
40
|
- clearInput() {
|
|
|
41
|
- $consignee.val('');
|
|
|
42
|
-
|
|
|
43
|
- // todo 省市区清空
|
|
|
44
|
- $address.val('');
|
|
|
45
|
- $mobile.val('');
|
|
|
46
|
- $phone.val('');
|
|
|
47
|
- },
|
|
|
48
|
-
|
|
|
49
|
- // 校验
|
|
|
50
|
- check(info) {
|
|
|
51
|
- let flag = true;
|
|
|
52
|
- let reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
|
|
|
53
|
-
|
|
|
54
|
- if (info.consignee === '' || info.address === '' || info.mobile === '') {
|
|
|
55
|
- flag = '有必填项为空';
|
|
|
56
|
- } else if (!reg.test(info.mobile)) {
|
|
|
57
|
- flag = '手机号码格式不对';
|
|
|
58
|
- }
|
|
|
59
|
- return flag;
|
|
|
60
|
- },
|
|
|
61
|
-
|
|
|
62
|
- // 拼接一条数据的html
|
|
|
63
|
- getHtml(info) {
|
|
|
64
|
- var html = '<tr class="table-body">';
|
|
|
65
|
-
|
|
|
66
|
- html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' +
|
|
|
67
|
- '<td class=\'width-80\'>' + info.consignee + '</td>' +
|
|
|
68
|
- '<td class=\'width-195\'>' + info.area + '</td>' +
|
|
|
69
|
- '<td class=\'width-280\'>' + info.address + '</td>' +
|
|
|
70
|
- '<td class=\'width-120\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' +
|
|
|
71
|
- '<td class=\'width-260\'><div><span class=\'blue opreation update-address\'>修改</span>\n|\n' +
|
|
|
72
|
- '<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' +
|
|
|
73
|
- '<span class=\'btn set-default opreation \' data-id=\'' + info.address_id + '\'>设为默认</span></div></td>';
|
|
|
74
|
- html += '</tr>';
|
|
|
75
|
- return html;
|
|
|
76
|
- },
|
|
|
77
|
-
|
|
|
78
|
- // 获取一条数据
|
|
|
79
|
- setInfo(id, td) {
|
|
|
80
|
- $addressId.val(id);
|
|
|
81
|
- $consignee.val(td.eq(0).text());
|
|
|
82
|
-
|
|
|
83
|
- // todo 省市区逆向展示
|
|
|
84
|
- // $areaCode.val(td.eq(1).text());
|
|
|
85
|
- $address.val(td.eq(2).text());
|
|
|
86
|
- $mobile.val(td.eq(3).children().eq(0).text());
|
|
|
87
|
- $phone.val(td.eq(3).children().eq(1).text());
|
|
|
88
|
- },
|
|
|
89
|
-
|
|
|
90
|
- // 设置表格头部
|
|
|
91
|
- setTableTile() {
|
|
|
92
|
- $('.table-title').text('已保存了' + currentLength +
|
|
|
93
|
- '条地址,还能保存' + leftLength + '条地址');
|
|
|
94
|
- }
|
|
|
95
|
-};
|
18
|
+var reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);// 手机号码校验
|
96
|
|
19
|
|
97
|
require('./me');
|
20
|
require('./me');
|
98
|
|
21
|
|
|
@@ -108,7 +31,7 @@ $('.default-address').click(function() { |
|
@@ -108,7 +31,7 @@ $('.default-address').click(function() { |
108
|
});
|
31
|
});
|
109
|
|
32
|
|
110
|
// 校验
|
33
|
// 校验
|
111
|
-$consignee.keydown(function() {
|
34
|
+$consignee.focus(function() {
|
112
|
$(this).next().hide();
|
35
|
$(this).next().hide();
|
113
|
});
|
36
|
});
|
114
|
$consignee.blur(function() {
|
37
|
$consignee.blur(function() {
|
|
@@ -116,7 +39,7 @@ $consignee.blur(function() { |
|
@@ -116,7 +39,7 @@ $consignee.blur(function() { |
116
|
$(this).next().show();
|
39
|
$(this).next().show();
|
117
|
}
|
40
|
}
|
118
|
});
|
41
|
});
|
119
|
-$address.keydown(function() {
|
42
|
+$address.focus(function() {
|
120
|
$(this).next().hide();
|
43
|
$(this).next().hide();
|
121
|
});
|
44
|
});
|
122
|
$address.blur(function() {
|
45
|
$address.blur(function() {
|
|
@@ -124,15 +47,13 @@ $address.blur(function() { |
|
@@ -124,15 +47,13 @@ $address.blur(function() { |
124
|
$(this).next().show();
|
47
|
$(this).next().show();
|
125
|
}
|
48
|
}
|
126
|
});
|
49
|
});
|
127
|
-$mobile.keydown(function() {
|
50
|
+$mobile.focus(function() {
|
128
|
$(this).next().hide();
|
51
|
$(this).next().hide();
|
129
|
});
|
52
|
});
|
130
|
$mobile.blur(function() {
|
53
|
$mobile.blur(function() {
|
131
|
if ($(this).val().trim() === '') {
|
54
|
if ($(this).val().trim() === '') {
|
132
|
$(this).next().show();
|
55
|
$(this).next().show();
|
133
|
} else {
|
56
|
} else {
|
134
|
- let reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/);
|
|
|
135
|
-
|
|
|
136
|
if (!reg.test(($(this).val().trim()))) {
|
57
|
if (!reg.test(($(this).val().trim()))) {
|
137
|
$(this).next().show();
|
58
|
$(this).next().show();
|
138
|
$(this).next().html('手机号码格式不正确');
|
59
|
$(this).next().html('手机号码格式不正确');
|
|
@@ -140,124 +61,227 @@ $mobile.blur(function() { |
|
@@ -140,124 +61,227 @@ $mobile.blur(function() { |
140
|
}
|
61
|
}
|
141
|
});
|
62
|
});
|
142
|
|
63
|
|
143
|
-// 保存收货地址
|
|
|
144
|
-$(document).on('click', '#save-address', function() {
|
|
|
145
|
- var info = Bll.getInfo();
|
|
|
146
|
- var area = $('#address-form').serialize();
|
|
|
147
|
-
|
|
|
148
|
- info.area_code = area.substring(area.length - 6);
|
|
|
149
|
- if (Bll.check(info) === true) {
|
|
|
150
|
- // 新增
|
|
|
151
|
- if (info.id === '') {
|
|
|
152
|
- $.ajax({
|
|
|
153
|
- type: 'POST',
|
|
|
154
|
- url: '/me/address/add',
|
|
|
155
|
- dataType: 'json',
|
|
|
156
|
- data: info,
|
|
|
157
|
- success: function(data) {
|
|
|
158
|
- let html = Bll.getHtml(data.data);
|
|
|
159
|
-
|
|
|
160
|
- currentLength++;
|
|
|
161
|
- leftLength--;
|
|
|
162
|
- $('tbody').append(html);
|
|
|
163
|
- Bll.setTableTile();
|
|
|
164
|
- Bll.clearInput();
|
|
|
165
|
- }
|
|
|
166
|
- });
|
|
|
167
|
- } else { // 修改
|
|
|
168
|
- console.log('上传info', info);
|
|
|
169
|
- $.ajax({
|
|
|
170
|
- type: 'POST',
|
|
|
171
|
- url: '/me/address/update',
|
|
|
172
|
- dataType: 'json',
|
|
|
173
|
- data: info,
|
|
|
174
|
- success: function(data) {
|
|
|
175
|
- if (data.code === 200) {
|
|
|
176
|
- $('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
|
|
|
177
|
- Bll.clearInput();
|
|
|
178
|
- } else {
|
|
|
179
|
|
64
|
|
180
|
- // alert('修改出错!');
|
|
|
181
|
- }
|
|
|
182
|
- }
|
65
|
+$(function() {
|
|
|
66
|
+ // 运行此demo
|
|
|
67
|
+ // 1. 安装 npm i -g json-server
|
|
|
68
|
+ // 2. json-server --watch mock/address.json
|
|
|
69
|
+ var address = cascadingAddress({
|
|
|
70
|
+ el: '#address',
|
|
|
71
|
+ url: 'http://localhost:3000/areas/0',
|
|
|
72
|
+ resource: 'areas'
|
|
|
73
|
+ });
|
|
|
74
|
+
|
|
|
75
|
+ var Bll = {
|
|
|
76
|
+ // 获取输入框输入的值
|
|
|
77
|
+ getInfo() {
|
|
|
78
|
+ // todo uid
|
|
|
79
|
+ var uid = '123456';
|
|
|
80
|
+
|
|
|
81
|
+ return {
|
|
|
82
|
+ id: $addressId.val(),
|
|
|
83
|
+ uid: uid,
|
|
|
84
|
+ consignee: $consignee.val(),
|
|
|
85
|
+ address: $address.val(),
|
|
|
86
|
+ mobile: $mobile.val(),
|
|
|
87
|
+ phone: $phone.val()
|
|
|
88
|
+
|
|
|
89
|
+ // todo 设置默认值
|
|
|
90
|
+ };
|
|
|
91
|
+ },
|
|
|
92
|
+
|
|
|
93
|
+ // 清空输入框
|
|
|
94
|
+ clearInput() {
|
|
|
95
|
+ $consignee.val('');
|
|
|
96
|
+
|
|
|
97
|
+ // todo 省市区清空
|
|
|
98
|
+ address.setAddress({
|
|
|
99
|
+ province: '', // 省
|
|
|
100
|
+ city: '', // 市
|
|
|
101
|
+ dist: '' // 区县
|
183
|
});
|
102
|
});
|
|
|
103
|
+ $address.val('');
|
|
|
104
|
+ $mobile.val('');
|
|
|
105
|
+ $phone.val('');
|
|
|
106
|
+ },
|
|
|
107
|
+
|
|
|
108
|
+ // 校验
|
|
|
109
|
+ check(info) {
|
|
|
110
|
+ let flag = true;
|
|
|
111
|
+
|
|
|
112
|
+ if (info.consignee === '' || info.address === '' || info.mobile === '') {
|
|
|
113
|
+ flag = '有必填项为空';
|
|
|
114
|
+ } else if (!reg.test(info.mobile)) {
|
|
|
115
|
+ flag = '手机号码格式不对';
|
|
|
116
|
+ } else if (typeof (info.area_code) === 'undefined') {
|
|
|
117
|
+ flag = '所在区域请选择到:区';
|
|
|
118
|
+ }
|
|
|
119
|
+ return flag;
|
|
|
120
|
+ },
|
|
|
121
|
+
|
|
|
122
|
+ // 拼接一条数据的html
|
|
|
123
|
+ getHtml(info) {
|
|
|
124
|
+ var html = '<tr class="table-body">';
|
|
|
125
|
+
|
|
|
126
|
+ html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' +
|
|
|
127
|
+ '<input type="hidden" id="tr_' + info.area_code + '" value="' + info.area_code + '">' +
|
|
|
128
|
+ '<td class=\'width-80\'>' + info.consignee + '</td>' +
|
|
|
129
|
+ '<td class=\'width-195\'>' + info.area + '</td>' +
|
|
|
130
|
+ '<td class=\'width-280\'>' + info.address + '</td>' +
|
|
|
131
|
+ '<td class=\'width-120\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' +
|
|
|
132
|
+ '<td class=\'width-260\'><div><span class=\'blue opreation update-address\' data-id=\''+
|
|
|
133
|
+ info.address_id + '\'>修改</span>\n|\n' +
|
|
|
134
|
+ '<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' +
|
|
|
135
|
+ '<span class=\'btn set-default opreation \' data-id=\'' + info.address_id + '\'>设为默认</span></div></td>';
|
|
|
136
|
+ html += '</tr>';
|
|
|
137
|
+ return html;
|
|
|
138
|
+ },
|
|
|
139
|
+
|
|
|
140
|
+ // 获取一条数据
|
|
|
141
|
+ setInfo(id, td) {
|
|
|
142
|
+ $addressId.val(id);
|
|
|
143
|
+ $consignee.val(td.eq(0).text());
|
|
|
144
|
+
|
|
|
145
|
+ // todo 省市区逆向展示
|
|
|
146
|
+ $address.val(td.eq(2).text());
|
|
|
147
|
+ $mobile.val(td.eq(3).children().eq(0).text());
|
|
|
148
|
+ $phone.val(td.eq(3).children().eq(1).text());
|
|
|
149
|
+ },
|
|
|
150
|
+
|
|
|
151
|
+ // 设置表格头部
|
|
|
152
|
+ setTableTile() {
|
|
|
153
|
+ $('.table-title').text('已保存了' + currentLength +
|
|
|
154
|
+ '条地址,还能保存' + leftLength + '条地址');
|
184
|
}
|
155
|
}
|
185
|
- } else {
|
|
|
186
|
- alert(Bll.check(info));
|
|
|
187
|
- }
|
|
|
188
|
-});
|
156
|
+ };
|
189
|
|
157
|
|
190
|
-// 修改收货地址
|
|
|
191
|
-$('.update-address').click(function() {
|
|
|
192
|
- let id = $(this).data('id');
|
|
|
193
|
- let tr = $(this).parents('.table-body');
|
|
|
194
|
- let td = tr.find('td');
|
|
|
195
|
|
158
|
|
196
|
- Bll.setInfo(id, td);
|
|
|
197
|
-});
|
159
|
+ // 保存收货地址
|
|
|
160
|
+ $(document).on('click', '#save-address', function() {
|
|
|
161
|
+ if (currentLength === 20) {
|
|
|
162
|
+ new _alert('您最多添加20个收货地址,可删除不需要的地址后再添加新地址!').show();
|
|
|
163
|
+ Bll.clearInput();
|
|
|
164
|
+ } else {
|
|
|
165
|
+ let info = Bll.getInfo();
|
|
|
166
|
+ let area = address.getAreaIds();
|
|
|
167
|
+ let areaInfo = address.getAreaLabels();
|
|
|
168
|
+
|
|
|
169
|
+ info.area_code = area.split(',')[2];
|
|
|
170
|
+ info.area = areaInfo.split(',').join(' ');
|
|
|
171
|
+ if (Bll.check(info) === true) {
|
|
|
172
|
+ // 新增
|
|
|
173
|
+ if (info.id === '') {
|
|
|
174
|
+ $.ajax({
|
|
|
175
|
+ type: 'POST',
|
|
|
176
|
+ url: '/me/address/add',
|
|
|
177
|
+ dataType: 'json',
|
|
|
178
|
+ data: info,
|
|
|
179
|
+ success: function(data) {
|
|
|
180
|
+ if (data.code === 200) {
|
|
|
181
|
+ let html = Bll.getHtml(data.data);
|
198
|
|
182
|
|
199
|
-// 删除收货地址
|
|
|
200
|
-$('.del-address').click(function() {
|
|
|
201
|
- let id = $(this).data('id');
|
|
|
202
|
- var tr = $(this).parents('.table-body');
|
|
|
203
|
-
|
|
|
204
|
- var a = new _confirm({
|
|
|
205
|
- content: '您确定要删除收货地址吗?',
|
|
|
206
|
- cb: function() {
|
|
|
207
|
- $.ajax({
|
|
|
208
|
- type: 'POST',
|
|
|
209
|
- url: '/me/address/del',
|
|
|
210
|
- dataType: 'json',
|
|
|
211
|
- data: {
|
|
|
212
|
- // todo uid
|
|
|
213
|
- uid: '123456',
|
|
|
214
|
- id: id
|
|
|
215
|
- },
|
|
|
216
|
- success: function() {
|
|
|
217
|
- currentLength--;
|
|
|
218
|
- leftLength++;
|
|
|
219
|
- tr.remove();
|
|
|
220
|
- Bll.setTableTile();
|
|
|
221
|
- a.close();
|
183
|
+ currentLength++;
|
|
|
184
|
+ leftLength--;
|
|
|
185
|
+ $('tbody').append(html);
|
|
|
186
|
+ Bll.setTableTile();
|
|
|
187
|
+ Bll.clearInput();
|
|
|
188
|
+
|
|
|
189
|
+ // location.href="/me/address";
|
|
|
190
|
+ } else {
|
|
|
191
|
+ new _alert('新增接口出错了').show();
|
|
|
192
|
+ }
|
|
|
193
|
+ }
|
|
|
194
|
+ });
|
|
|
195
|
+ } else { // 修改
|
|
|
196
|
+ $.ajax({
|
|
|
197
|
+ type: 'POST',
|
|
|
198
|
+ url: '/me/address/update',
|
|
|
199
|
+ dataType: 'json',
|
|
|
200
|
+ data: info,
|
|
|
201
|
+ success: function(data) {
|
|
|
202
|
+ if (data.code === 200) {
|
|
|
203
|
+ info.mobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
|
|
|
204
|
+ info.address_id = info.id;
|
|
|
205
|
+ $('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove();
|
|
|
206
|
+ Bll.clearInput();
|
|
|
207
|
+
|
|
|
208
|
+ // location.href="/me/address";
|
|
|
209
|
+ } else {
|
|
|
210
|
+ new _alert('修改接口出错了').show();
|
|
|
211
|
+ }
|
|
|
212
|
+ }
|
|
|
213
|
+ });
|
222
|
}
|
214
|
}
|
223
|
- });
|
215
|
+ } else {
|
|
|
216
|
+ new _alert(Bll.check(info)).show();
|
|
|
217
|
+ }
|
224
|
}
|
218
|
}
|
225
|
- }).show();
|
|
|
226
|
-});
|
|
|
227
|
|
219
|
|
228
|
-// 设置默认收货地址
|
|
|
229
|
-$(document).on('click', '.set-default', function() {
|
|
|
230
|
- var tr = $(this).parents('.table-body');
|
|
|
231
|
- var tbody = tr.parent();
|
|
|
232
|
- let id = $(this).data('id');
|
|
|
233
|
- var self = this;
|
|
|
234
|
-
|
|
|
235
|
- $.ajax({
|
|
|
236
|
- type: 'POST',
|
|
|
237
|
- url: '/me/address/default',
|
|
|
238
|
- dataType: 'json',
|
|
|
239
|
- data: {
|
|
|
240
|
- // todo uid
|
|
|
241
|
- uid: '123456',
|
|
|
242
|
- id: id
|
|
|
243
|
- },
|
|
|
244
|
- success: function() {
|
|
|
245
|
- $('.current-default').removeClass('current-default').text('设为默认');
|
|
|
246
|
- $(self).addClass('current-default').text('默认地址');
|
|
|
247
|
- tbody.find('.table-body').eq(0).before('<tr class=\'table-body\'>' + tr.html() + '</tr>');
|
|
|
248
|
- tr.remove();
|
|
|
249
|
- }
|
|
|
250
|
});
|
220
|
});
|
251
|
-});
|
|
|
252
|
|
221
|
|
|
|
222
|
+ // 修改收货地址
|
|
|
223
|
+ $(document).on('click', '.update-address', function() {
|
|
|
224
|
+ let id = $(this).data('id');
|
|
|
225
|
+ let tr = $(this).parents('.table-body');
|
|
|
226
|
+ let td = tr.find('td');
|
253
|
|
227
|
|
254
|
-$(function() {
|
|
|
255
|
- // 运行此demo
|
|
|
256
|
- // 1. 安装 npm i -g json-server
|
|
|
257
|
- // 2. json-server --watch mock/address.json
|
|
|
258
|
- cascadingAddress({
|
|
|
259
|
- el: '#address',
|
|
|
260
|
- url: 'http://localhost:3000/areas/0',
|
|
|
261
|
- resource: 'areas'
|
228
|
+ $('.error-tips').hide();
|
|
|
229
|
+ Bll.setInfo(id, td);
|
|
|
230
|
+ });
|
|
|
231
|
+
|
|
|
232
|
+ // 删除收货地址
|
|
|
233
|
+ $(document).on('click', '.del-address', function() {
|
|
|
234
|
+ let id = $(this).data('id');
|
|
|
235
|
+ var tr = $(this).parents('.table-body');
|
|
|
236
|
+
|
|
|
237
|
+ var a = new _confirm({
|
|
|
238
|
+ content: '您确定要删除收货地址吗?',
|
|
|
239
|
+ cb: function() {
|
|
|
240
|
+ $.ajax({
|
|
|
241
|
+ type: 'POST',
|
|
|
242
|
+ url: '/me/address/del',
|
|
|
243
|
+ dataType: 'json',
|
|
|
244
|
+ data: {
|
|
|
245
|
+ // todo uid
|
|
|
246
|
+ uid: '123456',
|
|
|
247
|
+ id: id
|
|
|
248
|
+ },
|
|
|
249
|
+ success: function() {
|
|
|
250
|
+ currentLength--;
|
|
|
251
|
+ leftLength++;
|
|
|
252
|
+ tr.remove();
|
|
|
253
|
+ Bll.setTableTile();
|
|
|
254
|
+ a.close();
|
|
|
255
|
+ Bll.clearInput();
|
|
|
256
|
+ }
|
|
|
257
|
+ });
|
|
|
258
|
+ }
|
|
|
259
|
+ }).show();
|
|
|
260
|
+
|
|
|
261
|
+ });
|
|
|
262
|
+
|
|
|
263
|
+ // 设置默认收货地址
|
|
|
264
|
+ $(document).on('click', '.set-default', function() {
|
|
|
265
|
+ var tr = $(this).parents('.table-body');
|
|
|
266
|
+ var tbody = tr.parent();
|
|
|
267
|
+ let id = $(this).data('id');
|
|
|
268
|
+ var self = this;
|
|
|
269
|
+
|
|
|
270
|
+ $.ajax({
|
|
|
271
|
+ type: 'POST',
|
|
|
272
|
+ url: '/me/address/default',
|
|
|
273
|
+ dataType: 'json',
|
|
|
274
|
+ data: {
|
|
|
275
|
+ // todo uid
|
|
|
276
|
+ uid: '123456',
|
|
|
277
|
+ id: id
|
|
|
278
|
+ },
|
|
|
279
|
+ success: function() {
|
|
|
280
|
+ $('.current-default').removeClass('current-default').text('设为默认');
|
|
|
281
|
+ $(self).addClass('current-default').text('默认地址');
|
|
|
282
|
+ tbody.find('.table-body').eq(0).before('<tr class=\'table-body\'>' + tr.html() + '</tr>');
|
|
|
283
|
+ tr.remove();
|
|
|
284
|
+ }
|
|
|
285
|
+ });
|
262
|
});
|
286
|
});
|
263
|
}); |
287
|
}); |