...
|
...
|
@@ -11,21 +11,16 @@ var $ = require('jquery'), |
|
|
|
|
|
var swiper,
|
|
|
$fixTitleBar,
|
|
|
$brandText,
|
|
|
$brandHref,
|
|
|
$brandList = $('.brand-list');
|
|
|
|
|
|
var searchH = $('.newbrand-search').outerHeight(),
|
|
|
headerH = $('.yoho-header').outerHeight(),
|
|
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
|
|
|
searchArray = [];
|
|
|
minBrandListTop;
|
|
|
|
|
|
var brandsData,
|
|
|
$keyword,
|
|
|
clearTextHammer,
|
|
|
removeHistory,
|
|
|
searchList,
|
|
|
yohoHistory;
|
|
|
clearTextHammer;
|
|
|
|
|
|
swiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
...
|
...
|
@@ -42,13 +37,15 @@ $('.yoho-header').css({ |
|
|
});
|
|
|
|
|
|
$fixTitleBar = $('<div class="title-bar fixed-title-bar"><h2></h2></div>');
|
|
|
$fixTitleBar.hide();
|
|
|
$fixTitleBar.css({
|
|
|
position: 'fixed',
|
|
|
top: brandSwipe
|
|
|
}).hide();
|
|
|
minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() + $('.banner-top').outerHeight();
|
|
|
$('.brand-list').last().append($fixTitleBar);
|
|
|
|
|
|
$(window).scroll(function() {
|
|
|
var scrTop = $(window).scrollTop(),
|
|
|
minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() +
|
|
|
$('.banner-top').outerHeight();
|
|
|
var scrTop = $(window).scrollTop();
|
|
|
|
|
|
if ($brandList.eq(0).offset().top < minBrandListTop) {
|
|
|
$fixTitleBar.hide();
|
...
|
...
|
@@ -59,9 +56,7 @@ $(window).scroll(function() { |
|
|
|
|
|
if (scrTop >= offTop) {
|
|
|
$fixTitleBar.css({
|
|
|
display: 'block',
|
|
|
position: 'fixed',
|
|
|
top: brandSwipe
|
|
|
display: 'block'
|
|
|
}).find('h2').html($(this).find('.title-bar').text());
|
|
|
}
|
|
|
|
...
|
...
|
@@ -70,10 +65,12 @@ $(window).scroll(function() { |
|
|
|
|
|
function rightBarBindClick() {
|
|
|
$('#right-bar .con').find('b').unbind().on('touchstart', function(e) {
|
|
|
var index = $(this).index();
|
|
|
var index = $(this).index(),
|
|
|
top;
|
|
|
|
|
|
if ($('.bar-' + index).size() > 0) {
|
|
|
document.body.scrollTop = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);
|
|
|
top = parseInt($('.bar-' + index)[0].offsetTop) - parseInt(brandSwipe - 1);
|
|
|
$(document).scrollTop(top);
|
|
|
}
|
|
|
e.stopPropagation();
|
|
|
});
|
...
|
...
|
@@ -146,21 +143,6 @@ function searchResult() { |
|
|
if (Object.keys(result).length > 0) {
|
|
|
rightBarBindClick();
|
|
|
}
|
|
|
$('.search-result .brand-list p').each(function (index) {
|
|
|
searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]);
|
|
|
searchList.on('tap', function() {
|
|
|
$brandText = $('.search-result .brand-list p').eq(index).find('a').html();
|
|
|
$brandHref = $('.search-result .brand-list p').eq(index).find('a').attr('href');
|
|
|
if (localStorage.getItem('yohoHistory')) {
|
|
|
yohoHistory = localStorage.getItem('yohoHistory');
|
|
|
searchArray.push(yohoHistory);
|
|
|
}
|
|
|
if (searchArray.toString().split($brandText).length < 2) {
|
|
|
searchArray.push('{"searchName":"' + $brandText + '","searchHref":"' + $brandText + '"}');
|
|
|
}
|
|
|
localStorage.setItem('yohoHistory', searchArray);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if ($('.brand-search-page').length) {
|
...
|
...
|
@@ -168,7 +150,6 @@ if ($('.brand-search-page').length) { |
|
|
$keyword = $('#keyword');
|
|
|
|
|
|
$keyword.on('input', function() {
|
|
|
$('.history').css('display', 'none');
|
|
|
if ($keyword.val().length) {
|
|
|
searchResult();
|
|
|
$(this).closest('.search-box').css('width', '11.25rem');
|
...
|
...
|
@@ -182,6 +163,7 @@ if ($('.brand-search-page').length) { |
|
|
clearTextHammer = new Hammer($('.clear-text')[0]);
|
|
|
clearTextHammer.on('tap', function(e) {
|
|
|
e.preventDefault();
|
|
|
$('.search-result').html('');
|
|
|
$('#keyword').val('').trigger('input');
|
|
|
e.srcEvent.stopPropagation();
|
|
|
});
|
...
|
...
|
@@ -189,18 +171,4 @@ if ($('.brand-search-page').length) { |
|
|
$('form.search-box').on('submit', function() {
|
|
|
return false;
|
|
|
});
|
|
|
if (localStorage && localStorage.getItem('yohoHistory')) {
|
|
|
yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
|
|
|
if (yohoHistory) {
|
|
|
$.each(yohoHistory, function(index, content) {
|
|
|
$('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList');
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
removeHistory = new Hammer($('.removeHistory')[0]);
|
|
|
removeHistory.on('tap', function(e) {
|
|
|
$('.historyList').html(' ');
|
|
|
localStorage.clear();
|
|
|
});
|
|
|
} |
...
|
...
|
|