...
|
...
|
@@ -16,6 +16,20 @@ const helpers = global.yoho.helpers; |
|
|
|
|
|
const pageSize = 10;
|
|
|
|
|
|
const _reduceArrByProductSku = data => {
|
|
|
const d = [];
|
|
|
|
|
|
d.push(data[0]);
|
|
|
|
|
|
data.reduce((p, c) => { //eslint-disable-line
|
|
|
if (p && c && p.productSku !== c.productSku) {
|
|
|
d.push[c];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return d;
|
|
|
};
|
|
|
|
|
|
const getUserReturn = (uid, page) => {
|
|
|
|
|
|
return api.get('', {
|
...
|
...
|
@@ -104,6 +118,32 @@ const _setRefundGoodList = (data) => { |
|
|
return resData;
|
|
|
};
|
|
|
|
|
|
const _setRefundDetailData = (data) => {
|
|
|
let resData = {};
|
|
|
|
|
|
switch (data.status) {
|
|
|
case 10:
|
|
|
resData.orderReview = {pass: true};
|
|
|
resData.refundExpress = true;
|
|
|
resData.refundAddress = true;
|
|
|
break;
|
|
|
case 20:
|
|
|
resData.refundExpress = true;
|
|
|
break;
|
|
|
case 30:
|
|
|
resData.backStorage = true;
|
|
|
break;
|
|
|
case 40:
|
|
|
resData.refundSure = true;
|
|
|
break;
|
|
|
default:
|
|
|
resData.orderReview = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return resData;
|
|
|
};
|
|
|
|
|
|
const getRefundGoodsData = (orderCode, uid) => {
|
|
|
return returnsAPI.getRefundGoodsAsync(orderCode, uid).then(result => {
|
|
|
let resData = {};
|
...
|
...
|
@@ -124,12 +164,36 @@ const getRefundGoodsData = (orderCode, uid) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const getRefundDetailData = (applyId, uid) => {
|
|
|
return returnsAPI.getRefundDetailAsync(applyId, uid).then(result => {
|
|
|
let resData = {};
|
|
|
|
|
|
Object.assign(resData, _setSideMenu('我的退/换货'));
|
|
|
resData = {
|
|
|
title: '退货申请',
|
|
|
refundDetail: {}
|
|
|
};
|
|
|
|
|
|
if (result.data) {
|
|
|
// console.log(_setRefundDetailData(result.data));
|
|
|
Object.assign(resData.refundDetail, _setRefundDetailData(result.data));
|
|
|
}
|
|
|
|
|
|
return {returns: resData};
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const saveRefund = (orderCode, uid, goods, payment) => {
|
|
|
return returnsAPI.getOrderInfoAsync(orderCode, uid, '').then(result => {
|
|
|
if (!_.isEmpty(result)) {
|
|
|
return returnsAPI.refundSubmitAsync(orderCode, uid, goods, payment).then(subRes => {
|
|
|
if (subRes && subRes.data) {
|
|
|
return {code: 200, data: {refer: subRes.data.apply_id}};
|
|
|
return {
|
|
|
code: 200,
|
|
|
data: {
|
|
|
refer: helpers.urlFormat(`/return/refund/detail/${subRes.data.apply_id}`)
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
return {code: 400, message: '申请失败'};
|
|
|
});
|
...
|
...
|
@@ -139,8 +203,53 @@ const saveRefund = (orderCode, uid, goods, payment) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const getProductInfo = (productId, productSkn) => {
|
|
|
return returnsAPI.getProductInfoAsync(productId, productSkn).then(result => {
|
|
|
if (result.code === 200) {
|
|
|
camelCase(result);
|
|
|
result.data.goodsList.forEach(good => {
|
|
|
good.colorImage = helpers.image(good.colorImage, 20, 20);
|
|
|
});
|
|
|
}
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getChangeGoodsList = (orderCode, uid) => {
|
|
|
return returnsAPI.getChangeGoodsListAsync(orderCode, uid).then(result => {
|
|
|
const basicData = {
|
|
|
title: '申请退货'
|
|
|
};
|
|
|
let data;
|
|
|
|
|
|
console.log(result);
|
|
|
|
|
|
if (result && result.data) {
|
|
|
data = camelCase(result.data);
|
|
|
|
|
|
|
|
|
data.goodsList = _reduceArrByProductSku(data.goodsList);
|
|
|
data.hidePrice = true;
|
|
|
|
|
|
data.goodsList.forEach(good => {
|
|
|
good.showCheckbox = true;
|
|
|
good.hidePrice = true;
|
|
|
good.buyNumber = good.num;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
return {
|
|
|
returnsChange: Object.assign(basicData, data)
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getUserReturn,
|
|
|
getRefundGoodsData,
|
|
|
getChangeGoodsList,
|
|
|
getProductInfo,
|
|
|
getRefundDetailData,
|
|
|
saveRefund
|
|
|
}; |
...
|
...
|
|