sale.page.js
1.88 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
/**
* 商品列表页
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/5/17
*/
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyload = require('yoho-jquery-lazyload');
var search = require('./sale/search');
require('../common');
search.start();
$('.swiper-container').each(function() {
if ($(this).find('.swiper-slide').length > 1) {
new Swiper($(this).get(0), {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: true,
paginationClickable: true,
pagination: $(this).closest('.banner-top').find('.pagination-inner').get(0)
});
}
});
$(function() {
var $body = $('body');
var $saleNavSelect = $('.sale-nav-select');
var $vipFloor = $('.vip-floor');
var $saleNavWrap = $('.sale-nav-wrap');
var $listNav = $saleNavWrap.find('#list-nav');
$('.sale-nav').on('click', function() {
$saleNavSelect.toggleClass('show');
});
lazyload($('img.lazy'));
// 读取会员专享商品
$.ajax({
url: '/product/sale/search',
data: {
channel: window.queryString.channel || 'boys',
yh_channel: window.queryString.channel || 'boys',
saleType: '2',
type: 'all',
order: '0',
limit: '4'
}
}).then(function(res) {
if (/good-info/.test(res)) {
$vipFloor.html(res).addClass('goods-container');
lazyload($vipFloor.find('img.lazy'));
}
});
$saleNavWrap.css({
height: $saleNavWrap.height()
});
$(window).on('scroll', function() {
if ($body.scrollTop() > $saleNavWrap.offset().top) {
$listNav.addClass('fixed');
} else {
$listNav.removeClass('fixed');
}
}).trigger('scroll');
});