|
|
/*
|
|
|
* @Author: Targaryen
|
|
|
* @Date: 2016-06-02 15:11:15
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2016-06-02 15:22:08
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
const library = '../../../library';
|
|
|
const utils = '../../../utils';
|
|
|
const API = require(`${library}/api`).API;
|
|
|
const api = new API();
|
|
|
const saleApi = require('./sale-api');
|
|
|
const saleHandler = require('./sale-handler');
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
/**
|
|
|
* 获取 VIP 会员专享和新降价专区数据 Controller 调用
|
|
|
* @return {[type]} [description]
|
|
|
*/
|
|
|
exports.getSaleOthersData = (params) => {
|
|
|
|
|
|
let promiseObject = [
|
|
|
saleApi.getSaleGoodsList(params),
|
|
|
saleApi.getLeftContentList()
|
|
|
];
|
|
|
|
|
|
return api.all(promiseObject).then(result => {
|
|
|
let finalResult = {};
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[0].code === 200) {
|
|
|
finalResult.goods = productProcess.processProductList(result[0].data.product_list);
|
|
|
if (!_.isEmpty(result[0].data.filter)) {
|
|
|
finalResult.filters = saleHandler.handleSaleFilterData(result[0].data.filter, params);
|
|
|
}
|
|
|
|
|
|
// 处理排序数据
|
|
|
finalResult.opts = saleHandler.handleSaleOptsData(params, result[0].data.total);
|
|
|
finalResult.totalCount = result[0].data.total;
|
|
|
finalResult.pager = saleHandler.handleSalePagerData(result[0].data.total, params);
|
|
|
}
|
|
|
|
|
|
// 获取左侧类目数据
|
|
|
if (result[1].code === 200) {
|
|
|
if (params.gender === '2,3') {
|
|
|
finalResult.leftContent = saleHandler.handleSaleSortData(result[1].data.girl, params);
|
|
|
} else {
|
|
|
finalResult.leftContent = saleHandler.handleSaleSortData(result[1].data.boy, params);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
|
|
});
|
|
|
}; |
...
|
...
|
|