sale.page.js
1.18 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
var $ = require('yoho-jquery'),
$saleBox = $('.sale-box'),
$navItem = $('.sale-nav li'),
lazyLoad = require('yoho-jquery-lazyload');
var product = require('./product');
require('./sale/banner');
require('../common/slider');
require('../common/filter');
require('../common/sort-pager');
product.init(4);
lazyLoad($('img.lazy'));
$('.slide-container').slider();
// 请求带导航的列表数据
function getNaviData(items) {
var location, url, goodItems, navTitle;
navTitle = items.attr('urlLocation');
location = 'http://localhost:6002/product/sale/goods';
goodItems = items.parent().parent('.sale-box').find('.goods');
url = location + navTitle;
$.ajax({
type: 'GET',
url: url,
data: ''
}).then(function(res) {
goodItems.html('');
goodItems.append(res);
lazyLoad($('img.lazy'));
});
}
$navItem.on('click', function() {
$(this).siblings('.active').removeClass('active');
$(this).addClass('active');
getNaviData($(this));
});
// 初始化页面数据
(function() {
$saleBox.each(function() {
var item = $(this).find($navItem).eq(0);
getNaviData(item);
});
}());