|
@@ -19,6 +19,8 @@ let isGetData; |
|
@@ -19,6 +19,8 @@ let isGetData; |
19
|
let $newCoupon = $('#new-coupon'),
|
19
|
let $newCoupon = $('#new-coupon'),
|
20
|
linkUrl = document.referrer,
|
20
|
linkUrl = document.referrer,
|
21
|
$couponList = $('#couponAvailable');
|
21
|
$couponList = $('#couponAvailable');
|
|
|
22
|
+let $useCoupon = $('#useCoupon');
|
|
|
23
|
+let $notUseCoupon = $('#notUseCoupon');
|
22
|
|
24
|
|
23
|
let winH = $(window).height();
|
25
|
let winH = $(window).height();
|
24
|
|
26
|
|
|
@@ -49,6 +51,9 @@ function goToBack() { |
|
@@ -49,6 +51,9 @@ function goToBack() { |
49
|
}
|
51
|
}
|
50
|
}
|
52
|
}
|
51
|
|
53
|
|
|
|
54
|
+/**
|
|
|
55
|
+ * 输入优惠券码兑换优惠券
|
|
|
56
|
+ */
|
52
|
$newCoupon.on('submit', function() {
|
57
|
$newCoupon.on('submit', function() {
|
53
|
let $this = $(this);
|
58
|
let $this = $(this);
|
54
|
|
59
|
|
|
@@ -58,7 +63,7 @@ $newCoupon.on('submit', function() { |
|
@@ -58,7 +63,7 @@ $newCoupon.on('submit', function() { |
58
|
}
|
63
|
}
|
59
|
$.ajax({
|
64
|
$.ajax({
|
60
|
method: 'POST',
|
65
|
method: 'POST',
|
61
|
- url: '/cart/index/new/couponSearch',
|
66
|
+ url: '/cart/index/new/useCouponCode',
|
62
|
data: $this.serialize()
|
67
|
data: $this.serialize()
|
63
|
}).then(function(res) {
|
68
|
}).then(function(res) {
|
64
|
if (res.message) {
|
69
|
if (res.message) {
|
|
@@ -66,12 +71,9 @@ $newCoupon.on('submit', function() { |
|
@@ -66,12 +71,9 @@ $newCoupon.on('submit', function() { |
66
|
}
|
71
|
}
|
67
|
if (res.code === 200) {
|
72
|
if (res.code === 200) {
|
68
|
tip.show('优惠券可用');
|
73
|
tip.show('优惠券可用');
|
69
|
-
|
|
|
70
|
- // 实付金额发生变化,使用有货币为0
|
|
|
71
|
- orderInfo('yohoCoin', 0);
|
|
|
72
|
- orderInfo('couponCode', res.data.coupon_code);
|
|
|
73
|
- orderInfo('couponName', res.data.coupon_title);
|
|
|
74
|
- goToBack();
|
74
|
+ setTimeout(function() {
|
|
|
75
|
+ location.reload();
|
|
|
76
|
+ }, 500);
|
75
|
}
|
77
|
}
|
76
|
}).fail(function() {
|
78
|
}).fail(function() {
|
77
|
tip.show('网络错误');
|
79
|
tip.show('网络错误');
|
|
@@ -79,34 +81,20 @@ $newCoupon.on('submit', function() { |
|
@@ -79,34 +81,20 @@ $newCoupon.on('submit', function() { |
79
|
return false;
|
81
|
return false;
|
80
|
});
|
82
|
});
|
81
|
|
83
|
|
82
|
-$couponList.on('touchstart', '.employ-main', function() {
|
|
|
83
|
- let $this = $(this);
|
|
|
84
|
-
|
|
|
85
|
- $this.siblings().removeClass('focus');
|
|
|
86
|
- $this.addClass('focus');
|
|
|
87
|
-}).on('touchend touchcancel', '.employ-main', function() {
|
|
|
88
|
- let $this = $(this);
|
|
|
89
|
-
|
|
|
90
|
- $this.siblings().removeClass('focus');
|
|
|
91
|
- $this.removeClass('focus');
|
|
|
92
|
-});
|
|
|
93
|
-
|
|
|
94
|
-$('body').on('touchend', '.not-use', function() {
|
|
|
95
|
- orderInfo('couponCode', null);
|
|
|
96
|
- orderInfo('couponName', null);
|
|
|
97
|
-
|
|
|
98
|
- // 实付金额发生变化,使用有货币为0
|
|
|
99
|
- orderInfo('yohoCoin', 0);
|
84
|
+/**
|
|
|
85
|
+ * 使用优惠券 TODO
|
|
|
86
|
+ */
|
|
|
87
|
+$useCoupon.on('click', function() {
|
|
|
88
|
+ orderInfo('coupon_code');
|
100
|
goToBack();
|
89
|
goToBack();
|
101
|
});
|
90
|
});
|
102
|
|
91
|
|
103
|
-
|
|
|
104
|
-$newCoupon.find('input').on('input', function() {
|
|
|
105
|
- if ($(this).val() !== '') {
|
|
|
106
|
- $newCoupon.find('.submit').css('background', '#444');
|
|
|
107
|
- } else {
|
|
|
108
|
- $newCoupon.find('.submit').css('background', '#b0b0b0');
|
|
|
109
|
- }
|
92
|
+/**
|
|
|
93
|
+ * 不使用优惠券 TODO
|
|
|
94
|
+ */
|
|
|
95
|
+$notUseCoupon.on('click', function() {
|
|
|
96
|
+ orderInfo('coupon_code', null);
|
|
|
97
|
+ goToBack();
|
110
|
});
|
98
|
});
|
111
|
|
99
|
|
112
|
function getCouponHandle(allCoupons) {
|
100
|
function getCouponHandle(allCoupons) {
|
|
@@ -141,20 +129,13 @@ function getCouponHandle(allCoupons) { |
|
@@ -141,20 +129,13 @@ function getCouponHandle(allCoupons) { |
141
|
|
129
|
|
142
|
$.ajax({
|
130
|
$.ajax({
|
143
|
method: 'POST',
|
131
|
method: 'POST',
|
144
|
- url: '/cart/index/new/couponSearch',
|
132
|
+ url: '/cart/index/new/useCouponCode',
|
145
|
data: {
|
133
|
data: {
|
146
|
couponCode: couponCode
|
134
|
couponCode: couponCode
|
147
|
}
|
135
|
}
|
148
|
}).then(function(res) {
|
136
|
}).then(function(res) {
|
149
|
if (res.code === 200) {
|
137
|
if (res.code === 200) {
|
150
|
-
|
|
|
151
|
- // tip.show('优惠券可用');
|
|
|
152
|
- orderInfo('couponCode', res.data.coupon_code);
|
|
|
153
|
- orderInfo('couponName', res.data.coupon_title);
|
|
|
154
|
-
|
|
|
155
|
- // 实付金额发生变化,使用有货币为0
|
|
|
156
|
- orderInfo('yohoCoin', 0);
|
|
|
157
|
- goToBack();
|
138
|
+ tip.show('这边逻辑要改!');
|
158
|
} else if (res.message) {
|
139
|
} else if (res.message) {
|
159
|
tip.show(res.message);
|
140
|
tip.show(res.message);
|
160
|
}
|
141
|
}
|
|
@@ -169,8 +150,6 @@ function getCouponHandle(allCoupons) { |
|
@@ -169,8 +150,6 @@ function getCouponHandle(allCoupons) { |
169
|
$('#couponUnavailable').append(conponNotAvaliableTmpl({
|
150
|
$('#couponUnavailable').append(conponNotAvaliableTmpl({
|
170
|
notAvailableCoupons: notAvailableCoupons
|
151
|
notAvailableCoupons: notAvailableCoupons
|
171
|
}));
|
152
|
}));
|
172
|
- window.rePosFooter();
|
|
|
173
|
-
|
|
|
174
|
}
|
153
|
}
|
175
|
|
154
|
|
176
|
function getCouponDate() {
|
155
|
function getCouponDate() {
|
|
@@ -196,9 +175,3 @@ function getCouponDate() { |
|
@@ -196,9 +175,3 @@ function getCouponDate() { |
196
|
}
|
175
|
}
|
197
|
|
176
|
|
198
|
getCouponDate(); |
177
|
getCouponDate(); |
199
|
-
|
|
|
200
|
-// $(window).scroll(function() {
|
|
|
201
|
-// if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
|
|
|
202
|
-// getCouponDate();
|
|
|
203
|
-// }
|
|
|
204
|
-// }); |
|
|