Authored by hongweigao

修改最新上架接口

... ... @@ -38,7 +38,8 @@ exports.getNewArrival = (req, res, next) => {
pageCount = reqBody.pageCount,
channel = reqBody.type || req.yoho.channel,
goods = [],
result = {};
result = {},
isJKChannel = reqBody.mChannel === 'japanKorean' ? true : false;
if (pageIndex < 0) {
pageIndex = 0;
... ... @@ -47,7 +48,7 @@ exports.getNewArrival = (req, res, next) => {
pageCount = 20;
}
channelModel.getNewArrival(channel).then(data => {
channelModel.getNewArrival(channel, isJKChannel).then(data => {
goods = _.slice(data, pageIndex, pageIndex + pageCount);
if (goods.length !== 0) {
... ...
... ... @@ -434,6 +434,25 @@ const _getSingleHotFloorData = (args, type) => {
return _getGirlsSingleHot(args, type);
}
};
/**
* 组装最新上架楼层数据
*
* @param string data
* return obj
*/
const _getNewGoodsFloorData = args => {
const data = {};
if (!_.isEmpty(args)) {
data.newArrivls = {
name: args[0].data.text,
navs: []
};
data.newArrivls.navs = args[1].data || {};
}
return data;
};
/**
* 文本标题
... ... @@ -452,6 +471,10 @@ const _getFloorTitleData = (args) => {
} else {
resData.floorHeader.name = args.data.text;
}
if (resData.floorHeader.name.indexOf('最新上架') >= 0) {
resData = _getNewGoodsFloorData(args);
}
return resData;
};
... ... @@ -565,25 +588,7 @@ const _processFloorDataWithQueryReusult = (rawData, originQuery, queryResult, ti
return data;
};
/**
* 组装最新上架楼层数据
*
* @param string data
* return obj
*/
const _getNewGoodsFloorData = args => {
const data = {};
if (!_.isEmpty(args)) {
data.newArrivls = {
name: args[0].data.text,
navs: []
};
data.newArrivls.navs = args[1].data || {};
}
return data;
};
const _getCategoryFloorData = args => {
const data = {
... ... @@ -715,9 +720,9 @@ const _processFloorData = (rawData, type, isJKChannel, code) => {
if (text.indexOf('最新速报') >= 0) {
floorData = _getNewReportFloorData(rawData.slice(index, index + 5), type, code);
//单个图作为最新速报模块用过的,标识一下,不作为广告位了
// 单个图作为最新速报模块用过的,标识一下,不作为广告位了
_.filter(rawData.slice(index, index + 5), function(o) {
if(o.template_name === 'single_image') {
if (o.template_name === 'single_image') {
o.hasUser = true;
}
});
... ... @@ -748,7 +753,7 @@ const _processFloorData = (rawData, type, isJKChannel, code) => {
// 1标题12图,在日韩馆频道页,作为7个品类显示
floorData = floorMap.sevenCategory.call(null, data.data);
} else if (isJKChannel && data && data.template_name === 'single_image') {
if(!data.hasUser) {
if (!data.hasUser) {
// 一张图,在日韩馆频道页,做广告位
floorData = floorMap.ad.call(null, data.data);
}
... ... @@ -922,9 +927,19 @@ const formatIndexGuideData = data => {
* @param string $channel
* @return array
*/
const getNewArrival = channel => {
const getNewArrival = (channel, isJKChannel)=> {
let rel = [],
sortList = sortMap[channel],
params = {},
method = '';
if (isJKChannel) {
method = 'app.search.sales';
params = {
productPool: 519
};
} else {
method = 'web.search.newshelve';
params = {
order: 'shelve_time:desc',
status: 1,
... ... @@ -933,6 +948,8 @@ const getNewArrival = channel => {
stocknumber: 3,
dayLimit: 4
};
}
params.gender = channelMap[channel].gender;
... ... @@ -940,7 +957,7 @@ const getNewArrival = channel => {
let data = Object.assign(item, params, {limit: item.viewNum});
rel.push(api.get('', Object.assign({
method: 'web.search.newshelve'
method: method
}, data), {cache: true}));
});
... ... @@ -978,13 +995,14 @@ const getContent = (type, req) => {
let title = req.query.title,
contentCode = req.query.content_code;
let isJKChannel = title === 'japanKorean' ? true : false;
return Promise.all([headerModel.requestHeaderData(type), _requestContent(type, contentCode)]).then(res => {
let headerData = res[0].data || res[0],
contentData = res[1].data ? res[1].data.list : res[1];
let data = {},
isJKChannel = title === 'japanKorean' ? true : false;
let data = {};
const processResult = _processFloorData(contentData, type, isJKChannel, contentCode);
... ... @@ -992,6 +1010,7 @@ const getContent = (type, req) => {
data.module = 'channel';
data.page = 'channel';
data.pageType = type;
isJKChannel ? data.mchannel = 'japanKorean' : '';// 子频道,如日韩馆
data.footerTop = true;
data.channel = processResult.floors;
... ...
<div class="home-page yoho-page {{pageType}}" data-page="{{pageType}}">
<div class="home-page yoho-page {{pageType}}" data-page="{{pageType}}" data-mchannel="{{mchannel}}">
{{# channel}}
{{! 头部banner}}
{{# slide}}
... ...
... ... @@ -19,6 +19,9 @@ module.exports = {
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
subDomains: {
... ...
... ... @@ -7,7 +7,10 @@
var $ = require('yoho-jquery');
var homePage = $('.home-page').data('page'),
brandUrl = $('.logo-brand').data('url');
brandUrl = $('.logo-brand').data('url'),
mChannel = $('.home-page').data('mchannel') || '';
var newArrParams = {};
// 给头部js获取当前频道
window.homePage = homePage;
... ... @@ -28,13 +31,19 @@ $(document).on('mouseout', '.imgopacity a img', function() {
$(this).css('opacity', 1); // eslint-disable-line
});
if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle', 'japanKorean']) > -1) {
require('../product/index/new-arrivls')({
if ($.inArray(homePage, ['boys', 'girls', 'kids', 'lifestyle']) > -1) {
newArrParams = {
type: homePage,
url: '/common/getNewArrival',
count: (homePage === 'boys') || (homePage === 'lifestyle') ? 5 : 4,
rows: [5, 3]
});
};
if (mChannel !== '') {
newArrParams.mChannel = mChannel;
}
require('../product/index/new-arrivls')(newArrParams);
window.setCookie('_Channel', homePage, {
domain: '.yohobuy.com',
path: '/',
... ...
... ... @@ -126,7 +126,6 @@ module.exports = function(data) {
pos = result.goods.length - len - 1;
result.goods.splice(pos, len);
myTemplate = Handlebars.compile(load.tpl);
$container.append(myTemplate(result.goods));
... ...