cart.page.js
2.47 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* 订单结算页
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2016/12/27
*/
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
$sellBox = $('.cart-table .pre-sell-box');
require('../plugins/slider');
require('../common/center-slider');
require('../common');
$('.side-img-dd').slider2({
shownum: 5,
isCircle: true
});
// var dialogTpl = require('hbs/cart/cart-togetherGoods.hbs');
lazyLoad($('#details-html img'));
function isCheckAll() {
var isAllCheck = true;
$('[data-role=pitem] [data-role=cart-item-check]').each(function() {
// 有一个没选中,跳出循环
if (!$(this).hasClass('cart-item-checked')) {
isAllCheck = false;
return false;
}
});
if (isAllCheck) {
// 头部全选
$('.cart-title .cart-item-check').addClass('cart-item-checked');
// 底部全选
$('#cbSelAllGoods').addClass('cart-item-checked');
}
}
// 判断商品是否已收藏,是否全选
function isCheckFav() {
var pidArray = [];
$sellBox.each(function() {
pidArray.push($(this).data('pid'));
});
$.ajax({
type: 'POST',
url: '/cart/cart/checkFav',
data: {
pidList: pidArray.join(',')
}
}).done(function(result) {
$.each(result.data, function(pid, obj) {
if (obj.code !== 200) {
return false;
}
if (obj.data) {
$sellBox.each(function() {
if (String($(this).data('pid')) === String(pid)) {
$(this).find('.cart-col-btn').addClass('has-col-btn').html('已收藏');
return false;
}
});
}
});
});
}
$(function() {
var $itemChecked = $('[data-role=pitem] .cart-item-checked');
$('.bottom-tab .change').click(function() {
$('.img-brand-switch .next').trigger('click');
});
// 商品子优惠显示和隐藏
$('.sale-info').mouseenter(function() {
$(this).addClass('active').children('ul').removeClass('none');
}).mouseleave(function() {
$(this).removeClass('active').children('ul').addClass('none');
});
isCheckAll();
isCheckFav();
if ($itemChecked.length === 0) {
$('#Y_SubmitBtn').addClass('btn-account-disable');
}
});
require('./cart-action');
require('./cart-color-panel');
require('./cart-goods-win');
require('./cart-together');