...
|
...
|
@@ -14,12 +14,16 @@ 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,
|
...
|
...
|
@@ -97,7 +101,10 @@ 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>');
|
|
|
}
|
...
|
...
|
@@ -128,6 +135,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) {
|
...
|
...
|
@@ -135,6 +156,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');
|
...
|
...
|
@@ -161,16 +183,20 @@ if ($('.brand-search-page').length) { |
|
|
$('form.search-box').on('submit', function() {
|
|
|
return false;
|
|
|
});
|
|
|
if (localStorage) {
|
|
|
|
|
|
// 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();
|
|
|
// });
|
|
|
yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
|
|
|
console.log(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();
|
|
|
});
|
|
|
} |
...
|
...
|
|