orders.js
1.84 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
/**
* 我的订单
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/2/17
*/
var $ = require('yoho.jquery');
require('./order-block');
//不同订单包裹提示
$('.why').click(function() {
$('#differentBag').show();
return false;
});
$('#differentBag').click(function() {
return false;
});
$(document).click(function() {
$('#differentBag').hide();
});
//订单包裹左右切换
function lunBo($pre, $next, $ul, $iWidth) {
var i = 1,
j = 1;
var iSpeed = 0,
isMoving = false;
$pre.click(function() {
if (isMoving) {
return;
}
if ($ul.css('left') === '0px') {
iSpeed = 0;
} else {
iSpeed += j * $iWidth;
isMoving = true;
}
$ul.stop().animate({
left: iSpeed
}, 300, function() {
isMoving = false;
});
});
$next.click(function() {
var $largeLeft = $ul.parent().width() - $ul.width() + 'px';
if (isMoving) {
return;
}
if ($ul.css('left') === $largeLeft) {
$ul.css('left', $largeLeft);
} else {
iSpeed += -i * $iWidth;
isMoving = true;
}
$ul.stop().animate({
left: iSpeed
}, 300, function() {
isMoving = false;
});
});
}
//订单分类
$('.bag').find('ul').each(function() {
var $pre = $(this).parent().parent().find('.pre');
var $next = $(this).parent().parent().find('.next');
var $iWidth = $(this).find('li').eq(0).width();
var $length = $(this).find('li').size();
var $ulWidth = $iWidth * $length;
$(this).css('width', $ulWidth);
if ($length > 5) {
$pre.show();
$next.show();
lunBo($pre, $next, $(this), $iWidth);
} else {
$pre.hide();
$next.hide();
}
});