Authored by 毕凯

Merge branch 'release/6.3' of git.yoho.cn:fe/yohobuywap-node into release/6.3

... ... @@ -56,7 +56,7 @@ module.exports = class extends global.yoho.BaseModel {
// sort_name: firstItem.category_name,
// gender: genderMap[key] || ''
// }), 'list'),
url: `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(firstItem, 'category_id')}-sn${firstItem.category_name}` // eslint-disable-line
url: `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(firstItem, 'category_id')}?title=${firstItem.category_name}` // eslint-disable-line
});
} else {
// firstItem.url = helpers.urlFormat('/', utils.mapSort({
... ...
... ... @@ -11,7 +11,7 @@ class newGuang extends global.yoho.BaseModel {
let options = {
url: '/operations/api/v5/resource/get',
data: {
content_code: 'a6d7d4bfa20b0892e2ebff76099a58b8',
content_code: '5523199f921ee2297b509397a224d9e8',
gender: params.gender
},
api: global.yoho.ServiceAPI
... ...
... ... @@ -279,7 +279,10 @@ const category = (req, res, next) => {
localCss: true,
appPath: appPath,
introText: req.query.intro_text
}, searchProcess.getListSeoData(req.query.gender, seoTitle)));
}, searchProcess.getListSeoData({
gender: req.query.gender,
sort_name: seoTitle
})));
}).catch(next);
};
... ... @@ -337,22 +340,24 @@ const listNew = (req, res, next) => {
let categoryIntroRedis = [];
let responseResult = {
list: productProcess.processProductList(result.data.product_list || [], {
list: productProcess.processProductList(_.get(result, 'data.product_list', []), {
isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
gender: _coverChannel[params.coverChannel],
showSimilar: params.shop_id || params.material === 'true' ? false : true
})
};
let seoParams = searchProcess.getFilterValueForSeo(initialData, _.get(result, 'data', {}));
let seoRenderData = searchProcess.getListSeoData(seoParams);
let seoTitle = _.get(seoParams, 'sort');
let paramsTitle = params.title || params.sort_name; // 可能会配置的标题,优先级最高
let seoTitle = _.get(result, 'data.filter.group_sort[0].sub[0].category_name');
if (!seoTitle || !initialData.category_id) {
if (!seoTitle) {
seoTitle = '商品列表';
}
if (params.sort_name) {
if (paramsTitle) {
try {
seoTitle = decodeURIComponent(params.sort_name);
seoTitle = decodeURIComponent(paramsTitle);
} catch (e) {
logger.error('decodeURIComponent seoTitle: ' + e);
}
... ... @@ -386,7 +391,7 @@ const listNew = (req, res, next) => {
localCss: true,
appPath: appPath,
categoryIntro: categoryIntro
}, searchProcess.getListSeoData(req.query.gender, seoTitle)));
}, seoRenderData));
})().catch(next);
};
... ...
{
"name": "yohobuywap-node",
"version": "6.2.37",
"version": "6.3.0",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -37,6 +37,7 @@ class GuangNew extends Page {
this.fixed();
this.fixedRetop();
this.list();
this.doMore();
}
list() {
... ...
... ... @@ -69,7 +69,7 @@ class Login {
* 展示弹窗
*/
showYohoFamilyTip() {
Modal2.alert('Yoho!Family账号可登录Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store等账户');
Modal2.alert('Yoho!Family账号可登录YOHO!旗下所有应用(含:Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store)');
}
/**
... ...
... ... @@ -64,7 +64,7 @@ class SmsLoginNew extends Page {
* 展示弹窗
*/
showYohoFamilyTip() {
Modal2.alert('Yoho!Family账号可登录Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store等账户');
Modal2.alert('Yoho!Family账号可登录YOHO!旗下所有应用(含:Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store)');
}
/**
... ...
... ... @@ -65,7 +65,7 @@ const imgSrcHandle = (imgUrl, params) => {
const rawLazyload = (selector, options) => {
let $imgs;
let params = {
threshold: 700
threshold: 700 * 3 // 一页大概700 ,提前加载三、四页
};
let imgParams = {
q: options && options.q || defaultQuality
... ...
... ... @@ -10,7 +10,7 @@
*/
const filter = require('plugin/filter');
const noResultHbs = require('product/search/no-result-new.hbs');
const lazyLoad = require('yoho-jquery-lazyload');
const lazyLoad = require('plugin/lazyload');
const cacheStore = require('./cache-store');
const loading = require('plugin/loading');
... ...
... ... @@ -32,7 +32,6 @@ const PARAMMAP = {
sf: 'specialoffer',
sh: 'shop_id',
si: 'specialsale_id',
sn: 'sort_name',
so: 'sort',
st: 'style',
sz: 'size',
... ...
... ... @@ -3,6 +3,7 @@
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/7/29
*/
const _ = require('lodash');
/**
* 根据频道判断出性别
... ... @@ -20,6 +21,26 @@ const getGenderByChannel = (channel) => {
}
};
/**
* seo 获取性别
*/
const _getGenderForSeo = (gender) => {
let seoGender = '男生|女生';
switch (gender) {
case '1,3':
seoGender = '男生';
break;
case '2,3':
seoGender = '女生';
break;
default:
break;
}
return seoGender;
};
// 频道转换
const getChannelType = (channel) => {
channel = channel ? channel : 'boys';
... ... @@ -67,22 +88,115 @@ const getTypeCont = (type, order) => {
};
/**
*
* @param 查询参数 queryParams
* @param 接口数据 apiData
*/
const getFilterValueForSeo = (queryParams, apiData) => {
let seoParams = {
color: '',
size: '',
style: '',
brand: '',
gender: '',
sort: '',
price: '',
senior: ''
};
let seniors = [];
_.forEach(queryParams, (value, key) => {
if (_.find(['color', 'size', 'style'], o => {
return key === o;
})) {
let colorObj = _.find(_.get(apiData, `filter.${key}`, []), o => {
return _.parseInt(value) === _.get(o, `${key}_id`);
});
seoParams[`${key}`] = _.get(colorObj, `${key}_name`, '');
}
if (key === 'brand') {
let brands = _.get(apiData, 'filter.brand', []);
let brandObj = _.find(brands, brand => {
return _.parseInt(value) === brand.id;
});
seoParams.brand = _.get(brandObj, 'brand_name', '');
}
if (key === 'gender') {
seoParams.channel = _getGenderForSeo(value);
}
if (key === 'sort' || key === 'category_id') {
let sorts = _.get(apiData, 'filter.group_sort', []);
let testSorts = _.cloneDeep(sorts);
_.forEach(sorts, sort => {
let sortSub = _.get(sort, 'sub', []);
if (sortSub) {
_.forEach(sortSub, subSort => {
testSorts.push(subSort);
});
}
});
let sortObj = _.find(testSorts, sort => {
return _.find(_.split(sort.category_id, ','), o => {
return value === o;
});
});
seoParams.sort = _.get(sortObj, 'category_name', '');
}
if (key === 'price') {
seoParams.price = `¥${_.replace(value, ',', '-')}`;
}
if (key === 'standard') {
let paramGroups = _.split(value, ',');
_.forEach(paramGroups, paramGroup => {
let paramValues = _.split(paramGroup, '_');
let standards = _.get(apiData, 'standard', []);
let standardObj = _.find(standards, o => {
return paramValues[0] === o.standard_id;
});
let standardSeObj = _.find(_.get(standardObj, 'sub', []), o => {
return paramValues[1] === o.standard_id;
});
seniors.push(_.get(standardSeObj, 'standard_name', ''));
});
}
});
if (seoParams.style) {
seniors.push(seoParams.style);
}
seoParams.senior = _.join(seniors, ',');
return seoParams;
};
/**
* 品类列表页 SEO 数据
* @param {*} gender
* @param {*} sort_name
*/
const getListSeoData = (gender, sort_name) => {
const getListSeoData = (params) => {
let seoData = {
title: '潮流服装配饰,创意生活用品_男生|女生|潮童服装,鞋履,配饰品牌正品-YOHO!BUY有货',
keywords: '潮流服装配饰,创意生活用品,男生服装配饰,女生服装配饰,潮童服装配饰',
description: '潮流服装配饰及创意生活正品网购!YOHO!BUY有货提供男生、女生、潮童服装配饰。100%品牌正品保证,支持货到付款。'
};
if (gender && sort_name) {
if (params) {
let baseInfo = `${params.brand}${params.sort}`;
seoData = {
title: `${sort_name}|新款${sort_name},${sort_name}品牌正品|YOHO!BUY有货`,
keywords: `${sort_name},新款${sort_name}${sort_name}品牌正品`,
description: `有货网${sort_name}专卖店销售正品新款${sort_name},支持货到付款。了解新款${sort_name}${sort_name}品牌价格、评价、图片等信息,网购超低折扣新款${sort_name}就上有货网。` // eslint-disable-line
title: `${baseInfo ? baseInfo + '|' : ''}新款${params.brand}${params.channel}${params.color}${params.size}${params.sort}${params.price},${params.brand}${params.senior}${params.sort}品牌正品|YOHO!BUY有货`, // eslint-disable-line
keywords: `${baseInfo ? baseInfo + ',' : ''}新款${params.brand}${params.channel}${params.color}${params.size}${params.sort}${params.price},${params.brand}${params.senior}${params.sort}品牌正品`, // eslint-disable-line
description: `${baseInfo}正品网购!YOHO!BUY有货提供新款${params.brand}${params.channel}${params.color}${params.size}${params.sort}${params.price},${params.brand}${params.senior}${params.sort}100%品牌正品保证,支持货到付款。` // eslint-disable-line
};
}
return seoData;
... ... @@ -220,6 +334,7 @@ module.exports = {
getGenderByChannel,
getChannelType,
getTypeCont,
getFilterValueForSeo,
getListSeoData,
getSearchParamsWithoutMethod
};
... ...