Showing
9 changed files
with
118 additions
and
73 deletions
@@ -59,12 +59,9 @@ class FloorProcess | @@ -59,12 +59,9 @@ class FloorProcess | ||
59 | { | 59 | { |
60 | $result = array(); | 60 | $result = array(); |
61 | 61 | ||
62 | - foreach ($data as &$one) { | ||
63 | - $one['url'] = Helpers::getFilterUrl($one['url']); | ||
64 | - $one['img'] = Helpers::getImageUrl($one['src'], 640, 310); | ||
65 | - unset($one['src']); | 62 | + foreach ($data as $one) { |
63 | + $result['bannerTop']['list'][] = Helpers::formatBanner($one, 640, 240); | ||
66 | } | 64 | } |
67 | - $result['bannerTop']['list'] = $data; | ||
68 | 65 | ||
69 | return $result; | 66 | return $result; |
70 | } | 67 | } |
@@ -197,6 +197,8 @@ class ListProcess | @@ -197,6 +197,8 @@ class ListProcess | ||
197 | foreach ($result['subs'] as &$val) { | 197 | foreach ($result['subs'] as &$val) { |
198 | if ($val['dataId'] === $gender) { | 198 | if ($val['dataId'] === $gender) { |
199 | $val['chosed'] = true; | 199 | $val['chosed'] = true; |
200 | + | ||
201 | + $result['name'] = $val['name']; | ||
200 | } | 202 | } |
201 | } | 203 | } |
202 | 204 |
@@ -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, |
@@ -97,7 +101,10 @@ function searchResult() { | @@ -97,7 +101,10 @@ function searchResult() { | ||
97 | brandHtml.push(k); | 101 | brandHtml.push(k); |
98 | brandHtml.push('</h2></div>'); | 102 | brandHtml.push('</h2></div>'); |
99 | $.each(v, function(i, brand) { | 103 | $.each(v, function(i, brand) { |
104 | + | ||
100 | 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); | ||
101 | if (brand.isNew) { | 108 | if (brand.isNew) { |
102 | brandHtml.push('<i class="icon-hot">HOT</i>'); | 109 | brandHtml.push('<i class="icon-hot">HOT</i>'); |
103 | } | 110 | } |
@@ -128,6 +135,20 @@ function searchResult() { | @@ -128,6 +135,20 @@ function searchResult() { | ||
128 | if (Object.keys(result).length > 0) { | 135 | if (Object.keys(result).length > 0) { |
129 | rightBarBindClick(); | 136 | rightBarBindClick(); |
130 | } | 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 | + }); | ||
131 | } | 152 | } |
132 | 153 | ||
133 | if ($('.brand-search-page').length) { | 154 | if ($('.brand-search-page').length) { |
@@ -135,6 +156,7 @@ if ($('.brand-search-page').length) { | @@ -135,6 +156,7 @@ if ($('.brand-search-page').length) { | ||
135 | $keyword = $('#keyword'); | 156 | $keyword = $('#keyword'); |
136 | 157 | ||
137 | $keyword.on('input', function() { | 158 | $keyword.on('input', function() { |
159 | + $('.history').css('display', 'none'); | ||
138 | if ($keyword.val().length) { | 160 | if ($keyword.val().length) { |
139 | searchResult(); | 161 | searchResult(); |
140 | $(this).closest('.search-box').css('width', '11.25rem'); | 162 | $(this).closest('.search-box').css('width', '11.25rem'); |
@@ -161,16 +183,20 @@ if ($('.brand-search-page').length) { | @@ -161,16 +183,20 @@ if ($('.brand-search-page').length) { | ||
161 | $('form.search-box').on('submit', function() { | 183 | $('form.search-box').on('submit', function() { |
162 | return false; | 184 | return false; |
163 | }); | 185 | }); |
186 | + if (localStorage) { | ||
164 | 187 | ||
165 | - // clearHistoryHammer = new Hammer($('#clear-text')[0]); | ||
166 | - // clearHistoryHammer.on('tap', function() { | ||
167 | - | ||
168 | - // // setcookie('h_brands', '', { | ||
169 | - // // expire: -1, | ||
170 | - // // path: '/', | ||
171 | - // // domain: '.m.yohobuy.com' | ||
172 | - // // }); | ||
173 | - // $('#history-keyword').remove(); | ||
174 | - // $(this).hide(); | ||
175 | - // }); | 188 | + yohoHistory = $.parseJSON('[' + localStorage.getItem('yohoHistory') + ']'); |
189 | + console.log(yohoHistory); | ||
190 | + if (yohoHistory) { | ||
191 | + $.each(yohoHistory, function(index, content) { | ||
192 | + $('<a href="' + content.searchHref + '">' + content.searchName + '</a>').appendTo('.historyList'); | ||
193 | + }); | ||
194 | + } | ||
195 | + } | ||
196 | + | ||
197 | + removeHistory = new Hammer($('.removeHistory')[0]); | ||
198 | + removeHistory.on('tap', function(e) { | ||
199 | + $('.historyList').html(' '); | ||
200 | + localStorage.clear(); | ||
201 | + }); | ||
176 | } | 202 | } |
@@ -180,6 +180,52 @@ | @@ -180,6 +180,52 @@ | ||
180 | 180 | ||
181 | .search-result { | 181 | .search-result { |
182 | padding-top: 176rem / $pxConvertRem; | 182 | padding-top: 176rem / $pxConvertRem; |
183 | + } | ||
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 | + } | ||
183 | } | 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 | + } | ||
184 | } | 230 | } |
185 | 231 |
@@ -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> |
@@ -60,8 +60,18 @@ class BrandModel | @@ -60,8 +60,18 @@ class BrandModel | ||
60 | // 搜索链接地址 | 60 | // 搜索链接地址 |
61 | $result['searchUrl'] = Helpers::url('/brands/search', null); | 61 | $result['searchUrl'] = Helpers::url('/brands/search', null); |
62 | 62 | ||
63 | - /* 顶部的轮翻广告列表 */ | ||
64 | - if (!empty($brand['brandTop'][0]['data'])) { | 63 | + /* 顶部的轮翻广告或热门品牌列表(当没有轮翻广告的情况下会是这个样子的! 此处是根据接口改造成的逻辑) */ |
64 | + if (!empty($brand['brandTop'][0]['data']['list'])) { | ||
65 | + $build = array(); | ||
66 | + foreach ($brand['brandTop'][0]['data']['list'] as $value) { | ||
67 | + $build['url'] = Helpers::getFilterUrl($value['url']); | ||
68 | + $build['img'] = Helpers::getImageUrl($value['src'], 144, 144); | ||
69 | + $build['name'] = $value['name']; | ||
70 | + $result['hotBrand']['list'][] = $build; | ||
71 | + } | ||
72 | + } | ||
73 | + // 顶部的轮翻广告列表 | ||
74 | + elseif (!empty($brand['brandTop'][0]['data'])) { | ||
65 | $build = array(); | 75 | $build = array(); |
66 | foreach ($brand['brandTop'][0]['data'] as $value) { | 76 | foreach ($brand['brandTop'][0]['data'] as $value) { |
67 | $build['url'] = Helpers::getFilterUrl($value['url']); | 77 | $build['url'] = Helpers::getFilterUrl($value['url']); |
@@ -71,7 +81,7 @@ class BrandModel | @@ -71,7 +81,7 @@ class BrandModel | ||
71 | } | 81 | } |
72 | } | 82 | } |
73 | 83 | ||
74 | - /* 顶部的热门品牌列表 */ | 84 | + /* 顶部的热门品牌列表 (备注: 当没有轮翻广告的时候,此处内部的foreach不会被执行) */ |
75 | if (!empty($brand['brandTop'][1]['data']['list'])) { | 85 | if (!empty($brand['brandTop'][1]['data']['list'])) { |
76 | $build = array(); | 86 | $build = array(); |
77 | foreach ($brand['brandTop'][1]['data']['list'] as $value) { | 87 | foreach ($brand['brandTop'][1]['data']['list'] as $value) { |
@@ -99,7 +99,7 @@ class HomeModel | @@ -99,7 +99,7 @@ class HomeModel | ||
99 | // 调用接口获取数据 | 99 | // 调用接口获取数据 |
100 | $banner = IndexData::getBannerStart(self::CODE_BG); | 100 | $banner = IndexData::getBannerStart(self::CODE_BG); |
101 | if (isset($banner['data'][0]['data']['list'][0]['src'])) { | 101 | if (isset($banner['data'][0]['data']['list'][0]['src'])) { |
102 | - $result = Helpers::getImageUrl($banner['data'][0]['data']['list'][0]['src'], 640, 800, 2); | 102 | + $result = Helpers::getImageUrl($banner['data'][0]['data']['list'][0]['src'], 640, 800, 1); |
103 | } | 103 | } |
104 | 104 | ||
105 | if (USE_CACHE) { | 105 | if (USE_CACHE) { |
1 | -<?php | ||
2 | - | ||
3 | -namespace Product; | ||
4 | - | ||
5 | -use Configs\CacheConfig; | ||
6 | -use LibModels\Wap\Product\SearchData; | ||
7 | -use LibModels\Wap\Category\BrandData; | ||
8 | -use LibModels\Wap\Category\ClassData; | ||
9 | -use Plugin\DataProcess\ListProcess; | ||
10 | - | ||
11 | -/** | ||
12 | - * 搜索相关的模板数据模型 | ||
13 | - * | ||
14 | - * @name Filter | ||
15 | - * @package Product | ||
16 | - * @copyright yoho.inc | ||
17 | - * @version 1.0 (2015-11-1 17:35:52) | ||
18 | - */ | ||
19 | -class FilterModel | ||
20 | -{ | ||
21 | - | ||
22 | - /** | ||
23 | - * 获取筛选的数据 | ||
24 | - * | ||
25 | - * @param array $condition 查询条件 | ||
26 | - * @return array | ||
27 | - */ | ||
28 | - public static function getFilterData($condition) | ||
29 | - { | ||
30 | - $result = array(); | ||
31 | - | ||
32 | - // 区别各种列表页面的筛选数据 | ||
33 | - if (isset($condition['brand'])) { | ||
34 | - $listData = BrandData::filterBrandData($condition); | ||
35 | - } else if(isset($condition['sort'])) { | ||
36 | - $listData = ClassData::filterClassData($condition); | ||
37 | - } else { | ||
38 | - $listData = SearchData::searchByCondition($condition); | ||
39 | - } | ||
40 | - | ||
41 | - if (isset($listData['data']) && isset($listData['data']['filter'])) { | ||
42 | - $result['filter'] = ListProcess::getFilterData($listData['data']['filter']); | ||
43 | - } | ||
44 | - | ||
45 | - return $result; | ||
46 | - } | ||
47 | - | ||
48 | -} |
@@ -183,8 +183,14 @@ class NewsaleModel | @@ -183,8 +183,14 @@ class NewsaleModel | ||
183 | $newsale = NewsaleData::getNewsaleFocus($codeKey); | 183 | $newsale = NewsaleData::getNewsaleFocus($codeKey); |
184 | 184 | ||
185 | // 调用接口获取数据并封装 | 185 | // 调用接口获取数据并封装 |
186 | - if (isset($newsale['code']) && isset($newsale['data'][0]['data'][0])) { | ||
187 | - $result = Helpers::formatBanner($newsale['data'][0]['data'][0], 640, 240); | 186 | + if (isset($newsale['code']) && isset($newsale['data'][0]['data'])) { |
187 | + if(count($newsale['data'][0]['data']) === 1) { | ||
188 | + $result = Helpers::formatBanner($newsale['data'][0]['data'][0], 640, 240); | ||
189 | + } else { | ||
190 | + foreach ($newsale['data'][0]['data'] as $one) { | ||
191 | + $result['list'][] = Helpers::formatBanner($one, 640, 240); | ||
192 | + } | ||
193 | + } | ||
188 | } | 194 | } |
189 | 195 | ||
190 | if (USE_CACHE) { | 196 | if (USE_CACHE) { |
-
Please register or login to post a comment