...
|
...
|
@@ -23,32 +23,74 @@ const _getAddressData = (params) => { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取三级地址列表数据
|
|
|
* @param params
|
|
|
* @returns {*}
|
|
|
* @private
|
|
|
*/
|
|
|
const _getThrAddressData = (params) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.address.getlist',
|
|
|
uid: params.uid
|
|
|
}, {code: 200, cache: true});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 地址管理页面
|
|
|
* @param params
|
|
|
* @param id
|
|
|
*/
|
|
|
const address = (params) => {
|
|
|
return _getAddressData(params).then(result => {
|
|
|
if (result.data) {
|
|
|
let apiList = [
|
|
|
_getAddressData(params)
|
|
|
];
|
|
|
|
|
|
if (params.id) { // 如果有 ID 是编辑地址页面
|
|
|
apiList.push(_getThrAddressData(params));
|
|
|
}
|
|
|
|
|
|
return api.all(apiList).then(result => {
|
|
|
let selfAddress = result[0];
|
|
|
|
|
|
if (selfAddress.data) {
|
|
|
|
|
|
_.forEach(result.data, (value, key) => {
|
|
|
result.data[key].address_id = crypto.encryption(null, result.data[key].address_id);
|
|
|
/* 加密地址 ID */
|
|
|
_.forEach(selfAddress.data, (value, key) => {
|
|
|
selfAddress.data[key].address_id = crypto.encryption(null, selfAddress.data[key].address_id);
|
|
|
});
|
|
|
|
|
|
/* 如果有 ID 是地址编辑页面 */
|
|
|
if (params.id) {
|
|
|
return {
|
|
|
address: camelCase(_.find(result.data, o => {
|
|
|
address: camelCase(_.find(selfAddress.data, o => {
|
|
|
return o.address_id === params.id;
|
|
|
}))
|
|
|
})),
|
|
|
addressList: camelCase(result[1] ? result[1].data : []),
|
|
|
addressActionPage: true
|
|
|
};
|
|
|
} else {
|
|
|
return {
|
|
|
address: camelCase(result.data)
|
|
|
address: camelCase(selfAddress.data)
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 三级地址数据
|
|
|
* @param params
|
|
|
*/
|
|
|
const locationList = (params) => {
|
|
|
return _getThrAddressData(params).then(result => {
|
|
|
if (result.data) {
|
|
|
return {
|
|
|
addressList: camelCase(result.data)
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
address
|
|
|
address,
|
|
|
locationList
|
|
|
}; |
...
|
...
|
|