Authored by 郭成尧

'shop-category'

@@ -351,6 +351,30 @@ const favoriteBrand = (req, res, next) => { @@ -351,6 +351,30 @@ const favoriteBrand = (req, res, next) => {
351 } 351 }
352 }; 352 };
353 353
  354 +/**
  355 + * 店铺品类页面
  356 + * @param req
  357 + * @param res
  358 + * @param next
  359 + */
  360 +const shopCategory = (req, res, next) => {
  361 +
  362 + listModel.getShopCategory({
  363 + shopId: req.query.shop_id,
  364 + channel: req.yoho.channel,
  365 + gender: req.query.gender || '1,3'
  366 + }).then(result => {
  367 + res.render('shop/category', {
  368 + content: result,
  369 + module: 'product',
  370 + page: 'category',
  371 + pageHeader: headerModel.setNav({
  372 + navTitle: '品类'
  373 + }),
  374 + });
  375 + }).catch(next);
  376 +};
  377 +
354 module.exports = { 378 module.exports = {
355 category, 379 category,
356 brand, 380 brand,
@@ -362,4 +386,5 @@ module.exports = { @@ -362,4 +386,5 @@ module.exports = {
362 shopAppCookie, 386 shopAppCookie,
363 shopFav, 387 shopFav,
364 baseShopFav, 388 baseShopFav,
  389 + shopCategory
365 }; 390 };
@@ -119,12 +119,13 @@ const _getShopInfo = (shopId, uid) => { @@ -119,12 +119,13 @@ const _getShopInfo = (shopId, uid) => {
119 * @param {string} channel 频道 119 * @param {string} channel 频道
120 * @return array 120 * @return array
121 */ 121 */
122 -const _getShopCategory = (shopId, channel) => { 122 +const _getShopCategory = (shopId, channel, gender) => {
123 return api.get('', { 123 return api.get('', {
124 method: 'app.shop.getSortInfo', 124 method: 'app.shop.getSortInfo',
125 yh_channel: channel, 125 yh_channel: channel,
  126 + gender: gender || '1,3',
126 shop_id: shopId 127 shop_id: shopId
127 - }).then((result) => { 128 + }).then(result => {
128 if (result && result.code === 200) { 129 if (result && result.code === 200) {
129 return camelCase(result.data); 130 return camelCase(result.data);
130 } else { 131 } else {
@@ -652,6 +653,47 @@ const getShopIntro = (shopId) => { @@ -652,6 +653,47 @@ const getShopIntro = (shopId) => {
652 }); 653 });
653 }; 654 };
654 655
  656 +/**
  657 + * 处理店铺品类
  658 + * @param params
  659 + */
  660 +const getShopCategory = (params) => {
  661 + let finalResult = {
  662 + class: [],
  663 + category: []
  664 + };
  665 +
  666 + return _getShopCategory(params.shopId, params.channel, params.gender).then(result => {
  667 + let resultCopy = _.cloneDeep(result);
  668 +
  669 + _.forEach(resultCopy, value => {
  670 + finalResult.class.push({
  671 + name: value.categoryName
  672 + });
  673 +
  674 + _.forEach(value.sub, (subValue, subKey) => {
  675 + value.sub[subKey].url = helpers.urlFormat({
  676 + shop: params.shopId,
  677 + categoryId: value.categoryId,
  678 + subCategoryId: subValue.categoryId,
  679 + title: subValue.categoryName,
  680 + query: subValue.categoryName
  681 + });
  682 + });
  683 +
  684 + finalResult.category.push({
  685 + subcategory: value.sub
  686 + });
  687 + });
  688 +
  689 + finalResult.allproduct = helpers.urlFormat('/search/list', {
  690 + shop_id: params.shopId
  691 + });
  692 +
  693 + return finalResult;
  694 + });
  695 +};
  696 +
655 module.exports = { 697 module.exports = {
656 getBaseShopData, 698 getBaseShopData,
657 getShopData, 699 getShopData,
@@ -662,5 +704,6 @@ module.exports = { @@ -662,5 +704,6 @@ module.exports = {
662 setFavorite, 704 setFavorite,
663 setFavoriteCancel, 705 setFavoriteCancel,
664 getShopIntro, 706 getShopIntro,
665 - getShopBrands 707 + getShopBrands,
  708 + getShopCategory
666 }; 709 };
@@ -100,6 +100,7 @@ router.get('/index/brandFav', list.brandFav); @@ -100,6 +100,7 @@ router.get('/index/brandFav', list.brandFav);
100 router.get('/index/shopAppCookie', list.shopAppCookie); 100 router.get('/index/shopAppCookie', list.shopAppCookie);
101 router.get('/index/shopFav', list.shopFav); 101 router.get('/index/shopFav', list.shopFav);
102 router.get('/index/baseShopFav', list.baseShopFav); 102 router.get('/index/baseShopFav', list.baseShopFav);
  103 +router.get('/index/category', list.shopCategory);
103 104
104 // 店铺介绍 105 // 店铺介绍
105 router.get('/index/intro', list.shopIntro); 106 router.get('/index/intro', list.shopIntro);
  1 +<div class="product-category yoho-page">
  2 +
  3 + <div id="allproduct" class="allproduct">
  4 + <a href={{allproduct}}>
  5 + <p class="allproductParagaraph buriedpoint" data-bp-id ="shop_category_all_1">全部商品</p>
  6 + <i class="arrow-icon iconfont">&#xe614;</i>
  7 + </a>
  8 + </div>
  9 + <div class="margin-under-allproduct">
  10 + </div>
  11 + <div class="category-container clearfix">
  12 + <div class="content">
  13 + {{# content}}
  14 + <ul class="primary-level">
  15 + {{# class}}
  16 + <li class="p-level-item buriedpoint" data-bp-id="shop_primarylevel_{{name}}_1">{{name}}
  17 + <div class="primary-level-trilangle trilanglefont hide">&#xe64a;</div>
  18 + </li>
  19 + {{/ class}}
  20 + </ul>
  21 + <div class="sub-level-container hide">
  22 + {{# category}}
  23 + <ul class="sub-level">
  24 + {{# subcategory}}
  25 + <li class="buriedpoint" data-bp-id="shop_sublevel_{{categoryName}}_1">
  26 + <a href={{url}}>
  27 + {{categoryName}}
  28 + </a>
  29 + </li>
  30 + {{/ subcategory}}
  31 + </ul>
  32 + {{/ category}}
  33 + </div>
  34 + {{/ content}}
  35 + </div>
  36 + </div>
  37 +</div>
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 {{^}} 22 {{^}}
23 <div class="banner-top-single"> 23 <div class="banner-top-single">
24 <a href={{url}}> 24 <a href={{url}}>
25 - <img class="img" src="{{image src 450 600}}"> 25 + <img class="img" src="{{image img 450 600}}">
26 </a> 26 </a>
27 </div> 27 </div>
28 {{/if}} 28 {{/if}}

7.97 KB | W: | H:

8.86 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
  1 +/**
  2 + * 分类
  3 + * @author: berry<lixia.zhang@yoho.cn>
  4 + * @date: 2016/4/25
  5 + */
  6 +var $ = require('yoho-jquery');
  7 +
  8 +var $allProductCell = $('.allproduct'),
  9 + $categoryContainer = $('.category-container'),
  10 + $contents = $categoryContainer.children('.content'),
  11 + $subLevelItem = $categoryContainer.find('.sub-level li'),
  12 + $trilangle = $categoryContainer.find('.primary-level-trilangle');
  13 +
  14 +//初始化container高度
  15 +(function() {
  16 + var $header = $('.yoho-header');
  17 + var h = $(window).height() - $header.outerHeight() - $allProductCell.outerHeight();
  18 + var trilangleRightMargin = $(window).width() * 0.55;
  19 +
  20 + $categoryContainer.css('min-height', h);
  21 + $trilangle.css('margin-right', trilangleRightMargin);
  22 + $contents.height(h);
  23 +
  24 +}());
  25 +
  26 +
  27 +$categoryContainer.on('touchend', function(e) {
  28 + var $this = $(e.target),
  29 + $subLevel,
  30 + $cur, index,
  31 + $subLevelContainer, $trilangleItem;
  32 +
  33 + $cur = $this.closest('.p-level-item');
  34 +
  35 + $subLevelContainer = $this.closest('.content').find('.sub-level-container');
  36 + $subLevelContainer.removeClass('hide');
  37 +
  38 + if ($cur.length > 0) {
  39 + index = $cur.index();
  40 + $subLevel = $this.closest('.content').find('.sub-level');
  41 + $trilangleItem = $this.closest('.content').find('.primary-level-trilangle');
  42 +
  43 + if ($this.hasClass('focus')) {
  44 + return;
  45 + }
  46 +
  47 + $subLevel.not('.hide').addClass('hide');
  48 + $subLevel.eq(index).removeClass('hide');
  49 +
  50 + $trilangleItem.not('.hide').addClass('hide');
  51 + $trilangleItem.eq(index).removeClass('hide');
  52 + }
  53 +});
  54 +
  55 +$categoryContainer.find('.sub-level').on('touchstart', 'li', function() {
  56 + $subLevelItem.removeClass('highlight');
  57 + $(this).addClass('highlight');
  58 +}).on('touchend touchcancel', 'li', function() {
  59 + $(this).removeClass('highlight');
  60 +});
  61 +
  62 +$allProductCell.on('touchstart', function() {
  63 + $(this).addClass('highlight');
  64 +}).on('touchend touchcancel', function() {
  65 + $(this).removeClass('highlight');
  66 +});
1 @import "shop-index"; 1 @import "shop-index";
2 @import "shop-prodfile"; 2 @import "shop-prodfile";
  3 +@import "product-category";
  1 +.product-category {
  2 + font-size: 30px;
  3 + background-color: #fff;
  4 +
  5 + .allproduct {
  6 + padding: 0px 30px;
  7 + display: block;
  8 + height: 89px;
  9 + line-height: 89px;
  10 +
  11 + &.highlight {
  12 + background: #dbdbdb;
  13 + }
  14 + }
  15 +
  16 + .margin-under-allproduct{
  17 + width: 100%;
  18 + height: 30px;
  19 + background-color: #f0f0f0;
  20 + }
  21 +
  22 + .category-container{
  23 + border-top: 1px solid #e6e6e6;
  24 + }
  25 + .arrow-icon {
  26 + position: relative;
  27 + float: right;
  28 + font-size: 30px;
  29 + top: 0px;
  30 + color: #e1e1e1;
  31 + padding: 0px 10px;
  32 + }
  33 +
  34 + .allproductParagaraph {
  35 + font-size: 18px;
  36 + left: 20px;
  37 + }
  38 +
  39 + .content {
  40 + background: #fff;
  41 +
  42 + &.hide {
  43 + display: none;
  44 + }
  45 + }
  46 +
  47 + .primary-level {
  48 + float: left;
  49 + box-sizing: border-box;
  50 + width: 100%;
  51 + position: absolute;
  52 + > li {
  53 + position:relative;
  54 + height: 89px;
  55 + line-height: 89px;
  56 + box-sizing: border-box;
  57 + border-bottom: 1px solid #e6e6e6;
  58 + background-color: #fff;
  59 + margin-left: 30px;
  60 + }
  61 + }
  62 +
  63 + .primary-level-trilangle{
  64 + float: right;
  65 + background: url(/product/arrow.png) no-repeat;
  66 + margin-top: 22px;
  67 + width: 20px;
  68 + height: 46px;
  69 + }
  70 +
  71 + .trilanglefont {
  72 + font-family: "iconfont" !important;
  73 + font-size: 30px;
  74 + font-style: normal;
  75 + text-decoration: none;
  76 + -webkit-font-smoothing: antialiased;
  77 + -webkit-text-stroke-width: 0.2px;
  78 + -moz-osx-font-smoothing: grayscale;
  79 + color: #f4f4f4;
  80 + }
  81 +
  82 +
  83 + .sub-level-container {
  84 + float: right;
  85 + box-sizing: border-box;
  86 + background: #f4f4f4;
  87 + width: 55%;
  88 + height: 100%;
  89 + position: relative;
  90 + }
  91 +
  92 + .sub-level {
  93 + width: 100%;
  94 +
  95 + &.hide {
  96 + display: none;
  97 + }
  98 +
  99 + > li {
  100 + box-sizing: border-box;
  101 + height: 89px;
  102 + line-height: 89px;
  103 + border-bottom: 1px solid #e6e6e6;
  104 + margin-left: 30px;
  105 + padding-left: 0;
  106 +
  107 + &.highlight {
  108 + background: #dbdbdb;
  109 + margin-left: 0;
  110 + padding-left: 30px;
  111 + }
  112 +
  113 + &:last-child {
  114 + border-bottom: none;
  115 + }
  116 + }
  117 +
  118 + a {
  119 + display: block;
  120 + height: 100%;
  121 + width: 100%;
  122 + color: #afafaf;
  123 + }
  124 + }
  125 +}