Authored by 刘传洋

seo

... ... @@ -15,7 +15,13 @@ const search = require(`${mRoot}/search`);
* @return {[type]} [description]
*/
exports.index = (req, res, next) => {
let resData = {};
let resData = {
title: '潮流商品搜索 | YOHO!BUY 有货',
keywords: 'Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,' +
'品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,' +
'new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流',
description: '潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜'
};
search.getSearchData(req.query, req.yoho.channel).then(result => {
Object.assign(resData, result);
... ...
... ... @@ -94,14 +94,6 @@ exports.getListData = (params, channel) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
// 获取高级筛选条件
/* if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}*/
}
// 分类介绍
... ... @@ -113,7 +105,12 @@ exports.getListData = (params, channel) => {
if (result[4] && result[4].code === 200) {
Object.assign(finalResult.list.leftContent, searchHandler.handleSortAds(result[4].data));
}
return finalResult;
let seo = searchHandler.getListSeo(channel,
_.get(finalResult, 'list.leftContent.allSort.list'),
_.get(finalResult, 'list.filters.checkedConditions.conditions'));
return Object.assign({}, seo, finalResult);
});
};
... ... @@ -158,14 +155,6 @@ exports.getListNewData = (params, channel) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
// 获取高级筛选条件
/* if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}*/
}
// 新品上架
... ... @@ -173,7 +162,9 @@ exports.getListNewData = (params, channel) => {
Object.assign(finalResult.list.leftContent, searchHandler.handleWeekNew(result[3].data, params));
}
return finalResult;
let seo = searchHandler.getNewSeo(channel, _.get(finalResult, 'list.leftContent.newSales.list'));
return Object.assign({}, seo, finalResult);
});
};
... ... @@ -251,21 +242,14 @@ exports.getBrandData = (params, extra, channel) => {
goods: productProcess.processProductList(result[2].data.product_list,
Object.assign({showDiscount: false}, params))
});
// 获取高级筛选条件
/* if (finalResult.list && finalResult.list.filters) {
Object.assign(finalResult.list.filters, searchHandler.handleSeniorFilterData({
style: _.get(result[2], 'data.filter.style', []),
standard: _.get(result[2], 'data.standard', [])
}, params));
}*/
}
// 品牌页不显示品牌筛选项
delete finalResult.brand.filters.brand;
return finalResult;
let seo = searchHandler.getBrandSeo(channel, extra);
return Object.assign({}, seo, finalResult);
});
};
... ...
... ... @@ -131,8 +131,8 @@ const getSortList = (params) => {
}
return ret;
});
}
});
/*}
});*/
};
/**
... ...
... ... @@ -61,7 +61,8 @@ const handleCheckedData = (params, origin, param) => {
dest.push({
name: value.name,
href: handleFilterUrl(tempPatam)
href: handleFilterUrl(tempPatam),
itemType: param
});
}
});
... ... @@ -120,6 +121,7 @@ const handleBrandCheckedData = (params, origin) => {
};
checked.href = handleFilterUrl(params, tempParam);
checked.itemType = 'brand';
if (checkedCount === 0) {
dest[0] = checked;
} else if (checkedCount === 1) {
... ... @@ -383,11 +385,13 @@ exports.handleSortData = (origin, params) => {
name: `全部${value.sort_name}`,
num: value.count,
href: handleFilterUrl(params, {msort: value.sort_id}, {misort: true}),
childActive: (params.msort === value.sort_id) && !params.misort
childActive: (params.msort === value.sort_id) && !params.misort,
sortId: value.sort_id
}
],
href: handleFilterUrl(params, {msort: value.sort_id}),
active: params.msort === value.sort_id
active: params.msort === value.sort_id,
sortId: value.sort_id
};
allCount += parseInt(value.count, 10);
... ... @@ -397,7 +401,8 @@ exports.handleSortData = (origin, params) => {
name: subValue.sort_name,
num: subValue.count,
href: handleFilterUrl(params, {msort: value.sort_id, misort: subValue.sort_id}),
childActive: params.misort === subValue.sort_id
childActive: params.misort === subValue.sort_id,
sortId: subValue.sort_id
});
if (params.misort === subValue.sort_id) {
category.active = true;
... ... @@ -1161,3 +1166,127 @@ exports.handleNextPage = (params, total) => {
'imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
};
};
const getChannelName = channel => {
let channelName = '';
switch(channel){
case 'boys':
channelName = '男生';
break;
case 'girls':
channelName = '女生';
break;
case 'kids':
channelName = '潮童';
break;
case 'lifestyle':
channelName = '创意生活';
break;
default:
channelName = '男生';
}
return channelName;
};
/**
* 列表页seo
* @param channel
* @param sorts
* @param checked
* @returns {{title: string, keywords: string, description: string}}
*/
exports.getListSeo = (channel, sorts, checked) => {
let channelName = getChannelName(channel),
brandName = '',
priceName = '',
msortName = '',
misortName = '';
_.forEach(sorts, val => {
if(val.active) {
msortName = val && val.name;
_.forEach(val.childList, sub => {
if(sub.childActive && sub.sortId !== val.sortId) {
misortName = sub && sub.name;
return false;
}
});
return false;
}
});
_.forEach(checked, ck => {
if(ck.itemType === 'price') {
priceName = ck.name;
} else if(ck.itemType === 'brand') {
brandName = ck.name;
}
});
let bmpcm = brandName + misortName + priceName + channelName + msortName,
bm = brandName + misortName,
bmp = brandName + misortName + priceName,
cmbm = channelName + msortName + brandName + misortName,
cm = channelName + msortName;
let title = (bmpcm ? bmpcm + '|' : '') + 'YOHO!BUY 有货 100%正品保证',
keywords = (bm ? bm + ',' : '') + (bmp ? bmp + ',' : '') + cmbm,
description = bmp + '正品网购。' + (cm ? cm + ',' : '') + bm + '官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。';
return {
title: title,
keywords: keywords,
description: description
};
};
/**
* 新品到页 seo
* @param channel
* @param dlist
* @returns {{title: string, keywords: string, description: string}}
*/
exports.getNewSeo = (channel, dlist) => {
let channelName = getChannelName(channel),
nlabel = '';
_.forEach(dlist, d => {
if(d && d.active) {
nlabel = d.name || '';
return false;
}
});
let newTitle = channelName + nlabel;
return {
title: newTitle + '新品上架-YOHO!BUY 有货 100%正品保证',
keywords: newTitle + '新品上架',
description: newTitle + '新品上架,正品网购,官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。'
}
};
exports.getBrandSeo = (channel, brandInfo) => {
let c = getChannelName(channel),
bcn = brandInfo && brandInfo.brandNameCn,
b = brandInfo && brandInfo.brandNameEn,
bb = b + ' ' + bcn,
bc = b + c,
bbc = b + bcn + c,
title = bb || b || '',
keywords = (b ? b + ',' : '') + ((b && bcn) ? (bb + ',') : '') + bc || '' + '品牌',
desc = b + '正品网购。' + bbc || '' + '品牌官方授权!YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。';
title += (title ? (title + '|') : '') + c + '品牌|YOHO!BUY 有货 100%正品保证';
return {
title: title,
keywords: keywords,
description: desc
};
};
... ...
... ... @@ -119,7 +119,7 @@ exports.processProductList = (list, options) => {
// 商品信息有问题,则不显示
if (!product.product_skn || !product.goods_list.length) {
if (!product || !product.product_skn || !product.goods_list.length) {
return;
}
... ...