Authored by 郝肖肖

node 门票

@@ -30,6 +30,9 @@ const BLANK_STR = ' '; @@ -30,6 +30,9 @@ const BLANK_STR = ' ';
30 30
31 const cachedRequestData = {}; 31 const cachedRequestData = {};
32 32
  33 +//展览票
  34 +const EXHIBITION_TICKET = 51257610;
  35 +
33 const _getProductAdditionInfoAsync = (data) => { 36 const _getProductAdditionInfoAsync = (data) => {
34 return co(function * () { 37 return co(function * () {
35 let productId = data.id; 38 let productId = data.id;
@@ -361,7 +364,8 @@ const _getSkuDataByProductBaseInfo = (data) => { @@ -361,7 +364,8 @@ const _getSkuDataByProductBaseInfo = (data) => {
361 // 商品的尺码列表 364 // 商品的尺码列表
362 cur.goodsSizeBoList.forEach(size => { 365 cur.goodsSizeBoList.forEach(size => {
363 if (data.attribute === 3) { 366 if (data.attribute === 3) {
364 - size.goodsSizeStorageNum = size.goodsSizeStorageNum > 1 ? 1 : 0; 367 + //虚拟商品,门票默认最大为4,
  368 + size.goodsSizeStorageNum = size.goodsSizeStorageNum > 4 ? 4 : size.goodsSizeStorageNum;
365 } 369 }
366 370
367 // 如果status为0,即skc下架时就跳过该商品 371 // 如果status为0,即skc下架时就跳过该商品
@@ -588,8 +592,10 @@ const _detailDataPkg = (origin, uid, vipLevel) => { @@ -588,8 +592,10 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
588 // VIP数据 592 // VIP数据
589 result.vipPrice = _getVipDataByProductBaseInfo(origin, vipLevel, uid); 593 result.vipPrice = _getVipDataByProductBaseInfo(origin, vipLevel, uid);
590 594
591 - // 促销活动banner  
592 - result.activity = _getActivityDataByProductBaseInfo(origin); 595 + // 促销活动banner,虚拟商品无促销
  596 + if (origin.attribute !== 3) {
  597 + result.activity = _getActivityDataByProductBaseInfo(origin);
  598 + }
593 599
594 const C_VALUE = { 600 const C_VALUE = {
595 type: '返YOHO币', 601 type: '返YOHO币',
@@ -697,6 +703,8 @@ const _detailDataPkg = (origin, uid, vipLevel) => { @@ -697,6 +703,8 @@ const _detailDataPkg = (origin, uid, vipLevel) => {
697 result.advancePrice = result.salePrice; // 先行价格 703 result.advancePrice = result.salePrice; // 先行价格
698 delete result.salePrice; 704 delete result.salePrice;
699 } 705 }
  706 + //是否展览票
  707 + result.isTicket = origin.erpProductId * 1 === EXHIBITION_TICKET;
700 } 708 }
701 709
702 // 去掉即将售罄 710 // 去掉即将售罄
@@ -163,7 +163,8 @@ @@ -163,7 +163,8 @@
163 </ul> 163 </ul>
164 </div> 164 </div>
165 165
166 - <div class="chose-size row clearfix"> 166 + <div class="chose-size row clearfix {{#if isTicket}} hide {{/if}}">
  167 + <input type="hidden" name="isTicket" value="{{isTicket}}" />
167 <span class="title pull-left"> 168 <span class="title pull-left">
168 选区域: 169 选区域:
169 </span> 170 </span>
@@ -267,28 +268,34 @@ @@ -267,28 +268,34 @@
267 </div> 268 </div>
268 269
269 <p class="row"> 270 <p class="row">
270 - {{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}  
271 - {{#unless soldOut}}  
272 - {{# buyNow}}  
273 - <span id="buy-now" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}"  
274 - data-base="{{buyNowBase}}">立即购买</span>  
275 - {{/ buyNow}}  
276 - {{# openSoon}}  
277 - <span id="open-soon" class="buy-btn item-buy dis">即将开售</span>  
278 - {{/ openSoon}}  
279 - {{#if notForSale}}  
280 - <span class="buy-btn dis">  
281 - <i class="iconfont">&#xe61c;</i>  
282 - 非买品  
283 - </span>  
284 - {{/if}}  
285 - {{#if addToCart}}  
286 - <span id="add-to-cart" class="buy-btn item-buy add-to-cart">  
287 - <i class="iconfont">&#xe61b;</i>  
288 - 添加到购物车  
289 - </span>  
290 - {{/if}}  
291 - {{/unless}} 271 + {{#if virtualGoods}}
  272 + {{!-- 电子门票按钮 --}}
  273 + <form name="ticket-form" action="//www.yohobuy.com/cart/index/ticketEnsure" method="POST" class="hide"></form>
  274 + <span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}" >立即购买</span>
  275 + {{else}}
  276 + {{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
  277 + {{#unless soldOut}}
  278 + {{# buyNow}}
  279 + <span id="buy-now" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}"
  280 + data-base="{{buyNowBase}}">立即购买</span>
  281 + {{/ buyNow}}
  282 + {{# openSoon}}
  283 + <span id="open-soon" class="buy-btn item-buy dis">即将开售</span>
  284 + {{/ openSoon}}
  285 + {{#if notForSale}}
  286 + <span class="buy-btn dis">
  287 + <i class="iconfont">&#xe61c;</i>
  288 + 非买品
  289 + </span>
  290 + {{/if}}
  291 + {{#if addToCart}}
  292 + <span id="add-to-cart" class="buy-btn item-buy add-to-cart">
  293 + <i class="iconfont">&#xe61b;</i>
  294 + 添加到购物车
  295 + </span>
  296 + {{/if}}
  297 + {{/unless}}
  298 + {{/if}}
292 299
293 <span id="sold-out" class="buy-btn dis{{#unless soldOut}} hide{{/unless}}"> 300 <span id="sold-out" class="buy-btn dis{{#unless soldOut}} hide{{/unless}}">
294 <i class="iconfont">&#xe61c;</i> 301 <i class="iconfont">&#xe61c;</i>
@@ -396,41 +403,44 @@ @@ -396,41 +403,44 @@
396 {{/ material}} 403 {{/ material}}
397 </div> 404 </div>
398 </div> 405 </div>
399 - <div class="size-info info-block">  
400 - <p class="block-title">  
401 - <span class="title cur">尺码信息 SIZE INFO</span>  
402 - </p>  
403 - {{# size}}  
404 - <table class="size-table">  
405 - <thead>  
406 - <tr>  
407 - {{# thead}}  
408 - <th>{{name}}</th>  
409 - {{/ thead}}  
410 - </tr>  
411 - </thead>  
412 - <tbody>  
413 - {{# tbody}} 406 + {{#if goodsInfo.virtualGoods}}
  407 + <!---虚拟商品-尺码信息没有--->
  408 + {{else}}
  409 + <div class="size-info info-block">
  410 + <p class="block-title">
  411 + <span class="title cur">尺码信息 SIZE INFO</span>
  412 + </p>
  413 + {{# size}}
  414 + <table class="size-table">
  415 + <thead>
414 <tr> 416 <tr>
415 - {{#each .}}  
416 - <td>{{.}}</td>  
417 - {{/each}} 417 + {{# thead}}
  418 + <th>{{name}}</th>
  419 + {{/ thead}}
418 </tr> 420 </tr>
419 - {{/ tbody}}  
420 - </tbody>  
421 - </table>  
422 - <p class="size-tip">  
423 - ※ 以上尺寸为实物人工测量,因测量方式不同会有1-2CM误差,相关数据仅作参考,以收到实物为准。 单位:CM  
424 - </p>  
425 - <p class="size-tip">  
426 - ※ 参考尺码因衣服版型、剪裁不同会有误差,仅供参考  
427 - </p>  
428 - {{#if sizeImg}}  
429 - <img class="size-img" src="{{sizeImg}}">  
430 - {{/if}}  
431 - {{/ size}}  
432 - </div>  
433 - 421 + </thead>
  422 + <tbody>
  423 + {{# tbody}}
  424 + <tr>
  425 + {{#each .}}
  426 + <td>{{.}}</td>
  427 + {{/each}}
  428 + </tr>
  429 + {{/ tbody}}
  430 + </tbody>
  431 + </table>
  432 + <p class="size-tip">
  433 + ※ 以上尺寸为实物人工测量,因测量方式不同会有1-2CM误差,相关数据仅作参考,以收到实物为准。 单位:CM
  434 + </p>
  435 + <p class="size-tip">
  436 + ※ 参考尺码因衣服版型、剪裁不同会有误差,仅供参考
  437 + </p>
  438 + {{#if sizeImg}}
  439 + <img class="size-img" src="{{sizeImg}}">
  440 + {{/if}}
  441 + {{/ size}}
  442 + </div>
  443 + {{/if}}
434 {{#if reference}} 444 {{#if reference}}
435 <div class="reference info-block"> 445 <div class="reference info-block">
436 <p class="block-title"> 446 <p class="block-title">
@@ -31,7 +31,8 @@ var $descColor = $('#desc-color'); @@ -31,7 +31,8 @@ var $descColor = $('#desc-color');
31 var thumbsLoaded = {}; 31 var thumbsLoaded = {};
32 32
33 var $main = $('.main'), 33 var $main = $('.main'),
34 - id = $main.data('id'); 34 + id = $main.data('id'),
  35 + isTicket = $('input[name="isTicket"]').length > 0 && $('input[name="isTicket"]').val() === true;
35 36
36 var maxStock = -1; // 记录当前选中的颜色-尺码的库存量,若为-1,代表未选择尺码 37 var maxStock = -1; // 记录当前选中的颜色-尺码的库存量,若为-1,代表未选择尺码
37 38
@@ -196,6 +197,12 @@ $('.colors').on('click', 'li', function() { @@ -196,6 +197,12 @@ $('.colors').on('click', 'li', function() {
196 // 切换尺码显示 197 // 切换尺码显示
197 $sizes.not('.hide').addClass('hide').children('li').removeClass('focus'); 198 $sizes.not('.hide').addClass('hide').children('li').removeClass('focus');
198 $sizes.eq(index).removeClass('hide'); 199 $sizes.eq(index).removeClass('hide');
  200 +
  201 + //是否展览票
  202 + if (isTicket) {
  203 + $sizes.eq(index).children('li').trigger('click');
  204 + $('.chose-size').addClass('hide');
  205 + }
199 } 206 }
200 207
201 resetNum(); 208 resetNum();
@@ -377,6 +384,50 @@ $('#keep-shopping').click(function() { @@ -377,6 +384,50 @@ $('#keep-shopping').click(function() {
377 $('#balance').slideUp(SLIDETIME); 384 $('#balance').slideUp(SLIDETIME);
378 }); 385 });
379 386
  387 +//电子票立即购买
  388 +$('#buy-ticket').click(function() {
  389 + var sku,
  390 + buyNumber;
  391 +
  392 + if (maxStock === -1) {
  393 + showSizeWarn();
  394 + return;
  395 + }
  396 +
  397 + if ($(this).hasClass('dis')) {
  398 + return;
  399 + }
  400 +
  401 + sku = $('.size:not(.hide) li.focus').data('sku');
  402 + buyNumber = getNum();
  403 +
  404 + $.ajax({
  405 + type: 'POST',
  406 + url: '/cart/index/setTicket',
  407 + data: {
  408 + productSku: sku,
  409 + buyNumber: buyNumber
  410 + }
  411 + }).then(function(data) {
  412 + var $ticketForm,
  413 + myAlert;
  414 +
  415 + if (data.code * 1 === 200) {
  416 + $ticketForm = $('form[name="ticket-form"]');
  417 + $ticketForm.html(
  418 + '<input name="productSku" value="' + sku + '" />' +
  419 + '<input name="buyNumber" value="' + buyNumber + '" />'
  420 + );
  421 + $ticketForm.submit();
  422 + } else if (data.code * 1 === 401) {
  423 + document.location.href = data.message;
  424 + } else {
  425 + myAlert = new Alert(data.message);
  426 + myAlert.show();
  427 + }
  428 + });
  429 +});
  430 +
380 // 立即购买 431 // 立即购买
381 $('#buy-now').click(function() { 432 $('#buy-now').click(function() {
382 var sku, 433 var sku,
@@ -253,7 +253,8 @@ @@ -253,7 +253,8 @@
253 } 253 }
254 } 254 }
255 255
256 - .chose-size, .chose-ticket { 256 + .chose-size,
  257 + .chose-ticket {
257 font-size: 12px; 258 font-size: 12px;
258 259
259 .title { 260 .title {
@@ -436,7 +437,8 @@ @@ -436,7 +437,8 @@
436 } 437 }
437 } 438 }
438 439
439 - .buy-btn, .buy-ticket { 440 + .buy-btn,
  441 + .buy-ticket {
440 display: inline-block; 442 display: inline-block;
441 margin-right: 10px; 443 margin-right: 10px;
442 height: 48px; 444 height: 48px;