Authored by 梁志锋

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

@@ -14,12 +14,16 @@ var swiper, @@ -14,12 +14,16 @@ 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,
21 searchBtnHammer, 22 searchBtnHammer,
22 - clearTextHammer; 23 + clearTextHammer,
  24 + removeHistory,
  25 + searchList,
  26 + yohoHistory;
23 27
24 swiper = new Swiper('.swiper-container', { 28 swiper = new Swiper('.swiper-container', {
25 lazyLoading: true, 29 lazyLoading: true,
@@ -31,7 +35,8 @@ swiper = new Swiper('.swiper-container', { @@ -31,7 +35,8 @@ swiper = new Swiper('.swiper-container', {
31 lazyLoad($('img.lazy')); 35 lazyLoad($('img.lazy'));
32 $('.yoho-header').css({ 36 $('.yoho-header').css({
33 'z-index': 2, 37 'z-index': 2,
34 - position: 'fixed' 38 + position: 'fixed',
  39 + top: 0
35 }); 40 });
36 41
37 $(window).scroll(function() { 42 $(window).scroll(function() {
@@ -96,12 +101,15 @@ function searchResult() { @@ -96,12 +101,15 @@ function searchResult() {
96 brandHtml.push(k); 101 brandHtml.push(k);
97 brandHtml.push('</h2></div>'); 102 brandHtml.push('</h2></div>');
98 $.each(v, function(i, brand) { 103 $.each(v, function(i, brand) {
  104 +
99 brandHtml.push('<p><a href="' + brand.url + '">' + brand.name); 105 brandHtml.push('<p><a href="' + brand.url + '">' + brand.name);
  106 +
  107 + // brandHtml.push('<p><span>' + brand.name);
100 if (brand.isNew) { 108 if (brand.isNew) {
101 - brandHtml.push('<i class="icon-hot">Hot</i>'); 109 + brandHtml.push('<i class="icon-hot">HOT</i>');
102 } 110 }
103 if (brand.isHot) { 111 if (brand.isHot) {
104 - brandHtml.push('<i class="icon-new">New</i>'); 112 + brandHtml.push('<i class="icon-new">NEW</i>');
105 } 113 }
106 brandHtml.push('</a></p>'); 114 brandHtml.push('</a></p>');
107 }); 115 });
@@ -127,6 +135,20 @@ function searchResult() { @@ -127,6 +135,20 @@ function searchResult() {
127 if (Object.keys(result).length > 0) { 135 if (Object.keys(result).length > 0) {
128 rightBarBindClick(); 136 rightBarBindClick();
129 } 137 }
  138 + $('.search-result .brand-list p').each(function (index) {
  139 + searchList = new Hammer($('.search-result .brand-list p').eq(index)[0]);
  140 + searchList.on('tap', function() {
  141 + if (localStorage.getItem('yohoHistory')) {
  142 + yohoHistory = localStorage.getItem('yohoHistory');
  143 + searchArray.push(yohoHistory);
  144 + }
  145 + searchArray.push('{"searchName":"' +
  146 + $('.search-result .brand-list p').eq(index).find('a').html() +
  147 + '","searchHref":"' + $('.search-result .brand-list p')
  148 + .eq(index).find('a').attr('href') + '"}');
  149 + localStorage.setItem('yohoHistory', searchArray);
  150 + });
  151 + });
130 } 152 }
131 153
132 if ($('.brand-search-page').length) { 154 if ($('.brand-search-page').length) {
@@ -134,6 +156,7 @@ if ($('.brand-search-page').length) { @@ -134,6 +156,7 @@ if ($('.brand-search-page').length) {
134 $keyword = $('#keyword'); 156 $keyword = $('#keyword');
135 157
136 $keyword.on('input', function() { 158 $keyword.on('input', function() {
  159 + $('.history').css('display', 'none');
137 if ($keyword.val().length) { 160 if ($keyword.val().length) {
138 searchResult(); 161 searchResult();
139 $(this).closest('.search-box').css('width', '11.25rem'); 162 $(this).closest('.search-box').css('width', '11.25rem');
@@ -142,7 +165,7 @@ if ($('.brand-search-page').length) { @@ -142,7 +165,7 @@ if ($('.brand-search-page').length) {
142 $(this).closest('.search-box').css('width', '12.5rem'); 165 $(this).closest('.search-box').css('width', '12.5rem');
143 $('.search-action').hide(); 166 $('.search-action').hide();
144 } 167 }
145 - }); 168 + }).focus();
146 169
147 170
148 searchBtnHammer = new Hammer($('.search-btn')[0]); 171 searchBtnHammer = new Hammer($('.search-btn')[0]);
@@ -162,16 +185,20 @@ if ($('.brand-search-page').length) { @@ -162,16 +185,20 @@ if ($('.brand-search-page').length) {
162 $('form.search-box').on('submit', function() { 185 $('form.search-box').on('submit', function() {
163 return false; 186 return false;
164 }); 187 });
  188 + if (localStorage) {
165 189
166 - // clearHistoryHammer = new Hammer($('#clear-text')[0]);  
167 - // clearHistoryHammer.on('tap', function() {  
168 -  
169 - // // setcookie('h_brands', '', {  
170 - // // expire: -1,  
171 - // // path: '/',  
172 - // // domain: '.m.yohobuy.com'  
173 - // // });  
174 - // $('#history-keyword').remove();  
175 - // $(this).hide();  
176 - // }); 190 + yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']');
  191 + console.log(yohoHistory);
  192 + if (yohoHistory) {
  193 + $.each(yohoHistory, function(index, content) {
  194 + $('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList');
  195 + });
  196 + }
  197 + }
  198 +
  199 + removeHistory = new Hammer($('.removeHistory')[0]);
  200 + removeHistory.on('tap', function(e) {
  201 + $('.historyList').html(' ');
  202 + localStorage.clear();
  203 + });
177 } 204 }
1 .brand-page { 1 .brand-page {
2 -  
3 - .newbrand-search { 2 +
  3 + .newbrand-search {
4 width: 93.75%; 4 width: 93.75%;
5 height: 60rem / $pxConvertRem; 5 height: 60rem / $pxConvertRem;
6 padding: 14rem / $pxConvertRem 3.125%; 6 padding: 14rem / $pxConvertRem 3.125%;
@@ -9,27 +9,28 @@ @@ -9,27 +9,28 @@
9 top: 88rem / $pxConvertRem; 9 top: 88rem / $pxConvertRem;
10 position: fixed; 10 position: fixed;
11 z-index: 2; 11 z-index: 2;
  12 +
12 .search-box { 13 .search-box {
13 position: relative; 14 position: relative;
14 - width: 500rem / $pxConvertRem;//450 15 + width: 500rem / $pxConvertRem; //450
15 height: 60rem / $pxConvertRem; 16 height: 60rem / $pxConvertRem;
16 background-color: #FFF; 17 background-color: #FFF;
17 border-radius: 30rem / $pxConvertRem; 18 border-radius: 30rem / $pxConvertRem;
18 padding: 0 32rem / $pxConvertRem 0 52rem / $pxConvertRem; 19 padding: 0 32rem / $pxConvertRem 0 52rem / $pxConvertRem;
19 -  
20 - a {  
21 - width: 100%;  
22 - height: 60rem / $pxConvertRem;  
23 - border: 0;  
24 - display: block;  
25 - span{ 20 +
  21 + a {
  22 + width: 100%;
  23 + height: 60rem / $pxConvertRem;
  24 + border: 0;
  25 + display: block;
  26 + span {
26 line-height: 60rem / $pxConvertRem; 27 line-height: 60rem / $pxConvertRem;
27 color: #bdbdbd; 28 color: #bdbdbd;
28 font-size: 1.2em; 29 font-size: 1.2em;
29 padding-left: 18rem / $pxConvertRem; 30 padding-left: 18rem / $pxConvertRem;
30 - }  
31 - }  
32 - 31 + }
  32 + }
  33 +
33 .search-icon { 34 .search-icon {
34 position: absolute; 35 position: absolute;
35 font-size: 24rem / $pxConvertRem; 36 font-size: 24rem / $pxConvertRem;
@@ -38,6 +39,7 @@ @@ -38,6 +39,7 @@
38 line-height: 60rem / $pxConvertRem; 39 line-height: 60rem / $pxConvertRem;
39 color: #bdbdbd; 40 color: #bdbdbd;
40 } 41 }
  42 +
41 .search-input { 43 .search-input {
42 border: none; 44 border: none;
43 width: 95%; 45 width: 95%;
@@ -45,6 +47,7 @@ @@ -45,6 +47,7 @@
45 line-height: 1; 47 line-height: 1;
46 padding: 0 10rem / $pxConvertRem; 48 padding: 0 10rem / $pxConvertRem;
47 } 49 }
  50 +
48 .search-action { 51 .search-action {
49 display: none; 52 display: none;
50 position: absolute; 53 position: absolute;
@@ -54,11 +57,11 @@ @@ -54,11 +57,11 @@
54 line-height: 60rem / $pxConvertRem; 57 line-height: 60rem / $pxConvertRem;
55 color: #666; 58 color: #666;
56 } 59 }
  60 +
57 .clear-text { 61 .clear-text {
58 margin-right: 20rem / $pxConvertRem; 62 margin-right: 20rem / $pxConvertRem;
59 } 63 }
60 } 64 }
61 -  
62 } 65 }
63 66
64 .banner-top { 67 .banner-top {
@@ -67,14 +70,15 @@ @@ -67,14 +70,15 @@
67 70
68 .hot-brand { 71 .hot-brand {
69 margin: (30rem / $pxConvertRem) 0 0; 72 margin: (30rem / $pxConvertRem) 0 0;
70 - 73 +
71 .hot-brand-list { 74 .hot-brand-list {
72 - background: #fff; 75 + background: #fff;
  76 +
73 li { 77 li {
74 float: left; 78 float: left;
75 width: 158rem / $pxConvertRem; 79 width: 158rem / $pxConvertRem;
76 height: 158rem / $pxConvertRem; 80 height: 158rem / $pxConvertRem;
77 - 81 +
78 .img-box { 82 .img-box {
79 display: table-cell; 83 display: table-cell;
80 vertical-align: middle; 84 vertical-align: middle;
@@ -91,11 +95,11 @@ @@ -91,11 +95,11 @@
91 .title-bar { 95 .title-bar {
92 width: 100%; 96 width: 100%;
93 background: #eeeeee; 97 background: #eeeeee;
94 -  
95 color: #999999; 98 color: #999999;
96 // font-weight: bold; 99 // font-weight: bold;
97 position: relative; 100 position: relative;
98 - h2 { 101 +
  102 + h2 {
99 // width: 100%; 103 // width: 100%;
100 padding: 0 20rem / $pxConvertRem; 104 padding: 0 20rem / $pxConvertRem;
101 height: 50rem / $pxConvertRem; 105 height: 50rem / $pxConvertRem;
@@ -105,11 +109,12 @@ @@ -105,11 +109,12 @@
105 background-color: #f4f4f4; 109 background-color: #f4f4f4;
106 } 110 }
107 } 111 }
108 - 112 +
109 p { 113 p {
110 cursor: pointer; 114 cursor: pointer;
111 // height: 50rem / $pxConvertRem; 115 // height: 50rem / $pxConvertRem;
112 padding: 0 20rem / $pxConvertRem; 116 padding: 0 20rem / $pxConvertRem;
  117 +
113 a { 118 a {
114 display: block; 119 display: block;
115 // padding-top: 10rem / $pxConvertRem; 120 // padding-top: 10rem / $pxConvertRem;
@@ -117,7 +122,8 @@ @@ -117,7 +122,8 @@
117 line-height: 76rem / $pxConvertRem; 122 line-height: 76rem / $pxConvertRem;
118 font-size: 28rem / $pxConvertRem; 123 font-size: 28rem / $pxConvertRem;
119 border-bottom: 1px solid #f3f3f3; 124 border-bottom: 1px solid #f3f3f3;
120 - border-top: 1px solid #f9f9f9; 125 + border-top: 1px solid #f9f9f9;
  126 +
121 i { 127 i {
122 display: inline-block; 128 display: inline-block;
123 margin-top: -4rem / $pxConvertRem; 129 margin-top: -4rem / $pxConvertRem;
@@ -129,11 +135,14 @@ @@ -129,11 +135,14 @@
129 font-size: 18rem / $pxConvertRem; 135 font-size: 18rem / $pxConvertRem;
130 line-height: 38rem / $pxConvertRem; 136 line-height: 38rem / $pxConvertRem;
131 color: #fff; 137 color: #fff;
132 - border-radius: 50rem / $pxConvertRem;; 138 + border-radius: 50rem / $pxConvertRem;
  139 + ;
133 } 140 }
  141 +
134 .icon-hot { 142 .icon-hot {
135 background: #ff0000; 143 background: #ff0000;
136 } 144 }
  145 +
137 .icon-new { 146 .icon-new {
138 background: #86c048; 147 background: #86c048;
139 } 148 }
@@ -141,32 +150,82 @@ @@ -141,32 +150,82 @@
141 } 150 }
142 } 151 }
143 152
144 - .right-bar {  
145 -  
146 - width: 60rem / $pxConvertRem;  
147 - height: 75%;  
148 - top: 20%;  
149 - overflow: auto;  
150 - position: fixed;  
151 - right: 2rem / $pxConvertRem;  
152 - border-radius: 12rem / $pxConvertRem;  
153 - background: rgba(0,0,0,.8);  
154 - z-index: 2;  
155 - b {  
156 - height: 36rem / $pxConvertRem;  
157 -  
158 - line-height: 36rem / $pxConvertRem;  
159 - text-align: center;  
160 - display: block;  
161 - color: #999999;  
162 - font-weight: bold;  
163 - }  
164 - }  
165 -  
166 - .con {  
167 - padding-top: 10rem / $pxConvertRem; 153 + .right-bar {
  154 + width: 60rem / $pxConvertRem;
  155 + height: 75%;
  156 + top: 20%;
  157 + overflow: auto;
  158 + position: fixed;
  159 + right: 2rem / $pxConvertRem;
  160 + border-radius: 12rem / $pxConvertRem;
  161 + background: rgba(0, 0, 0, .8);
  162 + z-index: 2;
  163 +
  164 + b {
  165 + height: 36rem / $pxConvertRem;
  166 + line-height: 36rem / $pxConvertRem;
  167 + text-align: center;
  168 + display: block;
  169 + color: #999999;
  170 + font-weight: bold;
168 } 171 }
  172 + }
  173 + .right-bar::-webkit-scrollbar {
  174 + display: none;
  175 + }
  176 +
  177 + .con {
  178 + padding-top: 10rem / $pxConvertRem;
  179 + }
  180 +
169 .search-result { 181 .search-result {
170 padding-top: 176rem / $pxConvertRem; 182 padding-top: 176rem / $pxConvertRem;
171 } 183 }
172 -}  
  184 +}
  185 +
  186 +.history{
  187 + width: 100%;
  188 + height: auto;
  189 + overflow: hidden;
  190 + position: absolute;
  191 + left: 0;
  192 + top: 176rem / $pxConvertRem;
  193 + > h6{
  194 + width: 100%;
  195 + height: 88rem / $pxConvertRem;
  196 + line-height: 88rem / $pxConvertRem;
  197 + color: #999;
  198 + text-indent: .6rem;
  199 + font-size: 36em / $pxConvertRem;
  200 + }
  201 + .historyList{
  202 + width: 100%;
  203 + height: auto;
  204 + overflow: hidden;
  205 + display: block;
  206 + > a{
  207 + width: auto;
  208 + height: 58rem / $pxConvertRem;
  209 + overflow: hidden;
  210 + line-height: 58rem / $pxConvertRem;
  211 + margin: 0 0 20rem / $pxConvertRem .6rem;
  212 + padding: 0 20rem / $pxConvertRem;
  213 + float: left;
  214 + background-color:#f8f8f8;
  215 + color: #444;
  216 + }
  217 + }
  218 + > span{
  219 + width: auto;
  220 + height: 68rem / $pxConvertRem;
  221 + overflow: hidden;
  222 + display: inline-block;
  223 + line-height: 68rem / $pxConvertRem;
  224 + border:1px solid #e6e6e6;
  225 + padding: 0 28rem / $pxConvertRem;
  226 + font-size: 48em / $pxConvertRem;
  227 + margin-left: .6rem;
  228 + color: #000;
  229 + }
  230 +}
  231 +
@@ -39,10 +39,10 @@ @@ -39,10 +39,10 @@
39 <p> 39 <p>
40 <a href="{{url}}">{{name}} 40 <a href="{{url}}">{{name}}
41 {{# isHot}} 41 {{# isHot}}
42 - <i class="icon-hot">Hot</i> 42 + <i class="icon-hot">HOT</i>
43 {{/ isHot}} 43 {{/ isHot}}
44 {{# isNew}} 44 {{# isNew}}
45 - <i class="icon-new">New</i> 45 + <i class="icon-new">NEW</i>
46 {{/ isNew}} 46 {{/ isNew}}
47 </a> 47 </a>
48 </p> 48 </p>
@@ -10,10 +10,16 @@ @@ -10,10 +10,16 @@
10 </div> 10 </div>
11 </form> 11 </form>
12 </div> 12 </div>
13 - 13 + <div class="history">
  14 + <h6>历史纪录</h6>
  15 + <div class="historyList">
  16 + </div>
  17 + <span class='removeHistory'>清空搜索历史</span>
  18 + </div>
14 <div class="search-result"> 19 <div class="search-result">
15 </div> 20 </div>
16 </div> 21 </div>
  22 +
17 <script id="brands-data" type="text/tmpl"> 23 <script id="brands-data" type="text/tmpl">
18 {{{brandList}}} 24 {{{brandList}}}
19 </script> 25 </script>