Authored by yyq

tdk

... ... @@ -7,6 +7,7 @@
'use strict';
const _ = require('lodash');
const cheerio = require('cheerio');
const guangModel = require('../models/guang-service');
const headerModel = require('../../../doraemon/models/header');
... ... @@ -296,10 +297,25 @@ exports.detail = (req, res, next) => {
};
}
title = `${info.title}-YOHO!BUY 有货网`;
let ctext = '';
_.forEach(ret[1] || [], val => {
if (!ctext && val.text) {
ctext = val.text;
return false;
}
});
let $ = cheerio.load(ctext);
$('p').each(function() {
if (!description) {
description = _.trim($(this).text());
}
});
title = `${info.title}_潮流资讯-YOHO!BUY 有货`;
keywords = info.title;
description = info.desc.length > 0 ? `${info.desc}` :
'潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜';
description = description || '潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜';
res.render('guang/detail', Object.assign({
module: 'guang',
... ...
... ... @@ -84,22 +84,22 @@ const getArticleUrl = (url, id) => {
const guangListSeoMap = {
1001: {
title: '高人气潮流文章,逛人气潮流资讯-YOHO!BUY 有货网',
title: '人气潮流资讯-YOHO!BUY 有货',
keywords: '人气潮流文章,潮流人气,逛潮流人气',
description: '有货网每天提供全球人气潮流文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解高人气潮流资讯就来有货网!'
},
2: {
title: '各种潮流搭配,逛潮流搭配资讯-YOHO!BUY 有货网',
title: '潮流搭配_潮流资讯-YOHO!BUY 有货',
keywords: '搭配潮流文章,潮流搭配',
description: '有货网每天提供全球潮流搭配文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解学习潮流搭配资讯就来有货网!'
},
4: {
title: '潮流品牌,逛各种潮流品牌资讯-YOHO!BUY 有货网',
title: '潮流品牌_潮流资讯-YOHO!BUY 有货',
keywords: '逛潮品,潮流潮品,潮品资讯',
description: '有货网每天提供全球潮流潮品文章资讯,宣传潮流商品,潮流文化,潮流品牌等信息,想更多了解学习潮流潮品资讯就来有货网!'
},
22: {
title: '潮流视频,欣赏新潮好玩的潮流视频-YOHO!BUY 有货网',
title: 'Buy TV潮流视频_潮流资讯-YOHO!BUY 有货',
keywords: '潮流视频,看潮流。',
description: '有货网每天提供全球新潮精彩的潮流视频,宣传潮流商品,潮流文化,潮流品牌等信息,想更多欣赏潮流视频就来有货网!'
}
... ... @@ -107,8 +107,8 @@ const guangListSeoMap = {
const getIndexSeo = (params, tabs) => {
let tdk = {
title: '逛潮流,原创潮流资讯 |YOHO!BUY有货',
keywords: '潮流资讯,潮流文章,有货潮流分享',
title: '最新潮流资讯-YOHO!BUY 有货',
keywords: '潮流资讯,时尚潮流资讯',
description: '来有货玩潮流,潮流资讯大分享!年轻人潮流购物中心,了解潮流趋势、掌握潮流文化知识信息,尽在有货逛潮流!'
};
... ... @@ -127,7 +127,7 @@ const getIndexSeo = (params, tabs) => {
const getEditorSeo = (name) => {
return {
title: `【${name}】潮流编辑${name}-YOHO!BUY 有货网`,
title: `【${name}】潮流编辑-YOHO!BUY 有货`,
keywords: ` ${name},潮流编辑${name},潮流编辑`,
description: `有货逛潮流,潮流编辑${name}分享大量原创潮流资讯,掌握大量不同类别的潮流文化知识信息,尽在有货逛潮流。`
};
... ... @@ -135,7 +135,7 @@ const getEditorSeo = (name) => {
const getTagSeo = (tagName) => {
return {
title: `【${tagName}${tagName}潮流资讯-YOHO!BUY 有货网`,
title: `【${tagName}潮流资讯-YOHO!BUY 有货`,
keywords: `${tagName}${tagName}潮流资讯,${tagName}文章`,
description: `来有货逛潮流,${tagName}潮流资讯大分享!了解${tagName}潮流趋势,掌握${tagName}潮流文化知识信息,尽在有货逛潮流。`
};
... ...
... ... @@ -19,7 +19,7 @@ exports.index = (req, res, next) => {
}
return res.render('news-index', Object.assign({
title: '资讯 | ' + (res.locals.title || ''),
title: '资讯_潮流资讯-YOHO!BUY 有货',
module: 'news',
page: 'index'
}, result));
... ...
... ... @@ -27,6 +27,8 @@ const ShopServiceModel = require('./shop-service');
const BrandServiceModel = require('./brand-service');
const FavoriteProductServiceModel = require('./favorite-product-service');
const seoHandler = require('./seo-handler');
const homeService = require('./home-service');
const HeaderModel = require('../../../doraemon/models/header');
... ... @@ -957,46 +959,6 @@ function _imageAlt(goodsInfo) {
return alt;
}
/**
* 获取seo信息
*
* @param array $goodsInfo
* @param array $navs
* @return array
*/
function _getSeoByGoodsInfo(goodsInfo, navs) {
let brandName = '';
let sortName = '';
let productName = _.get(goodsInfo, 'data.product_name', '');
goodsInfo = goodsInfo || {};
navs = navs || [];
if (_.get(goodsInfo, 'data.brand_info.brand_name', '')) {
brandName = _.get(goodsInfo, 'data.brand_info.brand_name');
}
if (_.get(navs, '[1].name')) {
sortName = navs[1].name;
}
let title = `【${brandName}${sortName}】` + productName + ' | YOHO!BUY 有货';
let keywords = brandName + sortName + ',' + brandName + sortName + '价格,' + brandName + sortName + '图片';
let description = `${productName},有货网仅售${_.get(goodsInfo, 'data.format_sales_price')}元,` +
`购买${brandName + sortName},了解${brandName + sortName}商品信息就上有货网!`;
let cononicalURL = helpers.getUrlBySkc(_.get(goodsInfo, 'data.product_skn'));
return {
title: title,
keywords: keywords.replace(/~+/, ''),
description: description,
cononicalURL: cononicalURL,
};
}
// 优惠券
function _getCoupon(coupons) {
if (coupons.code !== 200 || _.isEmpty(_.get(coupons, 'data', []))) {
... ... @@ -1580,7 +1542,9 @@ function showMainAsync(req, data) {
result.detail.goodsInfo.imageBanner = _getProductActivityBanner(productDescription.banner);
// seo
result.seo = _getSeoByGoodsInfo(productData, sortNavigator);
result.seo = Object.assign(seoHandler.getProductDetailSeo(productData, sortNavigator), {
cononicalURL: helpers.getUrlBySkc(_.get(productData, 'data.product_skn'))
});
// 商品页面统计
result.statGoodsInfo = Object.assign({fullSortName: sortNavigator.map(x => x.name).join('-')},
... ...
... ... @@ -150,10 +150,7 @@ function getListData(params, channel) {
}
});
const seo = seoHandler.getListSeo(channel, sortList, checkedList);
// seo
// const seo = searchHandler.getListSeo(channel, sortList, checkedList);
const seo = seoHandler.getListSeo(sortList, checkedList);
if (sortName) {
return redis.all([
... ... @@ -259,7 +256,7 @@ function getListNewData(params, channel) {
});
}
let seo = searchHandler.getNewSeo(channel, checkedList, checkedList, params.shelveTime);
let seo = seoHandler.getNewListSeo(sortList, checkedList);
return Object.assign(finalResult, seo);
});
... ...
... ... @@ -1441,151 +1441,6 @@ exports.handleNextPage = (params, total) => {
};
};
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;
};
const _handelSeoParamsName = (channel, sorts, checked) => {
let kd = {};
_.forEach(sorts, val => {
if (val.active) {
kd.sort = val && val.name;
_.forEach(val.childList, sub => {
if (sub.childActive && sub.categoryId !== val.categoryId) {
kd.sort = sub && sub.name;
}
});
}
});
checked = checked || [];
_.forEach(checked, ck => {
if (!(ck && ck.itemType)) {
return false;
}
switch (ck && ck.itemType) {
case 'brand':
case 'color':
case 'size':
case 'price':
case 'style':
kd[ck.itemType] = ck.name;
break;
case 'gender':
kd.channel = ck.name === 'GIRLS' ? '女生' : '男生';
break;
default:
if (ck.itemType) {
if (!kd.senior) {
kd.senior = '';
} else {
kd.senior += '、';
}
kd.senior += ck.name;
}
break;
}
});
return kd;
};
/**
* 列表页seo
* @param channel
* @param sorts
* @param checked
* @returns {{title: string, keywords: string, description: string}}
*/
exports.getListSeo = (channel, sorts, checked) => {
const defaultTdk = {
title: '潮流服装配饰,创意生活用品_男生|女生|潮童服装,鞋履,配饰品牌正品-YOHO!BUY有货',
keywords: '潮流服装配饰,创意生活用品,男生服装配饰,女生服装配饰,潮童服装配饰',
description: '潮流服装配饰及创意生活正品网购!YOHO!BUY有货提供男生、女生、潮童服装配饰。全场品牌正品保证,支持货到付款。'
};
const kd = _handelSeoParamsName(channel, sorts, checked);
// 无筛选参数时默认tdk
if (_.isEmpty(kd)) {
return defaultTdk;
}
_.forEach(['sort', 'brand', 'color', 'size', 'price', 'channel', 'style', 'senior'], val => {
kd[val] = kd[val] || '';
});
return {
title: `${kd.price ? '价格在' : ''}${kd.price}${kd.brand}${kd.channel}${kd.color}${kd.size}${kd.sort}|YOHO!BUY有货`, // eslint-disable-line
keywords: `${kd.size}${kd.color}${kd.brand}${kd.channel}${kd.sort}${kd.style ? ',' : ''}${kd.style}` || defaultTdk.keywords, // eslint-disable-line
description: `潮流网购${kd.brand}就上YOHO!BUY有货,有货网销售正品新款${kd.size}${kd.color}${kd.brand}${kd.channel}${kd.sort},全场低至4,全场品牌正品保证,支持货到付款。` // eslint-disable-line
};
};
/**
* 新品到页 seo
* @param channel
* @param sorts
* @param checked
* @returns {{title: string, keywords: string, description: string}}
*/
exports.getNewSeo = (channel, sorts, checked, shelveTime) => {
const channelName = _getChannelName(channel);
const defaultTdk = {
title: `${channelName}新品上架,全场正品保证-YOHO!BUY 有货`,
keywords: `${channelName}新品,潮流新品,潮流正品`,
description: `${channelName}新品上架,正品网购,官方授权!全场品牌正品保证,支持货到付款。 想购买潮流商品就来YOHO! 有货中国大型潮流商品购物网站。`
};
const kd = _handelSeoParamsName(channel, sorts, checked);
shelveTime = parseInt(`0${(_.toString(shelveTime) || '').split(',')[0]}`, 10);
if (shelveTime) {
const data = new Date(shelveTime * 1000);
kd.day = `${data.getFullYear()}${data.getMonth() + 1}${data.getDate()}日`;
kd.year = `${data.getFullYear()}年`;
}
// 无筛选参数时默认tdk
if (_.isEmpty(kd)) {
return defaultTdk;
}
_.forEach(['year', 'day', 'sort', 'brand', 'color', 'size', 'price', 'channel', 'style', 'senior'], val => {
kd[val] = kd[val] || '';
});
return {
title: `新品到着|${kd.price ? '价格在' : ''}${kd.price}${kd.brand}${kd.channel}${kd.color}${kd.size}${kd.sort}|YOHO!BUY有货`, // eslint-disable-line
keywords: `${kd.size}${kd.color}${kd.brand}${kd.channel}${kd.sort}${kd.style ? ',' : ''}${kd.style}` || defaultTdk.keywords, // eslint-disable-line
description: `${kd.day}新品到着,潮流网购${kd.brand}就上YOHO!BUY有货,有货网销售正品${kd.year}新款${kd.size}${kd.color}${kd.brand}${kd.channel}${kd.sort},全场低至4,全场品牌正品保证,支持货到付款。` // eslint-disable-line
};
};
/**
* 品牌店铺页 seo
* @param channel
... ...
... ... @@ -6,6 +6,8 @@
const _ = require('lodash');
const NOW_YEAR = new Date().getFullYear();
const getSeoCheckedParamsName = (sorts, checked) => {
let kd = {};
... ... @@ -77,7 +79,13 @@ const listDefaultTdk = {
description: '潮流网购就上YOHO!BUY有货,有货网潮流商品专卖店提供潮流商品品牌、潮流商品价格、潮流商品图片等信息。销售正品新款潮流男装、潮流女装、潮流童装,全场低至4折,★全场品牌正品保证,支持货到付款!★' // eslint-disable-line
};
const getListSeo = (cen, sorts, checked) => {
/**
* 列表页seo
* @param sorts
* @param checked
* @returns {{title: string, keywords: string, description: string}}
*/
const getListSeo = (sorts, checked) => {
let {brand, channel, color, style, sort} = getSeoCheckedParamsName(sorts, checked);
if (brand && _.indexOf(brand, '、') > -1) {
... ... @@ -106,6 +114,37 @@ const getListSeo = (cen, sorts, checked) => {
}
};
/**
* 新品到页 seo
* @param sorts
* @param checked
* @returns {{title: string, keywords: string, description: string}}
*/
const getNewListSeo = (sorts, checked) => {
const tdk = {
title: `【潮流新品】_引领潮流_${NOW_YEAR}时尚潮流新品-YOHO!BUY 有货`,
keywords: `潮流新品.引领潮流,${NOW_YEAR}时尚潮流新品`,
description: `【潮流新品】,${NOW_YEAR}时尚潮流新品,潮流网购就上YOHO!BUY有货,有货网销售正品新款,全场低至4,★全场品牌正品保证,支持货到付款!★`
};
const kd = getSeoCheckedParamsName(sorts, checked);
let name = _.compact([kd.price ? `价格在${kd.price}` : '', kd.brand,
kd.channel, kd.color, kd.size, kd.sort]).join('_');
if (name) {
tdk.title = `【潮流新品】_${name}-YOHO!BUY 有货`;
}
return tdk;
};
/**
* sale列表页seo
* @param sorts
* @param checked
* @param type
* @returns {{title: string, keywords: string, description: string}}
*/
const getSaleListSeo = (sorts, checked, type) => {
const defaultTdk = saleDefaultSeoMap[type] || {};
const kd = getSeoCheckedParamsName(sorts, checked);
... ... @@ -132,6 +171,12 @@ const getSaleListSeo = (sorts, checked, type) => {
};
};
/**
* 全球购列表页seo
* @param sorts
* @param checked
* @returns {{title: string, keywords: string, description: string}}
*/
const getGlobalListSeo = (sorts, checked) => {
const defaultTdk = {
title: '全球购潮流服装配饰,创意生活用品_男生|女生|潮童服装,鞋履,配饰品牌正品-YOHO!BUY有货',
... ... @@ -157,6 +202,12 @@ const getGlobalListSeo = (sorts, checked) => {
};
};
/**
* 店铺首页seo
* @param shopInfo
* @returns {{title: string, keywords: string, description: string}}
*/
const getShopHomeSeo = (shopInfo) => {
let params = {
nameEn: '',
... ... @@ -186,6 +237,13 @@ const getShopHomeSeo = (shopInfo) => {
};
};
/**
* 店铺列表页seo
* @param sorts
* @param checked
* @param shopInfo
* @returns {{title: string, keywords: string, description: string}}
*/
const getShopListSeo = (sorts, checked, shopInfo) => {
const kd = getSeoCheckedParamsName(sorts, checked);
const defaultTdk = getShopHomeSeo(shopInfo);
... ... @@ -210,12 +268,34 @@ const getShopListSeo = (sorts, checked, shopInfo) => {
};
};
/**
* 商品详情页seo
* @param goodsInfo
* @param navs
* @returns {{title: string, keywords: string, description: string}}
*/
const getProductDetailSeo = (goodsInfo, navs) => {
let brandName = _.get(goodsInfo, 'data.brand_info.brand_name', '');
let sortName = _.get(navs, '[1].name', '');
let productName = _.get(goodsInfo, 'data.product_name', '');
let priceName = _.get(goodsInfo, 'data.format_sales_price');
return {
title: `${productName}_${brandName}${sortName}-YOHO!BUY 有货`,
keywords: `${brandName}${sortName},${brandName}${sortName}价格,${brandName}${sortName}图片`,
description: `${productName},有货网仅售${priceName}元,购买${brandName +
sortName},了解${brandName + sortName}商品信息就上有货网!`
};
};
module.exports = {
getListSeo,
getSeoCheckedParamsName,
getListSeo,
getNewListSeo,
getSaleListSeo,
getGlobalListSeo,
getShopHomeSeo,
getShopListSeo,
getProductDetailSeo
};
... ...