red-shop.js
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* @Author: Targaryen
* @Date: 2017-03-23 11:31:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-03-24 16:32:30
*/
/* 红人店铺首页 */
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')) {
let num = $('.shop-swiper').length;
for (let i = 1; i <= num; i++) {
new Swiper2('.shop-swiper-' + i, {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
});
}
}