Authored by 张丽霞

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

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