Authored by 徐炜

商品列表页优化

@@ -13,6 +13,7 @@ const _ = require('lodash'); @@ -13,6 +13,7 @@ const _ = require('lodash');
13 const crypto = global.yoho.crypto; 13 const crypto = global.yoho.crypto;
14 const helpers = global.yoho.helpers; 14 const helpers = global.yoho.helpers;
15 const productProcess = require(`${utils}/product-process`); 15 const productProcess = require(`${utils}/product-process`);
  16 +const searchModel = require(`${mRoot}/search`);
16 17
17 /** 18 /**
18 * 从 useragent 获取 uid 19 * 从 useragent 获取 uid
@@ -211,19 +212,24 @@ const shopFav = (req, res) => { @@ -211,19 +212,24 @@ const shopFav = (req, res) => {
211 }; 212 };
212 213
213 // 品类落地页 214 // 品类落地页
214 -const category = (req, res) => { 215 +const category = (req, res, next) => {
215 let params = Object.assign({}, req.query); 216 let params = Object.assign({}, req.query);
216 217
217 - res.render('search/goods-list', {  
218 - module: 'product',  
219 - page: 'search-list',  
220 - pageHeader: headerModel.setNav({  
221 - navTitle: req.query.title || req.query.sort_name  
222 - }),  
223 - goodList: params,  
224 - showDownloadApp: true,  
225 - pageFooter: true  
226 - }); 218 + // 获取第一页数据
  219 + searchModel.getSearchData(Object.assign({page: 1, limit: 6}, params)).then((firstPageGoodsList) => {
  220 + res.render('search/goods-list', {
  221 + _noLazy: true, // 首屏不使用lazyload
  222 + module: 'product',
  223 + page: 'search-list',
  224 + pageHeader: headerModel.setNav({
  225 + navTitle: req.query.title || req.query.sort_name
  226 + }),
  227 + goodList: params,
  228 + firstPageGoodsList: firstPageGoodsList,
  229 + showDownloadApp: true,
  230 + pageFooter: true
  231 + });
  232 + }).catch(next);
227 }; 233 };
228 234
229 /** 235 /**
@@ -132,6 +132,7 @@ const list = (req, res, next) => { @@ -132,6 +132,7 @@ const list = (req, res, next) => {
132 */ 132 */
133 const index = (req, res, next) => { 133 const index = (req, res, next) => {
134 let title = '搜索'; 134 let title = '搜索';
  135 +
135 ((render) => { 136 ((render) => {
136 if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) { 137 if (_.get(req, 'app.locals.wap.search.removeHotSearch', false)) {
137 render([]); 138 render([]);
1 <div class="good-list-page yoho-page"> 1 <div class="good-list-page yoho-page">
  2 + {{#firstPageGoodsList}}
  3 + {{> common/goods}}
  4 + {{/firstPageGoodsList}}
2 {{> search/list}} 5 {{> search/list}}
3 </div> 6 </div>
1 {{#if this}} {{!-- 剔除值为false的项 --}} 1 {{#if this}} {{!-- 剔除值为false的项 --}}
2 - <div class="good-info {{#if @root.sale_vip_login}}sale-vip{{/if}}" data-good-id="{{product_id}}" data-id="{{product_skn}}" data-bp-id="guang_goodList_{{product_name}}_false"> 2 + <div class="good-info {{#if @root.sale_vip_login}}sale-vip{{/if}}" data-good-id="{{product_id}}"
  3 + data-id="{{product_skn}}" data-bp-id="guang_goodList_{{product_name}}_false">
3 <div class="tag-container clearfix"> 4 <div class="tag-container clearfix">
4 {{# tags}} 5 {{# tags}}
5 {{# is_new}} 6 {{# is_new}}
@@ -27,7 +28,11 @@ @@ -27,7 +28,11 @@
27 </div> 28 </div>
28 <div class="good-detail-img"> 29 <div class="good-detail-img">
29 <a class="good-thumb" href="{{url}}"> 30 <a class="good-thumb" href="{{url}}">
30 - <img class="lazy" data-original="{{image default_images 235 314}}"> 31 + {{#if @root._noLazy}}
  32 + <img src="{{image default_images 235 314}}" width="470" height="628"/>
  33 + {{else}}
  34 + <img class="lazy" data-original="{{image default_images 235 314}}"/>
  35 + {{/if}}
31 </a> 36 </a>
32 {{# is_soon_sold_out}} 37 {{# is_soon_sold_out}}
33 <p class="few-tag">即将售罄</p> 38 <p class="few-tag">即将售罄</p>