Authored by 郝肖肖

node 门票

... ... @@ -30,6 +30,9 @@ const BLANK_STR = ' ';
const cachedRequestData = {};
//展览票
const EXHIBITION_TICKET = 51257610;
const _getProductAdditionInfoAsync = (data) => {
return co(function * () {
let productId = data.id;
... ... @@ -361,7 +364,8 @@ const _getSkuDataByProductBaseInfo = (data) => {
// 商品的尺码列表
cur.goodsSizeBoList.forEach(size => {
if (data.attribute === 3) {
size.goodsSizeStorageNum = size.goodsSizeStorageNum > 1 ? 1 : 0;
//虚拟商品,门票默认最大为4,
size.goodsSizeStorageNum = size.goodsSizeStorageNum > 4 ? 4 : size.goodsSizeStorageNum;
}
// 如果status为0,即skc下架时就跳过该商品
... ... @@ -588,8 +592,10 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
// VIP数据
result.vipPrice = _getVipDataByProductBaseInfo(origin, vipLevel, uid);
// 促销活动banner
result.activity = _getActivityDataByProductBaseInfo(origin);
// 促销活动banner,虚拟商品无促销
if (origin.attribute !== 3) {
result.activity = _getActivityDataByProductBaseInfo(origin);
}
const C_VALUE = {
type: '返YOHO币',
... ... @@ -697,6 +703,8 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
result.advancePrice = result.salePrice; // 先行价格
delete result.salePrice;
}
//是否展览票
result.isTicket = origin.erpProductId * 1 === EXHIBITION_TICKET;
}
// 去掉即将售罄
... ...
... ... @@ -163,7 +163,8 @@
</ul>
</div>
<div class="chose-size row clearfix">
<div class="chose-size row clearfix {{#if isTicket}} hide {{/if}}">
<input type="hidden" name="isTicket" value="{{isTicket}}" />
<span class="title pull-left">
选区域:
</span>
... ... @@ -267,28 +268,34 @@
</div>
<p class="row">
{{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
{{#unless soldOut}}
{{# buyNow}}
<span id="buy-now" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}"
data-base="{{buyNowBase}}">立即购买</span>
{{/ buyNow}}
{{# openSoon}}
<span id="open-soon" class="buy-btn item-buy dis">即将开售</span>
{{/ openSoon}}
{{#if notForSale}}
<span class="buy-btn dis">
<i class="iconfont">&#xe61c;</i>
非买品
</span>
{{/if}}
{{#if addToCart}}
<span id="add-to-cart" class="buy-btn item-buy add-to-cart">
<i class="iconfont">&#xe61b;</i>
添加到购物车
</span>
{{/if}}
{{/unless}}
{{#if virtualGoods}}
{{!-- 电子门票按钮 --}}
<form name="ticket-form" action="//www.yohobuy.com/cart/index/ticketEnsure" method="POST" class="hide"></form>
<span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}" >立即购买</span>
{{else}}
{{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
{{#unless soldOut}}
{{# buyNow}}
<span id="buy-now" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}"
data-base="{{buyNowBase}}">立即购买</span>
{{/ buyNow}}
{{# openSoon}}
<span id="open-soon" class="buy-btn item-buy dis">即将开售</span>
{{/ openSoon}}
{{#if notForSale}}
<span class="buy-btn dis">
<i class="iconfont">&#xe61c;</i>
非买品
</span>
{{/if}}
{{#if addToCart}}
<span id="add-to-cart" class="buy-btn item-buy add-to-cart">
<i class="iconfont">&#xe61b;</i>
添加到购物车
</span>
{{/if}}
{{/unless}}
{{/if}}
<span id="sold-out" class="buy-btn dis{{#unless soldOut}} hide{{/unless}}">
<i class="iconfont">&#xe61c;</i>
... ... @@ -396,41 +403,44 @@
{{/ material}}
</div>
</div>
<div class="size-info info-block">
<p class="block-title">
<span class="title cur">尺码信息 SIZE INFO</span>
</p>
{{# size}}
<table class="size-table">
<thead>
<tr>
{{# thead}}
<th>{{name}}</th>
{{/ thead}}
</tr>
</thead>
<tbody>
{{# tbody}}
{{#if goodsInfo.virtualGoods}}
<!---虚拟商品-尺码信息没有--->
{{else}}
<div class="size-info info-block">
<p class="block-title">
<span class="title cur">尺码信息 SIZE INFO</span>
</p>
{{# size}}
<table class="size-table">
<thead>
<tr>
{{#each .}}
<td>{{.}}</td>
{{/each}}
{{# thead}}
<th>{{name}}</th>
{{/ thead}}
</tr>
{{/ tbody}}
</tbody>
</table>
<p class="size-tip">
※ 以上尺寸为实物人工测量,因测量方式不同会有1-2CM误差,相关数据仅作参考,以收到实物为准。 单位:CM
</p>
<p class="size-tip">
※ 参考尺码因衣服版型、剪裁不同会有误差,仅供参考
</p>
{{#if sizeImg}}
<img class="size-img" src="{{sizeImg}}">
{{/if}}
{{/ size}}
</div>
</thead>
<tbody>
{{# tbody}}
<tr>
{{#each .}}
<td>{{.}}</td>
{{/each}}
</tr>
{{/ tbody}}
</tbody>
</table>
<p class="size-tip">
※ 以上尺寸为实物人工测量,因测量方式不同会有1-2CM误差,相关数据仅作参考,以收到实物为准。 单位:CM
</p>
<p class="size-tip">
※ 参考尺码因衣服版型、剪裁不同会有误差,仅供参考
</p>
{{#if sizeImg}}
<img class="size-img" src="{{sizeImg}}">
{{/if}}
{{/ size}}
</div>
{{/if}}
{{#if reference}}
<div class="reference info-block">
<p class="block-title">
... ...
... ... @@ -31,7 +31,8 @@ var $descColor = $('#desc-color');
var thumbsLoaded = {};
var $main = $('.main'),
id = $main.data('id');
id = $main.data('id'),
isTicket = $('input[name="isTicket"]').length > 0 && $('input[name="isTicket"]').val() === true;
var maxStock = -1; // 记录当前选中的颜色-尺码的库存量,若为-1,代表未选择尺码
... ... @@ -196,6 +197,12 @@ $('.colors').on('click', 'li', function() {
// 切换尺码显示
$sizes.not('.hide').addClass('hide').children('li').removeClass('focus');
$sizes.eq(index).removeClass('hide');
//是否展览票
if (isTicket) {
$sizes.eq(index).children('li').trigger('click');
$('.chose-size').addClass('hide');
}
}
resetNum();
... ... @@ -377,6 +384,50 @@ $('#keep-shopping').click(function() {
$('#balance').slideUp(SLIDETIME);
});
//电子票立即购买
$('#buy-ticket').click(function() {
var sku,
buyNumber;
if (maxStock === -1) {
showSizeWarn();
return;
}
if ($(this).hasClass('dis')) {
return;
}
sku = $('.size:not(.hide) li.focus').data('sku');
buyNumber = getNum();
$.ajax({
type: 'POST',
url: '/cart/index/setTicket',
data: {
productSku: sku,
buyNumber: buyNumber
}
}).then(function(data) {
var $ticketForm,
myAlert;
if (data.code * 1 === 200) {
$ticketForm = $('form[name="ticket-form"]');
$ticketForm.html(
'<input name="productSku" value="' + sku + '" />' +
'<input name="buyNumber" value="' + buyNumber + '" />'
);
$ticketForm.submit();
} else if (data.code * 1 === 401) {
document.location.href = data.message;
} else {
myAlert = new Alert(data.message);
myAlert.show();
}
});
});
// 立即购买
$('#buy-now').click(function() {
var sku,
... ...
... ... @@ -253,7 +253,8 @@
}
}
.chose-size, .chose-ticket {
.chose-size,
.chose-ticket {
font-size: 12px;
.title {
... ... @@ -436,7 +437,8 @@
}
}
.buy-btn, .buy-ticket {
.buy-btn,
.buy-ticket {
display: inline-block;
margin-right: 10px;
height: 48px;
... ...