Authored by uedxwg

upadte

... ... @@ -10,6 +10,8 @@ var $ = require('jquery'),
lazyLoad = require('yoho.lazyload');
var swiper,
$brandText,
$brandHref,
$brandList = $('.brand-list');
var searchH = $('.newbrand-search').outerHeight(),
... ... @@ -137,14 +139,15 @@ function searchResult() {
$('.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)
searchArray.push(yohoHistory);
}
if (searchArray.toString().split($brandText).length < 2) {
searchArray.push('{"searchName":"' + $brandText + '","searchHref":"' + $brandText + '"}');
}
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);
});
});
... ... @@ -185,11 +188,10 @@ if ($('.brand-search-page').length) {
if (localStorage) {
yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
console.log(yohoHistory);
if (yohoHistory) {
$.each(yohoHistory, function(index, content) {
$('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList');
})
});
}
}
... ...