|
@@ -54,7 +54,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -54,7 +54,7 @@ module.exports = class extends global.yoho.BaseModel { |
54
|
return this.get({
|
54
|
return this.get({
|
55
|
data: {
|
55
|
data: {
|
56
|
method: params.id ? 'app.address.update' : 'app.address.add',
|
56
|
method: params.id ? 'app.address.update' : 'app.address.add',
|
57
|
- id: params.id,
|
57
|
+ id: decodeURIComponent(params.id),
|
58
|
address: params.address,
|
58
|
address: params.address,
|
59
|
area_code: params.area_code,
|
59
|
area_code: params.area_code,
|
60
|
consignee: params.consignee,
|
60
|
consignee: params.consignee,
|
|
@@ -76,7 +76,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -76,7 +76,7 @@ module.exports = class extends global.yoho.BaseModel { |
76
|
data: {
|
76
|
data: {
|
77
|
method: 'app.address.setdefault',
|
77
|
method: 'app.address.setdefault',
|
78
|
uid: params.uid,
|
78
|
uid: params.uid,
|
79
|
- id: params.id
|
79
|
+ id: decodeURIComponent(params.id)
|
80
|
}
|
80
|
}
|
81
|
});
|
81
|
});
|
82
|
}
|
82
|
}
|
|
@@ -90,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -90,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel { |
90
|
return this.get({
|
90
|
return this.get({
|
91
|
data: {
|
91
|
data: {
|
92
|
method: 'app.address.del',
|
92
|
method: 'app.address.del',
|
93
|
- id: params.id,
|
93
|
+ id: decodeURIComponent(params.id),
|
94
|
uid: params.uid
|
94
|
uid: params.uid
|
95
|
}
|
95
|
}
|
96
|
});
|
96
|
});
|
|
@@ -106,47 +106,33 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -106,47 +106,33 @@ module.exports = class extends global.yoho.BaseModel { |
106
|
];
|
106
|
];
|
107
|
|
107
|
|
108
|
if (params.id) { // 如果有 ID 是编辑地址页面
|
108
|
if (params.id) { // 如果有 ID 是编辑地址页面
|
|
|
109
|
+ params.id = decodeURIComponent(params.id);
|
109
|
apiList.push(this._getThrAddressData(params));
|
110
|
apiList.push(this._getThrAddressData(params));
|
110
|
}
|
111
|
}
|
111
|
|
112
|
|
112
|
return api.all(apiList).then(result => {
|
113
|
return api.all(apiList).then(result => {
|
113
|
- let selfAddress = result[0];
|
114
|
+ let selfAddress = _.get(result, '[0].data', []);
|
|
|
115
|
+ let editAddress = {};
|
114
|
|
116
|
|
115
|
- if (selfAddress.data) {
|
|
|
116
|
-
|
|
|
117
|
- _.forEach(selfAddress.data, (value) => {
|
117
|
+ _.forEach(selfAddress, (value) => {
|
118
|
if (value.area.length > 11) {
|
118
|
if (value.area.length > 11) {
|
119
|
value.showArea = value.area.substr(0, 5) + '...' + value.area.substr(-5);
|
119
|
value.showArea = value.area.substr(0, 5) + '...' + value.area.substr(-5);
|
120
|
} else {
|
120
|
} else {
|
121
|
value.showArea = value.area;
|
121
|
value.showArea = value.area;
|
122
|
}
|
122
|
}
|
123
|
- });
|
|
|
124
|
-
|
|
|
125
|
- /* 如果有 ID 是地址编辑页面 */
|
|
|
126
|
- if (params.id) {
|
|
|
127
|
- let returnResult = {
|
|
|
128
|
- address: camelCase(_.find(selfAddress.data, o => {
|
|
|
129
|
- return decodeURIComponent(o.address_id) === params.id;
|
|
|
130
|
- })),
|
|
|
131
|
- addressList: camelCase(result[1] ? result[1].data : []),
|
|
|
132
|
- navTitle: '编辑地址'
|
|
|
133
|
- };
|
|
|
134
|
-
|
|
|
135
|
- let area = _.get(returnResult, 'address.area', '');
|
|
|
136
|
|
123
|
|
137
|
- if (area.length > 11) {
|
|
|
138
|
- returnResult.address.area = area.substr(0, 5) + '...' + area.substr(-5);
|
124
|
+ if (params.id && value.address_id === params.id) {
|
|
|
125
|
+ editAddress = value;
|
139
|
}
|
126
|
}
|
140
|
|
127
|
|
141
|
- return returnResult;
|
|
|
142
|
- } else {
|
128
|
+ value.address_id = encodeURIComponent(value.address_id);
|
|
|
129
|
+ });
|
|
|
130
|
+
|
143
|
return {
|
131
|
return {
|
144
|
- address: camelCase(selfAddress.data),
|
|
|
145
|
- addressList: camelCase(result[1] ? result[1].data : []),
|
|
|
146
|
- navTitle: '添加地址'
|
132
|
+ address: camelCase(params.id ? editAddress : selfAddress),
|
|
|
133
|
+ addressList: camelCase(_.get(result, '[1].data', [])),
|
|
|
134
|
+ navTitle: params.id ? '编辑地址' : '添加地址'
|
147
|
};
|
135
|
};
|
148
|
- }
|
|
|
149
|
- }
|
|
|
150
|
});
|
136
|
});
|
151
|
}
|
137
|
}
|
152
|
|
138
|
|
|
@@ -219,7 +205,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
@@ -219,7 +205,7 @@ module.exports = class extends global.yoho.BaseModel { |
219
|
method: 'app.SpaceOrders.updateDeliveryAddress',
|
205
|
method: 'app.SpaceOrders.updateDeliveryAddress',
|
220
|
uid: uid,
|
206
|
uid: uid,
|
221
|
order_code: orderCode,
|
207
|
order_code: orderCode,
|
222
|
- address_id: addressId
|
208
|
+ address_id: decodeURIComponent(addressId)
|
223
|
}
|
209
|
}
|
224
|
}).then((result) => {
|
210
|
}).then((result) => {
|
225
|
return result;
|
211
|
return result;
|