...
|
...
|
@@ -430,145 +430,147 @@ function removeHistory() { |
|
|
}
|
|
|
|
|
|
// 初始化历史搜索的内容
|
|
|
require('./brand-render')(function() {
|
|
|
$netHistory = $('.net-history')
|
|
|
if ($('.brand-search-page').length > 0) {
|
|
|
chHammer = new Hammer($clearHistory[0]);
|
|
|
chHammer.on('tap', function() {
|
|
|
if (isLocalStorageSupported()) {
|
|
|
localStorage.removeItem('historys-brand');
|
|
|
}
|
|
|
$history.html('');
|
|
|
$historySearch.hide();
|
|
|
$clearHistory.hide();
|
|
|
|
|
|
if ($('.brand-search-page').length > 0) {
|
|
|
|
|
|
chHammer = new Hammer($clearHistory[0]);
|
|
|
chHammer.on('tap', function() {
|
|
|
if (isLocalStorageSupported()) {
|
|
|
localStorage.removeItem('historys-brand');
|
|
|
}
|
|
|
$history.html('');
|
|
|
$historySearch.hide();
|
|
|
$clearHistory.hide();
|
|
|
|
|
|
if ($('.net-search').length > 0) {
|
|
|
removeHistory();
|
|
|
}
|
|
|
|
|
|
window.rePosFooter();
|
|
|
});
|
|
|
if ($('.net-search').length > 0) {
|
|
|
removeHistory();
|
|
|
}
|
|
|
|
|
|
// 搜索页面
|
|
|
|
|
|
(function() {
|
|
|
var html = '',
|
|
|
history,
|
|
|
historys, i,
|
|
|
localHistory,
|
|
|
brand, data,
|
|
|
time, netArr, dict, dictc, localArr,
|
|
|
combinArr, key, date, temp;
|
|
|
|
|
|
localArr = [];
|
|
|
combinArr = [];
|
|
|
netArr = [];
|
|
|
|
|
|
$netHistory.find('li').each(function() {
|
|
|
|
|
|
brand = $(this).find('a').attr('brandName');
|
|
|
time = $(this).find('a').attr('collectTime');
|
|
|
dict = {
|
|
|
brand: brand,
|
|
|
time: time
|
|
|
}, dictc, dict;
|
|
|
netArr.push(dict);
|
|
|
window.rePosFooter();
|
|
|
});
|
|
|
|
|
|
// 搜索页面
|
|
|
|
|
|
(function() {
|
|
|
var html = '',
|
|
|
history,
|
|
|
historys, i,
|
|
|
localHistory,
|
|
|
brand, data,
|
|
|
time, netArr, dict, dictc, localArr,
|
|
|
combinArr, key, date, temp;
|
|
|
|
|
|
localArr = [];
|
|
|
combinArr = [];
|
|
|
netArr = [];
|
|
|
|
|
|
$netHistory.find('li').each(function() {
|
|
|
|
|
|
brand = $(this).find('a').attr('brandName');
|
|
|
time = $(this).find('a').attr('collectTime');
|
|
|
dict = {
|
|
|
brand: brand,
|
|
|
time: time
|
|
|
}, dictc, dict;
|
|
|
netArr.push(dict);
|
|
|
});
|
|
|
|
|
|
if (localStorage) {
|
|
|
if (isLocalStorageSupported()) {
|
|
|
historys = localStorage.getItem('historys-brand');
|
|
|
}
|
|
|
|
|
|
if (historys && historys.length > 0) {
|
|
|
historys = historys.split(ranToken);
|
|
|
for (i = historys.length; i > 0; i--) {
|
|
|
history = historys[i - 1];
|
|
|
if (localStorage) {
|
|
|
if (isLocalStorageSupported()) {
|
|
|
historys = localStorage.getItem('historys-brand');
|
|
|
}
|
|
|
|
|
|
if (history === '') {
|
|
|
continue;
|
|
|
}
|
|
|
localHistory = history.split(ranToken2);
|
|
|
if (historys && historys.length > 0) {
|
|
|
historys = historys.split(ranToken);
|
|
|
for (i = historys.length; i > 0; i--) {
|
|
|
history = historys[i - 1];
|
|
|
|
|
|
brand = localHistory[0];
|
|
|
time = localHistory[1];
|
|
|
if (history === '') {
|
|
|
continue;
|
|
|
}
|
|
|
localHistory = history.split(ranToken2);
|
|
|
|
|
|
dict = {
|
|
|
brand: brand,
|
|
|
time: time
|
|
|
};
|
|
|
brand = localHistory[0];
|
|
|
time = localHistory[1];
|
|
|
|
|
|
localArr.push(dict);
|
|
|
dict = {
|
|
|
brand: brand,
|
|
|
time: time
|
|
|
};
|
|
|
|
|
|
localArr.push(dict);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (localArr.length === 0 && netArr.length === 0) {
|
|
|
$historySearch.addClass('hide');
|
|
|
return;
|
|
|
}
|
|
|
if (localArr.length === 0 && netArr.length === 0) {
|
|
|
$historySearch.addClass('hide');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
date = {};
|
|
|
temp = {};
|
|
|
if (localArr.length > 0) {
|
|
|
for (dictc in localArr) {
|
|
|
if (localArr.hasOwnProperty(dictc)) {
|
|
|
temp = localArr[dictc];
|
|
|
if (!date[temp.brand] || date[temp.brand] < temp.time) {
|
|
|
date[temp.brand] = temp.time;
|
|
|
date = {};
|
|
|
temp = {};
|
|
|
if (localArr.length > 0) {
|
|
|
for (dictc in localArr) {
|
|
|
if (localArr.hasOwnProperty(dictc)) {
|
|
|
temp = localArr[dictc];
|
|
|
if (!date[temp.brand] || date[temp.brand] < temp.time) {
|
|
|
date[temp.brand] = temp.time;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (netArr.length > 0) {
|
|
|
for (dict in netArr) {
|
|
|
if (netArr.hasOwnProperty(dict)) {
|
|
|
temp = netArr[dict];
|
|
|
if (!date[temp.brand] || date[temp.brand] < temp.time) {
|
|
|
date[temp.brand] = temp.time;
|
|
|
if (netArr.length > 0) {
|
|
|
for (dict in netArr) {
|
|
|
if (netArr.hasOwnProperty(dict)) {
|
|
|
temp = netArr[dict];
|
|
|
if (!date[temp.brand] || date[temp.brand] < temp.time) {
|
|
|
date[temp.brand] = temp.time;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
data = {};
|
|
|
for (key in date) {
|
|
|
if (date.hasOwnProperty(key)) {
|
|
|
data = {
|
|
|
brand: key,
|
|
|
time: date[key]
|
|
|
};
|
|
|
combinArr.push(data);
|
|
|
data = {};
|
|
|
for (key in date) {
|
|
|
if (date.hasOwnProperty(key)) {
|
|
|
data = {
|
|
|
brand: key,
|
|
|
time: date[key]
|
|
|
};
|
|
|
combinArr.push(data);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
combinArr.sort(sequence);
|
|
|
combinArr.sort(sequence);
|
|
|
|
|
|
if (combinArr.length > 0) {
|
|
|
for (i = combinArr.length - 1; i >= ((combinArr.length > 10) ? (combinArr.length - 10) : 0); i--) {
|
|
|
if (combinArr.length > 0) {
|
|
|
for (i = combinArr.length - 1; i >= ((combinArr.length > 10) ? (combinArr.length - 10) : 0); i--) {
|
|
|
|
|
|
brand = combinArr[i].brand;
|
|
|
time = combinArr[i].time;
|
|
|
brand = combinArr[i].brand;
|
|
|
time = combinArr[i].time;
|
|
|
|
|
|
html += '<li><a brandName = "' + brand +
|
|
|
'">' + brand + '</li>';
|
|
|
$history.removeClass('hide');
|
|
|
html += '<li><a brandName = "' + brand +
|
|
|
'">' + brand + '</li>';
|
|
|
$history.removeClass('hide');
|
|
|
|
|
|
$history.html(html);
|
|
|
$clearHistory.removeClass('hide');
|
|
|
$history.html(html);
|
|
|
$clearHistory.removeClass('hide');
|
|
|
|
|
|
$hotSearch.removeClass('hide');
|
|
|
window.rePosFooter();
|
|
|
$hotSearch.removeClass('hide');
|
|
|
window.rePosFooter();
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
$history.addClass('hide');
|
|
|
}
|
|
|
} else {
|
|
|
$history.addClass('hide');
|
|
|
}
|
|
|
|
|
|
}());
|
|
|
}());
|
|
|
|
|
|
}
|
|
|
})
|
|
|
|
|
|
} |
...
|
...
|
|