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


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

goodsSwiper = new Swiper('.banner-swiper', {
    lazyLoading: true,
    lazyLoadingInPrevNext: true,
    loop: true,
    paginationClickable: true,
    pagination: '.swiper-pagination',
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev'
});


$('#nav-tab li').on('click', function() {
    var index = $(this).index();


    if (!$(this).hasClass('focus')) {

        $('#nav-tab li').each(function() {
            $(this).removeClass('focus');
        });
        $('#feedback-content .content').each(function() {
            $(this).addClass('hide');
        });

        $(this).addClass('focus');
        $('#feedback-content .content:eq(' + index + ')').removeClass('hide');
    }
});

sizeSwiper = new Swiper('#size-swiper-container',{
    slidesPerView: 'auto'
});

refSwiper = new Swiper('#reference-swiper-container',{
    slidesPerView: 'auto'
});


handleHelper = Handlebars.registerHelper('addOne', function(index) {
    return index + 1;
});

// $('#iframe').load(function() {
//     var mainheight = $(this).contents().find('body').height() + 30;
//     $(this).height(mainheight);
// });