...
|
...
|
@@ -16,22 +16,19 @@ const ORDER_TYPE = { |
|
|
waitingForSend: 3, // 待发货
|
|
|
waitingForReceive: 4, // 待收货
|
|
|
completed: 5, // 已完成
|
|
|
canceled: 7, // 已取取消
|
|
|
history: 8 // 历史
|
|
|
canceled: 7 // 已取取消
|
|
|
};
|
|
|
|
|
|
const ORDER_EMPTY_DESC = {
|
|
|
1: '您还没有任何订单',
|
|
|
5: '您目前还没有成功的订单',
|
|
|
7: '您还没有任何取消的订单',
|
|
|
8: '您没有历史订单'
|
|
|
7: '您还没有任何取消的订单'
|
|
|
};
|
|
|
|
|
|
const TABS = [
|
|
|
{type: 1, name: '现有订单'},
|
|
|
{type: 5, name: '成功订单'},
|
|
|
{type: 7, name: '已取消订单'},
|
|
|
{type: 8, name: '历史订单'}
|
|
|
{type: 7, name: '已取消订单'}
|
|
|
];
|
|
|
|
|
|
const _getTabs = (type) => {
|
...
|
...
|
@@ -347,7 +344,7 @@ const _getExpressInfo = (orderCode, uid, paymetType, createTime, isDetail) => { |
|
|
/**
|
|
|
* 获取我的订单列表数据
|
|
|
*/
|
|
|
const _getOrders = (uid, page, limit, type, isPage)=> {
|
|
|
const getOrders = (uid, page, limit, type, isPage)=> {
|
|
|
return co(function *() {
|
|
|
isPage = isPage || false;
|
|
|
|
...
|
...
|
@@ -457,70 +454,14 @@ const _getOrders = (uid, page, limit, type, isPage)=> { |
|
|
})();
|
|
|
};
|
|
|
|
|
|
const _getHistoryOrders = (uid, page, limit) => {
|
|
|
return co(function *() {
|
|
|
const EMPTY = {
|
|
|
empty: ORDER_EMPTY_DESC[ORDER_TYPE.history] || '',
|
|
|
list: [],
|
|
|
pager: {
|
|
|
total: 0
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let ordersData = yield orderApi.getHistoryOrders(uid, page, limit)
|
|
|
.then(result => _.get(result, 'data', {}));
|
|
|
|
|
|
if (_.isEmpty(ordersData.list)) {
|
|
|
return EMPTY;
|
|
|
}
|
|
|
|
|
|
const orders = _.get(ordersData, 'list', []).map((order) => {
|
|
|
return {
|
|
|
orderNum: _.get(order, 'order_code'),
|
|
|
orderTime: moment.unix(_.get(order, 'order_time')).format('YYYY/M/D H:m:s'),
|
|
|
goods: JSON.parse(_.get(order, 'goods_data') || '[]'),
|
|
|
orderSum: _.get(order, 'amount'),
|
|
|
payMode: _.get(order, 'payment')
|
|
|
};
|
|
|
});
|
|
|
|
|
|
let pageObj = {
|
|
|
total: _.get(ordersData, 'total'),
|
|
|
pageTotal: _.get(ordersData, 'total_page'),
|
|
|
page: _.get(ordersData, 'page')
|
|
|
};
|
|
|
|
|
|
return {
|
|
|
list: orders,
|
|
|
pager: pageObj
|
|
|
};
|
|
|
})();
|
|
|
};
|
|
|
|
|
|
const getOrders = (type, uid, page, limit) => {
|
|
|
switch (type) {
|
|
|
case ORDER_TYPE.history:
|
|
|
return {
|
|
|
list: _getHistoryOrders(uid, page, limit),
|
|
|
name: Promise.resolve('historyOrders')
|
|
|
};
|
|
|
default:
|
|
|
return {
|
|
|
list: _getOrders(uid, page, limit, type, true),
|
|
|
name: Promise.resolve('orders')
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const index = (uid, page, limit, type) => {
|
|
|
return co(function * () {
|
|
|
let result = yield Promise.props(Object.assign(getOrders(type, uid, page, limit), {
|
|
|
let result = yield Promise.props({
|
|
|
orders: getOrders(uid, page, limit, type, true),
|
|
|
cancelReason: orderApi.closeReasons().then(res => _.get(res, 'data', ''))
|
|
|
}));
|
|
|
|
|
|
result[result.name] = result.list;
|
|
|
});
|
|
|
|
|
|
result.pager = pager(_.get(result, 'list.pager.total', 0), {page, limit, type});
|
|
|
result.pager = pager(_.get(result, 'orders.pager.total', 0), {page, limit, type});
|
|
|
|
|
|
return Object.assign(result, {
|
|
|
tabs: _getTabs(type)
|
...
|
...
|
@@ -710,7 +651,7 @@ const _getPackageInfo = (cartInfo) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
const _getOrder = co(function * (uid, orderId) {
|
|
|
const _getOrderDetail = co(function * (uid, orderId) {
|
|
|
let orderInfo = yield orderApi.getOrderDetail(uid, orderId);
|
|
|
let detail = {};
|
|
|
|
...
|
...
|
@@ -868,7 +809,7 @@ const closeReason = () => { |
|
|
|
|
|
const detail = co(function * (uid, orderId) {
|
|
|
let apiData = yield Promise.props({
|
|
|
detailData: _getOrder(uid, orderId),
|
|
|
detailData: _getOrderDetail(uid, orderId),
|
|
|
reason: closeReason()
|
|
|
});
|
|
|
|
...
|
...
|
|