Authored by Lynnic

为评论咨询绑定tap事件 --code viewed by zhaobiao

@@ -10,7 +10,10 @@ var $ = require('jquery'), @@ -10,7 +10,10 @@ var $ = require('jquery'),
10 var commentsNum,consultsNum; 10 var commentsNum,consultsNum;
11 11
12 var consultFooterEle = document.getElementById('consult-content-footer'), 12 var consultFooterEle = document.getElementById('consult-content-footer'),
13 - consultFooterHammer = consultFooterEle && new Hammer(consultFooterEle); 13 + consultFooterHammer = consultFooterEle && new Hammer(consultFooterEle),
  14 +
  15 + navtabEle = document.getElementById('nav-tab'),
  16 + navtabHammer = navtabEle && new Hammer(navtabEle);
14 17
15 18
16 (function() { 19 (function() {
@@ -36,26 +39,29 @@ var consultFooterEle = document.getElementById('consult-content-footer'), @@ -36,26 +39,29 @@ var consultFooterEle = document.getElementById('consult-content-footer'),
36 39
37 })(); 40 })();
38 41
39 -$('#nav-tab li').on('touchend', function() {  
40 - var index = $(this).index(); 42 +if (navtabHammer) {
  43 + navtabHammer.on('tap', function(e) {
  44 + var $this = $(e.target).closest('li');
  45 + var index = $this.index();
41 46
42 - if ($(this).hasClass('comment-nav') && 0 === commentsNum) {  
43 - tip.show('暂无商品评价');  
44 - } else {  
45 - if (!$(this).hasClass('focus')) { 47 + if ($this.hasClass('comment-nav') && 0 === commentsNum) {
  48 + tip.show('暂无商品评价');
  49 + } else {
  50 + if (!$this.hasClass('focus')) {
46 51
47 - $('#nav-tab li').each(function() {  
48 - $(this).removeClass('focus');  
49 - });  
50 - $('#feedback-content .content').each(function() {  
51 - $(this).addClass('hide');  
52 - }); 52 + $('#nav-tab li').each(function() {
  53 + $this.removeClass('focus');
  54 + });
  55 + $('#feedback-content .content').each(function() {
  56 + $this.addClass('hide');
  57 + });
53 58
54 - $(this).addClass('focus');  
55 - $('#feedback-content .content:eq(' + index + ')').removeClass('hide'); 59 + $this.addClass('focus');
  60 + $('#feedback-content .content:eq(' + index + ')').removeClass('hide');
  61 + }
56 } 62 }
57 - }  
58 -}); 63 + });
  64 +}
59 65
60 if (consultFooterHammer) { 66 if (consultFooterHammer) {
61 consultFooterHammer.on('tap', function() { 67 consultFooterHammer.on('tap', function() {