Authored by hongweigao

Merge branch 'feature/new-product-detail' of http://git.yoho.cn/fe/yohobuy-node

…into feature/new-product-detail
... ... @@ -1138,6 +1138,9 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
// 秒杀商品
result.secKill = propOrigin('is_secKill', 'N');
// 量贩
result.bundleType = propOrigin('bundle_type', 0);
let requestApi = {
addition: _getProductAdditionInfoAsync(origin), // 预处理所有的数据
fav: _getProductFavoriteDataAsync(uid, result.productId), // 处理收藏喜欢数据
... ... @@ -1392,10 +1395,22 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
// 普通商品
result.bundle = {
count: 1,
type: 0
type: result.bundleType
};
}
// 非普通商品导航条移除加入购物车按钮
const hasNavCart = (pro) => {
return !(pro.limitedsale === 'Y' ||
pro.secKill === 'Y' ||
pro.deposit === 'Y' ||
pro.presale === 'Y' ||
pro.bundle.type !== 0);
};
result.hasNavCart = hasNavCart(result);
// 电子票
result.isTicket = propOrigin('product_skn') === YOHOOD_TICKET;
if (virtualGoods && result.isTicket) {
... ...
... ... @@ -124,7 +124,8 @@
</div>
{{/if}}
{{#if size}}<div class="description-material-tab info-block getnav" id="sizeMessage" data-id="1">
{{#if size.tbody}}<div class="description-material-tab info-block getnav" id="sizeMessage" data-id="1">
<p class="block-title" id="sizeTitle">
<span class="title-head"> <span class="title cur">尺码信息</span> </span>
</p>
... ... @@ -456,10 +457,19 @@
</div>
<div class="shoppingCar">
<div class="shoppingCar-btn">
<i class="iconfont">&#xe600;</i>
<span>加入购物车</span>
</div>
{{#if goodsInfo.hasNavCart}}
{{#if goodsInfo.soldOut}}
<div class="shoppingCar-btn disable">
<i class="iconfont">&#xe61c;</i>
<span>已售罄</span>
</div>
{{^}}
<div class="shoppingCar-btn">
<i class="iconfont">&#xe600;</i>
<span>加入购物车</span>
</div>
{{/if}}
{{/if}}
<div class="shoppingCar-nav">
<ul>
... ...
... ... @@ -149,7 +149,7 @@
{{/if}}
<span id="sold-out" class="buy-btn dis{{#unless soldOut}} hide{{/unless}}">
<i class="iconfont">&#xe61c;</i> 已售罄
<i class="iconfont">&#xe6ba;</i> 已售罄
</span>
<span id="enable-notify" class="buy-btn hide"> <i class="iconfont">
... ...
No preview for this file type
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Tue Dec 27 20:13:37 2016
Created by FontForge 20120731 at Wed Dec 28 10:07:42 2016
By admin
</metadata>
<defs>
... ... @@ -239,5 +239,9 @@ d="M562 224h109v-111h-109v111zM889 224h109v-111h-109v111zM562 113h109v-110h-109v
h222v-111h-222v111zM889 334h109v-111h-109v111zM780 113h109v-111h-109v111zM562 2h218v-110h-218v110zM889 2h109v-110h-109v110z" />
<glyph glyph-name="subtract" unicode="&#xe63c;"
d="M928 418h-832q-13 0 -22.5 -9.5t-9.5 -23t9.5 -22.5t22.5 -9h832q13 0 22.5 9t9.5 22.5t-9.5 23t-22.5 9.5z" />
<glyph glyph-name="shiliangzhinengduixiang" unicode="&#xe6ba;"
d="M875 747q-99 98 -231 133t-263.5 0t-229.5 -133q-98 -99 -133 -231t0 -263.5t133 -229.5q73 -74 167 -112.5t194 -38.5q101 0 195 38t168 111q73 74 111 170t38 193t-38 193t-111 170zM810 86q-60 -61 -139.5 -92.5t-159.5 -31.5t-159.5 31.5t-140.5 92.5
q-80 81 -108 189.5t1 217t110 189.5q61 61 138 93t160 32t160 -32t138 -93q81 -81 110 -189.5t0 -217t-110 -189.5zM786 595l-485 -485q67 -52 149.5 -67t164 10t142.5 86q93 93 101 224t-72 232zM723 658q-90 71 -211 71q-69 0 -132.5 -26t-112.5 -76q-61 -62 -86 -143
t-10 -163.5t67 -150.5z" />
</font>
</defs></svg>
... ...
No preview for this file type
No preview for this file type
... ... @@ -19,7 +19,7 @@
<em class="likeNum">{{like}}</em>
</span>
<span class="usefulData" data-id="{{id}}">
<i class="iconfont cususeful{{#if isUseful}} getzan{{/if}}" data-id="{{id}}" data-useful="{{useful}}">&#xe642;</i>有用
<i class="iconfont cususeful{{#if isUseful}} getzan{{/if}}" data-id="{{id}}" data-useful="{{useful}}">&#xe641;</i>有用
<em class="usefulNum">{{useful}}</em>
</span>
</div>
... ...
... ... @@ -23,6 +23,7 @@ var bindEvent = $.Callbacks(); // eslint-disable-line
var cartEvent = new EventProxy();
var Dialog = require('../common/dialog').Dialog;
var Alert = require('../common/dialog').Alert;
var yasAtHead = require('./yas-head');
var yasAtBottom = require('./yas-bottom');
var $main = $('.main'),
... ... @@ -41,6 +42,8 @@ var $main = $('.main'),
var maxStock = -1; // 记录当前选中的颜色-尺码的库存量,若为-1,代表未选择尺码
var $maxColor = null; // 记录当前选中的颜色
var $shoppingCarBtn = $('.shoppingCar-btn');
var SLIDETIME = 200;
var colTxt = {
... ... @@ -78,9 +81,79 @@ function isEmpty(el) {
return !$.trim(el.html());
}
function showSellOut() {
$shoppingCarBtn.addClass('disable')
.find('i').html('&#xe6ba;').end()
.data('gocart', 0)
.find('span').html('已售罄');
}
function showAddCart() {
$shoppingCarBtn.removeClass('disable')
.data('gocart', 0)
.find('i').html('&#xe600;').end()
.find('span').html('加入购物车');
}
function showHasAddCart() {
$shoppingCarBtn.removeClass('disable')
.data('gocart', 1)
.find('i').html('&#xe600;').end()
.find('span').html('去购物车结算');
}
cartEvent.on('selling', showAddCart);
cartEvent.on('sellout', showSellOut);
cartEvent.on('gocart', showHasAddCart);
require('../plugins/slider');
require('../common/center-slider');
// 获取当前选择的商品数目
function getNum() {
return +$('#num').text();
}
function getSku() {
return $('.size:not(.hide) li.focus').data('sku');
}
function addCart() {
return $.ajax({
type: 'POST',
url: '/cart/index/add',
data: {
productSku: getSku(),
buyNumber: getNum()
}
}).then(function(data) {
var code = data.code;
var alert;
if (code === 200) {
$('#type-chose').slideUp(SLIDETIME);
$('#balance').slideDown(SLIDETIME);
$('#cart-num').text(data.data.goods_count); // 更新数目
return $.Deferred().resolve().promise();
} else if (code === 500) {
if (deposit) {
alert = new Alert('定金预售商品只能在APP端购买');
alert.show();
}
if (secKill) {
alert = new Alert('秒杀商品只能在APP端购买');
alert.show();
}
}
return $.Deferred().reject().promise();
});
}
bindEvent.add(function() {
var $imgShow = $('#img-show'),
$thumbs = $('#thumbs > .thumb-wrap');
... ... @@ -111,8 +184,6 @@ bindEvent.add(function() {
var brandDomain = $('.home').attr('href');
var Alert = require('../common/dialog').Alert;
/** 优惠券开始 **/
var $moreCoupon = $('.more-coupon'),
$couponItem = $('.coupon-item');
... ... @@ -218,10 +289,6 @@ bindEvent.add(function() {
/** 优惠券结束 **/
function getSku() {
return $('.size:not(.hide) li.focus').data('sku');
}
function imgShow(src) {
$imgShow.attr('src', src);
}
... ... @@ -311,11 +378,6 @@ bindEvent.add(function() {
}
});
// 获取当前选择的商品数目
function getNum() {
return +$num.text();
}
// 是否能:量贩购买,量贩小于库存才能购买
function canBundleBuy() {
return goodsBaseNum < maxStock;
... ... @@ -390,9 +452,11 @@ bindEvent.add(function() {
if (sellout()) {
$itemBuy.addClass('hide');
$soldOut.removeClass('hide');
cartEvent.emit('sellout');
} else {
$itemBuy.removeClass('hide');
$soldOut.addClass('hide');
cartEvent.emit('selling');
}
// 尺码选中的状态
... ... @@ -400,9 +464,11 @@ bindEvent.add(function() {
if (canBundleBuy()) {
$itemBuy.removeClass('hide');
$soldOut.addClass('hide');
cartEvent.emit('gocart');
} else {
$itemBuy.addClass('hide');
$soldOut.removeClass('hide');
cartEvent.emit('sellout');
}
}
... ... @@ -414,10 +480,17 @@ bindEvent.add(function() {
if (maxStock === 0 || ($color && ~~$color.data('total') === 0)) {
$itemBuy.addClass('hide'); // 隐藏加入购物车、即将开售、立即购买等相同位置的按钮
$soldOut.removeClass('hide');
cartEvent.emit('sellout');
} else {
// 包括默认的-1情况下
$itemBuy.removeClass('hide');
$soldOut.addClass('hide');
if (maxStock === -1) {
cartEvent.emit('selling');
} else {
cartEvent.emit('gocart');
}
}
}
... ... @@ -756,34 +829,7 @@ bindEvent.add(function() {
PRD_SKU: getSku()
});
$.ajax({
type: 'POST',
url: '/cart/index/add',
data: {
productSku: getSku(),
buyNumber: getNum()
}
}).then(function(data) {
var code = data.code;
var alert;
if (code === 200) {
$('#type-chose').slideUp(SLIDETIME);
$('#balance').slideDown(SLIDETIME);
$('#cart-num').text(data.data.goods_count); // 更新数目
} else if (code === 500) {
if (deposit) {
alert = new Alert('定金预售商品只能在APP端购买');
alert.show();
}
if (secKill) {
alert = new Alert('秒杀商品只能在APP端购买');
alert.show();
}
}
});
addCart();
});
// 收藏
... ... @@ -1815,8 +1861,23 @@ $('.shoppingCar').on('click', '.option', function(e) {
});
$('.shoppingCar-btn').on('click', function() {
var $this = $(this);
if ($this.hasClass('disable')) {
return;
}
if ($this.data('gocart') === 1) {
addCart().then(function() {
window.jumpUrl($('.go-cart').attr('href'));
});
return;
}
var $addToCart = $('#add-to-cart');
var sc = $(document);
sc.scrollTop(200);
if (maxStock === -1) {
... ...
... ... @@ -948,7 +948,7 @@
margin-left: 961px;
}
.shoppingCar{
.shoppingCar {
background-color: #f5f5f5;
float: left;
height: 240px;
... ... @@ -978,6 +978,13 @@
background: rgba(233, 38, 1, 0.8);
}
&.disable {
background: #ccc;
border: 1px solid #ccc;
color: white;
}
}
.shoppingCar-nav{
... ...