Authored by 张丽霞

Merge branch 'feature/recommend-for-you' into release/4.8

Conflicts:
	static/js/cart/cart.js
@@ -22,15 +22,21 @@ class RecomData @@ -22,15 +22,21 @@ class RecomData
22 * 22 *
23 * @param string $gender "1,3"表示男, "2,3"表示女 23 * @param string $gender "1,3"表示男, "2,3"表示女
24 * @param string $channel 1表示男, 2表示女 24 * @param string $channel 1表示男, 2表示女
  25 + * @param string $uid 用户ID
  26 + * @param string $udid 设备号
  27 + * @param string $recPos 推荐位 100001表示男首,100002表示女首,1000009表示有货币
25 * @param int $page 分页第几页, 默认第1页 28 * @param int $page 分页第几页, 默认第1页
26 * @param int $limit 查询返回的最大限制数, 默认为50 29 * @param int $limit 查询返回的最大限制数, 默认为50
27 * @return array 30 * @return array
28 */ 31 */
29 - public static function mayLike($gender, $channel, $page = 1, $limit = 50) 32 + public static function mayLike($gender, $uid, $udid, $recPos, $channel, $page = 1, $limit = 50)
30 { 33 {
31 $param = Yohobuy::param(); 34 $param = Yohobuy::param();
32 - $param['method'] = 'app.search.last7day'; 35 + $param['method'] = 'app.search.newLast7day';
33 $param['gender'] = $gender; 36 $param['gender'] = $gender;
  37 + $param['uid'] = $uid;
  38 + $param['udid'] = $udid;
  39 + $param['rec_pos'] = $recPos;
34 $param['page'] = $page; 40 $param['page'] = $page;
35 $param['limit'] = $limit; 41 $param['limit'] = $limit;
36 $param['yh_channel'] = $channel; 42 $param['yh_channel'] = $channel;
@@ -34,15 +34,11 @@ function needLoadRecommandForYou() { @@ -34,15 +34,11 @@ function needLoadRecommandForYou() {
34 $('.cart-goods').length <= 0 && !isRefreshByDelete : 34 $('.cart-goods').length <= 0 && !isRefreshByDelete :
35 $('.cart-goods').length <= 0; 35 $('.cart-goods').length <= 0;
36 } 36 }
  37 + require('../product/recommend-for-you-cart');
37 38
38 -if (needLoadRecommandForYou()) {  
39 - require('../product/recommend-for-you');  
40 -} else {  
41 - if (isRefreshByDelete) {  
42 - $('body').css('background-color', '#f0f0f0');  
43 - } 39 +if (!needLoadRecommandForYou()) {
44 require('./good'); 40 require('./good');
45 -} 41 +}
46 42
47 $cartPage.css('display', 'block'); 43 $cartPage.css('display', 'block');
48 loading.hideLoadingMask(); 44 loading.hideLoadingMask();
@@ -24,8 +24,8 @@ module.exports = function(specificGender) { @@ -24,8 +24,8 @@ module.exports = function(specificGender) {
24 //The kidsType can be specified by the parameter. Add by @ZhaoBiao 24 //The kidsType can be specified by the parameter. Add by @ZhaoBiao
25 var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false, 25 var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
26 lifestyleType = specificGender === 'lifestyle' || 26 lifestyleType = specificGender === 'lifestyle' ||
27 - $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false;  
28 - 27 + $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
  28 + yohoCoinType = $('.coin').length ? true : false;
29 var $curNav, 29 var $curNav,
30 index, 30 index,
31 $navList = $('#maybe-like-nav'); 31 $navList = $('#maybe-like-nav');
@@ -36,14 +36,20 @@ module.exports = function(specificGender) { @@ -36,14 +36,20 @@ module.exports = function(specificGender) {
36 36
37 //ajax url 37 //ajax url
38 if (kidsType) { 38 if (kidsType) {
  39 +
39 url = '/product/recom/maylikekids'; 40 url = '/product/recom/maylikekids';
40 } else if (lifestyleType) { 41 } else if (lifestyleType) {
41 42
42 //有货币页面加载男生首页的数据 43 //有货币页面加载男生首页的数据
43 - url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife'; 44 + url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3&rec_pos=100009' : '/product/recom/maylikelife';
  45 + } else if (yohoCoinType) {
  46 +
  47 + gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
  48 + '1,3&rec_pos=100009' : '2,3&rec_pos=100009',
  49 + url = '/product/recom/maylike?gender=' + gender;
44 } else { 50 } else {
45 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? 51 gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
46 - '1,3' : '2,3', 52 + '1,3&rec_pos=100001' : '2,3&rec_pos=100002',
47 url = '/product/recom/maylike?gender=' + gender; 53 url = '/product/recom/maylike?gender=' + gender;
48 } 54 }
49 55
@@ -11,7 +11,7 @@ var $userAvatar = $('.user-avatar'), @@ -11,7 +11,7 @@ var $userAvatar = $('.user-avatar'),
11 var myImage = new Image(), 11 var myImage = new Image(),
12 avatar; 12 avatar;
13 13
14 -require('../product/recommend-for-you.js'); 14 +require('../product/recommend-for-you-user-center.js');
15 require('../product/suspend-cart.js'); 15 require('../product/suspend-cart.js');
16 16
17 // 部分老用户没有头像,显示默认头像 17 // 部分老用户没有头像,显示默认头像
@@ -6,22 +6,14 @@ @@ -6,22 +6,14 @@
6 6
7 7
8 var Swiper = require('yoho.iswiper'), 8 var Swiper = require('yoho.iswiper'),
9 - $ = require('jquery'); 9 + $ = require('jquery'),
  10 + lazyLoad = require('yoho.lazyload');
10 11
11 -var recommendSwiper,  
12 - $recommendForYou = $('.recommend-for-you'); 12 +var $recommendForYou = $('.recommend-for-you');
13 13
14 -$.get('/home/preference').then(function(html) { 14 +$.get('/product/recommend-for-you/cart').then(function(html) {
15 $recommendForYou.html(html).show(); 15 $recommendForYou.html(html).show();
16 - if ($('#swiper-recommend').length) {  
17 - recommendSwiper = new Swiper('#swiper-recommend', {  
18 - slidesPerView: 'auto',  
19 - grabCursor: true,  
20 - slideElement: 'a',  
21 - lazyLoading: true,  
22 - watchSlidesVisibility: true  
23 - });  
24 - } 16 + lazyLoad($('img.lazy'));
25 }).fail(function() { 17 }).fail(function() {
26 $recommendForYou.hide(); 18 $recommendForYou.hide();
27 }); 19 });
  1 +/**
  2 + * 为您优选
  3 + * @author: bikai<kai.bi@yoho.cn>
  4 + * @date: 2015/11/16
  5 + */
  6 +
  7 +
  8 +var Swiper = require('yoho.iswiper'),
  9 + $ = require('jquery'),
  10 + lazyLoad = require('yoho.lazyload');
  11 +
  12 +var $recommendForYou = $('.recommend-for-you');
  13 +
  14 +$.get('/product/recommend-for-you/userCenter').then(function(html) {
  15 + $recommendForYou.html(html).show();
  16 + lazyLoad($('img.lazy'));
  17 +
  18 +}).fail(function() {
  19 + $recommendForYou.hide();
  20 +});
@@ -122,3 +122,10 @@ @@ -122,3 +122,10 @@
122 } 122 }
123 } 123 }
124 } 124 }
  125 +
  126 +.goods-container {
  127 + position: relative;
  128 + padding-top: 8px;
  129 + padding-left: 15px;
  130 + min-height: 880px;
  131 +}
