Authored by yyq

代码规范

/**
* 商品基本信息
* 退换货API
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/19
*/
... ... @@ -7,12 +7,25 @@
const api = global.yoho.API;
/**
* 获取快递公司列表API
* @function getExpressCompanyAsync
* @return { Object } 快递公司列表
*/
const getExpressCompanyAsync = () => {
return api.get('', {
method: 'app.express.getExpressCompany'
}, {code: 200});
};
/**
* 获取订单信息API
* @function getOrderInfoAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @param { string } sessionKey session
* @return { Object } 订单信息
*/
const getOrderInfoAsync = (orderCode, uid, sessionKey) => {
return api.get('', {
method: 'app.SpaceOrders.info',
... ... @@ -22,6 +35,13 @@ const getOrderInfoAsync = (orderCode, uid, sessionKey) => {
}, {code: 200});
};
/**
* 获取订单退货信息API
* @function getRefundGoodsAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @return { Object } 订单退货信息
*/
const getRefundGoodsAsync = (orderCode, uid) => {
return api.get('', {
method: 'app.refund.goodsList',
... ... @@ -30,6 +50,13 @@ const getRefundGoodsAsync = (orderCode, uid) => {
}, {code: 200});
};
/**
* 获取退货详情信息API
* @function getRefundDetailAsync
* @param { number } applyId 退货申请id
* @param { number } uid 用户uid
* @return { Object } 退货详情信息
*/
const getRefundDetailAsync = (applyId, uid) => {
return api.get('', {
method: 'app.refund.detail',
... ... @@ -38,6 +65,15 @@ const getRefundDetailAsync = (applyId, uid) => {
}, {code: 200});
};
/**
* 退货申请提交API
* @function refundSubmitAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @param { Object } goods 退货商品信息
* @param { Object } payment 退款信息
* @return { Object } 退货申请结果
*/
const refundSubmitAsync = (orderCode, uid, goods, payment) => {
return api.get('', {
method: 'app.refund.submit',
... ... @@ -48,6 +84,13 @@ const refundSubmitAsync = (orderCode, uid, goods, payment) => {
}, {code: 200});
};
/**
* 获取换货商品信息API
* @function getChangeGoodsListAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @return { Object } 换货商品信息
*/
const getChangeGoodsListAsync = (orderCode, uid) => {
return api.get('', {
method: 'app.change.goodsList',
... ... @@ -56,6 +99,13 @@ const getChangeGoodsListAsync = (orderCode, uid) => {
});
};
/**
* 获取商品信息API
* @function getProductInfoAsync
* @param { number } productId 商品id
* @param { number } productSkn 商品skn
* @return { Object } 商品信息
*/
const getProductInfoAsync = (productId, productSkn) => {
return api.get('', {
method: 'app.product.data',
... ... @@ -64,6 +114,13 @@ const getProductInfoAsync = (productId, productSkn) => {
});
};
/**
* 获取换货详情API
* @function getExchangeDetail
* @param { number } id 收藏id
* @param { number } uid 用户uid
* @return { Object } 换货详情
*/
const getExchangeDetail = (id, uid) => {
return api.get('', {
method: 'app.change.detail',
... ... @@ -72,6 +129,13 @@ const getExchangeDetail = (id, uid) => {
});
};
/**
* 换货申请提交API
* @function changeSubmitAsync
* @param { number } data 换货信息
* @param { number } uid 用户uid
* @return { Object } 换货申请结果
*/
const changeSubmitAsync = (data, uid) => {
const requestData = Object.assign(data, {
method: 'app.change.submit',
... ... @@ -82,6 +146,14 @@ const changeSubmitAsync = (data, uid) => {
return api.get('', requestData);
};
/**
* 设置寄回快递信息API
* @function setExpressNumberAsync
* @param { number } uid 用户uid
* @param { number } param 寄回快递信息
* @param { boolean } isChange 是否换货 true--换货 false--退货
* @return { Object } 设置快递结果
*/
const setExpressNumberAsync = (uid, param, isChange) => {
return api.post('', {
method: isChange ? 'app.change.setexpress' : 'app.refund.setexpress',
... ... @@ -93,6 +165,14 @@ const setExpressNumberAsync = (uid, param, isChange) => {
});
};
/**
* 取消退换货API
* @function cancelReturnAsync
* @param { number } id 收藏id
* @param { number } uid 用户uid
* @param { boolean } isChange 是否换货 true--换货 false--退货
* @return { Object } 取消结果
*/
const cancelReturnAsync = (id, uid, isChange) => {
return api.post('', {
method: isChange ? 'app.change.cancel' : 'app.refund.cancel',
... ... @@ -101,6 +181,11 @@ const cancelReturnAsync = (id, uid, isChange) => {
});
};
/**
* 获取退货银行列表API
* @function getRefundBank
* @return { Object } 银行列表信息
*/
const getRefundBank = () => {
return api.get('', {
method: 'app.refund.refundBank'
... ...
... ... @@ -295,9 +295,11 @@ const _setRefundDetailData = (data) => {
switch (data.status) {
case 10:
resData.orderReview = {pass: true};
resData.refundExpress = true;
resData.refundAddress = returnAddress;
Object.assign(resData, {
orderReview: {pass: true},
refundExpress: true,
refundAddress: returnAddress
});
break;
case 20:
resData.refundExpress = true;
... ... @@ -399,17 +401,23 @@ const _setExchangeDetailData = (data) => {
switch (data.status) {
case 0:
list.audit = true;
list.reminder = true;
Object.assign(list, {
audit: true,
reminder: true
});
break;
case 10:
list.through = true;
list.reminder = true;
Object.assign(list, {
through: true,
reminder: true
});
if (data.deliveryTpyeName === '寄回换货') {
list.logistics = true;
list.sendBack = true;
list.exchangeAddress = returnAddress;
Object.assign(list, {
logistics: true,
sendBack: true,
exchangeAddress: returnAddress
});
} else {
list.inDoor = true;
}
... ... @@ -421,13 +429,17 @@ const _setExchangeDetailData = (data) => {
}
break;
case 50:
list.send = true;
list.reminder = true;
list.auditSuccess = true;
Object.assign(list, {
send: true,
reminder: true,
auditSuccess: true
});
break;
case 40:
list.finish = true;
list.auditSuccess = true;
Object.assign(list, {
finish: true,
auditSuccess: true
});
break;
case 91:
list.abolish = true;
... ... @@ -458,9 +470,11 @@ const getRefundGoodsData = (orderCode, uid) => {
};
if (result.data) {
Object.assign(resData.returns.refund, _setRefundGoodList(result.data), {
orderCode: orderCode
});
Object.assign(
resData.returns.refund,
_setRefundGoodList(result.data),
{orderCode: orderCode}
);
}
return resData;
... ... @@ -495,12 +509,11 @@ const getRefundDetailData = (applyId, uid) => {
data.expressList = _setExpressData(result[1].data);
}
// 设置状态进度
Object.assign(resData.returns.refundDetail, _setReturnStatus(data.statusList, !data.status));
// 设置退货详情信息
Object.assign(resData.returns.refundDetail, _setRefundDetailData(data));
Object.assign(
resData.returns.refundDetail,
_setReturnStatus(data.statusList, !data.status), // 设置状态进度
_setRefundDetailData(data) // 设置退货详情信息
);
}
return resData;
... ... @@ -615,19 +628,18 @@ const getExchangeDetailData = (id, uid) => {
};
if (result[0] && result[0].data) {
let data = result[0].data;
if (result[1] && result[1].data) {
data.expressList = _setExpressData(result[1].data);
}
Object.assign(exchangeData.exchangeDetail, _setReturnStatus(data.statusList));// 头部
Object.assign(exchangeData.exchangeDetail, _setExchangeDetailData(data));
Object.assign(exchangeData.exchangeDetail, camelCase(data));
Object.assign(
exchangeData.exchangeDetail,
_setReturnStatus(data.statusList),
_setExchangeDetailData(data),
camelCase(data)
);
}
return exchangeData;
... ...
... ... @@ -54,14 +54,14 @@ const getNavBar = (data, type) => {
let navBars = [];
_.forEach(data, item => {
let obj = {},
let obj = {
link: item.sort_url,
cn: item.sort_name,
en: item.sort_name_en,
isNewPage: item.is_new_page === 'Y'
},
lowEn = _.camelCase(item.sort_name_en).toLowerCase();
obj.link = item.sort_url;
obj.cn = item.sort_name;
obj.en = item.sort_name_en;
obj.isNewPage = item.is_new_page === 'Y' ? true : false;
if (type === lowEn) {
obj.cur = true;
}
... ... @@ -132,17 +132,19 @@ const getSubNav = (data, type) => {
_.forEach(data, it => {
if (type === _.camelCase(it.sort_name_en).toLowerCase()) {
_.forEach(it.sub, item => {
let obj = {};
obj.link = item.sort_url;
obj.cn = item.sort_name;
obj.en = item.sort_name_en;
obj.isHot = item.is_hot === 'Y' ? true : false;
obj.isNew = item.is_new === 'Y' ? true : false;
let obj = {
link: item.sort_url,
cn: item.sort_name,
en: item.sort_name_en,
isHot: item.is_hot === 'Y',
isNew: item.is_new === 'Y',
};
if (item.sub) {
obj.thirdNav = getThirdNav(item.sub);
obj.imgCode = item.content_code;
Object.assign(obj, {
thirdNav: getThirdNav(item.sub),
imgCode: item.content_code
});
}
subNav.push(obj);
... ... @@ -153,9 +155,6 @@ const getSubNav = (data, type) => {
return subNav;
};
/**
* 处理接口返回的数据
* @param {object} 接口返回的对象
... ... @@ -189,14 +188,12 @@ const requestNavBar = (type) => {
});
};
/**
* 请求头部数据
* @param {String} 频道类型
* @return {promise}
*/
exports.requestHeaderData = (type) => {
const requestHeaderData = (type) => {
let arr = [
getMenuData()
];
... ... @@ -211,3 +208,7 @@ exports.requestHeaderData = (type) => {
}, result[1]);
});
};
module.exports = {
requestHeaderData // 请求头部数据
};
... ...