detail.js 1.36 KB
/**
 *  商品详情
 * @author: liangzhifeng<zhifeng.liang@yoho.cn>
 * @date: 2015/10/20
 */
 var $ = require('jquery'),
    Swiper = require('yoho.iswiper'),
    lazyLoad = require('yoho.lazyload');

var goodsSwiper,
    $discountFolder = $('.goodsDiscount .discount-folder'),
    $discountArrow = $('.goodsDiscount .first-item span');


require('./desc');
require('./comments-consults');

//add extra marign-bottom for footer to show the yoho copyright
window.reMarginFooter('.cart-bar');

lazyLoad($('img.lazy'));

//顶部swiper
goodsSwiper = new Swiper('.banner-swiper', {
    lazyLoading: true,
    lazyLoadingInPrevNext: true,
    paginationClickable: true,
    pagination: '.banner-top .pagination-inner',
    nextButton: '.my-swiper-button-next',
    prevButton: '.my-swiper-button-prev'
});


//初始化goods-discount
if (0 === $('.goodsDiscount .discount-folder').children().length) {
    $discountFolder.css('display', 'none');
    $discountArrow.html('');
}

//goods-discount下拉按钮点击事件
$('.goodsDiscount .dropdown').on('click', function() {
    if ($discountFolder.is(':hidden')) {
        $discountArrow.removeClass('icon-down').addClass('icon-up').html('&#xe608;');
        $discountFolder.slideDown();
    } else {
        $discountArrow.removeClass('icon-up').addClass('icon-down').html('&#xe609;');
        $discountFolder.slideUp();
    }
});
require('./like');