Authored by 郭成尧

'shop-brand-seo'

... ... @@ -38,13 +38,16 @@ const _getUidFromUserAgent = (req) => {
*/
const _baseShop = (req, res, shopInfo, shopId) => {
listModel.getBaseShopData(req.query, shopInfo).then(result => {
listModel.getBaseShopData(Object.assign(req.query, {
channel: req.yoho.channel
}), shopInfo).then(result => {
if (result && result.baseShopHome && result.baseShopHome.banner) {
if (result.baseShopHome.banner.indexOf('?') < 0) {
result.baseShopHome.banner += '?imageMogr2/auto-orient/strip/thumbnail/x150/crop/640x150';
}
}
res.render('search/goods-list', {
res.render('search/goods-list', Object.assign({
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
... ... @@ -53,12 +56,13 @@ const _baseShop = (req, res, shopInfo, shopId) => {
goodList: result,
showDownloadApp: true,
pageFooter: true,
title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰',
description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
// title: shopInfo.shop_name + '|' + shopInfo.shop_name + '潮流服装服饰-Yoho!Buy有货',
// keywords: shopInfo.shop_name + ',' + shopInfo.shop_name + '服装服饰,' + shopInfo.shop_name + '潮流服装服饰',
// description: shopInfo.shop_name + '|Yoho!Buy有货' + shopInfo.shop_name + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
shopId: shopId,
shopPage: true
});
}, result.seoResult));
});
};
... ... @@ -142,19 +146,20 @@ const _shop = (req, res, shopId) => {
// 有领券功能,不缓存
res.set('Cache-Control', 'no-cache');
res.render('shop/index', {
res.render('shop/index', Object.assign({
module: 'product',
page: 'shop',
shopIndex: result,
shopHeadHide: true,
gender: req.query.gender,
channel: req.query.channel,
title: result.seoTitle + '|' + result.seoTitle + '潮流服装服饰-Yoho!Buy有货',
keywords: result.seoTitle + ',' + result.seoTitle + '服装服饰,' + result.seoTitle + '潮流服装服饰',
description: result.seoTitle + '|Yoho!Buy有货' + result.seoTitle + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
// title: result.seoTitle + '|' + result.seoTitle + '潮流服装服饰-Yoho!Buy有货',
// keywords: result.seoTitle + ',' + result.seoTitle + '服装服饰,' + result.seoTitle + '潮流服装服饰',
// description: result.seoTitle + '|Yoho!Buy有货' + result.seoTitle + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
shopId: shopId,
shopPage: true
});
}, result.seoResult));
});
}
... ... @@ -272,11 +277,13 @@ const brand = (req, res, next) => {
if (req.query.from !== 'search' && brandLogo.type === '2' && brandLogo.shopId) {
_shop(req, res, brandLogo.shopId);
} else { // 获取品牌店铺信息
listModel.getBrandShops(brandId).then(brandShop => {
listModel.getBrandShops(brandId, req).then(brandShop => {
if (brandId === 0) {
params.query = domain;
}
params.seoResult = brandShop.seoResult;
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息 或者品牌关联多店铺
if (req.query.from === 'search' || brandShop.length > 0) {
params = _.assign({
... ... @@ -303,7 +310,7 @@ const brand = (req, res, next) => {
res.set('Cache-Control', 'no-cache');
}
res.render('search/goods-list', {
res.render('search/goods-list', Object.assign({
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
... ... @@ -312,12 +319,13 @@ const brand = (req, res, next) => {
goodList: params,
showDownloadApp: true,
pageFooter: true,
title: title + '|' + title + '潮流服装服饰-Yoho!Buy有货',
keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
// title: title + '|' + title + '潮流服装服饰-Yoho!Buy有货',
// keywords: title + ',' + title + '服装服饰,' + title + '潮流服装服饰',
// description: title + '|Yoho!Buy有货' + title + '潮流服饰官方授权店!100%品牌正品保证,支持货到付款。',
domain: req.query.domain,
shopPage: true
});
}, params.seoResult));
});
}
}).catch(next);
... ...
... ... @@ -51,7 +51,11 @@ const _processBrandShops = (list) => {
*/
const _modifyWapUrl = (origin, shopId) => {
if (parseInt(_.get(origin, 'linkType', 0), 10) === 1) {
return helpers.urlFormat('', {filter_poolId: origin.categoryId, shop_id: shopId, title: origin.categoryName}, 'search'); //eslint-disable-line
return helpers.urlFormat('', {
filter_poolId: origin.categoryId,
shop_id: shopId,
title: origin.categoryName
}, 'search'); //eslint-disable-line
} else {
if (_.has(origin, 'url')) {
return origin.url;
... ... @@ -175,6 +179,70 @@ const _shopCouponsList = (shopId, uid) => {
};
/**
* 处理店铺或者品牌 seo 数据
* @param channel
* @param info
* @param qs
* @returns {{}}
* @private
*/
const _getBrandShopSeo = (channel, info, qs) => {
let resData = {},
ctype = {
boys: {fashionType: '男装', brandType: '男生品牌'},
girls: {fashionType: '女装', brandType: '女生品牌'},
kids: {fashionType: '童装', brandType: '潮童品牌'},
lifestyle: {fashionType: '创意生活', brandType: '创意生活品牌'}
};
let params = {
nameEn: '',
name: ''
};
if (info) {
Object.assign(params, {
nameEn: _.get(info, 'brand_name_en', ''),
nameCn: _.get(info, 'brand_name_cn', ''),
name: _.get(info, 'brand_name', '')
});
params.name = `${params.nameEn} ${params.nameCn} ${params.name}`;
if (info.shop_name) {
Object.assign(params, {
nameEn: info.shop_name,
name: info.shop_name
});
}
}
if (qs && qs.gender) {
if (qs.gender === '1,3') {
channel = 'boys';
} else if (qs.gender === '2,3') {
channel = 'girls';
}
Object.assign(params, ctype[channel] || ctype.boys);
Object.assign(resData, {
title: `${params.nameEn} | ${params.name} ${params.brandType}`,
keywords: `${params.nameEn}, ${params.name} ${params.fashionType},${params.nameEn} ${params.brandType}`,
description: `${params.nameEn}正品网购。${params.name}官方授权!`
});
} else {
Object.assign(resData, {
title: `${params.nameEn} | ${params.name}官网`,
keywords: `${params.nameEn}, ${params.name}官网`,
description: `${params.nameEn}正品网购。${params.name}官方授权!`
});
}
resData.title += resData.title ? ' | YOHO!有货 100%正品保证' : '';
resData.description += resData.description ? ' YOHO! 有货中国最大的潮流商品购物网站。100%品牌正品保证,支持货到付款。' : ''; // eslint-disable-line
return resData;
};
/**
* TODO TAR 店铺和品牌收藏状态调用新的接口
* 调用接口获取品牌或者店铺的收藏状态
* @private
... ... @@ -476,8 +544,11 @@ const _formShopData = (data, shopId, isApp) => {
*/
const getBaseShopData = (params, shopInfo) => {
/* tar add 161109 seo-info */
let seoResult = _getBrandShopSeo(params.channel, shopInfo, params);
let finalResult = {
cartUrl: helpers.urlFormat('/cart/index/index')
cartUrl: helpers.urlFormat('/cart/index/index'),
seoResult: seoResult
};
let shopId = params.shop_id || shopInfo.shops_id;
... ... @@ -530,6 +601,8 @@ const getShopData = (req, shopId, uid, isApp) => {
return _getShopInfo(shopId, uid).then(shopInfoResult => {
let seoResult = _getBrandShopSeo(channel, shopInfoResult, req.query);
/* 基础店铺返回程序内的跳转信号,跳转到基础店铺 */
if (shopInfoResult && shopInfoResult.shop_template_type && parseInt(shopInfoResult.shop_template_type, 10) === 1) {
return {
... ... @@ -596,7 +669,8 @@ const getShopData = (req, shopId, uid, isApp) => {
uid: uid ? crypto.encryption('', uid + '') : '',
coverChannel: channel,
shopCoupons: shopCoupons,
shopCouponsOne: shopCoupons.length === 1
shopCouponsOne: shopCoupons.length === 1,
seoResult: seoResult
}
);
});
... ... @@ -707,9 +781,10 @@ const getBrandLogoByDomain = (domain) => {
/**
* 根据brandId 获取相关店铺列表
* @param brandId
* @param req
* @return array
*/
const getBrandShops = (brandId) => {
const getBrandShops = (brandId, req) => {
return api.get('', {
method: 'app.shop.queryShopsByBrandId',
brand_id: brandId
... ... @@ -718,7 +793,9 @@ const getBrandShops = (brandId) => {
cache: true
}).then(result => {
if (_.isArray(result.data)) {
return _processBrandShops(result.data);
let seoResult = _getBrandShopSeo(req.channel, result.data[0], req.query);
return Object.assign(_processBrandShops(result.data), {seoResult: seoResult});
} else {
return [];
}
... ...