Authored by hf

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

@@ -8,7 +8,6 @@ var $ = require('yoho.zepto'), @@ -8,7 +8,6 @@ var $ = require('yoho.zepto'),
8 Swiper = require('yoho.iswiper'); 8 Swiper = require('yoho.iswiper');
9 9
10 var info = require('./info'), 10 var info = require('./info'),
11 - setLazyLoadAndMellipsis = info.setLazyLoadAndMellipsis,  
12 loadMore = info.loadMore; 11 loadMore = info.loadMore;
13 12
14 var $loadMoreInfo = $('#load-more-info'); 13 var $loadMoreInfo = $('#load-more-info');
@@ -45,10 +44,11 @@ info.initInfosEvt($infoList); @@ -45,10 +44,11 @@ info.initInfosEvt($infoList);
45 var gender = $('#gender').val(); 44 var gender = $('#gender').val();
46 45
47 $nav.children('.guang-nav-item').each(function() { 46 $nav.children('.guang-nav-item').each(function() {
48 - var type = $(this).data('type'); 47 + var type = $(this).data('type'),
  48 + focus = $(this).hasClass('focus');
49 49
50 state[type] = { 50 state[type] = {
51 - page: 1, 51 + page: focus ? 1 : 0,
52 gender: gender, 52 gender: gender,
53 type: type, 53 type: type,
54 end: false 54 end: false
@@ -65,6 +65,9 @@ $nav.delegate('.guang-nav-item', 'tap', function() { @@ -65,6 +65,9 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
65 return; 65 return;
66 } 66 }
67 67
  68 + $curNav = $this;
  69 + curType = $this.data('type');
  70 +
68 index = $this.index(); 71 index = $this.index();
69 72
70 $this.addClass('focus'); 73 $this.addClass('focus');
@@ -75,11 +78,7 @@ $nav.delegate('.guang-nav-item', 'tap', function() { @@ -75,11 +78,7 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
75 $content = $infos.eq(index); 78 $content = $infos.eq(index);
76 $content.removeClass('hide'); 79 $content.removeClass('hide');
77 80
78 - //lazyload & mellipsis  
79 - setLazyLoadAndMellipsis($content.children('.guang-info'));  
80 -  
81 - $curNav = $this;  
82 - curType = $this.data('type'); 81 + loadMore($content, state[curType]);
83 82
84 //重置当前Tab的load-more 83 //重置当前Tab的load-more
85 if (state[curType].end) { 84 if (state[curType].end) {
@@ -93,6 +92,6 @@ $nav.delegate('.guang-nav-item', 'tap', function() { @@ -93,6 +92,6 @@ $nav.delegate('.guang-nav-item', 'tap', function() {
93 92
94 $(document).scroll(function() { 93 $(document).scroll(function() {
95 if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) { 94 if ($(window).scrollTop() + winH >= $(document).height() - loadMoreH) {
96 - loadMore($infos, state[curType]); 95 + loadMore($infos.not('hide'), state[curType]);
97 } 96 }
98 }); 97 });
@@ -9,12 +9,13 @@ var $ = require('yoho.zepto'), @@ -9,12 +9,13 @@ var $ = require('yoho.zepto'),
9 lazyLoad = require('yoho.zeptolazyload'); 9 lazyLoad = require('yoho.zeptolazyload');
10 10
11 var tip = require('../plugin/tip'); 11 var tip = require('../plugin/tip');
  12 +var loading = require('../plugin/loading');
12 13
13 var $loadMoreInfo = $('#load-more-info'); 14 var $loadMoreInfo = $('#load-more-info');
14 var $loading = $(''), 15 var $loading = $(''),
15 $noMore = $(''); 16 $noMore = $('');
16 17
17 -var loading = false; 18 +var searching = false;
18 19
19 ellipsis.init(); 20 ellipsis.init();
20 21
@@ -84,7 +85,7 @@ function initInfosEvt($container) { @@ -84,7 +85,7 @@ function initInfosEvt($container) {
84 * 资讯LoadMore 85 * 资讯LoadMore
85 */ 86 */
86 function loadMore($container, opt) { 87 function loadMore($container, opt) {
87 - if (loading) { 88 + if (searching) {
88 return; 89 return;
89 } 90 }
90 91
@@ -92,7 +93,13 @@ function loadMore($container, opt) { @@ -92,7 +93,13 @@ function loadMore($container, opt) {
92 return; 93 return;
93 } 94 }
94 95
95 - loading = true; 96 + if (opt.page === 0) {
  97 +
  98 + //显示loading
  99 + loading.showLoadingMask();
  100 + }
  101 +
  102 + searching = true;
96 $.ajax({ 103 $.ajax({
97 type: 'GET', 104 type: 'GET',
98 url: ' /guang/index/page', 105 url: ' /guang/index/page',
@@ -100,7 +107,7 @@ function loadMore($container, opt) { @@ -100,7 +107,7 @@ function loadMore($container, opt) {
100 success: function(data) { 107 success: function(data) {
101 if (data === ' ') { 108 if (data === ' ') {
102 opt.end = true; 109 opt.end = true;
103 - loading = false; 110 + searching = false;
104 111
105 // 112 //
106 $loading.addClass('hide'); 113 $loading.addClass('hide');
@@ -112,13 +119,17 @@ function loadMore($container, opt) { @@ -112,13 +119,17 @@ function loadMore($container, opt) {
112 119
113 setLazyLoadAndMellipsis($container.find('.guang-info')); 120 setLazyLoadAndMellipsis($container.find('.guang-info'));
114 121
  122 + if (opt.page === 0) {
  123 + loading.hideLoadingMask();
  124 + }
  125 +
115 opt.page++; 126 opt.page++;
116 127
117 - loading = false; 128 + searching = false;
118 }, 129 },
119 error: function() { 130 error: function() {
120 tip.show('网络断开连接了~'); 131 tip.show('网络断开连接了~');
121 - loading = false; 132 + searching = false;
122 } 133 }
123 }); 134 });
124 } 135 }
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 var $ = require('yoho.zepto'); 8 var $ = require('yoho.zepto');
9 9
10 -var $filter = $('.filter-mask, .filter-body'); 10 +var $filter = $('.filter-mask');
11 11
12 var $classify = $filter.find('.classify'), 12 var $classify = $filter.find('.classify'),
13 $subClassify = $filter.find('.sub-classify'); 13 $subClassify = $filter.find('.sub-classify');
@@ -33,9 +33,11 @@ function registerCbFn(cb) { @@ -33,9 +33,11 @@ function registerCbFn(cb) {
33 $classify.children(':first-child').addClass('active'); //T:不在HTML中使用{{#if @first}}active{{/if}}来初始化active为避免sub设置高度时的闪烁 33 $classify.children(':first-child').addClass('active'); //T:不在HTML中使用{{#if @first}}active{{/if}}来初始化active为避免sub设置高度时的闪烁
34 34
35 //classify switch 35 //classify switch
36 -$classify.delegate('.classify-item', 'tap', function() { 36 +$classify.delegate('.classify-item', 'tap', function(e) {
37 var $this = $(this); 37 var $this = $(this);
38 38
  39 + e.stopPropagation();
  40 +
39 if ($this.hasClass('active')) { 41 if ($this.hasClass('active')) {
40 return; 42 return;
41 } 43 }
@@ -46,7 +48,7 @@ $classify.delegate('.classify-item', 'tap', function() { @@ -46,7 +48,7 @@ $classify.delegate('.classify-item', 'tap', function() {
46 }); 48 });
47 49
48 //点击Mask隐藏筛选界面 50 //点击Mask隐藏筛选界面
49 -$filter.filter('.filter-mask').tap(function() { 51 +$filter.tap(function() {
50 hideFilter(); 52 hideFilter();
51 }); 53 });
52 54
@@ -10,17 +10,14 @@ var $page = $('.yoho-page'); @@ -10,17 +10,14 @@ var $page = $('.yoho-page');
10 10
11 var $loading; 11 var $loading;
12 12
13 -/**  
14 - * 初始化loading mask  
15 - * @param $container loading容器, position:relative  
16 - */  
17 -function initLoadingMask() { 13 +//初始化
  14 +(function() {
18 var html = '<div class="loading-mask hide"><div class="loading"></div></div>'; 15 var html = '<div class="loading-mask hide"><div class="loading"></div></div>';
19 16
20 $page.append(html); 17 $page.append(html);
21 18
22 $loading = $page.children('.loading-mask'); 19 $loading = $page.children('.loading-mask');
23 -} 20 +}());
24 21
25 //显示loading 22 //显示loading
26 function showLoadingMask() { 23 function showLoadingMask() {
@@ -32,6 +29,5 @@ function hideLoadingMask() { @@ -32,6 +29,5 @@ function hideLoadingMask() {
32 $loading.addClass('hide'); 29 $loading.addClass('hide');
33 } 30 }
34 31
35 -exports.initLoadingMask = initLoadingMask;  
36 exports.showLoadingMask = showLoadingMask; 32 exports.showLoadingMask = showLoadingMask;
37 exports.hideLoadingMask = hideLoadingMask; 33 exports.hideLoadingMask = hideLoadingMask;
@@ -209,7 +209,6 @@ function search(opt) { @@ -209,7 +209,6 @@ function search(opt) {
209 lazyLoad($('.lazy')); 209 lazyLoad($('.lazy'));
210 210
211 filter.registerCbFn(search); 211 filter.registerCbFn(search);
212 -loading.initLoadingMask();  
213 212
214 //导航栏点击逻辑说明: 213 //导航栏点击逻辑说明:
215 //1.点击非active项时切换active状态 214 //1.点击非active项时切换active状态
1 .loading-mask { 1 .loading-mask {
2 position: absolute; 2 position: absolute;
3 - background: rgba(0,0,0,.3); 3 + background: rgba(0,0,0,.1);
4 top: 0; 4 top: 0;
5 bottom: 0; 5 bottom: 0;
6 right: 0; 6 right: 0;
1 {{# filter}} 1 {{# filter}}
2 - <div class="filter-mask hide"></div>  
3 - <div class="filter-body hide">  
4 - <ul class="classify">  
5 - {{#each classify}}  
6 - <li class="classify-item">  
7 - <p class="shower{{#if default}} default{{/if}}">  
8 - <span class="title">{{title}}:</span>  
9 - {{name}}  
10 - </p>  
11 - <ul class="sub-classify" data-type={{dataType}}>  
12 - {{# subs}}  
13 - <li {{#if chosed}}class=chosed{{/if}} data-id={{dataId}}>  
14 - {{name}}  
15 - <i class="iconfont chosed-icon">&#xe617;</i>  
16 - </li>  
17 - {{/ subs}}  
18 - </ul>  
19 - </li>  
20 - {{/each}}  
21 - </ul> 2 + <div class="filter-mask hide">
  3 + <div class="filter-body">
  4 + <ul class="classify">
  5 + {{#each classify}}
  6 + <li class="classify-item">
  7 + <p class="shower{{#if default}} default{{/if}}">
  8 + <span class="title">{{title}}:</span>
  9 + {{name}}
  10 + </p>
  11 + <ul class="sub-classify" data-type={{dataType}}>
  12 + {{# subs}}
  13 + <li {{#if chosed}}class=chosed{{/if}} data-id={{dataId}}>
  14 + {{name}}
  15 + <i class="iconfont chosed-icon">&#xe617;</i>
  16 + </li>
  17 + {{/ subs}}
  18 + </ul>
  19 + </li>
  20 + {{/each}}
  21 + </ul>
  22 + </div>
22 </div> 23 </div>
23 {{/ filter}} 24 {{/ filter}}