Authored by 周少峰

Merge branch 'feature/cartTips' into release/5.5

... ... @@ -189,7 +189,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
// 分析用: 商品ID列表
if (_.isArray(_.get(analysis, 'ids'))) {
analysis.ids.push(it.product_id);
analysis.ids.push(it.product_skn);
}
// 分析用: CRITEO
... ... @@ -203,7 +203,7 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
} else {
// 分析用: 商品ID列表
if (_.isArray(_.get(analysis, 'ids'))) {
analysis.ids.push(it.product_id);
analysis.ids.push(it.product_skn);
}
// 分析用: CRITEO
... ... @@ -460,13 +460,13 @@ const formatPoolPromotionInfos = (infoList, selectedGiftsList) => {
/**
* 格式化子优惠池信息,返回商品列表,子优惠列表放在每个商品中
*/
const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance) => {
const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance, analysis) => {
let goodsListPool = _.map(pools, p => {
let pool = {
poolType: p.pool_type,
isBrandGroup: Number(p.pool_type) === 1,
goodsList: formatCartGoods(p.goods_list, isAdvance),
goodsList: formatCartGoods(p.goods_list, isAdvance, false, false, analysis),
promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
};
... ... @@ -492,19 +492,19 @@ const formatSubPromotionPools = (pools, selectedGiftsList, isAdvance) => {
* giftsList, priceGifts 已选择的赠品和加价购,判断可选的赠品和加价购是否被选中
* 优惠池
*/
const formatPromotionPools = (pools, selectedGiftsList, isAdvance) => {
const formatPromotionPools = (pools, selectedGiftsList, isAdvance, analysis) => {
return _.map(pools, p => {
let pool = {
poolTitle: p.pool_title,
poolType: p.pool_type,
isBrandGroup: Number(p.pool_type) === 1,
goodsList: formatCartGoods(p.goods_list, isAdvance),
goodsList: formatCartGoods(p.goods_list, isAdvance, false, false, analysis),
promotionInfos: formatPoolPromotionInfos(p.promotion_list, selectedGiftsList)
};
if (p.sub_pool) {
pool.subs = formatSubPromotionPools(p.sub_pool, selectedGiftsList, isAdvance);
pool.subs = formatSubPromotionPools(p.sub_pool, selectedGiftsList, isAdvance, analysis);
/*
if (_.isArray(goodsWithPromotion) && goodsWithPromotion.length) {
... ... @@ -560,7 +560,7 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
result.advanceCart = {
// 未参加活动的商品
// goodsList: chelper.formatCartGoods(_.get(advCartData, 'goods_list'), true, false, false, analysisData),
pools: formatPromotionPools(_.get(advCartData, 'goods_pool_list'), null, true),
pools: formatPromotionPools(_.get(advCartData, 'goods_pool_list'), null, true, analysisData),
offShelves: formatOffShelves(_.get(advCartData, 'off_shelves_goods_list'), true, analysisData),
soldOuts: formatSoldOuts(_.get(advCartData, 'sold_out_goods_list'), true, analysisData),
promotionInfos: formatPromotionInfos(_.get(advCartData, 'promotion_info')),
... ... @@ -585,7 +585,7 @@ const formatCart = (cartDataRet, uid, shoppingKey, cartDelList) => {
// 已选择的全场加价购和赠品
goodsList: goodsList,
pools: formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), goodsList),
pools: formatPromotionPools(_.get(ordCartData, 'goods_pool_list'), goodsList, false, analysisData),
offShelves: formatOffShelves(_.get(ordCartData, 'off_shelves_goods_list'), false, analysisData),
soldOuts: formatSoldOuts(_.get(ordCartData, 'sold_out_goods_list'), false, analysisData),
... ...
... ... @@ -68,39 +68,4 @@
</div>
</div>
<!-- 商品详细信息窗口 -->
<!--
<script type="text/javascript">
(function (d) {
window.bd_cpro_rtid = "P1fsPWc";
var s = d.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = location.protocol + "//cpro.baidu.com/cpro/ui/rt.js";
var s0 = d.getElementsByTagName("script")[0];
s0.parentNode.insertBefore(s, s0);
})(document);
</script>
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
{event: "setAccount", account: 16184},
{event: "setCustomerId", id: "{{uid}}"},
{event: "setSiteType", type: "d"},
{event: "viewBasket", item: {{{cart.criteo}}} }
);
</script>
-->
<!-- 聚效 -->
<!--
<script type="text/javascript">
var _mvq = window._mvq || [];
window._mvq = _mvq;
_mvq.push(['$setAccount', 'm-23428-1']);
_mvq.push(['$setGeneral', 'cartview', '', /*用户名*/ '', '{{uid}}']);
_mvq.push(['$logConversion']);
_mvq.push(['$addItem', '', /*商品id*/ '{{cart.ids}}', '', '']);
_mvq.push(['$logData']);
</script>
-->
{{> cart-analysis}}
... ...
<!-- 商品详细信息窗口 -->
<script type="text/javascript">
(function (d) {
window.bd_cpro_rtid = "P1fsPWc";
var s = d.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = location.protocol + "//cpro.baidu.com/cpro/ui/rt.js";
var s0 = d.getElementsByTagName("script")[0];
s0.parentNode.insertBefore(s, s0);
})(document);
</script>
<script type="text/javascript" src="//static.criteo.net/js/ld/ld.js" async="true"></script>
<script type="text/javascript">
window.criteo_q = window.criteo_q || [];
window.criteo_q.push(
{event: "setAccount", account: 16184},
{event: "setCustomerId", id: "{{uid}}"},
{event: "setSiteType", type: "d"},
{event: "viewBasket", item: [
{{# cart.criteo}}
{"id":"{{id}}","quantity":"{{quantity}}","price":"{{price}}"},
{{/ cart.criteo}}
]}
);
</script>
<!-- 聚效 -->
<script type="text/javascript">
var _mvq = window._mvq || [];
window._mvq = _mvq;
_mvq.push(['$setAccount', 'm-23428-1']);
_mvq.push(['$setGeneral', 'cartview', '', /*用户名*/ '', '{{uid}}']);
_mvq.push(['$logConversion']);
_mvq.push(['$addItem', '', /*商品id*/ '{{cart.ids}}', '', '']);
_mvq.push(['$logData']);
</script>
... ...
... ... @@ -8,7 +8,7 @@
</div>
{{^}}
<!-- 购物车商品列表 -->
<div class="pay-wapper">
<div class="pay-wapper" data-role="order-cart">
<div class="cart-title">
<p class="left" style="width:6%;">
<i class="cart-item-check-title cart-item-check iconfont"></i>&nbsp;&nbsp;全选
... ... @@ -23,7 +23,8 @@
{{#advanceCart}}
<div class="mb20" data-role="advance">
<!-- 预售商品 -->
<div class="pre-sell">
<div class="pre-sell pre-sell-title">
<i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}" data-role="cart-item-check"></i>
<code>预售商品</code>预售商品不参加活动,不可使用优惠券,不同上市期的商品我们将为您先到先发。
</div>
... ... @@ -73,8 +74,9 @@
{{#ordinaryCart}}
<div data-role="ordinary">
<!-- 预售商品 -->
<div class="pre-sell ordinary-sell">
<!-- 普通商品 -->
<div class="pre-sell ord-sell-title">
<i class="cart-item-check iconfont {{#isChecked}}cart-item-checked{{/isChecked}}" data-role="cart-item-check"></i>
<code>普通商品</code> {{tips}}
</div>
... ...
{
"name": "yohobuy-node",
"version": "5.4.19",
"version": "5.4.20",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -55,6 +55,44 @@ function submitPoint(type) {
yas.givePoint('YB_SC_TOBUY_CLICK', {PRD_ID: productId.join(',')});
}
function toggleAll(obj, roleType) {
var $this = obj;
var selected;
var selectArray = [];
var $noStores = $cartListWrap.find('[data-role=' + roleType + '] [data-role=cart-item-check][data-tipnostore]');
$this.toggleClass('cart-item-checked');
selected = $this.hasClass('cart-item-checked') ? 'Y' : 'N';
$cartListWrap.find('[data-role=' + roleType + '] li[data-role=pitem]').each(function() {
var $t = $(this);
if ($t.data('id')) {
selectArray.push({
product_sku: $t.data('id'),
selected: selected,
buy_number: $t.data('productnum'),
goods_type: $t.data('goodstype'),
promotion_id: $t.data('promotionid') || 0
});
}
});
if (selected === 'Y' && $noStores && $noStores.length > 0) { // 无库存提示
$('html,body').animate({scrollTop: $noStores.eq(0).offset().top - 50 + 'px'}, 500);
$noStores.each(function() {
toastNoStore($(this).closest('li[data-role=pitem]'), '您全选的商品中存在库存不足商品,已帮您自动取消勾选');
});
setTimeout(function() {
capi.choiceOut(selectArray);
}, 2000);
} else {
capi.choiceOut(selectArray);
}
}
Cart = {
toggleSelectOne: function() { // 单选
... ... @@ -80,44 +118,15 @@ Cart = {
return capi.choiceOut(item);
},
toggleSelectAll: function() { // 全选
var $this = $(this);
var selected;
var selectArray = [];
var $noStores = $cartListWrap.find('[data-role=cart-item-check][data-tipnostore]');
$this.toggleClass('cart-item-checked');
selected = $this.hasClass('cart-item-checked') ? 'Y' : 'N';
$cartListWrap.find('li[data-role=pitem]').each(function() {
var $t = $(this);
if ($t.data('id')) {
selectArray.push({
product_sku: $t.data('id'),
selected: selected,
buy_number: $t.data('productnum'),
goods_type: $t.data('goodstype'),
promotion_id: $t.data('promotionid') || 0
});
}
});
if (selected === 'Y' && $noStores && $noStores.length > 0) { // 无库存提示
$('html,body').animate({scrollTop: $noStores.eq(0).offset().top - 50 + 'px'}, 500);
$noStores.each(function() {
toastNoStore($(this).closest('li[data-role=pitem]'), '您全选的商品中存在库存不足商品,已帮您自动取消勾选');
});
setTimeout(function() {
capi.choiceOut(selectArray);
}, 2000);
} else {
capi.choiceOut(selectArray);
}
toggleSelectAll: function() { // 全部
toggleAll($(this), 'order-cart');
},
togglePreAll: function() { // 预售全选
toggleAll($(this), 'advance');
},
toggleOrdAll: function() { // 普通全选
toggleAll($(this), 'ordinary');
},
del: function() {
... ... @@ -395,6 +404,8 @@ $cartListWrap.on('click', '[data-role=cart-mov2fav-btn]', Cart.toFav); // 移
$cartListWrap.on('click', '.minus, .plus', Cart.modNum); // 修改购物车数量
$cartListWrap.on('click', '.cart-title .cart-item-check', Cart.toggleSelectAll); // 全选
$cartListWrap.on('click', '.cartnew-sum .cart-item-check', Cart.toggleSelectAll); // 全选
$cartListWrap.on('click', '.pre-sell-title .cart-item-check', Cart.togglePreAll); // 预售全选
$cartListWrap.on('click', '.ord-sell-title .cart-item-check', Cart.toggleOrdAll); // 预售全选
$cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); // 批量删除商品
$cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品
$cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable);
... ...
... ... @@ -35,6 +35,47 @@ function isCheckAll() {
}
}
// 预售商品是否全选
function isPreCheckAll() {
var isAllCheck = true;
$('[data-role=advance] [data-role=pitem] [data-role=cart-item-check]').each(function() {
var $chk = $(this);
// 有一个没选中,跳出循环
if (!$(this).hasClass('cart-item-checked') && !$chk.data('tipnostore')) {
isAllCheck = false;
return false;
}
});
if (isAllCheck) {
// 头部全选
$('.pre-sell-title .cart-item-check').addClass('cart-item-checked');
}
}
// 普通商品是否全选
function isOrdCheckAll() {
var isAllCheck = true;
$('[data-role=ordinary] [data-role=pitem] [data-role=cart-item-check]').each(function() {
var $chk = $(this);
// 有一个没选中,跳出循环
if (!$(this).hasClass('cart-item-checked') && !$chk.data('tipnostore')) {
isAllCheck = false;
return false;
}
});
if (isAllCheck) {
$('.ord-sell-title .cart-item-check').addClass('cart-item-checked');
}
}
// 判断商品是否已收藏,是否全选
function isCheckFav() {
var pidArray = [];
... ... @@ -86,6 +127,8 @@ function cartInit() {
});
isCheckAll();
isPreCheckAll();
isOrdCheckAll();
isCheckFav();
}
... ...
... ... @@ -264,8 +264,10 @@
font-weight: 300;
height: 30px;
line-height: 30px;
padding-left: 30px;
padding-left: 55px;
padding-top :20px;
position: relative;
margin-bottom: 1px;
span {
margin-right: 10px;
}
... ... @@ -274,7 +276,7 @@
margin-right: 30px;
}
}
.ordinary-sell {
.ord-sell {
padding-top: 0px;
}
... ...