Showing
1 changed file
with
8 additions
and
2 deletions
@@ -22,10 +22,16 @@ var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()), | @@ -22,10 +22,16 @@ var conponTmpl = Handlebars.compile($('#tmpl-coupon').html()), | ||
22 | ellipsis.init(); | 22 | ellipsis.init(); |
23 | 23 | ||
24 | $newCoupon.on('submit', function() { | 24 | $newCoupon.on('submit', function() { |
25 | + var $this = $(this); | ||
26 | + | ||
27 | + if (!$this.find('[name="couponCode"]').val()) { | ||
28 | + tip.show('请输入优惠券码'); | ||
29 | + return false; | ||
30 | + } | ||
25 | $.ajax({ | 31 | $.ajax({ |
26 | method: 'POST', | 32 | method: 'POST', |
27 | url: '/cart/index/couponSearch', | 33 | url: '/cart/index/couponSearch', |
28 | - data: $(this).serialize() | 34 | + data: $this.serialize() |
29 | }).then(function(res) { | 35 | }).then(function(res) { |
30 | if (res.code === 200) { | 36 | if (res.code === 200) { |
31 | tip.show('优惠券可用'); | 37 | tip.show('优惠券可用'); |
@@ -33,7 +39,7 @@ $newCoupon.on('submit', function() { | @@ -33,7 +39,7 @@ $newCoupon.on('submit', function() { | ||
33 | orderInfo('couponValue', res.data.coupon_value); | 39 | orderInfo('couponValue', res.data.coupon_value); |
34 | window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code; | 40 | window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code; |
35 | } else { | 41 | } else { |
36 | - tip.show(res.message); | 42 | + tip.show(res.message || '网络错误'); |
37 | } | 43 | } |
38 | }).fail(function() { | 44 | }).fail(function() { |
39 | tip.show('网络错误'); | 45 | tip.show('网络错误'); |
-
Please register or login to post a comment