Authored by lijing

秒杀详情动态数据

@@ -60,7 +60,7 @@ exports.index = (req, res, next) => { @@ -60,7 +60,7 @@ exports.index = (req, res, next) => {
60 res.render('detail/detail', { 60 res.render('detail/detail', {
61 pageHeader: headerData, 61 pageHeader: headerData,
62 result: result, 62 result: result,
63 - page: 'detail', 63 + page: 'seckill-detail',
64 title: result.goodsName, 64 title: result.goodsName,
65 pageFooter: true 65 pageFooter: true
66 }); 66 });
@@ -94,7 +94,7 @@ exports.indexSkn = (req, res, next) => { @@ -94,7 +94,7 @@ exports.indexSkn = (req, res, next) => {
94 res.render('detail/detail', { 94 res.render('detail/detail', {
95 pageHeader: headerData, 95 pageHeader: headerData,
96 result: result, 96 result: result,
97 - page: 'detail', 97 + page: 'seckill-detail',
98 title: result.goodsName, 98 title: result.goodsName,
99 pageFooter: true 99 pageFooter: true
100 }); 100 });
@@ -623,7 +623,6 @@ let getProductData = (data) => { @@ -623,7 +623,6 @@ let getProductData = (data) => {
623 finalResult.enterStore = info[0]; 623 finalResult.enterStore = info[0];
624 finalResult.isStudent = data.isStudent; 624 finalResult.isStudent = data.isStudent;
625 Object.assign(finalResult.feedbacks, info[2]); 625 Object.assign(finalResult.feedbacks, info[2]);
626 - Object.assign(finalResult, {isSecKill: result.isSecKill});  
627 finalResult.goodsPrice.previousPrice = '¥' + result.marketPrice; 626 finalResult.goodsPrice.previousPrice = '¥' + result.marketPrice;
628 627
629 /* 预售商品不能购买 */ 628 /* 预售商品不能购买 */
@@ -232,7 +232,5 @@ @@ -232,7 +232,5 @@
232 <input type="hidden" id="showPannel" value="1"> 232 <input type="hidden" id="showPannel" value="1">
233 {{/if}} 233 {{/if}}
234 234
235 - <input type="hidden" id="isSecKill" value = "{{isSecKill}}">  
236 -  
237 </div> 235 </div>
238 {{/ result}} 236 {{/ result}}
@@ -23,10 +23,6 @@ var dialog = require('../plugin/dialog'); @@ -23,10 +23,6 @@ var dialog = require('../plugin/dialog');
23 23
24 require('../common'); 24 require('../common');
25 25
26 -if ($('#isSecKill').val() === 'Y') {  
27 - require('./tick');  
28 -}  
29 -  
30 // add extra marign-bottom for footer to show the yoho copyright 26 // add extra marign-bottom for footer to show the yoho copyright
31 function showFooter() { 27 function showFooter() {
32 var $cartBar = $('.cart-bar'); 28 var $cartBar = $('.cart-bar');
  1 +/**
  2 + * 商品详情
  3 + * @author: liangzhifeng<zhifeng.liang@yoho.cn>
  4 + * @date: 2015/10/20
  5 + */
  6 +var $ = require('yoho-jquery'),
  7 + Swiper = require('yoho-swiper'),
  8 + Hammer = require('yoho-hammer'),
  9 + lazyLoad = require('yoho-jquery-lazyload');
  10 +
  11 +var $discountFolder = $('.goods-discount .discount-folder'),
  12 + $discountArrow = $('.goods-discount .first-item span');
  13 +
  14 +var goodsDiscountEl = document.getElementById('goodsDiscount'),
  15 + goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl),
  16 + $discountFirstItem = $(goodsDiscountEl).find('.first-item');
  17 +
  18 +var $cart = $('.cart-bar');
  19 +
  20 +var appUrl = $('input[name="limitCodeUrl"]').val();
  21 +
  22 +var dialog = require('../plugin/dialog');
  23 +
  24 +require('../common');
  25 +
  26 +require('./tick');
  27 +
  28 +// add extra marign-bottom for footer to show the yoho copyright
  29 +function showFooter() {
  30 + var $cartBar = $('.cart-bar');
  31 +
  32 + var timer = setInterval(function() {
  33 + if ($cartBar) {
  34 + window.reMarginFooter('.cart-bar');
  35 + clearInterval(timer);
  36 + } else {
  37 + $cartBar = $('.cart-bar');
  38 + }
  39 + }, 200);
  40 +}
  41 +
  42 +showFooter();
  43 +
  44 +lazyLoad($('img.lazy'));
  45 +
  46 +if ($('#goodsDiscount h1').length < 1) {
  47 + $('.dropdown').remove();
  48 +}
  49 +
  50 +// 顶部swiper
  51 +new Swiper('.banner-swiper', {
  52 + lazyLoading: true,
  53 + lazyLoadingInPrevNext: true,
  54 + paginationClickable: true,
  55 + pagination: '.banner-top .pagination-inner',
  56 + nextButton: '.my-swiper-button-next',
  57 + prevButton: '.my-swiper-button-prev',
  58 + spaceBetween: 3
  59 +});
  60 +
  61 +// 初始化goods-discount
  62 +if ($discountFolder.children().length === 0) {
  63 + $discountFolder.css('display', 'none');
  64 + $discountArrow.html('');
  65 +}
  66 +
  67 +// goods-discount下拉按钮点击事件
  68 +if (goodsDiscountHammer && $discountFolder.children().length > 0) {
  69 + goodsDiscountHammer.on('tap', function() {
  70 + if ($discountFolder.is(':hidden')) {
  71 + $discountFirstItem.removeClass('short-text');
  72 + $discountArrow.removeClass('icon-down').addClass('icon-up').html('&#xe608;');
  73 + $discountFolder.slideDown();
  74 + } else {
  75 + $discountFirstItem.addClass('short-text');
  76 + $discountArrow.removeClass('icon-up').addClass('icon-down').html('&#xe609;');
  77 + $discountFolder.slideUp();
  78 + }
  79 + });
  80 +}
  81 +
  82 +$('#limit-sale').on('touchend', function(e) {
  83 + var loginUrl = $('#loginUrl').val(),
  84 + time,
  85 + ifr;
  86 +
  87 + e.stopPropagation();
  88 +
  89 + if (loginUrl) {
  90 + window.location = loginUrl;
  91 + } else {
  92 + dialog.showDialog({
  93 + dialogText: '进入有货APP,获取限购码',
  94 + hasFooter: {
  95 + rightBtnText: '打开Yoho!Buy有货APP'
  96 + }
  97 + }, function() {
  98 + ifr = document.createElement('iframe');
  99 + ifr.src = appUrl;
  100 + ifr.style.display = 'none';
  101 + document.body.appendChild(ifr);
  102 + window.location.href = appUrl;
  103 +
  104 + time = Date.now();
  105 + window.setTimeout(function() {
  106 + document.body.removeChild(ifr);
  107 + if (Date.now() - time < 3200) {
  108 + window.location.href = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho';
  109 + }
  110 + }, 3000);
  111 +
  112 + }, null, true);
  113 +
  114 + $('.dialog-wrapper').off('touchstart').on('touchstart', function(para) {
  115 + para.stopPropagation();
  116 + if ($(para.target).hasClass('dialog-wrapper')) {
  117 + dialog.hideDialog();
  118 + }
  119 + });
  120 + }
  121 +});
  122 +
  123 +require('./detail/like');
  124 +require('./detail/desc');
  125 +require('./detail/comments-consults');
  126 +require('./detail/consultform');
  127 +require('./detail/recommend-for-you-product-desc');
  128 +
  129 +// 购物车商品数量
  130 +$.ajax({
  131 + type: 'GET',
  132 + url: '/cart/index/count',
  133 + success: function(data) {
  134 + var count;
  135 +
  136 + if (data.code === 200) {
  137 + count = data.data.cart_goods_count || 0;
  138 + if (count === 0) {
  139 + return false;
  140 + }
  141 + if (count > 99) {
  142 + count = '99+';
  143 + }
  144 + $cart.find('.num-tag').html(count).removeClass('hide');
  145 + }
  146 + }
  147 +});
  148 +
  149 +if ($('.good-detail-page').length > 0) {
  150 + $('#yoho-footer').css('border-top', '1px solid #e0e0e0');
  151 +}