Authored by 王水玲

新品到着

... ... @@ -4,17 +4,18 @@
* @date: 2016/7/28
*/
'use strict';
const mRoot = '../models';
const utils = '../../../utils';
const headerModel = require('../../../doraemon/models/header');
const searchProcess = require(`${utils}/search-process`);
const newModel = require(`${mRoot}/new`);
const _ = require('lodash');
const helpers = global.yoho.helpers;
// 新品到着
const newGoods = (req, res, next) => {
let channel = req.query.channel || 'boys';
let channel = req.yoho.channel;
newModel.getNewFocus(channel).then((result) => {
res.render('new/new', {
... ... @@ -27,7 +28,7 @@ const newGoods = (req, res, next) => {
headerBanner: result,
brand: '0',
sort: '0',
gender: '',
gender: req.query.gender ? req.query.gender : searchProcess.getGenderByChannel(channel),
channel: channel,
price: '0',
size: '0',
... ... @@ -40,7 +41,7 @@ const newGoods = (req, res, next) => {
};
const selectNewSale = (req, res, next) => {
let params = Object.assign({}, req.query);
let params = _.assign({}, req.query);
newModel.getSearchData(params).then((result) => {
res.render('search/page', {
... ...
... ... @@ -10,6 +10,7 @@ const logger = global.yoho.logger;
const _ = require('lodash');
const contentCode = require('../../../config/content-code');
const resourcesProcess = require(`${utils}/resources-process`);
const searchProcess = require(`${utils}/search-process`);
const productProcess = require(`${utils}/product-process`);
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
... ... @@ -29,15 +30,17 @@ const _searchGoods = (params) => {
}
}
// params.yh_channel = channelType[params.yh_channel];
params.yh_channel = searchProcess.getChannelType(params.channel);
params = Object.assign({
delete params.channel;
params = _.assign({
limit: '60'
}, params);
params.order = params.order === '0' ? 's_t_asc' :'s_t_desc';
params.order = params.order === '0' ? 's_t_desc' :'s_t_asc';
return api.get('', Object.assign({
return api.get('', _.assign({
method: method
}, params), {
cache: true
... ...
... ... @@ -229,7 +229,7 @@ const _getResources = (page, channel) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
logger.error('SALE 页面资源位返回 code 不是 200');
logger.error('get sale resources return code is not 200');
return [];
}
});
... ... @@ -250,7 +250,7 @@ const _getBreakingSort = (yhChannel) => {
if (result && result.code === 200) {
return _processBreakingSort(result.data);
} else {
logger.error('断码区分类接口返回 code 不是 200');
logger.error('get BreakingSort classify return code is not 200');
return {};
}
});
... ... @@ -268,7 +268,7 @@ const getSearchData = (params, uid) => {
showSale: false
});
} else {
logger.error('SALE 商品搜索返回 code 不是 200');
logger.error('get sale goods search data return code is not 200');
return [];
}
}),
... ...
/**
* 搜索相关数据处理
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/7/29
*/
/**
* 根据频道判断出性别
*/
const getGenderByChannel =(channel) => {
channel = channel ? channel : 'boys';
switch (channel) {
case 'boys': // 男
return '1,3';
case 'girls': // 女
return '2,3';
default: // 其它
return '1,2,3';
}
};
// 频道转换
const getChannelType = (channel) => {
channel = channel ? channel : 'boys';
switch (channel) {
case 'boys': // 男
return '1';
case 'girls': // 女
return '2';
case 'kids': // 童装
return '3';
case 'lifestyle': // 创意生活
return '4';
default: // all
return '1,2,3,4';
}
};
module.exports = {
getGenderByChannel,
getChannelType
};
... ...