Authored by wangqing

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

... ... @@ -459,20 +459,7 @@ var brandsData,
loading.showLoadingMask();
//热门品牌滑动
hotBrandsSwiper = new Swiper('.brands-swiper', {
grabCursor: true,
slidesPerView: 'auto',
wrapperClass: 'brands-list',
slideElement: 'li'
});
swiper = new Swiper('.swiper-container', {
lazyLoading: true,
loop: true,
autoplay: 3000,
pagination: '.swiper-pagination .pagination-inner'
});
lazyLoad($('img.lazy'));
$('.yoho-header').css({
... ... @@ -488,6 +475,22 @@ $('.yoho-header').css({
$('.hide-when-loading').show();
loading.hideLoadingMask();
//banner滑动
swiper = new Swiper('.swiper-container', {
lazyLoading: true,
loop: true,
autoplay: 3000,
pagination: '.swiper-pagination .pagination-inner'
});
//热门品牌滑动
hotBrandsSwiper = new Swiper('.brands-swiper', {
grabCursor: true,
slidesPerView: 'auto',
wrapperClass: 'brands-list',
slideElement: 'li'
});
})();
$fixTitleBar = $('<div class="title-bar fixed-title-bar"><h2></h2></div>');
... ... @@ -1889,41 +1892,50 @@ module.exports = function(specificGender) {
if (kidsType) {
url = '/product/recom/maylikekids';
} else if (lifestyleType) {
url = '/product/recom/maylikelife';
//有货币页面加载男生首页的数据
url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife';
} else {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3' : '2,3',
url = '/product/recom/maylike?gender=' + gender;
}
//以防cookie异常,强制加载男首
if (specificGender === 'boys') {
url = '/product/recom/maylike?gender=1,3';
}
$curNav = $navList.children('.focus');
if (lifestyleType) {
navHammer = new Hammer($navList[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
$goods = $('.goods-list'),
$content;
e.preventDefault();
if ($this.hasClass('focus')) {
return;
}
navHammer = $navList[0] ? new Hammer($navList[0]) : undefined;
if (navHammer) {
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
$goods = $('.goods-list'),
$content;
e.preventDefault();
if ($this.hasClass('focus')) {
return;
}
index = $this.index();
index = $this.index();
$this.addClass('focus');
$curNav.removeClass('focus');
$this.addClass('focus');
$curNav.removeClass('focus');
$goods.not('.hide').addClass('hide');
$content = $goods.eq(index);
$content.removeClass('hide');
$goods.not('.hide').addClass('hide');
$content = $goods.eq(index);
$content.removeClass('hide');
$curNav = $this;
$curNav = $this;
$(document).trigger('scroll'); //Trigger lazyLoad
e.srcEvent.stopPropagation();
});
$(document).trigger('scroll'); //Trigger lazyLoad
e.srcEvent.stopPropagation();
});
}
}
loading.init($('.maybe-like'));
... ... @@ -5526,15 +5538,28 @@ function changeSizeChosed(newSizeIndex) {
$curSizeBlock.removeClass('chosed');
sizes = $sizeRowList.eq(newSizeIndex).children();
for (i = 0; i < sizes.length; i++) {
if ($(sizes[i]).data('name') === $curSizeBlock.data('name')) {
if ($(sizes[i]).data('id') === $curSizeBlock.data('id')) {
$curSizeBlock = $(sizes[i]);
queryString = '#' + $curSizeBlock.data('name');
queryString = '#' + $curSizeBlock.data('id');
curColorIndex = $(queryString).data('index');
$curSizeBlock.addClass('chosed');
return $curSizeBlock.data('num');
}
}
$curSizeBlock.addClass('chosed');
return $curSizeBlock.data('num');
//特殊处理: 老的选中尺码在新选中的颜色对应尺码中不存在,需要下述1,2,3
// 1.重置尺码选择的标志变量.
$curSizeBlock = null;
hasChooseSize = false;
// 2.当前颜色行隐藏
$colorRowList.eq(curColorIndex).addClass('hide');
// 3.目标颜色行第一行显示
$colorRowList.eq(0).removeClass('hide');
curColorIndex = 0;
return -1;
}
return 0;
}
... ... @@ -5612,7 +5637,15 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
// 颜色块切换勾选样式
$this.siblings('.chosed').removeClass('chosed');
$this.toggleClass('chosed');
// 特殊处理
if (-1 === curGoodNum) {
$curColorBlock = $($colorRowList.eq(0).children().get(index));
$curColorBlock.addClass('chosed');
} else {
$this.toggleClass('chosed');
}
$('#good-num').val(1);
// 设置按钮的样式和文字
... ... @@ -5645,7 +5678,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() {
} else {
hasChooseSize = true;
index = $('#' + $this.data('name')).data('index') - 1;
index = $('#' + $this.data('id')).data('index') - 1;
// 颜色当前行隐藏
$colorRowList.eq(curColorIndex).addClass('hide');
... ... @@ -8815,7 +8848,7 @@ define("js/me/currency-new", ["jquery","hammer","lazyload"], function(require, e
*/
function getGender() {
return window.cookie('_Channel');
return window.cookie('_Channel') || 'boys';
}
require("js/home/maybe-like")(getGender());
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -647,47 +647,58 @@ class CartModel
if (isset($productData['goods_list'])) {
$goodsList = $productData['goods_list'];
$sizeName = '';
$colors = array();
$colorList = array();
$oneColor = array();
$sizes = array();
$oneSize = array();
$sizeList = array();
$allSizeList = array(); // 所有尺码列表
$thumbImageList = array();
$colorNum = 0;
$totalStorageNum = 0; // 总库存数
$colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
foreach ($goodsList as $val) {
$colorNum = 0;
$sizeStorageStr = '';
// 尺码
foreach ($val['size_list'] as $one) {
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['skuId'] = $one['product_sku'];
$oneSize['goodsId'] = $val['goods_id'];
$oneSize['colorId'] = $val['color_id'];
$oneSize['name'] = $one['size_name'];
$oneSize['sizeNum'] = $one['storage_number'];
$colorNum += $one['storage_number'];
$sizeStorageStr .= $one['storage_number'] . '/';
$sizeList[$val['product_skc']][] = $oneSize;
$sizeName = '';
// 商品的尺码列表
$colorStorageGroup[ $val['product_skc'] ] = array();
if (isset($val['size_list'])) {
// 尺码
foreach ($val['size_list'] as $one) {
$sizeName = $one['size_name'];
$oneSize = array();
$oneSize['id'] = $one['size_id'];
$oneSize['skuId'] = $one['product_sku'];
$oneSize['goodsId'] = $val['goods_id'];
$oneSize['colorId'] = $val['color_id'];
$oneSize['name'] = $sizeName;
$oneSize['sizeNum'] = $one['storage_number'];
$sizeList[$val['product_skc']][] = $oneSize;
// 所有尺码列表,赋值用于前端展示默认尺码的时候 判断出没有库存则显示灰色
$allSizeList[$sizeName] = empty($allSizeList[$sizeName]['storage_number'])
? array('storage' => $one['storage_number'], 'id' => $one['size_id'])
: $allSizeList[$sizeName];
$colorNum += intval($one['storage_number']);
$colorStorageGroup[$val['product_skc']][$one['size_name']] = $one['storage_number'];
}
$colorStorageGroup[$val['product_skc']][$one['size_name']] = $one['storage_number'];
// 颜色分组
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['skcId'] = $val['product_skc'];
$oneColor['name'] = $val['color_name'];
$oneColor['goodsName'] = $productData['product_name'];
$oneColor['colorNum'] = $colorNum;
$colorList[] = $oneColor;
}
// 颜色
$oneColor = array();
$oneColor['id'] = $val['color_id'];
$oneColor['skcId'] = $val['product_skc'];
$oneColor['name'] = $val['color_name'];
$oneColor['goodsName'] = $productData['product_name'];
$oneColor['colorNum'] = $colorNum;
$oneColor['sizeNumStr'] = rtrim($sizeStorageStr, '/');
$colors[] = $oneColor;
// 缩略图
foreach ($val['images_list'] as $image) {
$thumbImageList[] = array(
... ... @@ -699,25 +710,38 @@ class CartModel
$totalStorageNum += $colorNum;
}
// 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断
foreach ($sizeList as $skc => $sizeArr) {
foreach ($sizeArr as $key => $value) {
$sizeStorageStr = '';
foreach ($colorStorageGroup as $colorArr) {
if (isset($colorArr[$value['name']])) {
$sizeStorageStr .= $colorArr[$value['name']] . '/';
} else {
$sizeStorageStr .= '0/';
}
}
$sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/');
// 遍历所有尺码,构建颜色显示数据
$i = 1;
foreach ($allSizeList as $sizeName => $value) {
// 默认尺码
$sizes[0]['size'][] = array(
'name' => $sizeName, // 尺码名称
'sizeNum' => empty($value['storage']) ? false : true, // 是否有库存 (false:表示没有库存,true:表示有库存)
'id' => $value['id'],
);
// 各个颜色的尺码, 每行显示一个尺码对应的颜色
foreach ($colorList as $colorArr) {
$colorArr['colorNum'] = isset($colorStorageGroup[ $colorArr['skcId'] ][$sizeName]) ? $colorStorageGroup[ $colorArr['skcId'] ][$sizeName] : 0;
$colors[$i]['color'][] = $colorArr;
}
$colors[$i]['id'] = $value['id'];
++ $i;
}
// 格式化尺码对应的各个颜色分组
foreach ($colors as $color) {
$sizes[]['size'] = $sizeList[$color['skcId']];
// 遍历所有颜色, 构建尺码显示数据
$i = 1;
foreach ($colorList as $value) {
// 各个尺码的颜色,每行显示一个颜色的对应尺码
$sizes[$i]['size'] = $sizeList[ $value['skcId'] ];
$sizes[$i]['colorId'] = $value['skcId'];
// 默认颜色
$colors[0]['color'][] = $value;
++ $i;
}
ksort($colors, SORT_NUMERIC);
$data['thumbs'] = $thumbImageList;
$data['colors'] = $colors;
... ...