Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
5 changed files
with
101 additions
and
44 deletions
@@ -459,20 +459,7 @@ var brandsData, | @@ -459,20 +459,7 @@ var brandsData, | ||
459 | 459 | ||
460 | loading.showLoadingMask(); | 460 | loading.showLoadingMask(); |
461 | 461 | ||
462 | -//热门品牌滑动 | ||
463 | -hotBrandsSwiper = new Swiper('.brands-swiper', { | ||
464 | - grabCursor: true, | ||
465 | - slidesPerView: 'auto', | ||
466 | - wrapperClass: 'brands-list', | ||
467 | - slideElement: 'li' | ||
468 | -}); | ||
469 | 462 | ||
470 | -swiper = new Swiper('.swiper-container', { | ||
471 | - lazyLoading: true, | ||
472 | - loop: true, | ||
473 | - autoplay: 3000, | ||
474 | - pagination: '.swiper-pagination .pagination-inner' | ||
475 | -}); | ||
476 | 463 | ||
477 | lazyLoad($('img.lazy')); | 464 | lazyLoad($('img.lazy')); |
478 | $('.yoho-header').css({ | 465 | $('.yoho-header').css({ |
@@ -488,6 +475,22 @@ $('.yoho-header').css({ | @@ -488,6 +475,22 @@ $('.yoho-header').css({ | ||
488 | 475 | ||
489 | $('.hide-when-loading').show(); | 476 | $('.hide-when-loading').show(); |
490 | loading.hideLoadingMask(); | 477 | loading.hideLoadingMask(); |
478 | + | ||
479 | + //banner滑动 | ||
480 | + swiper = new Swiper('.swiper-container', { | ||
481 | + lazyLoading: true, | ||
482 | + loop: true, | ||
483 | + autoplay: 3000, | ||
484 | + pagination: '.swiper-pagination .pagination-inner' | ||
485 | + }); | ||
486 | + | ||
487 | + //热门品牌滑动 | ||
488 | + hotBrandsSwiper = new Swiper('.brands-swiper', { | ||
489 | + grabCursor: true, | ||
490 | + slidesPerView: 'auto', | ||
491 | + wrapperClass: 'brands-list', | ||
492 | + slideElement: 'li' | ||
493 | +}); | ||
491 | })(); | 494 | })(); |
492 | 495 | ||
493 | $fixTitleBar = $('<div class="title-bar fixed-title-bar"><h2></h2></div>'); | 496 | $fixTitleBar = $('<div class="title-bar fixed-title-bar"><h2></h2></div>'); |
@@ -1889,17 +1892,25 @@ module.exports = function(specificGender) { | @@ -1889,17 +1892,25 @@ module.exports = function(specificGender) { | ||
1889 | if (kidsType) { | 1892 | if (kidsType) { |
1890 | url = '/product/recom/maylikekids'; | 1893 | url = '/product/recom/maylikekids'; |
1891 | } else if (lifestyleType) { | 1894 | } else if (lifestyleType) { |
1892 | - url = '/product/recom/maylikelife'; | 1895 | + |
1896 | + //有货币页面加载男生首页的数据 | ||
1897 | + url = specificGender === 'lifestyle' ? '/product/recom/maylike?gender=1,3' : '/product/recom/maylikelife'; | ||
1893 | } else { | 1898 | } else { |
1894 | gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? | 1899 | gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ? |
1895 | '1,3' : '2,3', | 1900 | '1,3' : '2,3', |
1896 | url = '/product/recom/maylike?gender=' + gender; | 1901 | url = '/product/recom/maylike?gender=' + gender; |
1897 | } | 1902 | } |
1898 | 1903 | ||
1904 | + //以防cookie异常,强制加载男首 | ||
1905 | + if (specificGender === 'boys') { | ||
1906 | + url = '/product/recom/maylike?gender=1,3'; | ||
1907 | + } | ||
1908 | + | ||
1899 | $curNav = $navList.children('.focus'); | 1909 | $curNav = $navList.children('.focus'); |
1900 | 1910 | ||
1901 | if (lifestyleType) { | 1911 | if (lifestyleType) { |
1902 | - navHammer = new Hammer($navList[0]); | 1912 | + navHammer = $navList[0] ? new Hammer($navList[0]) : undefined; |
1913 | + if (navHammer) { | ||
1903 | navHammer.on('tap', function(e) { | 1914 | navHammer.on('tap', function(e) { |
1904 | var $this = $(e.target).closest('li'), | 1915 | var $this = $(e.target).closest('li'), |
1905 | $goods = $('.goods-list'), | 1916 | $goods = $('.goods-list'), |
@@ -1925,6 +1936,7 @@ module.exports = function(specificGender) { | @@ -1925,6 +1936,7 @@ module.exports = function(specificGender) { | ||
1925 | e.srcEvent.stopPropagation(); | 1936 | e.srcEvent.stopPropagation(); |
1926 | }); | 1937 | }); |
1927 | } | 1938 | } |
1939 | + } | ||
1928 | 1940 | ||
1929 | loading.init($('.maybe-like')); | 1941 | loading.init($('.maybe-like')); |
1930 | 1942 | ||
@@ -5526,15 +5538,28 @@ function changeSizeChosed(newSizeIndex) { | @@ -5526,15 +5538,28 @@ function changeSizeChosed(newSizeIndex) { | ||
5526 | $curSizeBlock.removeClass('chosed'); | 5538 | $curSizeBlock.removeClass('chosed'); |
5527 | sizes = $sizeRowList.eq(newSizeIndex).children(); | 5539 | sizes = $sizeRowList.eq(newSizeIndex).children(); |
5528 | for (i = 0; i < sizes.length; i++) { | 5540 | for (i = 0; i < sizes.length; i++) { |
5529 | - if ($(sizes[i]).data('name') === $curSizeBlock.data('name')) { | 5541 | + if ($(sizes[i]).data('id') === $curSizeBlock.data('id')) { |
5530 | $curSizeBlock = $(sizes[i]); | 5542 | $curSizeBlock = $(sizes[i]); |
5531 | - queryString = '#' + $curSizeBlock.data('name'); | 5543 | + queryString = '#' + $curSizeBlock.data('id'); |
5532 | curColorIndex = $(queryString).data('index'); | 5544 | curColorIndex = $(queryString).data('index'); |
5545 | + $curSizeBlock.addClass('chosed'); | ||
5546 | + return $curSizeBlock.data('num'); | ||
5533 | } | 5547 | } |
5534 | } | 5548 | } |
5535 | 5549 | ||
5536 | - $curSizeBlock.addClass('chosed'); | ||
5537 | - return $curSizeBlock.data('num'); | 5550 | + //特殊处理: 老的选中尺码在新选中的颜色对应尺码中不存在,需要下述1,2,3 |
5551 | + // 1.重置尺码选择的标志变量. | ||
5552 | + $curSizeBlock = null; | ||
5553 | + hasChooseSize = false; | ||
5554 | + | ||
5555 | + // 2.当前颜色行隐藏 | ||
5556 | + $colorRowList.eq(curColorIndex).addClass('hide'); | ||
5557 | + | ||
5558 | + // 3.目标颜色行第一行显示 | ||
5559 | + $colorRowList.eq(0).removeClass('hide'); | ||
5560 | + curColorIndex = 0; | ||
5561 | + | ||
5562 | + return -1; | ||
5538 | } | 5563 | } |
5539 | return 0; | 5564 | return 0; |
5540 | } | 5565 | } |
@@ -5612,7 +5637,15 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -5612,7 +5637,15 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
5612 | 5637 | ||
5613 | // 颜色块切换勾选样式 | 5638 | // 颜色块切换勾选样式 |
5614 | $this.siblings('.chosed').removeClass('chosed'); | 5639 | $this.siblings('.chosed').removeClass('chosed'); |
5640 | + | ||
5641 | + // 特殊处理 | ||
5642 | + if (-1 === curGoodNum) { | ||
5643 | + $curColorBlock = $($colorRowList.eq(0).children().get(index)); | ||
5644 | + $curColorBlock.addClass('chosed'); | ||
5645 | + } else { | ||
5615 | $this.toggleClass('chosed'); | 5646 | $this.toggleClass('chosed'); |
5647 | + } | ||
5648 | + | ||
5616 | $('#good-num').val(1); | 5649 | $('#good-num').val(1); |
5617 | 5650 | ||
5618 | // 设置按钮的样式和文字 | 5651 | // 设置按钮的样式和文字 |
@@ -5645,7 +5678,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | @@ -5645,7 +5678,7 @@ $yohoPage.on('touchstart', '.color-list .block', function() { | ||
5645 | } else { | 5678 | } else { |
5646 | hasChooseSize = true; | 5679 | hasChooseSize = true; |
5647 | 5680 | ||
5648 | - index = $('#' + $this.data('name')).data('index') - 1; | 5681 | + index = $('#' + $this.data('id')).data('index') - 1; |
5649 | 5682 | ||
5650 | // 颜色当前行隐藏 | 5683 | // 颜色当前行隐藏 |
5651 | $colorRowList.eq(curColorIndex).addClass('hide'); | 5684 | $colorRowList.eq(curColorIndex).addClass('hide'); |
@@ -8815,7 +8848,7 @@ define("js/me/currency-new", ["jquery","hammer","lazyload"], function(require, e | @@ -8815,7 +8848,7 @@ define("js/me/currency-new", ["jquery","hammer","lazyload"], function(require, e | ||
8815 | */ | 8848 | */ |
8816 | 8849 | ||
8817 | function getGender() { | 8850 | function getGender() { |
8818 | - return window.cookie('_Channel'); | 8851 | + return window.cookie('_Channel') || 'boys'; |
8819 | } | 8852 | } |
8820 | 8853 | ||
8821 | require("js/home/maybe-like")(getGender()); | 8854 | 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,46 +647,57 @@ class CartModel | @@ -647,46 +647,57 @@ class CartModel | ||
647 | if (isset($productData['goods_list'])) { | 647 | if (isset($productData['goods_list'])) { |
648 | $goodsList = $productData['goods_list']; | 648 | $goodsList = $productData['goods_list']; |
649 | 649 | ||
650 | + $sizeName = ''; | ||
650 | $colors = array(); | 651 | $colors = array(); |
652 | + $colorList = array(); | ||
651 | $oneColor = array(); | 653 | $oneColor = array(); |
652 | $sizes = array(); | 654 | $sizes = array(); |
653 | $oneSize = array(); | 655 | $oneSize = array(); |
654 | $sizeList = array(); | 656 | $sizeList = array(); |
657 | + $allSizeList = array(); // 所有尺码列表 | ||
655 | $thumbImageList = array(); | 658 | $thumbImageList = array(); |
656 | $colorNum = 0; | 659 | $colorNum = 0; |
657 | $totalStorageNum = 0; // 总库存数 | 660 | $totalStorageNum = 0; // 总库存数 |
658 | $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 | 661 | $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 |
659 | foreach ($goodsList as $val) { | 662 | foreach ($goodsList as $val) { |
660 | $colorNum = 0; | 663 | $colorNum = 0; |
661 | - $sizeStorageStr = ''; | 664 | + $sizeName = ''; |
662 | 665 | ||
666 | + // 商品的尺码列表 | ||
667 | + $colorStorageGroup[ $val['product_skc'] ] = array(); | ||
668 | + if (isset($val['size_list'])) { | ||
663 | // 尺码 | 669 | // 尺码 |
664 | foreach ($val['size_list'] as $one) { | 670 | foreach ($val['size_list'] as $one) { |
671 | + $sizeName = $one['size_name']; | ||
665 | $oneSize = array(); | 672 | $oneSize = array(); |
673 | + | ||
666 | $oneSize['id'] = $one['size_id']; | 674 | $oneSize['id'] = $one['size_id']; |
667 | $oneSize['skuId'] = $one['product_sku']; | 675 | $oneSize['skuId'] = $one['product_sku']; |
668 | $oneSize['goodsId'] = $val['goods_id']; | 676 | $oneSize['goodsId'] = $val['goods_id']; |
669 | $oneSize['colorId'] = $val['color_id']; | 677 | $oneSize['colorId'] = $val['color_id']; |
670 | - $oneSize['name'] = $one['size_name']; | 678 | + $oneSize['name'] = $sizeName; |
671 | $oneSize['sizeNum'] = $one['storage_number']; | 679 | $oneSize['sizeNum'] = $one['storage_number']; |
680 | + $sizeList[$val['product_skc']][] = $oneSize; | ||
672 | 681 | ||
673 | - $colorNum += $one['storage_number']; | ||
674 | - $sizeStorageStr .= $one['storage_number'] . '/'; | 682 | + // 所有尺码列表,赋值用于前端展示默认尺码的时候 判断出没有库存则显示灰色 |
683 | + $allSizeList[$sizeName] = empty($allSizeList[$sizeName]['storage_number']) | ||
684 | + ? array('storage' => $one['storage_number'], 'id' => $one['size_id']) | ||
685 | + : $allSizeList[$sizeName]; | ||
675 | 686 | ||
676 | - $sizeList[$val['product_skc']][] = $oneSize; | 687 | + $colorNum += intval($one['storage_number']); |
677 | 688 | ||
678 | $colorStorageGroup[$val['product_skc']][$one['size_name']] = $one['storage_number']; | 689 | $colorStorageGroup[$val['product_skc']][$one['size_name']] = $one['storage_number']; |
679 | } | 690 | } |
680 | 691 | ||
681 | - // 颜色 | 692 | + // 颜色分组 |
682 | $oneColor = array(); | 693 | $oneColor = array(); |
683 | $oneColor['id'] = $val['color_id']; | 694 | $oneColor['id'] = $val['color_id']; |
684 | $oneColor['skcId'] = $val['product_skc']; | 695 | $oneColor['skcId'] = $val['product_skc']; |
685 | $oneColor['name'] = $val['color_name']; | 696 | $oneColor['name'] = $val['color_name']; |
686 | $oneColor['goodsName'] = $productData['product_name']; | 697 | $oneColor['goodsName'] = $productData['product_name']; |
687 | $oneColor['colorNum'] = $colorNum; | 698 | $oneColor['colorNum'] = $colorNum; |
688 | - $oneColor['sizeNumStr'] = rtrim($sizeStorageStr, '/'); | ||
689 | - $colors[] = $oneColor; | 699 | + $colorList[] = $oneColor; |
700 | + } | ||
690 | 701 | ||
691 | // 缩略图 | 702 | // 缩略图 |
692 | foreach ($val['images_list'] as $image) { | 703 | foreach ($val['images_list'] as $image) { |
@@ -699,25 +710,38 @@ class CartModel | @@ -699,25 +710,38 @@ class CartModel | ||
699 | $totalStorageNum += $colorNum; | 710 | $totalStorageNum += $colorNum; |
700 | } | 711 | } |
701 | 712 | ||
702 | - // 遍历所有尺码,统计出该尺码的每个颜色的库存量,没有时添0,不能空着,因为JS中需要判断 | ||
703 | - foreach ($sizeList as $skc => $sizeArr) { | ||
704 | - foreach ($sizeArr as $key => $value) { | ||
705 | - $sizeStorageStr = ''; | ||
706 | - foreach ($colorStorageGroup as $colorArr) { | ||
707 | - if (isset($colorArr[$value['name']])) { | ||
708 | - $sizeStorageStr .= $colorArr[$value['name']] . '/'; | ||
709 | - } else { | ||
710 | - $sizeStorageStr .= '0/'; | ||
711 | - } | ||
712 | - } | ||
713 | - $sizeList[$skc][$key]['colorNumStr'] = rtrim($sizeStorageStr, '/'); | 713 | + // 遍历所有尺码,构建颜色显示数据 |
714 | + $i = 1; | ||
715 | + foreach ($allSizeList as $sizeName => $value) { | ||
716 | + // 默认尺码 | ||
717 | + $sizes[0]['size'][] = array( | ||
718 | + 'name' => $sizeName, // 尺码名称 | ||
719 | + 'sizeNum' => empty($value['storage']) ? false : true, // 是否有库存 (false:表示没有库存,true:表示有库存) | ||
720 | + 'id' => $value['id'], | ||
721 | + ); | ||
722 | + | ||
723 | + // 各个颜色的尺码, 每行显示一个尺码对应的颜色 | ||
724 | + foreach ($colorList as $colorArr) { | ||
725 | + $colorArr['colorNum'] = isset($colorStorageGroup[ $colorArr['skcId'] ][$sizeName]) ? $colorStorageGroup[ $colorArr['skcId'] ][$sizeName] : 0; | ||
726 | + $colors[$i]['color'][] = $colorArr; | ||
714 | } | 727 | } |
728 | + $colors[$i]['id'] = $value['id']; | ||
729 | + | ||
730 | + ++ $i; | ||
715 | } | 731 | } |
716 | 732 | ||
717 | - // 格式化尺码对应的各个颜色分组 | ||
718 | - foreach ($colors as $color) { | ||
719 | - $sizes[]['size'] = $sizeList[$color['skcId']]; | 733 | + // 遍历所有颜色, 构建尺码显示数据 |
734 | + $i = 1; | ||
735 | + foreach ($colorList as $value) { | ||
736 | + // 各个尺码的颜色,每行显示一个颜色的对应尺码 | ||
737 | + $sizes[$i]['size'] = $sizeList[ $value['skcId'] ]; | ||
738 | + $sizes[$i]['colorId'] = $value['skcId']; | ||
739 | + // 默认颜色 | ||
740 | + $colors[0]['color'][] = $value; | ||
741 | + | ||
742 | + ++ $i; | ||
720 | } | 743 | } |
744 | + ksort($colors, SORT_NUMERIC); | ||
721 | 745 | ||
722 | $data['thumbs'] = $thumbImageList; | 746 | $data['thumbs'] = $thumbImageList; |
723 | $data['colors'] = $colors; | 747 | $data['colors'] = $colors; |
-
Please register or login to post a comment