|
@@ -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() {
|