Authored by zhangxiaoru

第一屏

@@ -121,7 +121,7 @@ @@ -121,7 +121,7 @@
121 <p class="intro-text">{{@root.introText}}</p> 121 <p class="intro-text">{{@root.introText}}</p>
122 {{/@root.introText}} 122 {{/@root.introText}}
123 123
124 - <div class="firstscreen-goods container clearfix"> 124 + <div class="default-goods container clearfix">
125 {{!--搜索推荐词模板--}} 125 {{!--搜索推荐词模板--}}
126 {{> search/search-word-content}} 126 {{> search/search-word-content}}
127 127
@@ -130,7 +130,6 @@ @@ -130,7 +130,6 @@
130 {{/@root.firstPageGoods.list}} 130 {{/@root.firstPageGoods.list}}
131 </div> 131 </div>
132 <div class="search-divide">正在加载...</div> 132 <div class="search-divide">正在加载...</div>
133 - <div class="default-goods container clearfix"></div>  
134 <div class="new-goods container clearfix"></div> 133 <div class="new-goods container clearfix"></div>
135 <div class="sale-goods container clearfix"></div> 134 <div class="sale-goods container clearfix"></div>
136 <div class="price-goods container clearfix hide"></div> 135 <div class="price-goods container clearfix hide"></div>
@@ -21,7 +21,6 @@ let tip = require('plugin/tip'); @@ -21,7 +21,6 @@ let tip = require('plugin/tip');
21 let loading = require('plugin/loading'); 21 let loading = require('plugin/loading');
22 22
23 let $goodsContainer = $('#goods-container'), 23 let $goodsContainer = $('#goods-container'),
24 - $fsgc = $goodsContainer.children('.firstscreen-goods'),  
25 $defaultgc = $goodsContainer.children('.default-goods'), 24 $defaultgc = $goodsContainer.children('.default-goods'),
26 $ngc = $goodsContainer.children('.new-goods'), 25 $ngc = $goodsContainer.children('.new-goods'),
27 $sgc = $goodsContainer.children('.sale-goods'), 26 $sgc = $goodsContainer.children('.sale-goods'),
@@ -46,7 +45,7 @@ let defaultOpt = require('common/query-param'); @@ -46,7 +45,7 @@ let defaultOpt = require('common/query-param');
46 require('common'); 45 require('common');
47 46
48 // 首屏加载标志 47 // 首屏加载标志
49 -let firstScreen = $('.firstscreen-goods').children().size() > 0; 48 +let firstScreen = $('.default-goods').children().size() > 0;
50 49
51 let isRecYas = window.queryString.needSuggestion === 'Y' || $('.word-content').length ? 'Y' : 'N'; // 是否是关键词 50 let isRecYas = window.queryString.needSuggestion === 'Y' || $('.word-content').length ? 'Y' : 'N'; // 是否是关键词
52 51
@@ -106,7 +105,7 @@ let noResultHbs = require('product/search/no-result-new.hbs'); @@ -106,7 +105,7 @@ let noResultHbs = require('product/search/no-result-new.hbs');
106 C_ID = window._ChannelVary[window.cookie('_Channel')]; 105 C_ID = window._ChannelVary[window.cookie('_Channel')];
107 106
108 // 首屏无数据 107 // 首屏无数据
109 -if ($fsgc.children().length === 0) { 108 +if (!firstScreen) {
110 $goodsContainer.html(noResultHbs()); 109 $goodsContainer.html(noResultHbs());
111 window.rePosFooter(); 110 window.rePosFooter();
112 } 111 }
@@ -259,12 +258,12 @@ couponId = getQueryString('coupon_id'); @@ -259,12 +258,12 @@ couponId = getQueryString('coupon_id');
259 couponCode = getQueryString('coupon_code'); 258 couponCode = getQueryString('coupon_code');
260 searchFrom = getQueryString('from'); 259 searchFrom = getQueryString('from');
261 260
262 -if ($fsgc.children().length > 0) { 261 +if ($defaultgc.children().length > 0) {
263 let fsgcgoods = [], 262 let fsgcgoods = [],
264 firstop, 263 firstop,
265 firstyasparm = {}; 264 firstyasparm = {};
266 265
267 - $fsgc.find('.good-info').each(function() { 266 + $defaultgc.find('.good-info').each(function() {
268 let fsgcgood = $(this).data('good-id'); 267 let fsgcgood = $(this).data('good-id');
269 268
270 if (fsgcgood) { 269 if (fsgcgood) {
@@ -287,7 +286,7 @@ if ($fsgc.children().length > 0) { @@ -287,7 +286,7 @@ if ($fsgc.children().length > 0) {
287 286
288 firstyasparm = Object.assign(firstyasparm, { 287 firstyasparm = Object.assign(firstyasparm, {
289 C_ID: C_ID, 288 C_ID: C_ID,
290 - RES_QTY: $fsgc.children().length, 289 + RES_QTY: $defaultgc.children().length,
291 PRD_LIST: JSON.stringify(fsgcgoods).replace(/\[|\]/g, ''), 290 PRD_LIST: JSON.stringify(fsgcgoods).replace(/\[|\]/g, ''),
292 PAGE_NUM: 1, 291 PAGE_NUM: 1,
293 FILTER_VALUE: '', 292 FILTER_VALUE: '',
@@ -418,6 +417,7 @@ function search(opt) { @@ -418,6 +417,7 @@ function search(opt) {
418 nav = navInfo[navType]; 417 nav = navInfo[navType];
419 418
420 page = nav.page + 1; 419 page = nav.page + 1;
  420 +
421 if (nav.reload) { 421 if (nav.reload) {
422 page = 1; 422 page = 1;
423 } else if (nav.end) { 423 } else if (nav.end) {
@@ -547,18 +547,6 @@ function search(opt) { @@ -547,18 +547,6 @@ function search(opt) {
547 547
548 argument = setting; 548 argument = setting;
549 549
550 - if (opt && opt.filtering) {  
551 - $fsgc.addClass('hide');  
552 - if (params.start) {  
553 - delete setting.start;  
554 - }  
555 - }  
556 -  
557 - // 如果page =1,默认是用户输入的搜索词,否则是推荐词  
558 - if (setting.start !== 12 && setting.page === 1 && oldquery) {  
559 - setting.query = oldquery;  
560 - }  
561 -  
562 $.ajax({ 550 $.ajax({
563 type: 'GET', 551 type: 'GET',
564 url: location.protocol + '//m.yohobuy.com/product/search/search', 552 url: location.protocol + '//m.yohobuy.com/product/search/search',
@@ -638,7 +626,7 @@ function search(opt) { @@ -638,7 +626,7 @@ function search(opt) {
638 }, 200); 626 }, 200);
639 } 627 }
640 } else { 628 } else {
641 - if (nav.reload) { 629 + if (nav.reload && !firstScreen) {
642 $container.html(data); 630 $container.html(data);
643 num = $container.find('.good-info').length; 631 num = $container.find('.good-info').length;
644 $('.search-divide').remove(); 632 $('.search-divide').remove();
@@ -725,6 +713,8 @@ function search(opt) { @@ -725,6 +713,8 @@ function search(opt) {
725 713
726 window.rePosFooter(); 714 window.rePosFooter();
727 715
  716 + firstScreen = false;
  717 +
728 $('.good-detail-text .name').each(function() { 718 $('.good-detail-text .name').each(function() {
729 $this = $(this); 719 $this = $(this);
730 $title = $this.find('a'); 720 $title = $this.find('a');
@@ -759,8 +749,6 @@ function search(opt) { @@ -759,8 +749,6 @@ function search(opt) {
759 break; 749 break;
760 } 750 }
761 } 751 }
762 -  
763 -  
764 }, 752 },
765 error: function() { 753 error: function() {
766 let $divide = $('.search-divide'); 754 let $divide = $('.search-divide');
@@ -774,10 +762,6 @@ function search(opt) { @@ -774,10 +762,6 @@ function search(opt) {
774 }); 762 });
775 } 763 }
776 }); 764 });
777 -  
778 - // 还原参数  
779 - params.start = 0;  
780 - firstScreen = false;  
781 } 765 }
782 766
783 require('common/suspend-cart'); // 悬浮购物车 767 require('common/suspend-cart'); // 悬浮购物车
@@ -934,6 +918,7 @@ $('.drop-list').on('touchend', 'li', function(e) { @@ -934,6 +918,7 @@ $('.drop-list').on('touchend', 'li', function(e) {
934 navType = 'default'; 918 navType = 'default';
935 } else { 919 } else {
936 navType = 'popularity'; 920 navType = 'popularity';
  921 + firstScreen = false;
937 } 922 }
938 923
939 if ($(this).hasClass('active')) { 924 if ($(this).hasClass('active')) {
@@ -949,7 +934,6 @@ $('.drop-list').on('touchend', 'li', function(e) { @@ -949,7 +934,6 @@ $('.drop-list').on('touchend', 'li', function(e) {
949 nav = navInfo[navType]; 934 nav = navInfo[navType];
950 935
951 $defaultgc.removeClass('hide'); 936 $defaultgc.removeClass('hide');
952 - $fsgc.removeClass('hide');  
953 937
954 $goodsContainer.children('.container:not(.hide)').addClass('hide'); 938 $goodsContainer.children('.container:not(.hide)').addClass('hide');
955 939
@@ -968,12 +952,10 @@ $('.drop-list').on('touchend', 'li', function(e) { @@ -968,12 +952,10 @@ $('.drop-list').on('touchend', 'li', function(e) {
968 952
969 case 'default': 953 case 'default':
970 $defaultgc.removeClass('hide'); 954 $defaultgc.removeClass('hide');
971 - $fsgc.removeClass('hide');  
972 break; 955 break;
973 956
974 case 'popularity': 957 case 'popularity':
975 $defaultgc.removeClass('hide'); 958 $defaultgc.removeClass('hide');
976 - $fsgc.removeClass('hide');  
977 break; 959 break;
978 960
979 case 'sale': 961 case 'sale':
@@ -1085,7 +1067,6 @@ $listNav.on('touchend touchcancel', function(e) { @@ -1085,7 +1067,6 @@ $listNav.on('touchend touchcancel', function(e) {
1085 1067
1086 case 'default': 1068 case 'default':
1087 $defaultgc.removeClass('hide'); 1069 $defaultgc.removeClass('hide');
1088 - $fsgc.removeClass('hide');  
1089 break; 1070 break;
1090 1071
1091 case 'sale': 1072 case 'sale':
@@ -1193,16 +1174,6 @@ if ($brandHeader.length > 0) { @@ -1193,16 +1174,6 @@ if ($brandHeader.length > 0) {
1193 }); 1174 });
1194 } 1175 }
1195 1176
1196 -let initialData = false;  
1197 -  
1198 -$(window).one('scroll', function() {  
1199 - // 初始请求最新第一页数据  
1200 - if (!initialData) {  
1201 - search();  
1202 - initialData = true;  
1203 - }  
1204 -});  
1205 -  
1206 $listNav.on('touchstart', 'li', function() { 1177 $listNav.on('touchstart', 'li', function() {
1207 $listNav.find('li').removeClass('bytouch'); 1178 $listNav.find('li').removeClass('bytouch');
1208 $(this).addClass('bytouch'); 1179 $(this).addClass('bytouch');