template.js
1.37 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
/**
* 模板页js
* @author: xuqi(qi.xu@yoho.cn)
* @date;2015/4/14
*/
var $ = require('jquery'),
timer = null;
require('lazyload');
/**
* 页面加载初始化
*/
exports.init = function() {
$(function() {
var $navItem = $('#goods-nav .nav-item'),
$goodsContainer = $('#goods-container'),
$goodList = $('#goods-container > div'),
$npc = $goodList.filter('.new-patterns-container'),
$svc = $goodList.filter('.sales-volume-container'),
$pc = $goodList.filter('.price-container');
//img lazyload
$('img.lazy').lazyload({
skip_invisible : false
});
//切换“最新”,“销量”,“价格”,“筛选”
$('#goods-nav').delegate('.nav-item', 'touchstart', function() {
var $cur = $(this);
if ($cur.hasClass('focus')) {
return;
}
$navItem.removeClass('focus');
$cur.addClass('focus');
$goodList.addClass('hide');
if ($cur.hasClass('new-patterns-nav')) {
$npc.removeClass('hide');
} else if ($cur.hasClass('sales-volume-nav')) {
$svc.removeClass('hide');
} else if ($cur.hasClass('price-nav')) {
$pc.removeClass('hide');
} else {
}
});
});
};