...
|
...
|
@@ -19,6 +19,8 @@ let isGetData; |
|
|
let $newCoupon = $('#new-coupon'),
|
|
|
linkUrl = document.referrer,
|
|
|
$couponList = $('#couponAvailable');
|
|
|
let $useCoupon = $('#useCoupon');
|
|
|
let $notUseCoupon = $('#notUseCoupon');
|
|
|
|
|
|
let winH = $(window).height();
|
|
|
|
...
|
...
|
@@ -49,6 +51,9 @@ function goToBack() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 输入优惠券码兑换优惠券
|
|
|
*/
|
|
|
$newCoupon.on('submit', function() {
|
|
|
let $this = $(this);
|
|
|
|
...
|
...
|
@@ -58,7 +63,7 @@ $newCoupon.on('submit', function() { |
|
|
}
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/new/couponSearch',
|
|
|
url: '/cart/index/new/useCouponCode',
|
|
|
data: $this.serialize()
|
|
|
}).then(function(res) {
|
|
|
if (res.message) {
|
...
|
...
|
@@ -66,12 +71,9 @@ $newCoupon.on('submit', function() { |
|
|
}
|
|
|
if (res.code === 200) {
|
|
|
tip.show('优惠券可用');
|
|
|
|
|
|
// 实付金额发生变化,使用有货币为0
|
|
|
orderInfo('yohoCoin', 0);
|
|
|
orderInfo('couponCode', res.data.coupon_code);
|
|
|
orderInfo('couponName', res.data.coupon_title);
|
|
|
goToBack();
|
|
|
setTimeout(function() {
|
|
|
location.reload();
|
|
|
}, 500);
|
|
|
}
|
|
|
}).fail(function() {
|
|
|
tip.show('网络错误');
|
...
|
...
|
@@ -79,34 +81,20 @@ $newCoupon.on('submit', function() { |
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$couponList.on('touchstart', '.employ-main', function() {
|
|
|
let $this = $(this);
|
|
|
|
|
|
$this.siblings().removeClass('focus');
|
|
|
$this.addClass('focus');
|
|
|
}).on('touchend touchcancel', '.employ-main', function() {
|
|
|
let $this = $(this);
|
|
|
|
|
|
$this.siblings().removeClass('focus');
|
|
|
$this.removeClass('focus');
|
|
|
});
|
|
|
|
|
|
$('body').on('touchend', '.not-use', function() {
|
|
|
orderInfo('couponCode', null);
|
|
|
orderInfo('couponName', null);
|
|
|
|
|
|
// 实付金额发生变化,使用有货币为0
|
|
|
orderInfo('yohoCoin', 0);
|
|
|
/**
|
|
|
* 使用优惠券 TODO
|
|
|
*/
|
|
|
$useCoupon.on('click', function() {
|
|
|
orderInfo('coupon_code');
|
|
|
goToBack();
|
|
|
});
|
|
|
|
|
|
|
|
|
$newCoupon.find('input').on('input', function() {
|
|
|
if ($(this).val() !== '') {
|
|
|
$newCoupon.find('.submit').css('background', '#444');
|
|
|
} else {
|
|
|
$newCoupon.find('.submit').css('background', '#b0b0b0');
|
|
|
}
|
|
|
/**
|
|
|
* 不使用优惠券 TODO
|
|
|
*/
|
|
|
$notUseCoupon.on('click', function() {
|
|
|
orderInfo('coupon_code', null);
|
|
|
goToBack();
|
|
|
});
|
|
|
|
|
|
function getCouponHandle(allCoupons) {
|
...
|
...
|
@@ -141,20 +129,13 @@ function getCouponHandle(allCoupons) { |
|
|
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/new/couponSearch',
|
|
|
url: '/cart/index/new/useCouponCode',
|
|
|
data: {
|
|
|
couponCode: couponCode
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
// tip.show('优惠券可用');
|
|
|
orderInfo('couponCode', res.data.coupon_code);
|
|
|
orderInfo('couponName', res.data.coupon_title);
|
|
|
|
|
|
// 实付金额发生变化,使用有货币为0
|
|
|
orderInfo('yohoCoin', 0);
|
|
|
goToBack();
|
|
|
tip.show('这边逻辑要改!');
|
|
|
} else if (res.message) {
|
|
|
tip.show(res.message);
|
|
|
}
|
...
|
...
|
@@ -169,8 +150,6 @@ function getCouponHandle(allCoupons) { |
|
|
$('#couponUnavailable').append(conponNotAvaliableTmpl({
|
|
|
notAvailableCoupons: notAvailableCoupons
|
|
|
}));
|
|
|
window.rePosFooter();
|
|
|
|
|
|
}
|
|
|
|
|
|
function getCouponDate() {
|
...
|
...
|
@@ -196,9 +175,3 @@ function getCouponDate() { |
|
|
}
|
|
|
|
|
|
getCouponDate(); |
|
|
|
|
|
// $(window).scroll(function() {
|
|
|
// if ($(window).scrollTop() + $(window).height() > $('body').height() * 0.9) {
|
|
|
// getCouponDate();
|
|
|
// }
|
|
|
// }); |
...
|
...
|
|