|
@@ -11,22 +11,16 @@ var $ = require('jquery'), |
|
@@ -11,22 +11,16 @@ 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
|
|
15
|
|
18
|
var searchH = $('.newbrand-search').outerHeight(),
|
16
|
var searchH = $('.newbrand-search').outerHeight(),
|
19
|
headerH = $('.yoho-header').outerHeight(),
|
17
|
headerH = $('.yoho-header').outerHeight(),
|
20
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
|
18
|
brandSwipe = parseInt(searchH) + parseInt(headerH) - 1,
|
21
|
- minBrandListTop,
|
|
|
22
|
- searchArray = [];
|
19
|
+ minBrandListTop;
|
23
|
|
20
|
|
24
|
var brandsData,
|
21
|
var brandsData,
|
25
|
$keyword,
|
22
|
$keyword,
|
26
|
- clearTextHammer,
|
|
|
27
|
- removeHistory,
|
|
|
28
|
- searchList,
|
|
|
29
|
- yohoHistory;
|
23
|
+ clearTextHammer;
|
30
|
|
24
|
|
31
|
swiper = new Swiper('.swiper-container', {
|
25
|
swiper = new Swiper('.swiper-container', {
|
32
|
lazyLoading: true,
|
26
|
lazyLoading: true,
|
|
@@ -147,21 +141,6 @@ function searchResult() { |
|
@@ -147,21 +141,6 @@ function searchResult() { |
147
|
if (Object.keys(result).length > 0) {
|
141
|
if (Object.keys(result).length > 0) {
|
148
|
rightBarBindClick();
|
142
|
rightBarBindClick();
|
149
|
}
|
143
|
}
|
150
|
- $('.search-result .brand-list p').each(function (index) {
|
|
|
151
|
- searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]);
|
|
|
152
|
- searchList.on('tap', function() {
|
|
|
153
|
- $brandText = $('.search-result .brand-list p').eq(index).find('a').html();
|
|
|
154
|
- $brandHref = $('.search-result .brand-list p').eq(index).find('a').attr('href');
|
|
|
155
|
- if (localStorage.getItem('yohoHistory')) {
|
|
|
156
|
- yohoHistory = localStorage.getItem('yohoHistory');
|
|
|
157
|
- searchArray.push(yohoHistory);
|
|
|
158
|
- }
|
|
|
159
|
- if (searchArray.toString().split($brandText).length < 2) {
|
|
|
160
|
- searchArray.push('{"searchName":"' + $brandText + '","searchHref":"' + $brandText + '"}');
|
|
|
161
|
- }
|
|
|
162
|
- localStorage.setItem('yohoHistory', searchArray);
|
|
|
163
|
- });
|
|
|
164
|
- });
|
|
|
165
|
}
|
144
|
}
|
166
|
|
145
|
|
167
|
if ($('.brand-search-page').length) {
|
146
|
if ($('.brand-search-page').length) {
|
|
@@ -169,7 +148,6 @@ if ($('.brand-search-page').length) { |
|
@@ -169,7 +148,6 @@ if ($('.brand-search-page').length) { |
169
|
$keyword = $('#keyword');
|
148
|
$keyword = $('#keyword');
|
170
|
|
149
|
|
171
|
$keyword.on('input', function() {
|
150
|
$keyword.on('input', function() {
|
172
|
- $('.history').css('display', 'none');
|
|
|
173
|
if ($keyword.val().length) {
|
151
|
if ($keyword.val().length) {
|
174
|
searchResult();
|
152
|
searchResult();
|
175
|
$(this).closest('.search-box').css('width', '11.25rem');
|
153
|
$(this).closest('.search-box').css('width', '11.25rem');
|
|
@@ -183,6 +161,7 @@ if ($('.brand-search-page').length) { |
|
@@ -183,6 +161,7 @@ if ($('.brand-search-page').length) { |
183
|
clearTextHammer = new Hammer($('.clear-text')[0]);
|
161
|
clearTextHammer = new Hammer($('.clear-text')[0]);
|
184
|
clearTextHammer.on('tap', function(e) {
|
162
|
clearTextHammer.on('tap', function(e) {
|
185
|
e.preventDefault();
|
163
|
e.preventDefault();
|
|
|
164
|
+ $('.search-result').html('');
|
186
|
$('#keyword').val('').trigger('input');
|
165
|
$('#keyword').val('').trigger('input');
|
187
|
e.srcEvent.stopPropagation();
|
166
|
e.srcEvent.stopPropagation();
|
188
|
});
|
167
|
});
|
|
@@ -190,20 +169,4 @@ if ($('.brand-search-page').length) { |
|
@@ -190,20 +169,4 @@ if ($('.brand-search-page').length) { |
190
|
$('form.search-box').on('submit', function() {
|
169
|
$('form.search-box').on('submit', function() {
|
191
|
return false;
|
170
|
return false;
|
192
|
});
|
171
|
});
|
193
|
- if (localStorage && localStorage.getItem('yohoHistory')) {
|
|
|
194
|
- yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
|
|
|
195
|
- if (yohoHistory) {
|
|
|
196
|
- $.each(yohoHistory, function(index, content) {
|
|
|
197
|
- $('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList');
|
|
|
198
|
- });
|
|
|
199
|
- }
|
|
|
200
|
- } else {
|
|
|
201
|
- $('.history').css('display', 'none');
|
|
|
202
|
- }
|
|
|
203
|
-
|
|
|
204
|
- removeHistory = new Hammer($('.removeHistory')[0]);
|
|
|
205
|
- removeHistory.on('tap', function(e) {
|
|
|
206
|
- $('.historyList').html(' ');
|
|
|
207
|
- localStorage.clear();
|
|
|
208
|
- });
|
|
|
209
|
} |
172
|
} |