...
|
...
|
@@ -5,7 +5,7 @@ |
|
|
*/
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const utils = '../../../utils';
|
|
|
const api = global.yoho.API;
|
|
|
const queryString = require('querystring');
|
|
|
const _ = require('lodash');
|
...
|
...
|
@@ -14,11 +14,13 @@ const studentsApi = require('./students-api'); |
|
|
const stuHandler = require('./students-handler');
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const crypto = global.yoho.crypto;
|
|
|
|
|
|
// const productProcess = require(`${utils}/product-process`);
|
|
|
// const _ = require('lodash');
|
|
|
const headerModel = require('../../../doraemon/models/header');
|
|
|
const serviceApi = global.yoho.ServiceAPI;
|
|
|
const searchApi = require('./search-api');
|
|
|
|
|
|
const productProcess = require(`${utils}/product-process`);
|
|
|
const searchHandler = require('./search-handler');
|
|
|
const needParams = ['query', 'msort', 'misort', 'gender', 'shelveTime'];
|
|
|
|
|
|
// 学生营销资源码
|
|
|
const studentsCode = '989396a17443bf61e3e269702e51ef04'; // h5 a83b7d55324fb65f96c1f85a3387ebd8
|
...
|
...
|
@@ -177,3 +179,86 @@ exports.userAcquireStatus = (uid, couponIds) => { |
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取学生返币专享商品列表数据
|
|
|
*/
|
|
|
exports.getStudentsList = (params, channel) => {
|
|
|
let standard = [];
|
|
|
|
|
|
_.forEach(params, (value, key) => {
|
|
|
let s = _.split(key, 'parameter_', 2);
|
|
|
|
|
|
if (s.length > 1) {
|
|
|
standard.push(`${s[1]}_${value}`);
|
|
|
_.unset(params, `${key}`);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (standard.length) {
|
|
|
params.standard = standard.join(',');
|
|
|
}
|
|
|
|
|
|
let searchParams = searchHandler.getSearchParams(params);
|
|
|
|
|
|
// 调用接口
|
|
|
let apiMethod = [
|
|
|
headerModel.requestHeaderData(channel),
|
|
|
searchApi.getSortList(Object.assign({}, {msort: '', misort: ''})),
|
|
|
studentsApi.getStudentsProduct(searchParams)
|
|
|
];
|
|
|
|
|
|
return Promise.all(apiMethod).then(result => {
|
|
|
let finalResult = {
|
|
|
module: 'product',
|
|
|
page: 'list',
|
|
|
headerData: Object.assign(result[0].headerData, {
|
|
|
header: true
|
|
|
}),
|
|
|
list: {
|
|
|
leftContent: {}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 获取左侧类目数据
|
|
|
if (result[1].code === 200) {
|
|
|
let dps = {};
|
|
|
|
|
|
_.forEach(needParams, (value) => {
|
|
|
if (params[value]) {
|
|
|
dps[value] = params[value];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
finalResult.list = Object.assign(
|
|
|
searchHandler.handlePathNavData(result[1].data.sort, params, 'sort', channel), {
|
|
|
leftContent: searchHandler.handleSortData(result[1].data.sort, dps)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 获取商品数据和顶部筛选条件
|
|
|
if (result[2].code === 200) {
|
|
|
// 删掉student_price,不让页面显示
|
|
|
_.forEach(result[2].data.product_list, goods => {
|
|
|
delete goods.student_price;
|
|
|
});
|
|
|
Object.assign(finalResult.list, {
|
|
|
filters: searchHandler.handleFilterDataAll(result[2].data, params),
|
|
|
opts: searchHandler.handleOptsData(params, result[2].data.total, result[2].data.filter),
|
|
|
totalCount: result[2].data.total,
|
|
|
footPager: searchHandler.handlePagerData(result[2].data.total, params),
|
|
|
goods: productProcess.processProductList(result[2].data.product_list,
|
|
|
Object.assign({showDiscount: false}, params, {
|
|
|
from: {type: 'list', params: params}
|
|
|
})),
|
|
|
hasNextPage: searchHandler.handleNextPage(params, result[2].data.total),
|
|
|
|
|
|
// 最近浏览记录
|
|
|
latestWalk: 6
|
|
|
});
|
|
|
}
|
|
|
|
|
|
finalResult.criteo = {skn: searchHandler.getCriteo(_.get(finalResult.list, 'goods'))};
|
|
|
return Object.assign({}, finalResult);
|
|
|
});
|
|
|
}; |
...
|
...
|
|