red-shop.js 1.51 KB
/*
 * @Author: Targaryen
 * @Date: 2017-03-23 11:31:51
 * @Last Modified by: Targaryen
 * @Last Modified time: 2017-03-28 09:46:21
 */
/* 红人店铺首页 */
const Swiper2 = require('yoho-swiper2');

let $shopIntroFolder = $('.shop-intro-folder');
let $shortIntro = $('#shortIntro');
let $shopIntro = $('#shopIntro');
let $shopIntrArrw = $('#shopIntrArrw');
let $goodsContainer = $('.index-goods-container');

/**
 * 店铺介绍展开收起
 */
$shopIntroFolder.on('click', function() {
    $shortIntro.toggleClass('hide');
    $shopIntro.toggleClass('active');

    if ($shopIntro.hasClass('active')) {
        $shopIntrArrw.html('');
    } else {
        $shopIntrArrw.html('');
    }
});

/**
 * 异步加载人气单品
 */
$.each($goodsContainer, function(index, elem) {
    $.ajax({
        type: 'GET',
        url: location.protocol + '//m.yohobuy.com/product//new/shop/hotlist',
        xhrFields: {
            withCredentials: true
        },
        data: {
            skns: $(elem).data('skns')
        },
        success: function(result) {
            $(elem).html(result);
        }
    });
});

/**
 * 店铺轮播图
 */
if ($('.shop-swiper').length > 0) {
    let num = $('.shop-swiper').length;

    for (let i = 1; i <= num; i++) {
        new Swiper2('.shop-swiper-' + i, {
            lazyLoadingInPrevNext: true,
            loop: true,
            autoplay: 3000,
            autoplayDisableOnInteraction: false,
            paginationClickable: true,
            slideElement: 'li',
        });
    }
}