...
|
...
|
@@ -2914,6 +2914,7 @@ $loginBtn.on('touchstart', function() { |
|
|
});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -3062,6 +3063,7 @@ $loginBtn.on('touchstart', function() { |
|
|
});
|
|
|
} else {
|
|
|
showErrTip('账号或密码有错误,请重新输入');
|
|
|
$loginBtn.text('登录').removeClass('disable');
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -4231,11 +4233,18 @@ $.ajax({ |
|
|
type: 'GET',
|
|
|
url: '/cart/index/count',
|
|
|
success: function(data) {
|
|
|
var count;
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
$cart.find('.cart-count').html(data.data.cart_goods_count).removeClass('hide');
|
|
|
count = data.data.cart_goods_count;
|
|
|
if (count > 99) {
|
|
|
count = '99+';
|
|
|
}
|
|
|
$cart.find('.cart-count').html(count).removeClass('hide');
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
});
|
|
|
define("js/product/newsale/discount", ["jquery","swiper","lazyload","hammer","index"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -5578,13 +5587,17 @@ var panelTmpl, |
|
|
$chosePanel = $('#chose-panel'),
|
|
|
$num,
|
|
|
$chosed,
|
|
|
re = /\d+/,
|
|
|
|
|
|
// re = /\d+/,
|
|
|
leftNum,
|
|
|
$colorList,
|
|
|
$sizeList,
|
|
|
firstColorId,
|
|
|
colorIndex,
|
|
|
confirming;
|
|
|
confirming,
|
|
|
hasChooseColor = false,
|
|
|
hasChooseSize = false,
|
|
|
curColorIndex,
|
|
|
curSizeIndex,
|
|
|
$curSizeRow,
|
|
|
$curSizeBlock = null,
|
|
|
$sizeRowList = $('.size-list ul');
|
|
|
|
|
|
// 读取模板
|
|
|
$.get('/cart/index/giftinfoTpl', function(html) {
|
...
|
...
|
@@ -5599,45 +5612,61 @@ $.get('/cart/index/giftinfoTpl', function(html) { |
|
|
|
|
|
//初始化购物车面板显示
|
|
|
function init() {
|
|
|
$colorList = $('.chose-panel .color-list ul>li');
|
|
|
$sizeList = $('.chose-panel .size-list ul>li');
|
|
|
firstColorId = $colorList.eq(0).data('id');
|
|
|
$sizeList.each(function() {
|
|
|
colorIndex = $(this).data('colorid');
|
|
|
|
|
|
if (colorIndex === firstColorId) {
|
|
|
$(this).removeClass('hide');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
//$colorList = $('.chose-panel .color-list ul>li');
|
|
|
//$sizeList = $('.chose-panel .size-list ul>li');
|
|
|
//firstColorId = $colorList.eq(0).data('id');
|
|
|
//$sizeList.each(function() {
|
|
|
// colorIndex = $(this).data('colorid');
|
|
|
//
|
|
|
// if (colorIndex === firstColorId) {
|
|
|
// $(this).removeClass('hide');
|
|
|
// }
|
|
|
//});
|
|
|
|
|
|
init();
|
|
|
var $firstRow = $sizeRowList.eq(0);
|
|
|
|
|
|
//显示
|
|
|
// function show(data) {
|
|
|
// // var html = tpl(data);
|
|
|
// $('.chose-panel').show();
|
|
|
// // $page.append(html);
|
|
|
// $('.chose-panel')
|
|
|
// $num = $('#good-num');
|
|
|
// }
|
|
|
$firstRow.toggleClass('hide');
|
|
|
$curSizeRow = $firstRow;
|
|
|
}
|
|
|
|
|
|
function checkColorSizeNum() {
|
|
|
if (!hasChooseColor && !hasChooseSize) {
|
|
|
tip.show('请选择颜色和尺码~');
|
|
|
return false;
|
|
|
} else if (!hasChooseColor) {
|
|
|
tip.show('请选择颜色~');
|
|
|
return false;
|
|
|
} else if (!hasChooseSize) {
|
|
|
tip.show('请选择尺码~');
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
init();
|
|
|
|
|
|
function show(data) {
|
|
|
if (data) {
|
|
|
$chosePanel.html(panelTmpl(data));
|
|
|
init();
|
|
|
}
|
|
|
|
|
|
$('.chose-panel').show();
|
|
|
|
|
|
$('body').css('overflow', 'hidden');
|
|
|
$num = $('#good-num');
|
|
|
}
|
|
|
|
|
|
//移除当前Panel
|
|
|
function remove() {
|
|
|
////显示当前Panel
|
|
|
//function show() {
|
|
|
// $('.chose-panel').show();
|
|
|
//
|
|
|
// $('body').css('overflow', 'hidden');
|
|
|
// $num = $('#good-num');
|
|
|
//}
|
|
|
|
|
|
//隐藏当前Panel
|
|
|
function hide() {
|
|
|
$('.chose-panel').hide();
|
|
|
$('body').css('overflow', 'auto');
|
|
|
}
|
...
|
...
|
@@ -5650,87 +5679,223 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
}
|
|
|
|
|
|
//点击蒙版消失
|
|
|
remove();
|
|
|
}).on('touchstart', '#chose-btn-sure', function() {
|
|
|
hide();
|
|
|
});
|
|
|
|
|
|
var productSku,
|
|
|
buyNumber = $('#good-num').val() - 0,
|
|
|
$('.color-list').on('touchstart', '.block', function(e) {
|
|
|
var $this = $(this),
|
|
|
$that = $(e.target).closest('.chose-items'),
|
|
|
index,
|
|
|
curSelectedSizeBlock,
|
|
|
$sizeChosed,
|
|
|
scindex,
|
|
|
curGoodNum;
|
|
|
|
|
|
promotionId,
|
|
|
isEdit = 0,
|
|
|
numInCart = $('.num-tag').html() - 0;
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
|
|
|
|
// goodsType,
|
|
|
// isEdit;
|
|
|
$this.siblings('.chosed').removeClass('chosed');
|
|
|
index = $this.index();
|
|
|
|
|
|
$chosed = $('.block-list>ul>li.chosed');
|
|
|
$sizeChosed = $siblingBlock.find('.chosed');
|
|
|
scindex = $sizeChosed.index();
|
|
|
$curSizeRow = $sizeRowList.eq(index);
|
|
|
|
|
|
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
|
|
|
productSku = $sizeList.closest('.chosed').data('skuid');
|
|
|
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
|
|
|
if (confirming) {
|
|
|
return false;
|
|
|
// 当前颜色已经是选中状态,再点击时
|
|
|
if ($this.hasClass('chosed')) {
|
|
|
|
|
|
//颜色原来已经是勾选时,要清空剩余件数的提示
|
|
|
$that.find('.num .left-num').html('');
|
|
|
$('#left-num').val(0);
|
|
|
hasChooseColor = false;
|
|
|
|
|
|
// 当前颜色不是选中状态,选中时
|
|
|
} else {
|
|
|
hasChooseColor = true;
|
|
|
|
|
|
//根据颜色切换图片
|
|
|
if ($this.closest('.block-list').hasClass('color-list')) {
|
|
|
$('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');
|
|
|
}
|
|
|
|
|
|
confirming = true;
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/add',
|
|
|
data: {
|
|
|
productSku: productSku,
|
|
|
buyNumber: buyNumber,
|
|
|
promotionId: promotionId,
|
|
|
isEdit: isEdit
|
|
|
//把当前选中颜色对应的尺码那一行显示出来
|
|
|
$sizeRowList.addClass('hide');
|
|
|
$curSizeRow.removeClass('hide').addClass('show');
|
|
|
|
|
|
// 之前选中的尺码去掉勾选样式
|
|
|
if ($sizeChosed.length > 0) {
|
|
|
$sizeChosed.removeClass('chosed');
|
|
|
curSelectedSizeBlock = $curSizeRow.children().get(scindex);
|
|
|
}
|
|
|
|
|
|
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
|
|
|
if (curSelectedSizeBlock) {
|
|
|
curGoodNum = $(curSelectedSizeBlock).data('num');
|
|
|
$(curSelectedSizeBlock).addClass('chosed');
|
|
|
|
|
|
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
|
|
|
if (curGoodNum > 0) {
|
|
|
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
|
|
|
$('#left-num').val(curGoodNum);
|
|
|
} else {
|
|
|
$(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
|
|
|
$that.find('.num .left-num').html('');
|
|
|
$('#left-num').val(0);
|
|
|
}
|
|
|
}).done(function(res) {
|
|
|
loading.hideLoadingMask();
|
|
|
if (res.code === 200) {
|
|
|
$('.num-tag').html(numInCart + buyNumber);
|
|
|
$('.num-tag').removeClass('hide');
|
|
|
remove();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 当前颜色块 切换勾选样式
|
|
|
$this.toggleClass('chosed');
|
|
|
curColorIndex = index;
|
|
|
|
|
|
// 设置按钮的样式和文字
|
|
|
$chosed = $('.chose-items').find('.chosed');
|
|
|
if (2 === $chosed.closest('.zero-stock').length) {
|
|
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
|
|
$('#chose-btn-sure').html('已售罄');
|
|
|
} else {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
}
|
|
|
|
|
|
/**if ($chosed.length === 0) {
|
|
|
$this.closest('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
if (res.message) {
|
|
|
tip.show(res.message);
|
|
|
});
|
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
|
|
|
$sizeList.addClass('hide');
|
|
|
|
|
|
//切换尺码信息
|
|
|
$sizeList.each(function() {
|
|
|
colorIndex = $(this).data('colorid');
|
|
|
if (colorIndex === $this.data('id')) {
|
|
|
$(this).removeClass('hide');
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出了点问题~');
|
|
|
}).always(function() {
|
|
|
confirming = false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}).on('touchstart', '.block', function(e) {
|
|
|
numArray = ($chosed.data('numstr') + '').split('/');
|
|
|
$siblingBlock.find('.block').removeClass('zero-stock');
|
|
|
for (i = 0; i < numArray.length; i++) {
|
|
|
if ('0' === numArray[i]) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
|
|
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
$that.find('.num .left-num').html('');
|
|
|
} else if ($chosed.length === 2) {
|
|
|
$siblingBlock.find('.block').removeClass('zero-stock');
|
|
|
for (i = 0; i < currentNumArray.length; i++) {
|
|
|
if ('0' === currentNumArray[i]) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
|
|
numArray = ($siblingBlock.find('.chosed').data('numstr') + '').split('/');
|
|
|
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
|
|
|
if (2 === $chosed.closest('.zero-stock').length) {
|
|
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
|
|
$('#chose-btn-sure').html('已售罄');
|
|
|
} else {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
}
|
|
|
}**/
|
|
|
|
|
|
});
|
|
|
|
|
|
$('.size-list').on('touchstart', '.block', function(e) {
|
|
|
var $this = $(this),
|
|
|
$that = $(e.target).closest('.chose-items'),
|
|
|
numArray,
|
|
|
index,
|
|
|
i;
|
|
|
$colorChosed,
|
|
|
curGoodNum;
|
|
|
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first'),
|
|
|
currentNumArray = ($this.data('numstr') + '').split('/');
|
|
|
var $siblingBlock = $this.closest('.block-list').siblings(':first');
|
|
|
|
|
|
$this.siblings('.chosed').removeClass('chosed');
|
|
|
$this.toggleClass('chosed');
|
|
|
index = $this.index();
|
|
|
$chosed = $('.block-list>ul>li.chosed');
|
|
|
|
|
|
//根据颜色切换图片
|
|
|
if ($this.closest('.block-list').hasClass('color-list')) {
|
|
|
$('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');
|
|
|
$colorChosed = $siblingBlock.find('.chosed');
|
|
|
$curSizeRow = $sizeRowList.eq(index);
|
|
|
|
|
|
// 当前尺码已经是选中状态,再点击时
|
|
|
if ($this.hasClass('chosed')) {
|
|
|
|
|
|
//尺码原来已经是勾选时,要清空剩余件数的提示
|
|
|
$that.find('.num .left-num').html('');
|
|
|
$('#left-num').val(0);
|
|
|
hasChooseSize = false;
|
|
|
|
|
|
// 去掉已经选中颜色的 数量为0的样式
|
|
|
if ($colorChosed.length > 0) {
|
|
|
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
|
|
|
}
|
|
|
|
|
|
// 当前尺码不是选中状态,选中时
|
|
|
} else {
|
|
|
hasChooseSize = true;
|
|
|
|
|
|
curGoodNum = $this.data('num');
|
|
|
|
|
|
// 之前选中的尺码去掉勾选样式
|
|
|
if ($curSizeBlock) {
|
|
|
$curSizeBlock.removeClass('chosed');
|
|
|
}
|
|
|
|
|
|
// 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
|
|
|
if (curGoodNum > 0 && hasChooseColor) {
|
|
|
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
|
|
|
$('#left-num').val(curGoodNum);
|
|
|
} else {
|
|
|
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
|
|
|
$that.find('.num .left-num').html('');
|
|
|
$('#left-num').val(0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this.toggleClass('chosed');
|
|
|
curSizeIndex = index;
|
|
|
$curSizeBlock = $this;
|
|
|
|
|
|
// 设置按钮的样式和文字
|
|
|
$chosed = $('.chose-items').find('.chosed');
|
|
|
if (2 === $chosed.closest('.zero-stock').length) {
|
|
|
$('#chose-btn-sure').css('background-color', '#c0c0c0');
|
|
|
$('#chose-btn-sure').html('已售罄');
|
|
|
} else {
|
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
}
|
|
|
|
|
|
if ($chosed.length === 0) {
|
|
|
/**if ($chosed.length === 0) {
|
|
|
$this.closest('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -5751,7 +5916,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
numArray = ($chosed.data('numstr') + '').split('/');
|
|
|
$siblingBlock.find('.block').removeClass('zero-stock');
|
|
|
for (i = 0; i < numArray.length; i++) {
|
|
|
if (0 === numArray[i] - 0) {
|
|
|
if ('0' === numArray[i]) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -5761,7 +5926,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
|
|
|
$siblingBlock.find('ul>li').each(function() {
|
|
|
$(this).removeClass('zero-stock');
|
|
|
if (0 === $(this).data('num') - 0) {
|
|
|
if ('0' === $(this).data('num')) {
|
|
|
$(this).addClass('zero-stock');
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -5769,7 +5934,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
} else if ($chosed.length === 2) {
|
|
|
$siblingBlock.find('.block').removeClass('zero-stock');
|
|
|
for (i = 0; i < currentNumArray.length; i++) {
|
|
|
if (0 === currentNumArray[i] - 0) {
|
|
|
if ('0' === currentNumArray[i]) {
|
|
|
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -5782,15 +5947,16 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
$('#chose-btn-sure').css('background-color', '#eb0313');
|
|
|
$('#chose-btn-sure').html('确定');
|
|
|
}
|
|
|
}
|
|
|
}**/
|
|
|
|
|
|
}).on('touchstart', '.btn-minus', function() {
|
|
|
var num = +$num.val(),
|
|
|
$chosed = $('.block-list>ul>li.chosed'),
|
|
|
leftNum = re.exec($('.num .left-num').html());
|
|
|
});
|
|
|
|
|
|
$('.btn-minus').on('touchstart', function() {
|
|
|
var num = $num.val();
|
|
|
|
|
|
leftNum = $('#left-num').val();
|
|
|
|
|
|
//若颜色和尺码没有被同时选中,则不能点击
|
|
|
if ($chosed.length < 2) {
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -5799,15 +5965,19 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
}
|
|
|
|
|
|
$num.val(num - 1);
|
|
|
}).on('touchstart', '.btn-plus', function() {
|
|
|
var num = +$num.val();
|
|
|
});
|
|
|
|
|
|
$('.btn-plus').on('touchstart', function() {
|
|
|
var num = $num.val();
|
|
|
|
|
|
//若颜色和尺码没有被同时选中,则不能点击
|
|
|
if ($('.block-list>ul>li.chosed').length < 2) {
|
|
|
leftNum = $('#left-num').val();
|
|
|
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
|
|
}
|
|
|
leftNum = re.exec($('.num .left-num').html());
|
|
|
if (num - 0 === leftNum - 0 || 0 === leftNum - 0) {
|
|
|
|
|
|
|
|
|
if (num - 0 === leftNum || 0 === leftNum) {
|
|
|
return;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -5815,6 +5985,71 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { |
|
|
$num.val(num + 1);
|
|
|
});
|
|
|
|
|
|
$('#chose-btn-sure').on('touchstart', function() {
|
|
|
|
|
|
var productSku,
|
|
|
buyNumber = $('#good-num').val() - 0,
|
|
|
|
|
|
promotionId,
|
|
|
isEdit = 0,
|
|
|
numInCart = $('.num-tag').html() - 0,
|
|
|
num = $num.val();
|
|
|
|
|
|
if (!checkColorSizeNum()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if ($('#chose-btn-sure').html() === '已售罄') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
leftNum = $('#left-num').val();
|
|
|
|
|
|
if (num > leftNum) {
|
|
|
tip.show('您选择的数量超过了最大库存量~');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$chosed = $('.block-list>ul>li.chosed');
|
|
|
|
|
|
if (2 === $chosed.length && 0 === $chosed.closest('.zero-stock').length) {
|
|
|
productSku = $curSizeBlock.data('skuid');
|
|
|
promotionId = $('[data-id="' + productSku + '"]').closest('.advance-block').data('promotion-id');
|
|
|
if (confirming) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
confirming = true;
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/add',
|
|
|
data: {
|
|
|
productSku: productSku,
|
|
|
buyNumber: buyNumber,
|
|
|
promotionId: promotionId,
|
|
|
isEdit: isEdit
|
|
|
}
|
|
|
}).done(function(res) {
|
|
|
loading.hideLoadingMask();
|
|
|
if (res.code === 200) {
|
|
|
$('.num-tag').html(numInCart + buyNumber);
|
|
|
$('.num-tag').removeClass('hide');
|
|
|
confirming = false;
|
|
|
hide();
|
|
|
}
|
|
|
if (res.message) {
|
|
|
tip.show(res.message);
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络出了点问题~');
|
|
|
}).always(function() {
|
|
|
confirming = false;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
exports.init = init;
|
|
|
exports.show = show;
|
|
|
|
...
|
...
|
@@ -8463,17 +8698,24 @@ var $ = require("jquery"), |
|
|
lazyLoad = require("lazyload"),
|
|
|
Hammer = require("hammer");
|
|
|
|
|
|
var chosePanel = require("js/cart/chose-panel");
|
|
|
var chosePanel = require("js/cart/chose-panel"),
|
|
|
tip = require("js/plugin/tip");
|
|
|
|
|
|
var $cartContent = $('.cart-content');
|
|
|
|
|
|
var navHammer,
|
|
|
cartType = $('#cartType').val();
|
|
|
|
|
|
var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
|
|
|
|
|
|
require("js/cart/good");
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
|
|
|
if ('advance' === cartType) {
|
|
|
$cartContent.toggleClass('hide');
|
|
|
}
|
|
|
|
|
|
if ($('.cart-nav').length > 0) {
|
|
|
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
|
|
|
navHammer.on('tap', function(e) {
|
...
|
...
|
@@ -8501,7 +8743,11 @@ if ($('.cart-nav').length > 0) { |
|
|
}
|
|
|
|
|
|
$('.btn-balance').on('touchend', function() {
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
if (hasChecked) {
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
} else {
|
|
|
tip.show('请先勾选商品');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.chose').on('touchend', function() {
|
...
|
...
|
@@ -8510,6 +8756,8 @@ $('.chose').on('touchend', function() { |
|
|
chosePanel.show();
|
|
|
});
|
|
|
|
|
|
//提前触发lazyload
|
|
|
$(window).scrollTop(1).scrollTop(0);
|
|
|
});
|
|
|
define("js/cart/good", ["jquery","mlellipsis","handlebars","source-map","lazyload","hammer"], function(require, exports, module){
|
|
|
/**
|
...
|
...
|
@@ -8526,8 +8774,7 @@ var $ = require("jquery"), |
|
|
var dialog = require("js/me/dialog"),
|
|
|
tip = require("js/plugin/tip");
|
|
|
|
|
|
var $names,
|
|
|
$selectAllBtn = $('.balance .iconfont'),
|
|
|
var $selectAllBtn = $('.balance .checkbox'),
|
|
|
cartType = $('#cartType').val(),
|
|
|
requesting = false;
|
|
|
|
...
|
...
|
@@ -8537,11 +8784,9 @@ lazyLoad({ |
|
|
try_again_css: 'good-failure'
|
|
|
});
|
|
|
|
|
|
|
|
|
$names = $('.name');
|
|
|
if ($names.length > 0) {
|
|
|
$names[0].mlellipsis(2);
|
|
|
}
|
|
|
$('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
|
|
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
|
|
$('.cart-goods').on('touchstart', '.checkbox', function() {
|
...
|
...
|
@@ -8566,7 +8811,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
this.selected = properties.selected;
|
|
|
}
|
|
|
|
|
|
goodInfo.goods_type = getCartType();
|
|
|
goodInfo.goods_type = cartType;
|
|
|
goodInfo.selected = isSelected ? 'N' : 'Y';
|
|
|
goodInfo.product_sku = id;
|
|
|
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
|
...
|
...
|
@@ -8587,44 +8832,12 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
} else {
|
|
|
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
}
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: 'getCartData',
|
|
|
data: {
|
|
|
id: id
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data) {
|
|
|
if (cartType === 'ordinary') {
|
|
|
$('#good-totalprice').html('¥' + data.commonCart.price);
|
|
|
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
|
|
|
$('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
|
|
|
if (data.commonCart.isAllSelected) {
|
|
|
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
} else {
|
|
|
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
}
|
|
|
} else {
|
|
|
$('#good-totalprice').html('¥' + data.preSellCart.price);
|
|
|
$('#good-activityPrice').html('¥' + data.preSellCart.activityPrice);
|
|
|
$('#good-total').html('总计:¥' + data.preSellCart.sumPrice + ' (' + data.preSellCart.count + '件)');
|
|
|
if (data.preSellCart.isAllSelected) {
|
|
|
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
|
|
|
} else {
|
|
|
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络错误');
|
|
|
}
|
|
|
});
|
|
|
window.history.go(0);
|
|
|
} else if (data.code === 400) {
|
|
|
tip.show('网络错误');
|
|
|
tip.show('网络异常');
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络错误');
|
|
|
}, function() {
|
|
|
tip.show('网络异常');
|
|
|
});
|
|
|
}).on('touchstart', '.icon-del', function(e) {
|
|
|
var $this = $(this);
|
...
|
...
|
@@ -8657,10 +8870,10 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
});
|
|
|
history.go(0);
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
}, function() {
|
|
|
dialog.showDialog({
|
|
|
autoHide: true,
|
|
|
dialogText: '网络错误~'
|
|
|
dialogText: '网络异常'
|
|
|
});
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -8717,6 +8930,7 @@ function didUpdateAllGoodsCheckStatus() { |
|
|
$(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox');
|
|
|
});
|
|
|
}
|
|
|
window.history.go(0);
|
|
|
}
|
|
|
|
|
|
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
|
...
|
...
|
@@ -8765,6 +8979,7 @@ function willBeSelected($this) { |
|
|
//全选按钮点击事件
|
|
|
$selectAllBtn.on('touchend', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
|
|
|
});
|
|
|
|
...
|
...
|
@@ -8844,6 +9059,7 @@ var dispatchModeHammer, |
|
|
dispatchTimeHammer,
|
|
|
$invoice = $('.invoice'),
|
|
|
$price = $('.price-cal'),
|
|
|
$couponUse = $('.coupon-use.used'),
|
|
|
payType,
|
|
|
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
|
|
|
queryString = $.queryString(),
|
...
|
...
|
@@ -8855,6 +9071,11 @@ if (window.getUid() !== orderInfo('uid')) { |
|
|
order.init();
|
|
|
}
|
|
|
|
|
|
if ($couponUse.data('value') !== orderInfo('couponValue')) {
|
|
|
orderInfo('couponCode', null);
|
|
|
orderInfo('couponValue', null);
|
|
|
}
|
|
|
|
|
|
function dispacthTapEvt(e) {
|
|
|
var $cur = $(e.target).closest('li');
|
|
|
|
...
|
...
|
@@ -8912,21 +9133,17 @@ function orderCompute() { |
|
|
if (!res) {
|
|
|
tip.show('网络出错');
|
|
|
} else {
|
|
|
if (res.order_amount) {
|
|
|
/*if (res.order_amount) {
|
|
|
res.order_amount = (+res.order_amount).toFixed(2);
|
|
|
}
|
|
|
if (res.discount_amount) {
|
|
|
res.discount_amount = (+res.discount_amount).toFixed(2);
|
|
|
}
|
|
|
}*/
|
|
|
if (res.last_order_amount) {
|
|
|
res.last_order_amount = (+res.last_order_amount).toFixed(2);
|
|
|
}
|
|
|
priceHtml = priceTmpl({
|
|
|
sumPrice: res.order_amount,
|
|
|
salePrice: res.discount_amount,
|
|
|
freight: res.promotion_formula_list[1].promotion_amount,
|
|
|
couponPrice: res.coupon_amount,
|
|
|
yohoCoin: res.use_yoho_coin,
|
|
|
cartPayData: res.promotion_formula_list,
|
|
|
price: res.last_order_amount
|
|
|
});
|
|
|
|
...
|
...
|
@@ -8938,9 +9155,24 @@ function orderCompute() { |
|
|
}
|
|
|
|
|
|
function submitOrder() {
|
|
|
if (orderInfo('invoice') && !orderInfo('invoiceText')) {
|
|
|
tip.show('请输入发票抬头');
|
|
|
return;
|
|
|
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
|
|
|
msg = $('#msg').find('input').val() || orderInfo('msg');
|
|
|
|
|
|
if (orderInfo('invoice')) {
|
|
|
if (!invoiceText) {
|
|
|
tip.show('请输入发票抬头');
|
|
|
return;
|
|
|
}
|
|
|
if (invoiceText.length > 30) {
|
|
|
tip.show('发票抬头不得超过30个汉字');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (msg) {
|
|
|
if (msg.length > 40) {
|
|
|
tip.show('留言不得超过40个汉字');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
...
|
...
|
@@ -8951,9 +9183,9 @@ function submitOrder() { |
|
|
cartType: queryString.cartType || queryString.carttype || 'ordinary',
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
deliveryTimeId: orderInfo('deliveryTimeId'),
|
|
|
invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
|
|
|
invoiceText: invoiceText,
|
|
|
invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
|
|
|
msg: $('#msg').find('input').val() || orderInfo('msg'),
|
|
|
msg: msg,
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
paymentType: orderInfo('paymentType'), //支付方式
|
|
|
couponCode: orderInfo('couponCode'),
|
...
|
...
|
@@ -9026,7 +9258,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() { |
|
|
orderInfo('invoiceType', $(this).val());
|
|
|
});
|
|
|
|
|
|
$('#msg').find('input').on('blur', function() {
|
|
|
$('#msg').find('textarea').on('blur', function() {
|
|
|
orderInfo('msg', $(this).val());
|
|
|
});
|
|
|
|
...
|
...
|
@@ -9104,9 +9336,10 @@ var page = 1, |
|
|
isGetData;
|
|
|
|
|
|
var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()),
|
|
|
conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
|
|
|
$newCoupon = $('#new-coupon');
|
|
|
|
|
|
// conponNotAvaliableTmpl = Handlebars.compile($('#tmpl-coupon-not-avaliable').html()),
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
$newCoupon.on('submit', function() {
|
...
|
...
|
@@ -9142,6 +9375,12 @@ $('#coupon-list').on('touchend', '.employ-main', function() { |
|
|
orderInfo('couponValue', $this.data('coupon-value'));
|
|
|
});
|
|
|
|
|
|
$('body').on('touchend', '.not-use', function() {
|
|
|
orderInfo('couponCode', null);
|
|
|
orderInfo('couponValue', null);
|
|
|
});
|
|
|
|
|
|
|
|
|
$newCoupon.find('input').on('input', function() {
|
|
|
if ($(this).val() !== '') {
|
|
|
$newCoupon.find('.submit').css('background', '#444');
|
...
|
...
|
@@ -9197,15 +9436,17 @@ function getCouponHandle(coupons) { |
|
|
}
|
|
|
});
|
|
|
|
|
|
if (notAvailableCoupons.length) {
|
|
|
$('.not-avaliable-coupon-line').show();
|
|
|
}
|
|
|
$('#coupon-list').append(conponTmpl({
|
|
|
coupons: coupons
|
|
|
}));
|
|
|
$('#coupon-list-not').append(conponNotAvaliableTmpl({
|
|
|
notAvailableCoupons: notAvailableCoupons
|
|
|
}));
|
|
|
|
|
|
// 产品说,暂时不做不可使用的优惠券
|
|
|
// if (notAvailableCoupons.length) {
|
|
|
// $('.not-avaliable-coupon-line').show();
|
|
|
// }
|
|
|
// $('#coupon-list-not').append(conponNotAvaliableTmpl({
|
|
|
// notAvailableCoupons: notAvailableCoupons
|
|
|
// }));
|
|
|
window.rePosFooter();
|
|
|
}
|
|
|
|
...
|
...
|
|