Authored by zhangxiaoru

第一屏

... ... @@ -121,7 +121,7 @@
<p class="intro-text">{{@root.introText}}</p>
{{/@root.introText}}
<div class="firstscreen-goods container clearfix">
<div class="default-goods container clearfix">
{{!--搜索推荐词模板--}}
{{> search/search-word-content}}
... ... @@ -130,7 +130,6 @@
{{/@root.firstPageGoods.list}}
</div>
<div class="search-divide">正在加载...</div>
<div class="default-goods container clearfix"></div>
<div class="new-goods container clearfix"></div>
<div class="sale-goods container clearfix"></div>
<div class="price-goods container clearfix hide"></div>
... ...
... ... @@ -21,7 +21,6 @@ let tip = require('plugin/tip');
let loading = require('plugin/loading');
let $goodsContainer = $('#goods-container'),
$fsgc = $goodsContainer.children('.firstscreen-goods'),
$defaultgc = $goodsContainer.children('.default-goods'),
$ngc = $goodsContainer.children('.new-goods'),
$sgc = $goodsContainer.children('.sale-goods'),
... ... @@ -46,7 +45,7 @@ let defaultOpt = require('common/query-param');
require('common');
// 首屏加载标志
let firstScreen = $('.firstscreen-goods').children().size() > 0;
let firstScreen = $('.default-goods').children().size() > 0;
let isRecYas = window.queryString.needSuggestion === 'Y' || $('.word-content').length ? 'Y' : 'N'; // 是否是关键词
... ... @@ -106,7 +105,7 @@ let noResultHbs = require('product/search/no-result-new.hbs');
C_ID = window._ChannelVary[window.cookie('_Channel')];
// 首屏无数据
if ($fsgc.children().length === 0) {
if (!firstScreen) {
$goodsContainer.html(noResultHbs());
window.rePosFooter();
}
... ... @@ -259,12 +258,12 @@ couponId = getQueryString('coupon_id');
couponCode = getQueryString('coupon_code');
searchFrom = getQueryString('from');
if ($fsgc.children().length > 0) {
if ($defaultgc.children().length > 0) {
let fsgcgoods = [],
firstop,
firstyasparm = {};
$fsgc.find('.good-info').each(function() {
$defaultgc.find('.good-info').each(function() {
let fsgcgood = $(this).data('good-id');
if (fsgcgood) {
... ... @@ -287,7 +286,7 @@ if ($fsgc.children().length > 0) {
firstyasparm = Object.assign(firstyasparm, {
C_ID: C_ID,
RES_QTY: $fsgc.children().length,
RES_QTY: $defaultgc.children().length,
PRD_LIST: JSON.stringify(fsgcgoods).replace(/\[|\]/g, ''),
PAGE_NUM: 1,
FILTER_VALUE: '',
... ... @@ -418,6 +417,7 @@ function search(opt) {
nav = navInfo[navType];
page = nav.page + 1;
if (nav.reload) {
page = 1;
} else if (nav.end) {
... ... @@ -547,18 +547,6 @@ function search(opt) {
argument = setting;
if (opt && opt.filtering) {
$fsgc.addClass('hide');
if (params.start) {
delete setting.start;
}
}
// 如果page =1,默认是用户输入的搜索词,否则是推荐词
if (setting.start !== 12 && setting.page === 1 && oldquery) {
setting.query = oldquery;
}
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
... ... @@ -638,7 +626,7 @@ function search(opt) {
}, 200);
}
} else {
if (nav.reload) {
if (nav.reload && !firstScreen) {
$container.html(data);
num = $container.find('.good-info').length;
$('.search-divide').remove();
... ... @@ -725,6 +713,8 @@ function search(opt) {
window.rePosFooter();
firstScreen = false;
$('.good-detail-text .name').each(function() {
$this = $(this);
$title = $this.find('a');
... ... @@ -759,8 +749,6 @@ function search(opt) {
break;
}
}
},
error: function() {
let $divide = $('.search-divide');
... ... @@ -774,10 +762,6 @@ function search(opt) {
});
}
});
// 还原参数
params.start = 0;
firstScreen = false;
}
require('common/suspend-cart'); // 悬浮购物车
... ... @@ -934,6 +918,7 @@ $('.drop-list').on('touchend', 'li', function(e) {
navType = 'default';
} else {
navType = 'popularity';
firstScreen = false;
}
if ($(this).hasClass('active')) {
... ... @@ -949,7 +934,6 @@ $('.drop-list').on('touchend', 'li', function(e) {
nav = navInfo[navType];
$defaultgc.removeClass('hide');
$fsgc.removeClass('hide');
$goodsContainer.children('.container:not(.hide)').addClass('hide');
... ... @@ -968,12 +952,10 @@ $('.drop-list').on('touchend', 'li', function(e) {
case 'default':
$defaultgc.removeClass('hide');
$fsgc.removeClass('hide');
break;
case 'popularity':
$defaultgc.removeClass('hide');
$fsgc.removeClass('hide');
break;
case 'sale':
... ... @@ -1085,7 +1067,6 @@ $listNav.on('touchend touchcancel', function(e) {
case 'default':
$defaultgc.removeClass('hide');
$fsgc.removeClass('hide');
break;
case 'sale':
... ... @@ -1193,16 +1174,6 @@ if ($brandHeader.length > 0) {
});
}
let initialData = false;
$(window).one('scroll', function() {
// 初始请求最新第一页数据
if (!initialData) {
search();
initialData = true;
}
});
$listNav.on('touchstart', 'li', function() {
$listNav.find('li').removeClass('bytouch');
$(this).addClass('bytouch');
... ...