|
@@ -5,6 +5,7 @@ |
|
@@ -5,6 +5,7 @@ |
5
|
*/
|
5
|
*/
|
6
|
|
6
|
|
7
|
var $ = require('jquery'),
|
7
|
var $ = require('jquery'),
|
|
|
8
|
+ ellipsis = require('mlellipsis'),
|
8
|
Hammer = require('yoho.hammer');
|
9
|
Hammer = require('yoho.hammer');
|
9
|
|
10
|
|
10
|
var chosePanel = require('./chose-panel'),
|
11
|
var chosePanel = require('./chose-panel'),
|
|
@@ -13,23 +14,36 @@ var chosePanel = require('./chose-panel'), |
|
@@ -13,23 +14,36 @@ var chosePanel = require('./chose-panel'), |
13
|
|
14
|
|
14
|
var $cartContent = $('.cart-content'),
|
15
|
var $cartContent = $('.cart-content'),
|
15
|
cartType = $('#cartType').val(),
|
16
|
cartType = $('#cartType').val(),
|
|
|
17
|
+ $cartNav = $('.cart-nav'),
|
16
|
hasShowCartPresellTip = false;
|
18
|
hasShowCartPresellTip = false;
|
17
|
|
19
|
|
18
|
-var $cartContentShow = $cartContent.not('.hide');
|
|
|
19
|
-
|
|
|
20
|
var navHammer,
|
20
|
var navHammer,
|
21
|
advanceBuyHammer,
|
21
|
advanceBuyHammer,
|
22
|
freebieHammer,
|
22
|
freebieHammer,
|
23
|
switchChose = false;
|
23
|
switchChose = false;
|
24
|
|
24
|
|
25
|
require('../product/recommend-for-you');
|
25
|
require('../product/recommend-for-you');
|
|
|
26
|
+require('./good');
|
|
|
27
|
+
|
|
|
28
|
+ellipsis.init();
|
|
|
29
|
+
|
|
|
30
|
+function cartContentShow() {
|
|
|
31
|
+ return $cartContent.not('.hide');
|
|
|
32
|
+}
|
|
|
33
|
+
|
|
|
34
|
+function mlellipsisHiddenNames() {
|
|
|
35
|
+ cartContentShow().find('.shopping-cart-good .name').each(function() {
|
|
|
36
|
+ this.mlellipsis(2);
|
|
|
37
|
+ });
|
|
|
38
|
+ switchChose = true;
|
|
|
39
|
+}
|
26
|
|
40
|
|
27
|
function hasChecked() {
|
41
|
function hasChecked() {
|
28
|
- return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false;
|
42
|
+ return cartContentShow().find('.cart-goods .icon-cb-checked').length > 0 ? true : false;
|
29
|
}
|
43
|
}
|
30
|
|
44
|
|
31
|
function shouldSelectGift() {
|
45
|
function shouldSelectGift() {
|
32
|
- var $freebie = $cartContentShow.find('.freebie');
|
46
|
+ var $freebie = cartContentShow().find('.freebie');
|
33
|
|
47
|
|
34
|
if ($freebie.length <= 0) {
|
48
|
if ($freebie.length <= 0) {
|
35
|
return false;
|
49
|
return false;
|
|
@@ -70,16 +84,12 @@ function showChooseGifDialog() { |
|
@@ -70,16 +84,12 @@ function showChooseGifDialog() { |
70
|
rightBtnText: '去选择'
|
84
|
rightBtnText: '去选择'
|
71
|
}
|
85
|
}
|
72
|
}, function() {
|
86
|
}, function() {
|
73
|
- window.location.href = $cartContentShow.find('.freebie > a').attr('href');
|
87
|
+ window.location.href = cartContentShow().find('.freebie > a').attr('href');
|
74
|
}, function() {
|
88
|
}, function() {
|
75
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
89
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
76
|
});
|
90
|
});
|
77
|
}
|
91
|
}
|
78
|
|
92
|
|
79
|
-require('./good');
|
|
|
80
|
-
|
|
|
81
|
-//lazyLoad($('img.lazy'));
|
|
|
82
|
-
|
|
|
83
|
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
|
93
|
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
|
84
|
$('#presell-tip').removeClass('show').addClass('hide');
|
94
|
$('#presell-tip').removeClass('show').addClass('hide');
|
85
|
hasShowCartPresellTip = true;
|
95
|
hasShowCartPresellTip = true;
|
|
@@ -91,12 +101,12 @@ if ('advance' === cartType) { |
|
@@ -91,12 +101,12 @@ if ('advance' === cartType) { |
91
|
$cartContent.toggleClass('hide');
|
101
|
$cartContent.toggleClass('hide');
|
92
|
$('#common-cart-nav').removeClass('active');
|
102
|
$('#common-cart-nav').removeClass('active');
|
93
|
$('#presell-cart-nav').addClass('active');
|
103
|
$('#presell-cart-nav').addClass('active');
|
94
|
- $('.shopping-cart-good .name').each(function() {
|
|
|
95
|
- this.mlellipsis(2);
|
|
|
96
|
- });
|
104
|
+
|
|
|
105
|
+ mlellipsisHiddenNames();
|
|
|
106
|
+ $(window).trigger('scroll');
|
97
|
}
|
107
|
}
|
98
|
|
108
|
|
99
|
-if ($('.cart-nav').length > 0) {
|
109
|
+if ($cartNav.length > 0) {
|
100
|
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
|
110
|
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
|
101
|
navHammer.on('tap', function(e) {
|
111
|
navHammer.on('tap', function(e) {
|
102
|
var $this = $(e.target).closest('li');
|
112
|
var $this = $(e.target).closest('li');
|
|
@@ -119,13 +129,8 @@ if ($('.cart-nav').length > 0) { |
|
@@ -119,13 +129,8 @@ if ($('.cart-nav').length > 0) { |
119
|
//切换普通商品和预售商品购物车显示
|
129
|
//切换普通商品和预售商品购物车显示
|
120
|
$cartContent.toggleClass('hide');
|
130
|
$cartContent.toggleClass('hide');
|
121
|
|
131
|
|
122
|
- $cartContentShow = $cartContent.not('.hide');
|
|
|
123
|
-
|
|
|
124
|
if (switchChose === false) {
|
132
|
if (switchChose === false) {
|
125
|
- $cartContentShow.find('.shopping-cart-good .name').each(function() {
|
|
|
126
|
- this.mlellipsis(2);
|
|
|
127
|
- });
|
|
|
128
|
- switchChose = true;
|
133
|
+ mlellipsisHiddenNames();
|
129
|
}
|
134
|
}
|
130
|
|
135
|
|
131
|
//trigger lazyload
|
136
|
//trigger lazyload
|
|
@@ -176,16 +181,11 @@ $('.chose').on('touchend', function() { |
|
@@ -176,16 +181,11 @@ $('.chose').on('touchend', function() { |
176
|
chosePanel.show();
|
181
|
chosePanel.show();
|
177
|
});
|
182
|
});
|
178
|
|
183
|
|
179
|
-function notAllowScroll() {
|
|
|
180
|
- var docH = $(document).height(),
|
|
|
181
|
- winH = $(window).height();
|
|
|
182
|
-
|
|
|
183
|
- if (docH - winH <= 10) {
|
|
|
184
|
- $('body').css('overflow', 'hidden');
|
|
|
185
|
- }
|
|
|
186
|
-}
|
|
|
187
|
-
|
|
|
188
|
-notAllowScroll();
|
184
|
+$cartNav.on('touchstart', 'li', function(e) {
|
|
|
185
|
+ $(this).addClass('bytouch');
|
|
|
186
|
+}).on('touchend touchcancel', function() {
|
|
|
187
|
+ $cartNav.find('li').removeClass('bytouch');
|
|
|
188
|
+});
|
189
|
|
189
|
|
190
|
//提前触发lazyload
|
190
|
//提前触发lazyload
|
191
|
$(window).scrollTop(1).scrollTop(0); |
191
|
$(window).scrollTop(1).scrollTop(0); |