Authored by whb

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

@@ -513,6 +513,11 @@ @@ -513,6 +513,11 @@
513 { 513 {
514 attr: 'style', //查找的键值 514 attr: 'style', //查找的键值
515 name: '风格', 515 name: '风格',
  516 +
  517 + //若无子项,传url
  518 + url: '',
  519 +
  520 + //若有子项,传sub
516 showMulti: true, //是否显示多选按钮 521 showMulti: true, //是否显示多选按钮
517 sub: [ 522 sub: [
518 { 523 {
@@ -196,17 +196,22 @@ @@ -196,17 +196,22 @@
196 <div class="attr-content"> 196 <div class="attr-content">
197 <ul class="clearfix senior-attr-wrap"> 197 <ul class="clearfix senior-attr-wrap">
198 {{#each seniorChose}} 198 {{#each seniorChose}}
199 - <li class="attr"> 199 + <li class="attr{{#unless sub}} no-sub{{/unless}}">
  200 + {{#if sub}}
200 {{name}} 201 {{name}}
201 <span class="iconfont">&#xe600;</span> 202 <span class="iconfont">&#xe600;</span>
202 203
203 <div class="senior-up-icon"></div> 204 <div class="senior-up-icon"></div>
  205 + {{^}}
  206 + <a href="{{url}}">{{name}}</a>
  207 + {{/if}}
204 </li> 208 </li>
205 {{/each}} 209 {{/each}}
206 </ul> 210 </ul>
207 211
208 <div class="senior-sub-wrap"> 212 <div class="senior-sub-wrap">
209 {{#each seniorChose}} 213 {{#each seniorChose}}
  214 + {{#if sub}}
210 <div class="senior-sub hide" data-attr="{{attr}}"> 215 <div class="senior-sub hide" data-attr="{{attr}}">
211 <div class="senior-content"> 216 <div class="senior-content">
212 {{#if showMulti}} 217 {{#if showMulti}}
@@ -228,6 +233,7 @@ @@ -228,6 +233,7 @@
228 </div> 233 </div>
229 </div> 234 </div>
230 </div> 235 </div>
  236 + {{/if}}
231 {{/each}} 237 {{/each}}
232 </div> 238 </div>
233 </div> 239 </div>
1 {{#if latestWalk}} 1 {{#if latestWalk}}
  2 + <input id="latest-walk-count" type="hidden" value="{{latestWalk}}">
2 <div class="latest-walk"> 3 <div class="latest-walk">
3 <h2>最近浏览的商品</h2> 4 <h2>最近浏览的商品</h2>
4 - <div class="goods clearfix">  
5 - {{# latestWalk}} 5 + <div id="latest-walk-goods" class="goods clearfix"></div>
  6 + </div>
  7 + <script id="latest-walk-tpl" type="text/html">
  8 + \{{# latestWalk}}
6 <div class="good"> 9 <div class="good">
7 - <a href="{{href}}">  
8 - <img class="lazy" data-original="{{img}}"> 10 + <a href="\{{href}}">
  11 + <img class="lazy" data-original="\{{img}}">
9 </a> 12 </a>
10 - <a class="name" href="{{href}}">{{name}}</a> 13 + <a class="name" href="\{{href}}">\{{name}}</a>
11 <p class="price"> 14 <p class="price">
12 - {{#if salePrice}}  
13 - <span class="market-price">¥{{marketPrice}}</span>  
14 - {{/if}}  
15 - <span class="sale-price">¥{{salePrice}}</span> 15 + <span class="market-price">\{{marketPrice}}</span>
  16 + <span class="sale-price">\{{salePrice}}</span>
16 </p> 17 </p>
17 </div> 18 </div>
18 - {{/ latestWalk}}  
19 - </div>  
20 - </div> 19 + \{{/ latestWalk}}
  20 + </script>
21 {{/if}} 21 {{/if}}
@@ -309,6 +309,9 @@ $seniorAttrWrap.on('mouseenter', '.attr', function() { @@ -309,6 +309,9 @@ $seniorAttrWrap.on('mouseenter', '.attr', function() {
309 var $this = $(this); 309 var $this = $(this);
310 var index = $this.index(); 310 var index = $this.index();
311 311
  312 + if ($this.hasClass('no-sub')) {
  313 + return;
  314 + }
312 $this.addClass('hover').siblings().removeClass('hover'); 315 $this.addClass('hover').siblings().removeClass('hover');
313 316
314 $seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide'); 317 $seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
@@ -316,6 +319,10 @@ $seniorAttrWrap.on('mouseenter', '.attr', function() { @@ -316,6 +319,10 @@ $seniorAttrWrap.on('mouseenter', '.attr', function() {
316 var $this = $(this), 319 var $this = $(this),
317 index = $this.index(); 320 index = $this.index();
318 321
  322 + if ($this.hasClass('no-sub')) {
  323 + return;
  324 + }
  325 +
319 hoveredIndex = index; 326 hoveredIndex = index;
320 327
321 seniorHoverTime = setTimeout(function() { 328 seniorHoverTime = setTimeout(function() {
  1 +/**
  2 + * 最近浏览取接口渲染模板
  3 + * @author: xuqi<qi.xu@yoho.cn>
  4 + 8 @date: 2016/1/20
  5 + */
  6 +
  7 +var $ = require('yoho.jquery');
  8 +var Handlebars = require('yoho.handlebars');
  9 +var lazyLoad = require('yoho.lazyload');
  10 +
  11 +var $latestWalkCount = $('#latest-walk-count');
  12 +
  13 +(function() {
  14 + var tpl;
  15 +
  16 + if ($latestWalkCount.lenght < 0) {
  17 + return;
  18 + }
  19 +
  20 + tpl = Handlebars.compile($('#latest-walk-tpl').html());
  21 +
  22 + $.ajax({
  23 + url: 'http://itemapi.yohobuy.com/item/item/recentreview',
  24 + dataType: 'jsonp',
  25 + data: {
  26 + limit: $latestWalkCount.val()
  27 + },
  28 + success: function(data) {
  29 + var latestWalk = [],
  30 + res, i, cur;
  31 +
  32 + if (data.code === 200) {
  33 + res = data.data;
  34 +
  35 + for (i = 0; i < res.length; i++) {
  36 + cur = res[i];
  37 +
  38 + latestWalk.push({
  39 + href: cur.url,
  40 + img: cur.pic_url,
  41 + name: cur.product_name,
  42 + salePrice: cur.price,
  43 + marketPrice: cur.market_price
  44 + });
  45 + }
  46 +
  47 + if (latestWalk.length > 0) {
  48 + $('#latest-walk-goods').html(tpl({
  49 + latestWalk: latestWalk
  50 + }));
  51 +
  52 + lazyLoad($('#latest-walk-goods .lazy'));
  53 + }
  54 + }
  55 + }
  56 + });
  57 +}());
@@ -8,4 +8,6 @@ require('./filter'); @@ -8,4 +8,6 @@ require('./filter');
8 8
9 require('./sort-pager'); 9 require('./sort-pager');
10 10
  11 +require('./latest-walk');
  12 +
11 require('./product'); 13 require('./product');
@@ -386,6 +386,10 @@ @@ -386,6 +386,10 @@
386 } 386 }
387 } 387 }
388 388
  389 + .promise .left {
  390 + margin-right: 45px;
  391 + }
  392 +
389 .subscribe { 393 .subscribe {
390 width: 200px; 394 width: 200px;
391 395
@@ -248,19 +248,7 @@ class Index1Controller extends AbstractAction @@ -248,19 +248,7 @@ class Index1Controller extends AbstractAction
248 array( 248 array(
249 'attr' => 'weather', 249 'attr' => 'weather',
250 'name' => '适用季节', 250 'name' => '适用季节',
251 - 'sub' => array(  
252 - array(  
253 - 'id' => '1',  
254 - 'href' => '',  
255 - 'name' => '春天',  
256 - 'checked' => true  
257 - ),  
258 - array(  
259 - 'id' => '2',  
260 - 'href' => '',  
261 - 'name' => '夏天'  
262 - )  
263 - ) 251 + 'url' => ''
264 ) 252 )
265 ) 253 )
266 ), 254 ),
@@ -970,44 +958,7 @@ class Index1Controller extends AbstractAction @@ -970,44 +958,7 @@ class Index1Controller extends AbstractAction
970 ), 958 ),
971 'totalCount' => '2259', 959 'totalCount' => '2259',
972 'pager' => '<a href="" class="cur"><span>1</span></a><a href=""><span>2</span></a><a href="" title="下一页">下一页<span class="iconfont">&gt;</span></a>', 960 'pager' => '<a href="" class="cur"><span>1</span></a><a href=""><span>2</span></a><a href="" title="下一页">下一页<span class="iconfont">&gt;</span></a>',
973 - 'latestWalk' => array(  
974 - array(  
975 - 'img' => 'http://img11.static.yhbimg.com/goodsimg/2015/08/24/11/018fd5cbe604b37ea35336257fcbff8114.jpg?imageMogr2/thumbnail/195x260/extent/195x260/background/d2hpdGU=/position/center/quality/90',  
976 - 'name' => 'Life·After Life 牛角扣夹棉连帽大衣(M51款)【吴亦凡亲身试着】',  
977 - 'marketPrice' => '939',  
978 - 'salePrice' => '679'  
979 - ),  
980 - array(  
981 - 'img' => 'http://img10.static.yhbimg.com/goodsimg/2014/11/05/08/0110a09053658b079265a553ee20a5779d.jpg?imageMogr2/thumbnail/195x260/extent/195x260/background/d2hpdGU=/position/center/quality/90',  
982 - 'name' => 'th:字母撞色毛衣',  
983 - 'marketPrice' => '698',  
984 - 'salePrice' => '209'  
985 - ),  
986 - array(  
987 - 'img' => 'http://img10.static.yhbimg.com/goodsimg/2014/11/05/08/0110a09053658b079265a553ee20a5779d.jpg?imageMogr2/thumbnail/195x260/extent/195x260/background/d2hpdGU=/position/center/quality/90',  
988 - 'name' => 'th:字母撞色毛衣',  
989 - 'marketPrice' => '698',  
990 - 'salePrice' => '209'  
991 - ),  
992 - array(  
993 - 'img' => 'http://img10.static.yhbimg.com/goodsimg/2014/11/05/08/0110a09053658b079265a553ee20a5779d.jpg?imageMogr2/thumbnail/195x260/extent/195x260/background/d2hpdGU=/position/center/quality/90',  
994 - 'name' => 'th:字母撞色毛衣',  
995 - 'marketPrice' => '698',  
996 - 'salePrice' => '209'  
997 - ),  
998 - array(  
999 - 'img' => 'http://img10.static.yhbimg.com/goodsimg/2014/11/05/08/0110a09053658b079265a553ee20a5779d.jpg?imageMogr2/thumbnail/195x260/extent/195x260/background/d2hpdGU=/position/center/quality/90',  
1000 - 'name' => 'th:字母撞色毛衣',  
1001 - 'marketPrice' => '698',  
1002 - 'salePrice' => '209'  
1003 - ),  
1004 - array(  
1005 - 'img' => 'http://img10.static.yhbimg.com/goodsimg/2014/11/05/08/0110a09053658b079265a553ee20a5779d.jpg?imageMogr2/thumbnail/195x260/extent/195x260/background/d2hpdGU=/position/center/quality/90',  
1006 - 'name' => 'th:字母撞色毛衣',  
1007 - 'marketPrice' => '698',  
1008 - 'salePrice' => '209'  
1009 - )  
1010 - ) 961 + 'latestWalk' => 6
1011 ) 962 )
1012 ); 963 );
1013 $this->_view->display('list', $data); 964 $this->_view->display('list', $data);