...
|
...
|
@@ -14,12 +14,15 @@ var swiper, |
|
|
|
|
|
var searchH = $('.newbrand-search').outerHeight(),
|
|
|
headerH = $('.yoho-header').outerHeight(),
|
|
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1;
|
|
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
|
|
|
searchArray = [];
|
|
|
|
|
|
var brandsData,
|
|
|
$keyword,
|
|
|
searchBtnHammer,
|
|
|
clearTextHammer;
|
|
|
clearTextHammer,
|
|
|
removeHistory,
|
|
|
searchList,
|
|
|
yohoHistory;
|
|
|
|
|
|
swiper = new Swiper('.swiper-container', {
|
|
|
lazyLoading: true,
|
...
|
...
|
@@ -31,7 +34,8 @@ swiper = new Swiper('.swiper-container', { |
|
|
lazyLoad($('img.lazy'));
|
|
|
$('.yoho-header').css({
|
|
|
'z-index': 2,
|
|
|
position: 'fixed'
|
|
|
position: 'fixed',
|
|
|
top: 0
|
|
|
});
|
|
|
|
|
|
$(window).scroll(function() {
|
...
|
...
|
@@ -96,12 +100,15 @@ function searchResult() { |
|
|
brandHtml.push(k);
|
|
|
brandHtml.push('</h2></div>');
|
|
|
$.each(v, function(i, brand) {
|
|
|
|
|
|
brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);
|
|
|
|
|
|
// brandHtml.push('<p><span>' + brand.name);
|
|
|
if (brand.isNew) {
|
|
|
brandHtml.push('<i class="icon-hot">Hot</i>');
|
|
|
brandHtml.push('<i class="icon-hot">HOT</i>');
|
|
|
}
|
|
|
if (brand.isHot) {
|
|
|
brandHtml.push('<i class="icon-new">New</i>');
|
|
|
brandHtml.push('<i class="icon-new">NEW</i>');
|
|
|
}
|
|
|
brandHtml.push('</a></p>');
|
|
|
});
|
...
|
...
|
@@ -127,6 +134,20 @@ 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() {
|
|
|
if (localStorage.getItem('yohoHistory')) {
|
|
|
yohoHistory = localStorage.getItem('yohoHistory');
|
|
|
searchArray.push(yohoHistory);
|
|
|
}
|
|
|
searchArray.push('{"searchName":"' +
|
|
|
$('.search-result .brand-list p').eq(index).find('a').html() +
|
|
|
'","searchHref":"' + $('.search-result .brand-list p')
|
|
|
.eq(index).find('a').attr('href') + '"}');
|
|
|
localStorage.setItem('yohoHistory', searchArray);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if ($('.brand-search-page').length) {
|
...
|
...
|
@@ -134,6 +155,7 @@ 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');
|
...
|
...
|
@@ -142,14 +164,7 @@ if ($('.brand-search-page').length) { |
|
|
$(this).closest('.search-box').css('width', '12.5rem');
|
|
|
$('.search-action').hide();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
searchBtnHammer = new Hammer($('.search-btn')[0]);
|
|
|
searchBtnHammer.on('tap', function(e) {
|
|
|
searchResult();
|
|
|
e.srcEvent.stopPropagation();
|
|
|
});
|
|
|
}).focus();
|
|
|
|
|
|
clearTextHammer = new Hammer($('.clear-text')[0]);
|
|
|
clearTextHammer.on('tap', function(e) {
|
...
|
...
|
@@ -160,16 +175,18 @@ 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');
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// clearHistoryHammer = new Hammer($('#clear-text')[0]);
|
|
|
// clearHistoryHammer.on('tap', function() {
|
|
|
|
|
|
// // setcookie('h_brands', '', {
|
|
|
// // expire: -1,
|
|
|
// // path: '/',
|
|
|
// // domain: '.m.yohobuy.com'
|
|
|
// // });
|
|
|
// $('#history-keyword').remove();
|
|
|
// $(this).hide();
|
|
|
// });
|
|
|
removeHistory = new Hammer($('.removeHistory')[0]);
|
|
|
removeHistory.on('tap', function(e) {
|
|
|
$('.historyList').html(' ');
|
|
|
localStorage.clear();
|
|
|
});
|
|
|
} |
...
|
...
|
|