Authored by 郭成尧

coupon-chose

... ... @@ -100,7 +100,7 @@ exports.orderEnsure = (req, res, next) => {
}
}
if (!orderInfo.coupon_code && autoSelectCouponCodeStr) {
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('order-info', JSON.stringify(orderInfo), actCkOpthn);
}
... ...
... ... @@ -37,7 +37,7 @@ class cartModel extends global.yoho.BaseModel {
// 是否需要重新计算
let needReComputer = orderInfoCookie && !_.isEmpty(orderInfoCookie) &&
(orderInfoCookie.yohoCoin || orderInfoCookie.coupon_code);
(orderInfoCookie.yohoCoin || orderInfoCookie.user_check_coupon === 'Y');
if (needReComputer) {
orderInfoCookie.paymentType = orderInfoCookie.paymentType ? orderInfoCookie.paymentType : '';
... ... @@ -114,7 +114,8 @@ class cartModel extends global.yoho.BaseModel {
coupon: paymentProcess.handleCoupons({
paymentApiCouponData,
validCouponCount: validCouponCount,
orderComputeCouponPay: orderCompute.coupon_pay
orderComputeCouponPay: orderCompute.coupon_pay,
userCheckCoupon: orderInfoCookie.user_check_coupon === 'Y'
}),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: validGiftCardCount,
... ...
... ... @@ -102,7 +102,7 @@
<span class="nums">{{to_pay_amount_str}}</span></p>
</div>
{{/ couponPay}}
<button class="use-now-btn" id="useNowBtn">立即使用</button>
<button class="use-now-btn" id="useNowBtn">确认</button>
</div>
{{/ result}}
</section>
... ...
... ... @@ -18,7 +18,6 @@ class qrcodeModel extends global.yoho.BaseModel {
order_code: id,
uid: uid
}}).then(result => {
console.log(result);
if (result && result.code === 200) {
return result.data;
} else {
... ...
... ... @@ -144,8 +144,6 @@ class SelectCouponController extends Page {
tabChange(event) {
let itemClicked = $(event.currentTarget);
console.log(this.view.useNowBox);
if (itemClicked.hasClass('active')) {
itemClicked.removeClass('active');
} else {
... ... @@ -184,7 +182,9 @@ class SelectCouponController extends Page {
let theCoupon = $(e.delegateTarget);
let theCouponData = theCoupon.data();
console.log(theCouponData.code);
if (!this.orderInfo('user_check_coupon')) {
this.orderInfo('user_check_coupon', 'Y');
}
if (theCouponCheck.hasClass('icon-cb-radio')) {
this.selectCouponCodes.splice($.inArray(theCouponData.code, this.selectCouponCodes), 1);
... ...
... ... @@ -348,6 +348,7 @@ function handleCoupons(params) {
let showText = '';
let priceText = '';
// 重新计算过后取重新计算的值
if (!_.isEmpty(orderComputeCouponPay)) {
couponData = orderComputeCouponPay;
}
... ... @@ -365,11 +366,15 @@ function handleCoupons(params) {
showText = `${validCouponCount}张可用,未使用`;
}
if (!_.isEmpty(orderComputeCouponPay)) {
if (!_.isEmpty(orderComputeCouponPay) && couponData.coupon_count) {
showText = `已选${couponData.coupon_count}张`;
priceText = `-${couponData.coupon_amount_str}`;
}
if (!_.isEmpty(orderComputeCouponPay) && !couponData.coupon_count) {
showText = `${validCouponCount}张可用,未使用`;
}
return {
showText, priceText, couponCode
};
... ...