index.js
1.56 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
/**
* 个人中心首页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/2/17
*/
var $ = require('yoho.jquery');
require('./order-block');
//关闭消息提示
$('#close-message').click(function() {
$('.message-tip').slideUp(200);
});
//新品上架
(function() {
var $naPager = $('.na-pager'),
$naUl = $('.new-arrival ul'),
naPage = Math.ceil($naUl.children('li').length / 5),
naItemWith = $naUl.children('li:last-child').outerWidth(),
naCurPage = 1;
$naUl.width($naUl.width() * naPage);
//最新上架翻页
$naPager.click(function() {
var $this = $(this),
left;
if ($this.hasClass('next')) {
//后翻
++naCurPage;
//第2页显示前翻按钮
if (naCurPage === 2) {
$this.siblings().removeClass('no-visible');
}
//最后一页隐藏后翻按钮
if (naCurPage === naPage) {
$this.addClass('no-visible');
}
} else {
//前翻
--naCurPage;
//倒数第2页显示后翻按钮
if (naCurPage === naPage - 1) {
$this.siblings().removeClass('no-visible');
}
//第1页隐藏前翻按钮
if (naCurPage === 1) {
$this.addClass('no-visible');
}
}
left = -5 * (naCurPage - 1) * naItemWith;
$naUl.animate({
marginLeft: left
}, 400);
});
}());