...
|
...
|
@@ -54,7 +54,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
return this.get({
|
|
|
data: {
|
|
|
method: params.id ? 'app.address.update' : 'app.address.add',
|
|
|
id: params.id,
|
|
|
id: decodeURIComponent(params.id),
|
|
|
address: params.address,
|
|
|
area_code: params.area_code,
|
|
|
consignee: params.consignee,
|
...
|
...
|
@@ -76,7 +76,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
data: {
|
|
|
method: 'app.address.setdefault',
|
|
|
uid: params.uid,
|
|
|
id: params.id
|
|
|
id: decodeURIComponent(params.id)
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
@@ -90,7 +90,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
return this.get({
|
|
|
data: {
|
|
|
method: 'app.address.del',
|
|
|
id: params.id,
|
|
|
id: decodeURIComponent(params.id),
|
|
|
uid: params.uid
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -106,47 +106,33 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
];
|
|
|
|
|
|
if (params.id) { // 如果有 ID 是编辑地址页面
|
|
|
params.id = decodeURIComponent(params.id);
|
|
|
apiList.push(this._getThrAddressData(params));
|
|
|
}
|
|
|
|
|
|
return api.all(apiList).then(result => {
|
|
|
let selfAddress = result[0];
|
|
|
let selfAddress = _.get(result, '[0].data', []);
|
|
|
let editAddress = {};
|
|
|
|
|
|
if (selfAddress.data) {
|
|
|
|
|
|
_.forEach(selfAddress.data, (value) => {
|
|
|
_.forEach(selfAddress, (value) => {
|
|
|
if (value.area.length > 11) {
|
|
|
value.showArea = value.area.substr(0, 5) + '...' + value.area.substr(-5);
|
|
|
} else {
|
|
|
value.showArea = value.area;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/* 如果有 ID 是地址编辑页面 */
|
|
|
if (params.id) {
|
|
|
let returnResult = {
|
|
|
address: camelCase(_.find(selfAddress.data, o => {
|
|
|
return decodeURIComponent(o.address_id) === params.id;
|
|
|
})),
|
|
|
addressList: camelCase(result[1] ? result[1].data : []),
|
|
|
navTitle: '编辑地址'
|
|
|
};
|
|
|
|
|
|
let area = _.get(returnResult, 'address.area', '');
|
|
|
|
|
|
if (area.length > 11) {
|
|
|
returnResult.address.area = area.substr(0, 5) + '...' + area.substr(-5);
|
|
|
if (params.id && value.address_id === params.id) {
|
|
|
editAddress = value;
|
|
|
}
|
|
|
|
|
|
return returnResult;
|
|
|
} else {
|
|
|
value.address_id = encodeURIComponent(value.address_id);
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
address: camelCase(selfAddress.data),
|
|
|
addressList: camelCase(result[1] ? result[1].data : []),
|
|
|
navTitle: '添加地址'
|
|
|
address: camelCase(params.id ? editAddress : selfAddress),
|
|
|
addressList: camelCase(_.get(result, '[1].data', [])),
|
|
|
navTitle: params.id ? '编辑地址' : '添加地址'
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -219,7 +205,7 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
method: 'app.SpaceOrders.updateDeliveryAddress',
|
|
|
uid: uid,
|
|
|
order_code: orderCode,
|
|
|
address_id: addressId
|
|
|
address_id: decodeURIComponent(addressId)
|
|
|
}
|
|
|
}).then((result) => {
|
|
|
return result;
|
...
|
...
|
|