Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

... ... @@ -129,7 +129,7 @@ class Helpers
*/
public static function getShoppingKeyByCookie()
{
$cookie = isset($_COOKIE['_spk']) ? $_COOKIE['_spk'] : '';
$cookie = isset($_COOKIE['_Spk']) ? $_COOKIE['_Spk'] : '';
return $cookie;
}
... ...
... ... @@ -22,7 +22,6 @@ var $chosePanel = $('#chose-panel'),
confirming,
curColorIndex,
curSizeIndex,
$curSizeRow,
hasChooseColor,
hasChooseSize,
$curSizeBlock,
... ... @@ -34,8 +33,6 @@ var $chosePanel = $('#chose-panel'),
//初始化购物车面板显示
function init() {
var $firstRow;
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
... ... @@ -44,9 +41,7 @@ function init() {
$allChoseItems = $('.chose-items');
$sizeRowList = $('.size-list ul');
$leftNum = $('#left-num');
$firstRow = $sizeRowList.eq(0);
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
$sizeRowList.eq(0).toggleClass('hide');
}
function checkColorSizeNum() {
... ... @@ -69,6 +64,7 @@ function show(html, cb) {
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
cbFn = cb;
}
... ... @@ -76,6 +72,7 @@ function show(html, cb) {
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
//修改加入购物车的文字和背景
... ... @@ -90,21 +87,25 @@ function updateConformButtonClassAndText() {
//重置颜色块的库存为0的样式
function resetColorZeroStock($siblingBlock) {
var numArray = ($curSizeBlock.data('numstr') + '').split('/'),
var numArray,
i;
if (!hasChooseSize) {
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
if (0 === $(this).data('num')) {
$(this).addClass('zero-stock');
} else {
$(this).removeClass('zero-stock');
}
});
} else {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
} else {
$siblingBlock.find('.block').eq(i).removeClass('zero-stock');
}
}
}
... ... @@ -130,12 +131,14 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) {
hide();
});
$yohoPage.on('touchstart', '.color-list .block', function(e) {
$yohoPage.on('touchstart', '.color-list .block', function() {
var $this = $(this),
index,
curSizeBlock,
$preSiblingBlock,
scindex,
$curSizeRow,
numArray,
i,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
... ... @@ -144,7 +147,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
index = $this.index();
$preSiblingBlock = $siblingBlock.find('.chosed');
scindex = $preSiblingBlock.index();
$curSizeRow = $sizeRowList.eq(index);
// 当前颜色已经是选中状态,再点击时
... ... @@ -155,6 +157,16 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
$leftNum.val(0);
hasChooseColor = false;
$this.removeClass('zero-stock');
if ($curSizeBlock) {
numArray = ($curSizeBlock.data('numstr') + '').split('/');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$('.color-list .block').eq(i).addClass('zero-stock');
}
}
}
// 当前颜色不是选中状态,选中时
} else {
hasChooseColor = true;
... ... @@ -166,7 +178,7 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 之前选中的尺码去掉勾选样式
if ($preSiblingBlock.length > 0) {
$preSiblingBlock.removeClass('chosed');
curSizeBlock = $curSizeRow.children().get(scindex);
curSizeBlock = $curSizeRow.children().get(curSizeIndex);
}
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
... ... @@ -194,11 +206,10 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor();
});
$yohoPage.on('touchstart', '.size-list .block', function(e) {
}).on('touchstart', '.size-list .block', function() {
var $this = $(this),
index,
$curSizeRow,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
... ... @@ -246,7 +257,6 @@ $yohoPage.on('touchstart', '.size-list .block', function(e) {
// 重置颜色块的样式
resetColorZeroStock($siblingBlock);
});
$yohoPage.on('touchstart', '.btn-minus', function() {
... ... @@ -332,7 +342,6 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
confirming = false;
hide();
if (cbFn) {
cbFn();
... ... @@ -341,6 +350,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
if (res.message) {
tip.show(res.message);
}
hide();
}).fail(function() {
tip.show('网络出了点问题~');
}).always(function() {
... ...
... ... @@ -457,7 +457,7 @@ class IndexController extends AbstractAction
// 设置加入购物车凭证到客户端浏览器
if (!$shoppingKey && isset($result['data']['shopping_key'])) {
$this->setCookie('_spk', $result['data']['shopping_key']);
$this->setCookie('_Spk', $result['data']['shopping_key']);
}
}
... ...