Showing
2 changed files
with
23 additions
and
35 deletions
framework @ 75bbc3b0
@@ -14,7 +14,8 @@ var swiper, | @@ -14,7 +14,8 @@ var swiper, | ||
14 | 14 | ||
15 | var searchH = $('.newbrand-search').outerHeight(), | 15 | var searchH = $('.newbrand-search').outerHeight(), |
16 | headerH = $('.yoho-header').outerHeight(), | 16 | headerH = $('.yoho-header').outerHeight(), |
17 | - brandSwipe = parseInt(searchH) + parseInt(headerH) - 1; | 17 | + brandSwipe = parseInt(searchH) + parseInt(headerH) - 1, |
18 | + searchArray = []; | ||
18 | 19 | ||
19 | var brandsData, | 20 | var brandsData, |
20 | $keyword, | 21 | $keyword, |
@@ -100,15 +101,16 @@ function searchResult() { | @@ -100,15 +101,16 @@ function searchResult() { | ||
100 | brandHtml.push('</h2></div>'); | 101 | brandHtml.push('</h2></div>'); |
101 | $.each(v, function(i, brand) { | 102 | $.each(v, function(i, brand) { |
102 | 103 | ||
103 | - // brandHtml.push('<p><a href="' + brand.url + '">' + brand.name); | ||
104 | - brandHtml.push('<p><span>' + brand.name); | 104 | + brandHtml.push('<p><a href="' + brand.url + '">' + brand.name); |
105 | + | ||
106 | + // brandHtml.push('<p><span>' + brand.name); | ||
105 | if (brand.isNew) { | 107 | if (brand.isNew) { |
106 | brandHtml.push('<i class="icon-hot">Hot</i>'); | 108 | brandHtml.push('<i class="icon-hot">Hot</i>'); |
107 | } | 109 | } |
108 | if (brand.isHot) { | 110 | if (brand.isHot) { |
109 | brandHtml.push('<i class="icon-new">New</i>'); | 111 | brandHtml.push('<i class="icon-new">New</i>'); |
110 | } | 112 | } |
111 | - brandHtml.push('</span></p>'); | 113 | + brandHtml.push('</a></p>'); |
112 | }); | 114 | }); |
113 | brandHtml.push('</div>'); | 115 | brandHtml.push('</div>'); |
114 | html += brandHtml.join(''); | 116 | html += brandHtml.join(''); |
@@ -132,19 +134,18 @@ function searchResult() { | @@ -132,19 +134,18 @@ function searchResult() { | ||
132 | if (Object.keys(result).length > 0) { | 134 | if (Object.keys(result).length > 0) { |
133 | rightBarBindClick(); | 135 | rightBarBindClick(); |
134 | } | 136 | } |
135 | - console.log($('.search-result .brand-list p').length); | ||
136 | $('.search-result .brand-list p').each(function (index) { | 137 | $('.search-result .brand-list p').each(function (index) { |
137 | - | ||
138 | - // $('.search-result .brand-list').eq(index).find('p span').click(function () { | ||
139 | - // console.log(index); | ||
140 | - // }) | ||
141 | - | ||
142 | searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]); | 138 | searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]); |
143 | searchList.on('tap', function() { | 139 | searchList.on('tap', function() { |
144 | - | ||
145 | - // var $el = $(e.target); | ||
146 | - // console.log($el.closest('sapn')).html(); | ||
147 | - console.log($('.search-result .brand-list p').eq(index).find('span').html()); | 140 | + if (localStorage.getItem('yohoHistory')) { |
141 | + yohoHistory = localStorage.getItem('yohoHistory'); | ||
142 | + searchArray.push(yohoHistory) | ||
143 | + } | ||
144 | + searchArray.push('{"searchName":"' + | ||
145 | + $('.search-result .brand-list p').eq(index).find('a').html() + | ||
146 | + '","searchHref":"' + $('.search-result .brand-list p') | ||
147 | + .eq(index).find('a').attr('href') + '"}'); | ||
148 | + localStorage.setItem('yohoHistory', searchArray); | ||
148 | }); | 149 | }); |
149 | }); | 150 | }); |
150 | } | 151 | } |
@@ -182,13 +183,14 @@ if ($('.brand-search-page').length) { | @@ -182,13 +183,14 @@ if ($('.brand-search-page').length) { | ||
182 | return false; | 183 | return false; |
183 | }); | 184 | }); |
184 | if (localStorage) { | 185 | if (localStorage) { |
185 | - yohoHistory = localStorage.getItem('yohoHistory'); | ||
186 | 186 | ||
187 | - // if (yohoHistory) { | ||
188 | - // for (var i = 1; i < yohoHistory.split(" ").length - 1; i++) { | ||
189 | - // $("<a href='#'>" + yohoHistory.split(" ")[i] + "</a>").appendTo(".historyList"); | ||
190 | - // } | ||
191 | - // } | 187 | + yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']'); |
188 | + console.log(yohoHistory); | ||
189 | + if (yohoHistory) { | ||
190 | + $.each(yohoHistory, function(index, content) { | ||
191 | + $('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList'); | ||
192 | + }) | ||
193 | + } | ||
192 | } | 194 | } |
193 | 195 | ||
194 | removeHistory = new Hammer($('.removeHistory')[0]); | 196 | removeHistory = new Hammer($('.removeHistory')[0]); |
@@ -196,18 +198,4 @@ if ($('.brand-search-page').length) { | @@ -196,18 +198,4 @@ if ($('.brand-search-page').length) { | ||
196 | $('.historyList').html(' '); | 198 | $('.historyList').html(' '); |
197 | localStorage.clear(); | 199 | localStorage.clear(); |
198 | }); | 200 | }); |
199 | - | ||
200 | - | ||
201 | - // clearHistoryHammer = new Hammer($('#clear-text')[0]); | ||
202 | - // clearHistoryHammer.on('tap', function() { | ||
203 | - | ||
204 | - // // setcookie('h_brands', '', { | ||
205 | - // // expire: -1, | ||
206 | - // // path: '/', | ||
207 | - // // domain: '.m.yohobuy.com' | ||
208 | - // // }); | ||
209 | - // $('#history-keyword').remove(); | ||
210 | - // $(this).hide(); | ||
211 | - // }); | ||
212 | - | ||
213 | } | 201 | } |
-
Please register or login to post a comment