Authored by 郭成尧

Merge branch 'feature/brand' of git.yoho.cn:fe/yohoblk-wap into feature/brand

1 const $ = require('yoho-jquery'); 1 const $ = require('yoho-jquery');
2 const Vue = require('yoho-vue'); 2 const Vue = require('yoho-vue');
3 3
4 -const resources = require('channel/resources.vue');  
5 -const letterList = require('channel/letter-list.vue'); 4 +var $nav = $('.cate-nav'),
  5 + $cateContainer = $('.cate-container'),
  6 + $contents = $cateContainer.children('.content'),
  7 + $subLevelItem = $cateContainer.find('.sub-level li'),
  8 + $primaryItem = $cateContainer.find('.primary-level li');
6 9
7 -require('common/vue-filter'); 10 +var $curContent = $contents.not('.hide');
8 11
9 -new Vue({  
10 - el: '#cate',  
11 - components: {  
12 - resources,  
13 - letterList 12 +(function() {
  13 + var $header = $('.yoho-header'),
  14 + $search = $('#search-input');
  15 +
  16 + var h = $(window).height() - $header.outerHeight() - $search.outerHeight() - $nav.outerHeight();
  17 +
  18 + $cateContainer.css('min-height', h);
  19 +
  20 + $contents.height(h);
  21 +}());
  22 +
  23 +$('#search-input').focus(function() {
  24 + $(this).blur();
  25 +});
  26 +$nav.bind('contextmenu', function() {
  27 + return false;
  28 +});
  29 +$('.cate-container').bind('contextmenu', function() {
  30 + return false;
  31 +});
  32 +
  33 +$nav.on('touchend touchcancel', function(e) {
  34 + var $this = $(e.target).closest('li'),
  35 + index = $this.index();
  36 +
  37 + if ($this.hasClass('focus')) {
  38 + return;
  39 + }
  40 +
  41 + $nav.find('li.focus').removeClass('focus');
  42 + $this.addClass('focus');
  43 +
  44 + $curContent.addClass('hide');
  45 + $curContent = $contents.eq(index).removeClass('hide');
  46 +});
  47 +
  48 +$cateContainer.on('touchend', function(e) {
  49 + var $this = $(e.target),
  50 + $subLevel,
  51 + $cur, index;
  52 +
  53 + $cur = $this.closest('.p-level-item');
  54 + if ($cur.length > 0) {
  55 + index = $cur.index();
  56 + $subLevel = $this.closest('.content').find('.sub-level');
  57 +
  58 + if ($this.hasClass('focus')) {
  59 + return;
  60 + }
  61 +
  62 + $this.closest('.primary-level').children('.focus').removeClass('focus');
  63 + $this.addClass('focus');
  64 +
  65 + $subLevel.not('.hide').addClass('hide');
  66 + $subLevel.eq(index).removeClass('hide');
  67 +
  68 + $subLevel.css({
  69 + top: $cur.offset().top - 60
  70 + });
14 } 71 }
15 }); 72 });
  73 +
  74 +$cateContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
  75 + $primaryItem.removeClass('highlight');
  76 + $(this).addClass('highlight');
  77 +}).on('touchend touchcancel', 'li', function() {
  78 + $(this).removeClass('highlight');
  79 +});
  80 +
  81 +$cateContainer.find('.sub-level').on('touchstart', 'li', function() {
  82 + $subLevelItem.removeClass('highlight');
  83 + $(this).addClass('highlight');
  84 +}).on('touchend touchcancel', 'li', function() {
  85 + $(this).removeClass('highlight');
  86 +});
  87 +
  88 +$nav.on('touchstart', 'li', function() {
  89 + $nav.find('li').removeClass('bytouch');
  90 + $(this).addClass('bytouch');
  91 +}).on('touchend touchcancel', 'li', function() {
  92 + $nav.find('li').removeClass('bytouch');
  93 +});
  94 +
@@ -50,10 +50,13 @@ @@ -50,10 +50,13 @@
50 box-sizing: border-box; 50 box-sizing: border-box;
51 float: left; 51 float: left;
52 height: 100%; 52 height: 100%;
53 - padding: 20px 0; 53 + padding: 20px 10px;
54 width: 25%; 54 width: 25%;
55 text-align: center; 55 text-align: center;
56 color: #999; 56 color: #999;
  57 + white-space: nowrap;
  58 + overflow: hidden;
  59 + text-overflow: ellipsis;
57 60
58 &:last-child { 61 &:last-child {
59 border-right: none; 62 border-right: none;
@@ -124,18 +127,7 @@ @@ -124,18 +127,7 @@
124 .sub-level { 127 .sub-level {
125 width: 100%; 128 width: 100%;
126 background-color: #f6f6f6; 129 background-color: #f6f6f6;
127 -  
128 - &:before {  
129 - content: "";  
130 - width: 0;  
131 - height: 0;  
132 - border-top: 20px solid transparent;  
133 - border-bottom: 20px solid transparent;  
134 - border-right: 20px solid #efefef;  
135 - position: absolute;  
136 - margin-top: 32px;  
137 - margin-left: -16px;  
138 - } 130 + position: relative;
139 131
140 &.hide { 132 &.hide {
141 display: none; 133 display: none;
@@ -155,6 +147,22 @@ @@ -155,6 +147,22 @@
155 &:last-child { 147 &:last-child {
156 border-bottom: none; 148 border-bottom: none;
157 } 149 }
  150 +
  151 + &:hover {
  152 + background-color: #efefef;
  153 + }
  154 +
  155 + &:first-child:before {
  156 + content: "";
  157 + width: 0;
  158 + height: 0;
  159 + border-top: 20px solid transparent;
  160 + border-bottom: 20px solid transparent;
  161 + border-right: 20px solid #efefef;
  162 + position: absolute;
  163 + margin-top: 32px;
  164 + margin-left: -40px;
  165 + }
158 } 166 }
159 167
160 a { 168 a {