Authored by 毕凯

Merge branch 'feature/seo2' into 'gray'

Feature/seo2



See merge request !1100
@@ -326,7 +326,6 @@ const listNew = (req, res, next) => { @@ -326,7 +326,6 @@ const listNew = (req, res, next) => {
326 } 326 }
327 co(function* () { 327 co(function* () {
328 let result = yield req.ctx(searchModel).getCategoryGoods(initialData); 328 let result = yield req.ctx(searchModel).getCategoryGoods(initialData);
329 - let categoryIntro = '';  
330 329
331 let responseResult = { 330 let responseResult = {
332 list: productProcess.processProductList(result.data.product_list || [], { 331 list: productProcess.processProductList(result.data.product_list || [], {
@@ -346,7 +345,12 @@ const listNew = (req, res, next) => { @@ -346,7 +345,12 @@ const listNew = (req, res, next) => {
346 seoTitle = decodeURIComponent(params.sort_name); 345 seoTitle = decodeURIComponent(params.sort_name);
347 } 346 }
348 347
349 - categoryIntro = yield redis.hmgetAsync(`category:description:${md5(seoTitle)}`, 'category', 'description'); 348 + let categoryIntroRedis =
  349 + yield redis.hmgetAsync(`category:description:${md5(seoTitle)}`, 'category', 'description');
  350 + let categoryIntro = categoryIntroRedis[1] ? {
  351 + title: categoryIntroRedis[0],
  352 + desc: categoryIntroRedis[1]
  353 + } : null;
350 354
351 res.render('search/goods-list', Object.assign({ 355 res.render('search/goods-list', Object.assign({
352 _noLazy: true, // 首屏不使用lazyload 356 _noLazy: true, // 首屏不使用lazyload
@@ -4,3 +4,8 @@ @@ -4,3 +4,8 @@
4 <input type="text" id="category-point" style="display:none" value="{{category}}"> 4 <input type="text" id="category-point" style="display:none" value="{{category}}">
5 {{/if}} 5 {{/if}}
6 </div> 6 </div>
  7 +{{#categoryIntro}}
  8 +<div class="seo-data">
  9 + <h1>{{title}}</h1>{{desc}}
  10 +</div>
  11 +{{/categoryIntro}}
@@ -600,3 +600,12 @@ @@ -600,3 +600,12 @@
600 margin-bottom: 100px; 600 margin-bottom: 100px;
601 } 601 }
602 } 602 }
  603 +
  604 +.seo-data {
  605 + > h1 {
  606 + display: inline;
  607 + }
  608 +
  609 + color: #b0b0b0;
  610 + padding: 30px;
  611 +}
@@ -41,7 +41,10 @@ const getParams = (url) => { @@ -41,7 +41,10 @@ const getParams = (url) => {
41 41
42 _.forEach(paramsRaw, paramRaw => { 42 _.forEach(paramsRaw, paramRaw => {
43 let keyRaw = paramRaw.substr(0, 2); 43 let keyRaw = paramRaw.substr(0, 2);
44 - let valueRaw = _.replace(paramRaw, keyRaw, ''); 44 + let valueRaw = _.chain(paramRaw)
  45 + .replace(keyRaw, '')
  46 + .replace('__', '-')
  47 + .value();
45 48
46 if (PARAMMAP[keyRaw]) { 49 if (PARAMMAP[keyRaw]) {
47 params[PARAMMAP[keyRaw]] = valueRaw; 50 params[PARAMMAP[keyRaw]] = valueRaw;
@@ -102,15 +102,15 @@ const getSearchParamsWithoutMethod = (params) => { @@ -102,15 +102,15 @@ const getSearchParamsWithoutMethod = (params) => {
102 finalParams.yh_channel = params.yh_channel; 102 finalParams.yh_channel = params.yh_channel;
103 } 103 }
104 104
105 - if (params.brand) { 105 + if (params.brand && params.brand !== '0') {
106 finalParams.brand = params.brand; 106 finalParams.brand = params.brand;
107 } 107 }
108 108
109 - if (params.brand_id) { 109 + if (params.brand_id && params.brand_id !== '0') {
110 finalParams.brand = params.brand_id; 110 finalParams.brand = params.brand_id;
111 } 111 }
112 112
113 - if (params.shop_id) { 113 + if (params.shop_id && params.shop_id !== '0') {
114 finalParams.shop_id = params.shop_id; 114 finalParams.shop_id = params.shop_id;
115 } 115 }
116 116
@@ -158,7 +158,7 @@ const getSearchParamsWithoutMethod = (params) => { @@ -158,7 +158,7 @@ const getSearchParamsWithoutMethod = (params) => {
158 finalParams.type = params.type; 158 finalParams.type = params.type;
159 } 159 }
160 160
161 - if (params.category_id) { 161 + if (params.category_id && params.category_id !== '0') {
162 finalParams.category_id = params.category_id; 162 finalParams.category_id = params.category_id;
163 } 163 }
164 164