list.js
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* @Author: Targaryen
* @Date: 2016-06-02 15:11:15
* @Last Modified by: Targaryen
* @Last Modified time: 2016-06-07 16:10:50
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const API = require(`${library}/api`).API;
const api = new API();
const saleApi = require('./sale-api');
const productProcess = require(`${utils}/product-process`);
const publicHandler = require('./public-handler');
const headerModel = require('../../../doraemon/models/header');
/**
* 获取商品列表商品数据 Controller 调用
* @param {[type]} params [常规参数]
* @param {[type]} extra [左侧列表额外要拼接的参数]
* @return {[type]} [description]
*/
exports.getSaleOthersData = (params, channel) => {
return api.all([
headerModel.requestHeaderData(channel),
saleApi.getSaleGoodsList(params),
saleApi.getSaleGoodsList({ saleType: '4', limit: '1', channel: channel })
]).then(result => {
let finalResult = result[0];
// 获取商品数据和顶部筛选条件
if (result[1].code === 200) {
finalResult.goods = productProcess.processProductList(result[1].data.product_list);
}
// 获取左侧类目数据
if (result[2].code === 200) {
finalResult.leftContent = publicHandler.handleSaleSortData(result[2].data.filter.group_sort, params);
finalResult.filters = publicHandler.handleSaleFilterData(result[2].data.filter, params);
// 处理排序数据
finalResult.opts = publicHandler.handleSaleOptsData(params, result[2].data.total);
finalResult.totalCount = result[2].data.total;
finalResult.pager = publicHandler.handleSalePagerData(result[2].data.total, params);
}
return finalResult;
});
};