Authored by 周少峰

detail & list

... ... @@ -210,28 +210,29 @@ const keyId = (req, res, next) => {
let params = req.query;
let id = req.params.id;
return search.getSearchKeywordDataById(id, params, req.yoho.channel).then(result => {
return search.getSearchKeywordDataById(id, Object.assign({stocknumber: -1}, params),
req.yoho.channel).then(result => {
if (!result) {
return next();
}
if (!result) {
return next();
}
let query = result.queryKey;
let query = result.queryKey;
Object.assign(result, {
pageNoFollow: true,
title: `${query}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${query},${query}价格,${query}图片,${query}怎么样,${query}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${query}网上潮流购物商城,为您找到${_.get(result,
Object.assign(result, {
pageNoFollow: true,
title: `${query}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${query},${query}价格,${query}图片,${query}怎么样,${query}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${query}网上潮流购物商城,为您找到${_.get(result,
'search.totalCount', 0)}${query}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${query},就上YOHO!BUY有货`
});
});
if (!_.get(result, 'search.goods') || !_.get(result, 'search.goods').length) {
_.set(result, 'search.keyWord', query);
return res.render('search/no-result', result);
}
res.render('search/index', result);
}).catch(next);
if (!_.get(result, 'search.goods') || !_.get(result, 'search.goods').length) {
_.set(result, 'search.keyWord', query);
return res.render('search/no-result', result);
}
res.render('search/index', result);
}).catch(next);
};
module.exports = {
... ...
... ... @@ -56,7 +56,7 @@ const indexAsync = pid => {
marketPrice: cur.product.productPriceBo.formatMarketPrice,
productName: cur.product.productName,
href: helpers.getUrlBySkc(
_.get(goods, 'goodsImagesList[0].productSkn', ''))
_.get(cur.product, 'productPriceBo.productSkn', ''))
};
acc.push(point);
... ...
... ... @@ -6,6 +6,7 @@
const api = global.yoho.API;
const config = global.yoho.config;
const redis = global.yoho.redis;
/**
* 商品的 banner
... ... @@ -131,8 +132,8 @@ const getShopRecommendAsync = (skn, page, limit) => {
return api.get('', {
method: 'web.product.shopRecommend',
product_skn: skn,
page: page,
limit: limit
page: page || 1,
limit: limit || 20
});
};
... ... @@ -146,6 +147,30 @@ const getBundleAsync = (skn) => {
});
};
/**
* 找相似
*/
const getLikeAsync = (skn, limit) => {
return api.get('', {
method: 'app.search.findLike',
limit: limit || 10,
product_skn: skn
});
};
// 根据small_sort从redis获取分类下的关键词
const getRecommendKeywords = (smallSort) => {
return Promise.race([
redis.getAsync(`golobal:yoho:seo:keywords:sortId:${smallSort}`),
new Promise((resolve)=>{
setTimeout(resolve, 500, []);
})
]).then(function(res) {
return res;
});
};
module.exports = {
getProductBannerAsync,
sizeInfoAsync,
... ... @@ -156,5 +181,7 @@ module.exports = {
isSupportReturnedSale,
getLimitedProductStatusAsync,
getShopRecommendAsync,
getBundleAsync
getBundleAsync,
getLikeAsync,
getRecommendKeywords
};
... ...
... ... @@ -36,6 +36,7 @@ const BLANK_STR = ' ';
const BUNDLE_PRODUCE = 2; // 量贩
const BUNDLE_PACKAGE = 1; // 套餐
const tdk = require('../../../utils/getTDK');
const Helpers = global.yoho.helpers;
const _getProductAdditionInfoAsync = (data) => {
return co(function * () {
... ... @@ -1009,6 +1010,19 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> {
return result;
};
// 返回6条推荐关键词页面
const getKeywordsInfo = (keywords) => {
let res = [];
_.forEach(_.slice(_.shuffle(keywords), 0, 12), val => {
res.push({
url: Helpers.urlFormat(`/chanpin/${val.id}.html`),
keyword: val.keyword
});
});
return res;
};
/**
* 获取seo信息
*
... ... @@ -1103,6 +1117,9 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
return result;
}
// sku商品信息,尺寸信息
let skuData = _getSkuDataByProductBaseInfo(origin);
result.name = propOrigin('product_name');
result.skn = propOrigin('product_skn');
result.productId = propOrigin('product_id');
... ... @@ -1145,6 +1162,17 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
requestApi.bundle = productAPI.getBundleAsync(result.skn); // 量贩
}
// 找相似
if (skuData.totalStorageNum === 0) {
requestApi.alike = productAPI.getLikeAsync(result.skn);
}
// 相关推荐词
requestApi.recommendKeywords = productAPI.getRecommendKeywords(result.smallSortId);
// 店铺推荐直出(seo需要)
requestApi.shopRecommend = productAPI.getShopRecommendAsync(result.skn);
let requestData = yield Promise.props(requestApi);
let additionalData = requestData.addition;
... ... @@ -1153,6 +1181,20 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
let coupon = requestData.coupon;
let limitedInfo = requestData.limited;
let bundle = requestData.bundle;
let recommendKeywords = JSON.parse(requestData.recommendKeywords);
// 处理相似商品
result.alike = _.map(_.get(requestData, 'alike.data.product_list', ''), val =>{
return Object.assign({url: Helpers.getUrlBySkc(val.product_skn)}, val);
});
// 推荐关键词页面
result.recommendKeywords = getKeywordsInfo(recommendKeywords);
// 处理店铺推荐
result.shopRecommend = _.map(_.get(requestData, 'shopRecommend.data.product_list', ''), val =>{
return Object.assign({url: Helpers.getUrlBySkc(val.product_skn)}, val);
});
// 商品标签
result.tags = _getTagsDataByProductInfo(origin);
... ... @@ -1240,9 +1282,6 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
result.presale = 'Y';
}
// sku商品信息,尺寸信息
let skuData = _getSkuDataByProductBaseInfo(origin);
result.img = skuData.defaultImage;
result.colors = skuData.skuGoods;
let totalStorageNum = skuData.totalStorageNum;
... ... @@ -1722,7 +1761,6 @@ const getPackage = co(function * (skn) {
return resData;
});
module.exports = {
getShareOrderListAsync: commentService.getShareOrderListAsync, // 获取评论列表
indexConsultAsync: consultService.indexAsync, // 获取咨询列表
... ...
... ... @@ -23,6 +23,8 @@
<div id="package" class="package-box clearfix hide"></div>
{{> product/alike}}
<div class="total-content">
<div class="other-infos">
{{> product/description}}
... ... @@ -39,6 +41,8 @@
{{> product/after-service}}
{{> product/recommend-keywords}}
{{> product/recommend-receiveview}}
</div>
... ...
{{#if goodsInfo.alike}}
<div class="bottom-tab alike-title">
<p>
<span class="bottom-title bottom-cur">相似商品</span>
<span class="bottom-title change">换一批
<span class="iconfont change-icon">&#xe6d3;</span>
</span>
</p>
</div>
<div class="individual-comment info-block info-bottom alike">
<div>
<div class="recommend-content clearfix">
<div class="recommend-slider-alike">
<ul class=" img-list">
{{# goodsInfo.alike}}
<li class="img-item">
<span class="hide goods-id">{{goods_id}}</span>
<div class="good">
<a href="{{url}}" target="_blank">
<img class="lazy" src="{{image2 default_images w=280 h=382}}"/>
</a>
<a class="name" href="{{url}}" target="_blank">{{product_name}}</a>
<p class="price">
<span class="market-price">¥{{market_price}}</span>
<span class="sale-price">¥{{sales_price}}</span>
</p>
</div>
</li>
{{/goodsInfo.alike}}
</ul>
<div class="img-brand-switch">
<a class="prev iconfont" href="javascript:;">&#xe609;</a>
<a class="next iconfont" href="javascript:;">&#xe608;</a>
</div>
</div>
</div>
</div>
</div>
{{/if}}
\ No newline at end of file
... ...
{{#if goodsInfo.recommendKeywords}}
<div class="recommend-keywords">
<h3>相关推荐</h3>
<p>
{{# goodsInfo.recommendKeywords}}
<a href="{{url}}" title="{{keyword}}" target="_blank">{{keyword}}</a>
{{/ goodsInfo.recommendKeywords}}
</p>
</div>
{{/if}}
... ...
... ... @@ -25,17 +25,34 @@
{{> product/latest-walk-tpl}}
</div>
{{/if}}
<div id="recommend-shop" class="hide">
<div class="recommend-content clearfix">
<div class="recommend-slider">
<ul class=" img-list" id="recommend-content"></ul>
<div class="img-brand-switch">
<a class="prev iconfont" href="javascript:;">&#xe609;</a>
<a class="next iconfont" href="javascript:;">&#xe608;</a>
{{#if goodsInfo.shopRecommend}}
<div id="recommend-shop">
<div class="recommend-content clearfix">
<div class="recommend-slider">
<ul class=" img-list" id="recommend-content">
{{# goodsInfo.shopRecommend}}
<li class="img-item">
<span class="hide goods-id">{{goods_id}}</span>
<div class="good">
<a href="{{url}}" target="_blank">
<img class="lazy" src="{{image2 default_images w=280 h=382}}"/>
</a>
<a class="name" href="{{url}}" target="_blank">{{product_name}}</a>
<p class="price">
<span class="market-price">¥{{market_price}}</span>
<span class="sale-price">¥{{sales_price}}</span>
</p>
</div>
</li>
{{/ goodsInfo.shopRecommend}}
</ul>
<div class="img-brand-switch">
<a class="prev iconfont" href="javascript:;">&#xe609;</a>
<a class="next iconfont" href="javascript:;">&#xe608;</a>
</div>
</div>
</div>
</div>
</div>
{{/if}}
</div>
{{/unless}}
... ...
... ... @@ -1495,45 +1495,29 @@ function initPageYas() {
yas.givePoint('YB_CHOOSE_FOR_YOU_Y', loadYas);
}
// 店铺推荐
// 店铺推荐 改为后台直出
function loadRecommend() {
return $.ajax({
type: 'GET',
url: '/product/detail/recommend',
data: {
skn: skn,
size: 20,
num: 1
}
}).then(function(data) {
var pro = data.data.products;
var recommendTpl = require('hbs/product/recommend.hbs');
var html = recommendTpl(data.data);
if (data.code === 200 && pro.length !== 0) {
$('#recommend-shop').removeClass('hide');
$('#recommend-content').append(html);
$('.recommend-slider').slider2({
shownum: 5,
isCircle: true
});
$('.recommend-slider .img-item .goods-id').each(function() {
$goodsIdArr.push($(this).html());
});
} else {
$('.bottom-title').eq(0).removeClass('bottom-cur').addClass('hide');
$('.bottom-title').eq(1).addClass('bottom-cur');
$('.bottom-title').filter('.change').addClass('hide');
var imgItem = $('.recommend-slider .img-item'),
$bottomTitle = $('.bottom-tab .bottom-title');
$('#recommend-shop').remove();
$('.individual-comment .latest-walk').show();
fetchLatestWalk(); // eslint-disable-line
}
if (imgItem.length !== 0) {
// 页面加载完,埋点
initPageYas();
});
$('.recommend-slider .img-item .goods-id').each(function() {
$goodsIdArr.push($(this).html());
});
} else {
$bottomTitle.eq(0).removeClass('bottom-cur').addClass('hide');
$bottomTitle.eq(1).addClass('bottom-cur');
$bottomTitle.filter('.change').addClass('hide');
$('#recommend-shop').remove();
$('.individual-comment .latest-walk').show();
fetchLatestWalk(); // eslint-disable-line
}
// 页面加载完,埋点
initPageYas();
}
// 点击为您推荐商品埋点
... ... @@ -1835,14 +1819,14 @@ $('.bottom-tab').on('click', '.bottom-title', function() {
$recommendComment.slideDown(SLIDETIME);
$latestWalk.slideUp(SLIDETIME);
$('.change').removeClass('hide');
$(this).siblings('.change').removeClass('hide');
} else {
// 最近游览
window.fetchLatestWalk(); // eslint-disable-line
$recommendComment.slideUp(SLIDETIME);
$latestWalk.slideDown(SLIDETIME);
$('.change').addClass('hide');
$(this).siblings('.change').addClass('hide');
}
});
... ... @@ -1959,6 +1943,12 @@ $(function() {
}
});
});
// 猜你喜欢、店铺推荐初始化
$('.recommend-slider-alike, .recommend-slider').slider2({
shownum: 5,
isCircle: true
});
});
yasAtBottom.yasBottom();
... ...
... ... @@ -1009,7 +1009,8 @@
}
}
.bottom-tab {
.bottom-tab,
.alike-title {
.bottom-title {
font-size: 15px;
display: inline-block;
... ... @@ -1804,6 +1805,31 @@
}
}
.recommend-keywords {
margin-top: 30px;
margin-bottom: 20px;
border: 1px #e0e0e0 solid;
h3 {
height: 46px;
border-bottom: 1px #e0e0e0 solid;
line-height: 44px;
background: #f5f5f5;
text-align: center;
font-size: 15px;
}
p {
padding: 10px;
a {
display: inline-block;
margin: 5px 15px;
font-size: 12px;
}
}
}
.support-salereturned-service {
$service: product/service.png;
... ... @@ -2083,6 +2109,20 @@
}
}
}
.alike-title {
margin-top: 30px;
}
.alike {
.recommend-content {
height: 340px;
li {
height: 340px;
}
}
}
}
.coupon-big {
... ...