Authored by yyq

mini购物车 搜索提示降级

@@ -82,7 +82,9 @@ @@ -82,7 +82,9 @@
82 {{/ navbars}} 82 {{/ navbars}}
83 </ul> 83 </ul>
84 <div class="func-area hide"> 84 <div class="func-area hide">
85 - <ul class="search-suggest"></ul> 85 + {{#unless @root.pc.common.disSearchAssociation}}
  86 + <ul class="search-suggest"></ul>
  87 + {{/unless}}
86 <div class="search-2016"> 88 <div class="search-2016">
87 <form action="//search.yohobuy.com" method="get" id="search-form"> 89 <form action="//search.yohobuy.com" method="get" id="search-form">
88 <input type="hidden" id="defaultsearch"> 90 <input type="hidden" id="defaultsearch">
@@ -101,14 +103,16 @@ @@ -101,14 +103,16 @@
101 <span class="goods-num-tip">0</span> 103 <span class="goods-num-tip">0</span>
102 {{/unless}} 104 {{/unless}}
103 </a> 105 </a>
104 - <div class="mini-cart-wrapper">  
105 - <div class="loading-cart">  
106 - <h3>加载中,请稍后</h3> 106 + {{#unless @root.pc.common.disCartHover}}
  107 + <div class="mini-cart-wrapper">
  108 + <div class="loading-cart">
  109 + <h3>加载中,请稍后</h3>
  110 + </div>
  111 + <div class="empty-cart">
  112 + <h3>您的购物车暂无商品</h3>
  113 + </div>
107 </div> 114 </div>
108 - <div class="empty-cart">  
109 - <h3>您的购物车暂无商品</h3>  
110 - </div>  
111 - </div> 115 + {{/unless}}
112 </div> 116 </div>
113 </div> 117 </div>
114 </div> 118 </div>
@@ -608,14 +608,16 @@ $searchForm.on('keyup', '.search-key', function(e) { @@ -608,14 +608,16 @@ $searchForm.on('keyup', '.search-key', function(e) {
608 $focus.addClass('action'); 608 $focus.addClass('action');
609 $(this).val($focus.find('.searchvalue').text()); 609 $(this).val($focus.find('.searchvalue').text());
610 } else if (e.which === 13) { 610 } else if (e.which === 13) {
  611 + val = val.replace(new RegExp('\'', 'gm'), '');
611 if (val !== '') { 612 if (val !== '') {
  613 + $(this).val(val);
612 $searchForm.submit(); 614 $searchForm.submit();
613 } 615 }
614 } else { 616 } else {
615 - val = val.replace(new RegExp('\'', 'gm'), ''); // 去掉特殊字符  
616 -  
617 - $(this).val(val);  
618 - searchSuggest(val); 617 + if ($searchSug && $searchSug.length) {
  618 + val = val.replace(new RegExp('\'', 'gm'), ''); // 去掉特殊字符
  619 + searchSuggest(val);
  620 + }
619 } 621 }
620 }).on('blur', '.search-key', function() { 622 }).on('blur', '.search-key', function() {
621 setTimeout(function() { 623 setTimeout(function() {
@@ -623,39 +625,41 @@ $searchForm.on('keyup', '.search-key', function(e) { @@ -623,39 +625,41 @@ $searchForm.on('keyup', '.search-key', function(e) {
623 }, 200); 625 }, 200);
624 }); 626 });
625 627
626 -$goCart.hover(function() {  
627 - var data, _html = '';  
628 -  
629 - if ($goCart.hasClass('on-hover')) {  
630 - return;  
631 - } 628 +if ($miniCart && $miniCart.length) {
  629 + $goCart.hover(function() {
  630 + var data, _html = '';
632 631
633 - data = $goCart.data();  
634 - if (data && data.num * 1) {  
635 - _html = '<div class="loading-cart"><h3>加载中,请稍后</h3></div>';  
636 - loadCartDetail(data.key);  
637 - } else {  
638 - _html = '<div class="empty-cart"><h3>您的购物车暂无商品</h3></div>';  
639 - }  
640 - $miniCart.html(_html);  
641 - $goCart.addClass('on-hover');  
642 -}, function() {  
643 - $goCart.removeClass('on-hover');  
644 -}); 632 + if ($goCart.hasClass('on-hover')) {
  633 + return;
  634 + }
645 635
646 -$goCart.on('click', '.cart-goods-del', function() {  
647 - var $dom = $(this),  
648 - data = $dom.data(),  
649 - callback; 636 + data = $goCart.data();
  637 + if (data && data.num * 1) {
  638 + _html = '<div class="loading-cart"><h3>加载中,请稍后</h3></div>';
  639 + loadCartDetail(data.key);
  640 + } else {
  641 + _html = '<div class="empty-cart"><h3>您的购物车暂无商品</h3></div>';
  642 + }
  643 + $miniCart.html(_html);
  644 + $goCart.addClass('on-hover');
  645 + }, function() {
  646 + $goCart.removeClass('on-hover');
  647 + });
650 648
651 - if (data) {  
652 - callback = function() {  
653 - $dom.closest('.goods-item').remove();  
654 - };  
655 - data.key = $goCart.data().key;  
656 - delCartGoods(data, callback);  
657 - }  
658 -}); 649 + $goCart.on('click', '.cart-goods-del', function() {
  650 + var $dom = $(this),
  651 + data = $dom.data(),
  652 + callback;
  653 +
  654 + if (data) {
  655 + callback = function() {
  656 + $dom.closest('.goods-item').remove();
  657 + };
  658 + data.key = $goCart.data().key;
  659 + delCartGoods(data, callback);
  660 + }
  661 + });
  662 +}
659 663
660 $subNav.on({ 664 $subNav.on({
661 mouseenter: function() { 665 mouseenter: function() {