|
@@ -11,8 +11,6 @@ var $ = require('jquery'), |
|
@@ -11,8 +11,6 @@ var $ = require('jquery'), |
11
|
|
11
|
|
12
|
var swiper,
|
12
|
var swiper,
|
13
|
$fixTitleBar,
|
13
|
$fixTitleBar,
|
14
|
- $brandText,
|
|
|
15
|
- $brandHref,
|
|
|
16
|
$brandList = $('.brand-list');
|
14
|
$brandList = $('.brand-list');
|
17
|
var $icon = $('.search-icon');
|
15
|
var $icon = $('.search-icon');
|
18
|
|
16
|
|
|
@@ -21,10 +19,6 @@ var searchH = $('.newbrand-search').outerHeight(), |
|
@@ -21,10 +19,6 @@ var searchH = $('.newbrand-search').outerHeight(), |
21
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
|
19
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
|
22
|
minBrandListTop,
|
20
|
minBrandListTop,
|
23
|
searchArray = [],
|
21
|
searchArray = [],
|
24
|
- clearTextHammer,
|
|
|
25
|
- removeHistory,
|
|
|
26
|
- searchList,
|
|
|
27
|
- yohoHistory,
|
|
|
28
|
minBrandListTop;
|
22
|
minBrandListTop;
|
29
|
|
23
|
|
30
|
var brandsData,
|
24
|
var brandsData,
|
|
@@ -118,21 +112,6 @@ function searchResult() { |
|
@@ -118,21 +112,6 @@ function searchResult() { |
118
|
|
112
|
|
119
|
// 插入 dom,绑定事件
|
113
|
// 插入 dom,绑定事件
|
120
|
$('.search-result').html(html);
|
114
|
$('.search-result').html(html);
|
121
|
- $('.search-result .brand-list p').each(function (index) {
|
|
|
122
|
- searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]);
|
|
|
123
|
- searchList.on('tap', function() {
|
|
|
124
|
- $brandText = $('.search-result .brand-list p').eq(index).find('a').html();
|
|
|
125
|
- $brandHref = $('.search-result .brand-list p').eq(index).find('a').attr('href');
|
|
|
126
|
- if (localStorage.getItem('yohoHistory')) {
|
|
|
127
|
- yohoHistory = localStorage.getItem('yohoHistory');
|
|
|
128
|
- searchArray.push(yohoHistory);
|
|
|
129
|
- }
|
|
|
130
|
- if (searchArray.toString().split($brandText).length < 2) {
|
|
|
131
|
- searchArray.push('{"searchName":"' + $brandText + '","searchHref":"' + $brandText + '"}');
|
|
|
132
|
- }
|
|
|
133
|
- localStorage.setItem('yohoHistory', searchArray);
|
|
|
134
|
- });
|
|
|
135
|
- });
|
|
|
136
|
}
|
115
|
}
|
137
|
|
116
|
|
138
|
if ($('.brand-search-page').length) {
|
117
|
if ($('.brand-search-page').length) {
|
|
@@ -156,7 +135,6 @@ if ($('.brand-search-page').length) { |
|
@@ -156,7 +135,6 @@ if ($('.brand-search-page').length) { |
156
|
clearTextHammer = new Hammer($('.clear-text')[0]);
|
135
|
clearTextHammer = new Hammer($('.clear-text')[0]);
|
157
|
clearTextHammer.on('tap', function(e) {
|
136
|
clearTextHammer.on('tap', function(e) {
|
158
|
e.preventDefault();
|
137
|
e.preventDefault();
|
159
|
- $('.search-result').html('');
|
|
|
160
|
$('#keyword').val('').trigger('input');
|
138
|
$('#keyword').val('').trigger('input');
|
161
|
e.srcEvent.stopPropagation();
|
139
|
e.srcEvent.stopPropagation();
|
162
|
});
|
140
|
});
|
|
@@ -164,20 +142,4 @@ if ($('.brand-search-page').length) { |
|
@@ -164,20 +142,4 @@ if ($('.brand-search-page').length) { |
164
|
$('form.search-box').on('submit', function() {
|
142
|
$('form.search-box').on('submit', function() {
|
165
|
return false;
|
143
|
return false;
|
166
|
});
|
144
|
});
|
167
|
- if (localStorage && localStorage.getItem('yohoHistory')) {
|
|
|
168
|
- yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
|
|
|
169
|
- if (yohoHistory) {
|
|
|
170
|
- $.each(yohoHistory, function(index, content) {
|
|
|
171
|
- $('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList');
|
|
|
172
|
- });
|
|
|
173
|
- }
|
|
|
174
|
- } else {
|
|
|
175
|
- $('.history').css('display', 'none');
|
|
|
176
|
- }
|
|
|
177
|
-
|
|
|
178
|
- removeHistory = new Hammer($('.removeHistory')[0]);
|
|
|
179
|
- removeHistory.on('tap', function(e) {
|
|
|
180
|
- $('.historyList').html(' ');
|
|
|
181
|
- localStorage.clear();
|
|
|
182
|
- });
|
|
|
183
|
} |
145
|
} |