...
|
...
|
@@ -7,7 +7,7 @@ var $ = require('yoho-jquery'), // eslint-disable-line |
|
|
RAlert = rDialog.RAlert,
|
|
|
capi = require('./cart-api'),
|
|
|
yas = require('../common/data-yas'),
|
|
|
Cart;
|
|
|
Cart, cartScroll;
|
|
|
|
|
|
var $cartnewTips = $('.cartnew-tips'),
|
|
|
$cartListWrap = $('#Y_CartListWrap');
|
...
|
...
|
@@ -114,6 +114,43 @@ function toggleAll(obj, roleType) { |
|
|
capi.choiceOut(selectArray);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
cartScroll = {
|
|
|
init: function() {
|
|
|
this.$listWrap = $cartListWrap;
|
|
|
this.$win = $(window);
|
|
|
|
|
|
this.resetWindowHeight();
|
|
|
this.resetFixedWrapInfo();
|
|
|
this.onScroll();
|
|
|
|
|
|
this.$win.resize(this.resetWindowHeight.bind(this));
|
|
|
this.$win.scroll(this.onScroll.bind(this));
|
|
|
this.$listWrap.on('reset-wrap', this.resetFixedWrapInfo.bind(this));
|
|
|
},
|
|
|
resetWindowHeight: function() {
|
|
|
this.wh = this.$win.height();
|
|
|
},
|
|
|
resetFixedWrapInfo: function() {
|
|
|
var $fixedWrap = this.$listWrap.find('.cart-fixed-wrap');
|
|
|
|
|
|
this.fh = $fixedWrap.height() + $fixedWrap.offset().top;
|
|
|
},
|
|
|
onScroll: function() {
|
|
|
var num = this.$win.scrollTop() + this.wh;
|
|
|
|
|
|
if (num > this.fh) {
|
|
|
if (this.$listWrap.hasClass('fixed')) {
|
|
|
this.$listWrap.removeClass('fixed');
|
|
|
}
|
|
|
} else {
|
|
|
if (!this.$listWrap.hasClass('fixed')) {
|
|
|
this.$listWrap.addClass('fixed');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Cart = {
|
|
|
|
|
|
toggleSelectOne: function() { // 单选
|
...
|
...
|
@@ -545,17 +582,19 @@ Cart = { |
|
|
}
|
|
|
};
|
|
|
|
|
|
cartScroll.init(); // 购物车页面滚动
|
|
|
|
|
|
$cartListWrap.on('click', 'li[data-role="pitem"] .cart-item-check', Cart.toggleSelectOne); // 单选
|
|
|
$cartListWrap.on('click', '[data-role=cart-del-btn]', Cart.del); // 删除商品
|
|
|
$cartListWrap.on('click', '[data-role=cart-mov2fav-btn]', Cart.toFav); // 移入收藏夹
|
|
|
$cartListWrap.on('click', '.minus, .plus', Cart.modNum); // 修改购物车数量
|
|
|
$cartListWrap.on('click', '.cart-title .cart-item-check', Cart.toggleSelectAll); // 全选
|
|
|
$cartListWrap.on('click', '.cartnew-sum .cart-item-check', Cart.toggleSelectAll); // 全选
|
|
|
$cartListWrap.on('click', '#cbSelAllGoods', Cart.toggleSelectAll); // 全选
|
|
|
$cartListWrap.on('click', '.pre-sell-title .cart-item-check', Cart.togglePreAll); // 预售全选
|
|
|
$cartListWrap.on('click', '.ord-sell-title .cart-item-check', Cart.toggleOrdAll); // 预售全选
|
|
|
$cartListWrap.on('click', '.cartnew-sum .delete-all-sel', Cart.delAll); // 批量删除商品
|
|
|
$cartListWrap.on('click', '.cartnew-sum .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品
|
|
|
$cartListWrap.on('click', '.cartnew-sum .clean-all-disable', Cart.cleanAllDisable);
|
|
|
$cartListWrap.on('click', '.cart-fixed-submit .delete-all-sel', Cart.delAll); // 批量删除商品
|
|
|
$cartListWrap.on('click', '.cart-fixed-submit .remove-all-2fav', Cart.toFavAll); // 批量移入收藏夹商品
|
|
|
$cartListWrap.on('click', '.cart-fixed-submit .clean-all-disable', Cart.cleanAllDisable);
|
|
|
$cartListWrap.on('click', '#Y_SubmitBtn', Cart.submit); // 结算
|
|
|
$cartListWrap.on('click', '#Y_CartSelectDialog .btn-account', Cart.submitSingle);
|
|
|
|
...
|
...
|
|