...
|
...
|
@@ -11,11 +11,19 @@ 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,
|
|
|
minBrandListTop,
|
|
|
searchArray = [],
|
|
|
clearTextHammer,
|
|
|
removeHistory,
|
|
|
searchList,
|
|
|
yohoHistory,
|
|
|
minBrandListTop;
|
|
|
|
|
|
var brandsData,
|
...
|
...
|
@@ -109,6 +117,21 @@ function searchResult() { |
|
|
|
|
|
// 插入 dom,绑定事件
|
|
|
$('.search-result').html(html);
|
|
|
$('.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) {
|
...
|
...
|
@@ -116,6 +139,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');
|
...
|
...
|
@@ -137,4 +161,20 @@ 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');
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
$('.history').css('display', 'none');
|
|
|
}
|
|
|
|
|
|
removeHistory = new Hammer($('.removeHistory')[0]);
|
|
|
removeHistory.on('tap', function(e) {
|
|
|
$('.historyList').html(' ');
|
|
|
localStorage.clear();
|
|
|
});
|
|
|
} |
...
|
...
|
|