Merge branch 'release/6.3' of git.yoho.cn:fe/yohobuywap-node into release/6.3
Showing
11 changed files
with
141 additions
and
21 deletions
@@ -56,7 +56,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -56,7 +56,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
56 | // sort_name: firstItem.category_name, | 56 | // sort_name: firstItem.category_name, |
57 | // gender: genderMap[key] || '' | 57 | // gender: genderMap[key] || '' |
58 | // }), 'list'), | 58 | // }), 'list'), |
59 | - url: `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(firstItem, 'category_id')}-sn${firstItem.category_name}` // eslint-disable-line | 59 | + url: `//m.yohobuy.com/list/gd${genderMap[key] || ''}-ci${_.get(firstItem, 'category_id')}?title=${firstItem.category_name}` // eslint-disable-line |
60 | }); | 60 | }); |
61 | } else { | 61 | } else { |
62 | // firstItem.url = helpers.urlFormat('/', utils.mapSort({ | 62 | // firstItem.url = helpers.urlFormat('/', utils.mapSort({ |
@@ -11,7 +11,7 @@ class newGuang extends global.yoho.BaseModel { | @@ -11,7 +11,7 @@ class newGuang extends global.yoho.BaseModel { | ||
11 | let options = { | 11 | let options = { |
12 | url: '/operations/api/v5/resource/get', | 12 | url: '/operations/api/v5/resource/get', |
13 | data: { | 13 | data: { |
14 | - content_code: 'a6d7d4bfa20b0892e2ebff76099a58b8', | 14 | + content_code: '5523199f921ee2297b509397a224d9e8', |
15 | gender: params.gender | 15 | gender: params.gender |
16 | }, | 16 | }, |
17 | api: global.yoho.ServiceAPI | 17 | api: global.yoho.ServiceAPI |
@@ -279,7 +279,10 @@ const category = (req, res, next) => { | @@ -279,7 +279,10 @@ const category = (req, res, next) => { | ||
279 | localCss: true, | 279 | localCss: true, |
280 | appPath: appPath, | 280 | appPath: appPath, |
281 | introText: req.query.intro_text | 281 | introText: req.query.intro_text |
282 | - }, searchProcess.getListSeoData(req.query.gender, seoTitle))); | 282 | + }, searchProcess.getListSeoData({ |
283 | + gender: req.query.gender, | ||
284 | + sort_name: seoTitle | ||
285 | + }))); | ||
283 | }).catch(next); | 286 | }).catch(next); |
284 | }; | 287 | }; |
285 | 288 | ||
@@ -337,22 +340,24 @@ const listNew = (req, res, next) => { | @@ -337,22 +340,24 @@ const listNew = (req, res, next) => { | ||
337 | let categoryIntroRedis = []; | 340 | let categoryIntroRedis = []; |
338 | 341 | ||
339 | let responseResult = { | 342 | let responseResult = { |
340 | - list: productProcess.processProductList(result.data.product_list || [], { | 343 | + list: productProcess.processProductList(_.get(result, 'data.product_list', []), { |
341 | isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), | 344 | isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'), |
342 | gender: _coverChannel[params.coverChannel], | 345 | gender: _coverChannel[params.coverChannel], |
343 | showSimilar: params.shop_id || params.material === 'true' ? false : true | 346 | showSimilar: params.shop_id || params.material === 'true' ? false : true |
344 | }) | 347 | }) |
345 | }; | 348 | }; |
349 | + let seoParams = searchProcess.getFilterValueForSeo(initialData, _.get(result, 'data', {})); | ||
350 | + let seoRenderData = searchProcess.getListSeoData(seoParams); | ||
351 | + let seoTitle = _.get(seoParams, 'sort'); | ||
352 | + let paramsTitle = params.title || params.sort_name; // 可能会配置的标题,优先级最高 | ||
346 | 353 | ||
347 | - let seoTitle = _.get(result, 'data.filter.group_sort[0].sub[0].category_name'); | ||
348 | - | ||
349 | - if (!seoTitle || !initialData.category_id) { | 354 | + if (!seoTitle) { |
350 | seoTitle = '商品列表'; | 355 | seoTitle = '商品列表'; |
351 | } | 356 | } |
352 | 357 | ||
353 | - if (params.sort_name) { | 358 | + if (paramsTitle) { |
354 | try { | 359 | try { |
355 | - seoTitle = decodeURIComponent(params.sort_name); | 360 | + seoTitle = decodeURIComponent(paramsTitle); |
356 | } catch (e) { | 361 | } catch (e) { |
357 | logger.error('decodeURIComponent seoTitle: ' + e); | 362 | logger.error('decodeURIComponent seoTitle: ' + e); |
358 | } | 363 | } |
@@ -386,7 +391,7 @@ const listNew = (req, res, next) => { | @@ -386,7 +391,7 @@ const listNew = (req, res, next) => { | ||
386 | localCss: true, | 391 | localCss: true, |
387 | appPath: appPath, | 392 | appPath: appPath, |
388 | categoryIntro: categoryIntro | 393 | categoryIntro: categoryIntro |
389 | - }, searchProcess.getListSeoData(req.query.gender, seoTitle))); | 394 | + }, seoRenderData)); |
390 | })().catch(next); | 395 | })().catch(next); |
391 | }; | 396 | }; |
392 | 397 |
@@ -69,7 +69,7 @@ class Login { | @@ -69,7 +69,7 @@ class Login { | ||
69 | * 展示弹窗 | 69 | * 展示弹窗 |
70 | */ | 70 | */ |
71 | showYohoFamilyTip() { | 71 | showYohoFamilyTip() { |
72 | - Modal2.alert('Yoho!Family账号可登录Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store等账户'); | 72 | + Modal2.alert('Yoho!Family账号可登录YOHO!旗下所有应用(含:Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store)'); |
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
@@ -64,7 +64,7 @@ class SmsLoginNew extends Page { | @@ -64,7 +64,7 @@ class SmsLoginNew extends Page { | ||
64 | * 展示弹窗 | 64 | * 展示弹窗 |
65 | */ | 65 | */ |
66 | showYohoFamilyTip() { | 66 | showYohoFamilyTip() { |
67 | - Modal2.alert('Yoho!Family账号可登录Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store等账户'); | 67 | + Modal2.alert('Yoho!Family账号可登录YOHO!旗下所有应用(含:Yoho!Buy有货、Yoho!Now、mars、BLK、Yoho!Store)'); |
68 | } | 68 | } |
69 | 69 | ||
70 | /** | 70 | /** |
@@ -65,7 +65,7 @@ const imgSrcHandle = (imgUrl, params) => { | @@ -65,7 +65,7 @@ const imgSrcHandle = (imgUrl, params) => { | ||
65 | const rawLazyload = (selector, options) => { | 65 | const rawLazyload = (selector, options) => { |
66 | let $imgs; | 66 | let $imgs; |
67 | let params = { | 67 | let params = { |
68 | - threshold: 700 | 68 | + threshold: 700 * 3 // 一页大概700 ,提前加载三、四页 |
69 | }; | 69 | }; |
70 | let imgParams = { | 70 | let imgParams = { |
71 | q: options && options.q || defaultQuality | 71 | q: options && options.q || defaultQuality |
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | */ | 10 | */ |
11 | const filter = require('plugin/filter'); | 11 | const filter = require('plugin/filter'); |
12 | const noResultHbs = require('product/search/no-result-new.hbs'); | 12 | const noResultHbs = require('product/search/no-result-new.hbs'); |
13 | -const lazyLoad = require('yoho-jquery-lazyload'); | 13 | +const lazyLoad = require('plugin/lazyload'); |
14 | const cacheStore = require('./cache-store'); | 14 | const cacheStore = require('./cache-store'); |
15 | const loading = require('plugin/loading'); | 15 | const loading = require('plugin/loading'); |
16 | 16 |
@@ -32,7 +32,6 @@ const PARAMMAP = { | @@ -32,7 +32,6 @@ const PARAMMAP = { | ||
32 | sf: 'specialoffer', | 32 | sf: 'specialoffer', |
33 | sh: 'shop_id', | 33 | sh: 'shop_id', |
34 | si: 'specialsale_id', | 34 | si: 'specialsale_id', |
35 | - sn: 'sort_name', | ||
36 | so: 'sort', | 35 | so: 'sort', |
37 | st: 'style', | 36 | st: 'style', |
38 | sz: 'size', | 37 | sz: 'size', |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | * @author: wsl<shuiling.wang@yoho.cn> | 3 | * @author: wsl<shuiling.wang@yoho.cn> |
4 | * @date: 2016/7/29 | 4 | * @date: 2016/7/29 |
5 | */ | 5 | */ |
6 | +const _ = require('lodash'); | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * 根据频道判断出性别 | 9 | * 根据频道判断出性别 |
@@ -20,6 +21,26 @@ const getGenderByChannel = (channel) => { | @@ -20,6 +21,26 @@ const getGenderByChannel = (channel) => { | ||
20 | } | 21 | } |
21 | }; | 22 | }; |
22 | 23 | ||
24 | +/** | ||
25 | + * seo 获取性别 | ||
26 | + */ | ||
27 | +const _getGenderForSeo = (gender) => { | ||
28 | + let seoGender = '男生|女生'; | ||
29 | + | ||
30 | + switch (gender) { | ||
31 | + case '1,3': | ||
32 | + seoGender = '男生'; | ||
33 | + break; | ||
34 | + case '2,3': | ||
35 | + seoGender = '女生'; | ||
36 | + break; | ||
37 | + default: | ||
38 | + break; | ||
39 | + } | ||
40 | + | ||
41 | + return seoGender; | ||
42 | +}; | ||
43 | + | ||
23 | // 频道转换 | 44 | // 频道转换 |
24 | const getChannelType = (channel) => { | 45 | const getChannelType = (channel) => { |
25 | channel = channel ? channel : 'boys'; | 46 | channel = channel ? channel : 'boys'; |
@@ -67,22 +88,115 @@ const getTypeCont = (type, order) => { | @@ -67,22 +88,115 @@ const getTypeCont = (type, order) => { | ||
67 | }; | 88 | }; |
68 | 89 | ||
69 | /** | 90 | /** |
91 | + * | ||
92 | + * @param 查询参数 queryParams | ||
93 | + * @param 接口数据 apiData | ||
94 | + */ | ||
95 | +const getFilterValueForSeo = (queryParams, apiData) => { | ||
96 | + let seoParams = { | ||
97 | + color: '', | ||
98 | + size: '', | ||
99 | + style: '', | ||
100 | + brand: '', | ||
101 | + gender: '', | ||
102 | + sort: '', | ||
103 | + price: '', | ||
104 | + senior: '' | ||
105 | + }; | ||
106 | + let seniors = []; | ||
107 | + | ||
108 | + _.forEach(queryParams, (value, key) => { | ||
109 | + if (_.find(['color', 'size', 'style'], o => { | ||
110 | + return key === o; | ||
111 | + })) { | ||
112 | + let colorObj = _.find(_.get(apiData, `filter.${key}`, []), o => { | ||
113 | + return _.parseInt(value) === _.get(o, `${key}_id`); | ||
114 | + }); | ||
115 | + | ||
116 | + seoParams[`${key}`] = _.get(colorObj, `${key}_name`, ''); | ||
117 | + } | ||
118 | + if (key === 'brand') { | ||
119 | + let brands = _.get(apiData, 'filter.brand', []); | ||
120 | + let brandObj = _.find(brands, brand => { | ||
121 | + return _.parseInt(value) === brand.id; | ||
122 | + }); | ||
123 | + | ||
124 | + seoParams.brand = _.get(brandObj, 'brand_name', ''); | ||
125 | + } | ||
126 | + if (key === 'gender') { | ||
127 | + seoParams.channel = _getGenderForSeo(value); | ||
128 | + } | ||
129 | + if (key === 'sort' || key === 'category_id') { | ||
130 | + let sorts = _.get(apiData, 'filter.group_sort', []); | ||
131 | + let testSorts = _.cloneDeep(sorts); | ||
132 | + | ||
133 | + _.forEach(sorts, sort => { | ||
134 | + let sortSub = _.get(sort, 'sub', []); | ||
135 | + | ||
136 | + if (sortSub) { | ||
137 | + _.forEach(sortSub, subSort => { | ||
138 | + testSorts.push(subSort); | ||
139 | + }); | ||
140 | + } | ||
141 | + }); | ||
142 | + | ||
143 | + let sortObj = _.find(testSorts, sort => { | ||
144 | + return _.find(_.split(sort.category_id, ','), o => { | ||
145 | + return value === o; | ||
146 | + }); | ||
147 | + }); | ||
148 | + | ||
149 | + seoParams.sort = _.get(sortObj, 'category_name', ''); | ||
150 | + } | ||
151 | + if (key === 'price') { | ||
152 | + seoParams.price = `¥${_.replace(value, ',', '-')}`; | ||
153 | + } | ||
154 | + if (key === 'standard') { | ||
155 | + let paramGroups = _.split(value, ','); | ||
156 | + | ||
157 | + _.forEach(paramGroups, paramGroup => { | ||
158 | + let paramValues = _.split(paramGroup, '_'); | ||
159 | + let standards = _.get(apiData, 'standard', []); | ||
160 | + let standardObj = _.find(standards, o => { | ||
161 | + return paramValues[0] === o.standard_id; | ||
162 | + }); | ||
163 | + let standardSeObj = _.find(_.get(standardObj, 'sub', []), o => { | ||
164 | + return paramValues[1] === o.standard_id; | ||
165 | + }); | ||
166 | + | ||
167 | + seniors.push(_.get(standardSeObj, 'standard_name', '')); | ||
168 | + }); | ||
169 | + } | ||
170 | + }); | ||
171 | + | ||
172 | + if (seoParams.style) { | ||
173 | + seniors.push(seoParams.style); | ||
174 | + } | ||
175 | + | ||
176 | + seoParams.senior = _.join(seniors, ','); | ||
177 | + | ||
178 | + return seoParams; | ||
179 | +}; | ||
180 | + | ||
181 | +/** | ||
70 | * 品类列表页 SEO 数据 | 182 | * 品类列表页 SEO 数据 |
71 | * @param {*} gender | 183 | * @param {*} gender |
72 | * @param {*} sort_name | 184 | * @param {*} sort_name |
73 | */ | 185 | */ |
74 | -const getListSeoData = (gender, sort_name) => { | 186 | +const getListSeoData = (params) => { |
75 | let seoData = { | 187 | let seoData = { |
76 | title: '潮流服装配饰,创意生活用品_男生|女生|潮童服装,鞋履,配饰品牌正品-YOHO!BUY有货', | 188 | title: '潮流服装配饰,创意生活用品_男生|女生|潮童服装,鞋履,配饰品牌正品-YOHO!BUY有货', |
77 | keywords: '潮流服装配饰,创意生活用品,男生服装配饰,女生服装配饰,潮童服装配饰', | 189 | keywords: '潮流服装配饰,创意生活用品,男生服装配饰,女生服装配饰,潮童服装配饰', |
78 | description: '潮流服装配饰及创意生活正品网购!YOHO!BUY有货提供男生、女生、潮童服装配饰。100%品牌正品保证,支持货到付款。' | 190 | description: '潮流服装配饰及创意生活正品网购!YOHO!BUY有货提供男生、女生、潮童服装配饰。100%品牌正品保证,支持货到付款。' |
79 | }; | 191 | }; |
80 | 192 | ||
81 | - if (gender && sort_name) { | 193 | + if (params) { |
194 | + let baseInfo = `${params.brand}${params.sort}`; | ||
195 | + | ||
82 | seoData = { | 196 | seoData = { |
83 | - title: `${sort_name}|新款${sort_name},${sort_name}品牌正品|YOHO!BUY有货`, | ||
84 | - keywords: `${sort_name},新款${sort_name},${sort_name}品牌正品`, | ||
85 | - description: `有货网${sort_name}专卖店销售正品新款${sort_name},支持货到付款。了解新款${sort_name}、${sort_name}品牌价格、评价、图片等信息,网购超低折扣新款${sort_name}就上有货网。` // eslint-disable-line | 197 | + 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 |
198 | + keywords: `${baseInfo ? baseInfo + ',' : ''}新款${params.brand}${params.channel}${params.color}${params.size}${params.sort}${params.price},${params.brand}${params.senior}${params.sort}品牌正品`, // eslint-disable-line | ||
199 | + 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 | ||
86 | }; | 200 | }; |
87 | } | 201 | } |
88 | return seoData; | 202 | return seoData; |
@@ -220,6 +334,7 @@ module.exports = { | @@ -220,6 +334,7 @@ module.exports = { | ||
220 | getGenderByChannel, | 334 | getGenderByChannel, |
221 | getChannelType, | 335 | getChannelType, |
222 | getTypeCont, | 336 | getTypeCont, |
337 | + getFilterValueForSeo, | ||
223 | getListSeoData, | 338 | getListSeoData, |
224 | getSearchParamsWithoutMethod | 339 | getSearchParamsWithoutMethod |
225 | }; | 340 | }; |
-
Please register or login to post a comment