Authored by ccbikai

删除品牌搜索记录

@@ -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 }
@@ -195,49 +195,4 @@ @@ -195,49 +195,4 @@
195 padding-top: 176rem / $pxConvertRem; 195 padding-top: 176rem / $pxConvertRem;
196 } 196 }
197 197
198 - .history{  
199 - width: 100%;  
200 - height: auto;  
201 - overflow: hidden;  
202 - position: absolute;  
203 - left: 0;  
204 - top: 176rem / $pxConvertRem;  
205 - > h6{  
206 - width: 100%;  
207 - height: 88rem / $pxConvertRem;  
208 - line-height: 88rem / $pxConvertRem;  
209 - color: #999;  
210 - text-indent: .6rem;  
211 - font-size: 36em / $pxConvertRem;  
212 - }  
213 - .historyList{  
214 - width: 100%;  
215 - height: auto;  
216 - overflow: hidden;  
217 - display: block;  
218 - > a{  
219 - width: auto;  
220 - height: 58rem / $pxConvertRem;  
221 - overflow: hidden;  
222 - line-height: 58rem / $pxConvertRem;  
223 - margin: 0 0 20rem / $pxConvertRem .6rem;  
224 - padding: 0 20rem / $pxConvertRem;  
225 - float: left;  
226 - background-color:#f8f8f8;  
227 - color: #444;  
228 - }  
229 - }  
230 - > span{  
231 - width: auto;  
232 - height: 68rem / $pxConvertRem;  
233 - overflow: hidden;  
234 - display: inline-block;  
235 - line-height: 68rem / $pxConvertRem;  
236 - border:1px solid #e6e6e6;  
237 - padding: 0 28rem / $pxConvertRem;  
238 - font-size: 48em / $pxConvertRem;  
239 - margin-left: .6rem;  
240 - color: #000;  
241 - }  
242 - }  
243 } 198 }
@@ -10,12 +10,6 @@ @@ -10,12 +10,6 @@
10 </div> 10 </div>
11 </form> 11 </form>
12 </div> 12 </div>
13 - <div class="history">  
14 - <h6>历史纪录</h6>  
15 - <div class="historyList">  
16 - </div>  
17 - <span class='removeHistory'>清空搜索历史</span>  
18 - </div>  
19 <div class="search-result"> 13 <div class="search-result">
20 </div> 14 </div>
21 </div> 15 </div>