...
|
...
|
@@ -28,7 +28,9 @@ var $main = $('.main'), |
|
|
skn = $main.data('skn'),
|
|
|
deposit = $main.data('deposit') === 'Y',
|
|
|
secKill = $main.data('seckill') === 'Y',
|
|
|
limitCode = $main.data('limitcode');
|
|
|
limitCode = $main.data('limitcode'),
|
|
|
isBundle = $main.data('type') === 2, // 量贩商品
|
|
|
goodsBaseNum = isBundle ? $main.data('count'): 1; // 每次购买最低件数
|
|
|
|
|
|
var SLIDETIME = 200;
|
|
|
|
...
|
...
|
@@ -38,7 +40,7 @@ var colTxt = { |
|
|
hover: '取消收藏'
|
|
|
};
|
|
|
|
|
|
var oldtatus = {
|
|
|
var oldStatus = {
|
|
|
txt: '已领取',
|
|
|
html: '<a class="coupon-btn">去使用</a>'
|
|
|
};
|
...
|
...
|
@@ -236,13 +238,6 @@ bindEvent.add(function() { |
|
|
|
|
|
if ($(this).hasClass('active')) {
|
|
|
$(this).find('span').html(icon.fold);
|
|
|
|
|
|
if (!$('.activity-container').html()) {
|
|
|
$('.activity-container').append($('.activity').clone().find('li').each(function() {
|
|
|
$(this).removeClass('hide');
|
|
|
}).end());
|
|
|
}
|
|
|
|
|
|
$('.activity-container').slideDown(400);
|
|
|
} else {
|
|
|
$(this).find('span').html(icon.unfold);
|
...
|
...
|
@@ -274,19 +269,23 @@ bindEvent.add(function() { |
|
|
|
|
|
/**
|
|
|
* 获取当前选择的商品数目
|
|
|
* @return [Number]
|
|
|
*/
|
|
|
|
|
|
function getNum() {
|
|
|
return +$num.text();
|
|
|
}
|
|
|
|
|
|
// 重置Num显示为1
|
|
|
// 是否能:量贩购买
|
|
|
function canBundleBuy() {
|
|
|
return goodsBaseNum < maxStock;
|
|
|
}
|
|
|
|
|
|
// 重置Num显示为最小购买数
|
|
|
function resetNum() {
|
|
|
$num.text('1');
|
|
|
$num.text(goodsBaseNum + '');
|
|
|
|
|
|
// +-按钮状态重置
|
|
|
if (maxStock === 1 || maxStock === 0) {
|
|
|
if (maxStock === 1 || maxStock === 0 || !canBundleBuy()) {
|
|
|
|
|
|
// 数目为1/0时
|
|
|
$plusNum.addClass('dis');
|
...
|
...
|
@@ -310,44 +309,13 @@ bindEvent.add(function() { |
|
|
}
|
|
|
|
|
|
// 选中的商品存量为0或者某个颜色的total为0
|
|
|
if (maxStock === 0 || ($color && ~~$color.data('total') === 0)) {
|
|
|
if (maxStock === 0 || ($color && ~~$color.data('total') === 0) || !canBundleBuy()) {
|
|
|
$itemBuy.addClass('hide'); // 隐藏加入购物车、即将开售、立即购买等相同位置的按钮
|
|
|
$soldOut.removeClass('hide');
|
|
|
|
|
|
$enableNotifyYou.removeClass('hide');
|
|
|
|
|
|
notify.status(getSku()).then(function(result) {
|
|
|
// 检查当前请求是否是选中的sku
|
|
|
if (result.data.sku !== getSku()) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
if (result.data.status === 'Y') {
|
|
|
$enableNotifyYou.addClass('dis');
|
|
|
$enableNotifyYou.find('span').text('已订阅到货通知');
|
|
|
} else {
|
|
|
$enableNotifyYou.removeClass('dis');
|
|
|
$enableNotifyYou.find('span').text('到货通知');
|
|
|
}
|
|
|
}).fail(function(err) {
|
|
|
if (err.code === 400) {
|
|
|
window.jumpUrl(err.data.refer);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 检查当前请求是否是选中的sku
|
|
|
if (err.data.sku !== getSku()) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
$enableNotifyYou.removeClass('dis');
|
|
|
$enableNotifyYou.find('span').text('到货通知');
|
|
|
});
|
|
|
} else {
|
|
|
// 包括默认的-1情况下
|
|
|
$itemBuy.removeClass('hide');
|
|
|
$soldOut.addClass('hide');
|
|
|
$enableNotifyYou.addClass('hide');
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -475,6 +443,36 @@ bindEvent.add(function() { |
|
|
|
|
|
switchBtnStatus();
|
|
|
|
|
|
/// 到货通知:状态
|
|
|
if ($this.data('notify') === 'Y') {
|
|
|
$enableNotifyYou.removeClass('hide');
|
|
|
|
|
|
notify.statusAsync(getSku()).then(function(result) {
|
|
|
// 检查当前请求是否是选中的sku
|
|
|
if (result.data.sku !== getSku()) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
if (result.data.status === 'Y') {
|
|
|
$enableNotifyYou.addClass('dis');
|
|
|
$enableNotifyYou.find('span').text('已订阅到货通知');
|
|
|
} else {
|
|
|
$enableNotifyYou.removeClass('dis');
|
|
|
$enableNotifyYou.find('span').text('到货通知');
|
|
|
}
|
|
|
}).fail(function(err) {
|
|
|
// 检查当前请求是否是选中的sku
|
|
|
if (err.data.sku !== getSku()) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
$enableNotifyYou.removeClass('dis');
|
|
|
$enableNotifyYou.find('span').text('到货通知');
|
|
|
});
|
|
|
} else {
|
|
|
$enableNotifyYou.addClass('hide');
|
|
|
}
|
|
|
|
|
|
resetNum();
|
|
|
}).on('click', '.size-ruler', function() {
|
|
|
|
...
|
...
|
@@ -485,14 +483,62 @@ bindEvent.add(function() { |
|
|
}, 300);
|
|
|
});
|
|
|
|
|
|
// 增加到货通知
|
|
|
$enableNotifyYou.on('click', function() {
|
|
|
var opt = {
|
|
|
if ($enableNotifyYou.hasClass('dis')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
var opt = { //eslint-disable-line
|
|
|
className: 'notify-goods-wrapper',
|
|
|
closeIcon: true,
|
|
|
content: notifyTpl({msg: '测试信息!'})
|
|
|
content: notifyTpl({pid: id, sku: getSku()})
|
|
|
};
|
|
|
|
|
|
new Dialog(opt).show();
|
|
|
var dialog = new Dialog(opt); // eslint-disable-line
|
|
|
|
|
|
var FAV = { //eslint-disable-line
|
|
|
checked: '',
|
|
|
unchecked: ''
|
|
|
};
|
|
|
|
|
|
dialog.$el.on('click', '.ok', function() {
|
|
|
var $this = $(this),
|
|
|
sku = $this.data('sku'),
|
|
|
isFav = dialog.$el.find('.active').length === 1;
|
|
|
|
|
|
notify.addAsync(skn, sku).then(function() {
|
|
|
if (isFav) {
|
|
|
$('#collect-product').triggerHandler('click');
|
|
|
}
|
|
|
|
|
|
$enableNotifyYou.addClass('dis');
|
|
|
$enableNotifyYou.find('span').text('已订阅到货通知');
|
|
|
}).fail(function(err) {
|
|
|
if (err.code === 400) {
|
|
|
window.jumpUrl(err.data.refer);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
alert(err.message);
|
|
|
}).always(function() {
|
|
|
dialog.close();
|
|
|
});
|
|
|
});
|
|
|
|
|
|
dialog.$el.on('click', '.checked', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
$this.toggleClass('active');
|
|
|
|
|
|
if ($this.hasClass('active')) {
|
|
|
$this.html(FAV.checked);
|
|
|
} else {
|
|
|
$this.html(FAV.unchecked);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
dialog.show();
|
|
|
});
|
|
|
|
|
|
// 增加购买数量
|
...
|
...
|
@@ -787,8 +833,8 @@ bindEvent.add(function() { |
|
|
switch (status) {
|
|
|
case 1:
|
|
|
getCouponAsync(couponId).then(function() {
|
|
|
$ele.find('.coupon-status').text(oldtatus.txt);
|
|
|
$ele.find('.coupon-go').empty().append(oldtatus.html);
|
|
|
$ele.find('.coupon-status').text(oldStatus.txt);
|
|
|
$ele.find('.coupon-go').empty().append(oldStatus.html);
|
|
|
|
|
|
$item.data('status', 3);
|
|
|
}).fail(function(err) {
|
...
|
...
|
@@ -1031,12 +1077,12 @@ function fetchComment() { |
|
|
|
|
|
$('#consults-ul .zan-content').on('click', '.cuslike', function() {
|
|
|
var $this = $(this);
|
|
|
var id = $this.data('id');
|
|
|
var cid = $this.data('id');
|
|
|
var like = $this.data('like');
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/detail/consult/like/' + id
|
|
|
url: '/product/detail/consult/like/' + cid
|
|
|
}).then(function(data) {
|
|
|
if (data && data.code === 400) {
|
|
|
return window.jumpUrl(data.data.refer);
|
...
|
...
|
@@ -1044,7 +1090,7 @@ function fetchComment() { |
|
|
|
|
|
if (data && data.code === 200) {
|
|
|
$this.addClass('getzan');
|
|
|
$('.zan-content .icon-border[data-id=' + id + '] .likeNum')
|
|
|
$('.zan-content .icon-border[data-id=' + cid + '] .likeNum')
|
|
|
.replaceWith('<em class="likeNum">' + (like + 1) + '</em>');
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1054,20 +1100,22 @@ function fetchComment() { |
|
|
|
|
|
$('#consults-ul .zan-content').on('click', '.cususeful', function() {
|
|
|
var $this = $(this);
|
|
|
var id = $this.data('id');
|
|
|
var cid = $this.data('id');
|
|
|
var useful = $this.data('useful');
|
|
|
|
|
|
$this.addClass('getzan');
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/product/detail/consult/useful/' + id
|
|
|
url: '/product/detail/consult/useful/' + cid
|
|
|
}).then(function(data) {
|
|
|
if (data && data.code === 400) {
|
|
|
return window.jumpUrl(data.data.refer);
|
|
|
}
|
|
|
|
|
|
if (data && data.code === 200) {
|
|
|
$('.zan-content .usefulData[data-id=' + id + '] .usefulNum')
|
|
|
.replaceWith('<em class="usefulNum">' + (useful + 1) + '</em>');
|
|
|
$('.zan-content .usefulData[data-id=' + cid + '] .usefulNum')
|
|
|
.replaceWith('<em class="usefulNum">' + (useful + 1) + '</em>');
|
|
|
}
|
|
|
|
|
|
});
|
...
|
...
|
@@ -1075,7 +1123,6 @@ function fetchComment() { |
|
|
|
|
|
baseUrl = '/product/detail/consult?productId=' + id + '&filterId=7';
|
|
|
|
|
|
|
|
|
$('.consults-devide').empty().append(
|
|
|
setPager({baseUrl: baseUrl,
|
|
|
totalRecords: totalnum,
|
...
|
...
|
|