@@ -225,7 +225,8 @@ @@ -225,7 +225,8 @@
225 padding: 20px; 225 padding: 20px;
226 border-top: 1px solid #e0e0e0; 226 border-top: 1px solid #e0e0e0;
227 font-size: 28px; 227 font-size: 28px;
228 - 228 + margin-bottom: 37px;
  229 +
229 .title { 230 .title {
230 display: inline-block; 231 display: inline-block;
231 width: 175px; 232 width: 175px;
@@ -50,7 +50,6 @@ @@ -50,7 +50,6 @@
50 line-height: 1; 50 line-height: 1;
51 51
52 .sale-price { 52 .sale-price {
53 - display: block;  
54 color: #d9134f; 53 color: #d9134f;
55 margin-right: 8px; 54 margin-right: 8px;
56 } 55 }
@@ -10,48 +10,48 @@ @@ -10,48 +10,48 @@
10 </p> 10 </p>
11 {{/if}} 11 {{/if}}
12 {{#if isEmptyCart}} 12 {{#if isEmptyCart}}
13 - <div class="cart-zero">  
14 - <i class="iconfont">&#xe640;</i>  
15 - <p>您的购物车暂无商品</p>  
16 - <a href="/product/new">随便逛逛</a>  
17 - </div>  
18 - {{> product/recommend-for-you}} 13 + <div class="cart-zero">
  14 + <i class="iconfont">&#xe640;</i>
  15 + <p>您的购物车暂无商品</p>
  16 + <a href="/product/new">随便逛逛</a>
  17 + </div>
  18 + {{> product/recommend-for-you}}
19 {{^}} 19 {{^}}
20 - {{#if cartNav}}  
21 - <ul class="cart-nav clearfix">  
22 -  
23 - <li class="active" id="common-cart-nav">  
24 - <span >  
25 - 普通商品({{commonGoodsCount}})  
26 - </span>  
27 - </li>  
28 - <li id="presell-cart-nav">  
29 - <span >  
30 - 预售商品({{presellGoodsCount}})  
31 - </span>  
32 - <div id="presell-tip" class="presell-tip hide">  
33 - <div class="triangle"></div>  
34 - <p class="pt-content">预售商品点这里结算哦~</p>  
35 - </div>  
36 - </li>  
37 -  
38 - </ul>  
39 - {{/if}}  
40 - {{# commonCart}}  
41 - <div class="cart-content common">  
42 - {{> cart/cart-content}}  
43 - </div>  
44 - {{/ commonCart}}  
45 - {{# preSellCart}}  
46 - <div class="cart-content presell hide">  
47 - <p class="presell-info">  
48 - <span class="iconfont">&#xe61a;</span>  
49 - <span class="txt">由于商品上市期不同,先到的将先发货</span>  
50 - <span class="txt">预售商品不参加活动,不可使用优惠券</span>  
51 - </p>  
52 - {{> cart/cart-content}}  
53 - </div>  
54 - {{/ preSellCart}} 20 + {{#if cartNav}}
  21 + <ul class="cart-nav clearfix">
  22 +
  23 + <li class="active" id="common-cart-nav">
  24 + <span >
  25 + 普通商品({{commonGoodsCount}})
  26 + </span>
  27 + </li>
  28 + <li id="presell-cart-nav">
  29 + <span >
  30 + 预售商品({{presellGoodsCount}})
  31 + </span>
  32 + <div id="presell-tip" class="presell-tip hide">
  33 + <div class="triangle"></div>
  34 + <p class="pt-content">预售商品点这里结算哦~</p>
  35 + </div>
  36 + </li>
  37 +
  38 + </ul>
  39 + {{/if}}
  40 + {{# commonCart}}
  41 + <div class="cart-content common">
  42 + {{> cart/cart-content}}
  43 + </div>
  44 + {{/ commonCart}}
  45 + {{# preSellCart}}
  46 + <div class="cart-content presell hide">
  47 + <p class="presell-info">
  48 + <span class="iconfont">&#xe61a;</span>
  49 + <span class="txt">由于商品上市期不同,先到的将先发货</span>
  50 + <span class="txt">预售商品不参加活动,不可使用优惠券</span>
  51 + </p>
  52 + {{> cart/cart-content}}
  53 + </div>
  54 + {{/ preSellCart}}
55 {{/if}} 55 {{/if}}
56 <input id="cartType" type="hidden" value="{{cartType}}"> 56 <input id="cartType" type="hidden" value="{{cartType}}">
57 {{/ shoppingCart}} 57 {{/ shoppingCart}}
@@ -67,6 +67,8 @@ @@ -67,6 +67,8 @@
67 <p>{{formulaPrice}}</p> 67 <p>{{formulaPrice}}</p>
68 </div> 68 </div>
69 69
  70 +{{> product/recommend-for-you}}
  71 +
70 <div class="balance"> 72 <div class="balance">
71 {{#if isAllSelected}} 73 {{#if isAllSelected}}
72 <span class="checkbox icon-cb-checked iconfont"></span> 74 <span class="checkbox icon-cb-checked iconfont"></span>
@@ -34,13 +34,16 @@ class RecomController extends AbstractAction @@ -34,13 +34,16 @@ class RecomController extends AbstractAction
34 /* 取可能喜欢的数据 */ 34 /* 取可能喜欢的数据 */
35 $recom = array(); 35 $recom = array();
36 $gender = $this->get('gender', '1,3'); 36 $gender = $this->get('gender', '1,3');
  37 + $recPos = $this->get('rec_pos', '100001');
  38 + $uid = $this->getUid();
  39 + $udid = $this->getUdid();
37 // 女 40 // 女
38 if ($gender === '2,3') { 41 if ($gender === '2,3') {
39 - $recom = RecomData::mayLike('2,3', 2, $page); 42 + $recom = RecomData::mayLike('2,3', $uid, $udid, $recPos, 2, $page);
40 } 43 }
41 // 男 44 // 男
42 else { 45 else {
43 - $recom = RecomData::mayLike('1,3', 1, $page); 46 + $recom = RecomData::mayLike('1,3', $uid, $udid, $recPos, 1, $page);
44 } 47 }
45 48
46 /* 判断是否有内容返回 */ 49 /* 判断是否有内容返回 */