public.js
3.68 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* 首页 JS
* @author xuqi/liuyue
* @date: 2015/7/15
*/
var $ = require('jquery'),
swiper = require('yoho-idangerous.swiper'),
lazyLoad = require('./common/lazyload'),
bannerSwiper,
hotBrandsSwiper,
recommendSwiper,
trendTopicSwiper,
goodsSwiper;
require('./common/maybe-like');
//lazyload
lazyLoad();
//点击首页汉堡menu图标,滑出侧栏导航
$('.nav-btn').on('click', function(event) {
if (!$(this).hasClass('menu-open')) {
$('.mobile-wrap').addClass('menu-open');
$('.overlay').addClass('show');
//设置boy高度,页面不能上下滑动
$('body').css({
height: $(window).height(),
overflow: 'hidden'
});
}
event.stopPropagation();
});
//点击页面主体,收起侧栏导航及二级导航
$('.mobile-wrap').on('click', function() {
if ($(this).hasClass('menu-open')) {
$('.mobile-wrap').removeClass('menu-open');
$('.overlay').removeClass('show');
$('.sub-nav').removeClass('show');
$('body').css({
height: 'auto',
overflow: 'auto'
})
}
});
//点击一级导航,弹出二级导航
$('.side-nav').on('click', 'li', function() {
if ($(this).find('.sub-nav').size() > 0) {
$('.sub-nav').removeClass('show');
$(this).find('.sub-nav').addClass('show');
}
});
//返回一级导航,收起二级导航
$('.sub-nav').each(function() {
$(this).find('li').eq(0).on('click', function() {
$('.sub-nav').removeClass('show');
event.stopPropagation();
});
});
//头部banner轮播
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new swiper('.banner-swiper', {
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner',
onSlideChangeStart: function() {
lazyLoad($('.banner-swiper .swiper-slide').eq(bannerSwiper.activeIndex).find('img'));
}
});
};
//热门品牌滑动
hotBrandsSwiper = new swiper('.brands-swiper', {
grabCursor: true,
slidesPerView: 'auto',
wrapperClass: 'brands-list',
slideElement: 'li'
});
//推荐搭配滑动
recommendSwiper = new swiper('.recommend-swiper', {
grabCursor: true,
slidesPerView: 'auto',
wrapperClass: 'recommend-list',
slideElement: 'li'
});
//潮品话题轮播
if ($('.trend-topic-swiper').find('li').size() > 1) {
trendTopicSwiper = new swiper('.trend-topic-swiper', {
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.trend-topic-content .pagination-inner',
onSlideChangeStart: function() {
lazyLoad($('.trend-topic-swiper .swiper-slide').eq(trendTopicSwiper.activeIndex).find('img'));
}
});
};
//潮流上装/经典裤装等轮播
$('.category-swiper').each(function(i, index) {
var swiperClass = 'category-swiper' + i;
$(this).addClass(swiperClass);
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
goodsSwiper = new swiper('.' + swiperClass, {
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.' + swiperClass + ' .pagination-inner'
});
}
});
//回到顶部
$('.back-to-top').bind('touchstart', function(e) {
e.preventDefault();
$(window).scrollTop(0);
});
//关闭头部下载浮层
$('.header-download').on('click', '.close-btn', function() {
$(this).parent().remove();
});