Authored by htoooth

最近浏览功能。

... ... @@ -29,6 +29,11 @@ class DetailAction extends YohoAction {
let gid = req.params[1];
let uid = req.user.uid || '';
let vipLevel = detailHelper.vipLevel(req.user.vip);
let saveCurrentGoodsInCookies = _.partial(service.saveRecentGoodInCookies,
req.cookies._browse,
req.cookies._browseskn,
this.response
);
return service.showMainAsync({
pid: pid,
... ... @@ -36,7 +41,8 @@ class DetailAction extends YohoAction {
channel: this.getSessionChannel(),
gender: this.guessUserGender(),
uid: uid,
vipLevel: vipLevel
vipLevel: vipLevel,
saveInCookies: saveCurrentGoodsInCookies
}).then(result=> {
const seo = result.seo;
... ...
... ... @@ -529,6 +529,29 @@ function _getSortNavAsync(smallSortId, gender) {
})();
}
// 保存在 gids 和 skns ,最近流览功能
const saveRecentGoodInCookies = (oldGids, oldSkns, res, addGids, addSkns) => {
oldGids = (oldGids || '').split(',');
oldSkns = (oldSkns || '').split(',');
addSkns = `${addSkns}-${addGids}`;
_.remove(oldGids, addGids);
_.remove(oldSkns, addSkns);
oldGids.unshift(addGids);
oldSkns.unshift(addSkns);
res.cookie('_browse', oldGids.splice(0, 30).join(','), {
maxAge: 2000000000,
domain: 'yohobuy.com'
});
res.cookie('_browseskn', oldSkns.splice(0, 30).join(','), {
maxAge: 2000000000,
domain: 'yohobuy.com'
});
};
/**
* 详情页数据格式化
* @param origin Object 原始数据
... ... @@ -736,24 +759,21 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
if (domainBrand.type && domainBrand.shopId) {
switch (parseInt(domainBrand.type, 10)) {
case 1:
{
case 1: {
// 多品店不显示
banner = [];
break;
}
case 2:
{
banner = [];
break;
}
case 2: {
// 单品店显示新版的店铺banner
let basisData = yield shopService.basisTemplateAsync(domainBrand.shopId);
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
break;
}
default:
{
break;
}
let basisData = yield shopService.basisTemplateAsync(domainBrand.shopId);
banner.bgImg = basisData.shopTopBanner.banner || banner.bgImg;
break;
}
default: {
break;
}
}
}
}
... ... @@ -1372,12 +1392,17 @@ const showMainAsync = (data) => {
HeaderModel.requestHeaderData(data.channel)
]);
// 分类导航
// 分类导航 ,seo
let navs = requestData[0];
const seo = _getSeoByGoodsInfo(productInfo.goodsInfo, navs);
result.seo = seo;
// 最近浏览功能 ,限量商品不能使用这个功能
if (!_.has(productInfo, 'goodsInfo.fashionTopGoods')) {
data.saveInCookies(data.gid, _.get(productInfo, 'goodsInfo.skn', ''));
}
// 获取商品尺寸相关
let sizeInfo = _getSizeInfo(productInfo.goodsInfo, productInfo.goodsInfo.maxSortId);
... ... @@ -1407,5 +1432,6 @@ module.exports = {
indexConsultAsync: consultService.indexAsync, // 获取咨询列表
createConsultAsync: consultService.createAsync, // 添加咨询
showMainAsync: showMainAsync, // 获取某一个商品详情主页面
indexHotAreaAsync: hotAreaService.indexAsync // 获取某一个商品的热区数据
indexHotAreaAsync: hotAreaService.indexAsync, // 获取某一个商品的热区数据
saveRecentGoodInCookies // 保存最近的商品
};
... ...