|
@@ -86,12 +86,19 @@ export default {
|
|
return Number.parseInt(i.replace(/coupon/g, ''));
|
|
return Number.parseInt(i.replace(/coupon/g, ''));
|
|
},
|
|
},
|
|
checkboxItemChange(name, index) {
|
|
checkboxItemChange(name, index) {
|
|
|
|
+ const coupon = this.couponList[index];
|
|
|
|
+ if ( coupon.disabled ) {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // 根据电子券规则判断是否可选
|
|
|
|
+ this.isDisabledByRule(coupon, index);
|
|
|
|
+ }, 100)
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 取消勾选时
|
|
// 取消勾选时
|
|
if (this.checkedCouponList.indexOf(name) > -1) {
|
|
if (this.checkedCouponList.indexOf(name) > -1) {
|
|
this.checkedCouponList = this.checkedCouponList.filter((i) => i !== name);
|
|
this.checkedCouponList = this.checkedCouponList.filter((i) => i !== name);
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
- // console.log(158, this.checkedCouponList);
|
|
|
|
- // this.groupedCouponData();
|
|
|
|
this.remainPrice = this.remainPrice - this.couponList[index].discountFee
|
|
this.remainPrice = this.remainPrice - this.couponList[index].discountFee
|
|
this.newGroupedCouponData()
|
|
this.newGroupedCouponData()
|
|
}, 100)
|
|
}, 100)
|
|
@@ -102,10 +109,6 @@ export default {
|
|
this.remainPrice = this.remainPrice + this.couponList[index].discountFee
|
|
this.remainPrice = this.remainPrice + this.couponList[index].discountFee
|
|
if (!item.disabled) {
|
|
if (!item.disabled) {
|
|
this.checkedCouponList.push(`coupon${index}`);
|
|
this.checkedCouponList.push(`coupon${index}`);
|
|
- setTimeout(() => {
|
|
|
|
- // 根据电子券规则判断是否可选
|
|
|
|
- this.isDisabledByRule(item, index);
|
|
|
|
- }, 100)
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 对不同类型的优惠券进行汇总统计
|
|
// 对不同类型的优惠券进行汇总统计
|
|
@@ -201,16 +204,18 @@ export default {
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
case '2': // 同类型可叠加
|
|
case '2': // 同类型可叠加
|
|
|
|
+ // 找到
|
|
couponList = couponList.map((elm, i) => {
|
|
couponList = couponList.map((elm, i) => {
|
|
elm.disabled = false; // 默认可选
|
|
elm.disabled = false; // 默认可选
|
|
- const elmName = `coupon${i}`;
|
|
|
|
|
|
+ // 找到所以 superposition === 2 的同类型的券
|
|
if (elm.superposition === superposition) {
|
|
if (elm.superposition === superposition) {
|
|
|
|
+ const selectCouponIds = couponList.filter((iem, iemi) => iem.couponId === elm.couponId && this.checkedCouponList.indexOf(`coupon${iemi}`) > -1);
|
|
if (elm.limitCountPerOrder > 1) { // 是否存在上限
|
|
if (elm.limitCountPerOrder > 1) { // 是否存在上限
|
|
- if (this.checkedCouponList.length >= limitCountPerOrder) {
|
|
|
|
- elm.disabled = this.checkedCouponList.indexOf(elmName) < 0
|
|
|
|
|
|
+ if (selectCouponIds.length >= elm.limitCountPerOrder) {
|
|
|
|
+ elm.disabled = selectCouponIds.findIndex(iem => iem.code === elm.code) < 0
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- elm.disabled = this.checkedCouponList.indexOf(elmName) < 0 // 同类型可选的券,如果可选上限是1,就设为不可选择
|
|
|
|
|
|
+ elm.disabled = selectCouponIds.findIndex(iem => iem.code === elm.code) < 0 && selectCouponIds.length > 0 // 同类型可选的券,如果可选上限是1,就设为不可选择
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
elm.disabled = true; // 非同批次的优惠券设置为不可选择
|
|
elm.disabled = true; // 非同批次的优惠券设置为不可选择
|
|
@@ -219,7 +224,6 @@ export default {
|
|
})
|
|
})
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- console.log(220, couponList)
|
|
|
|
this.couponList = [...couponList];
|
|
this.couponList = [...couponList];
|
|
},
|
|
},
|
|
// 根据电子券规则判断是否可选
|
|
// 根据电子券规则判断是否可选
|
|
@@ -343,10 +347,8 @@ export default {
|
|
confirm() {
|
|
confirm() {
|
|
// 重新计算兑换券优惠
|
|
// 重新计算兑换券优惠
|
|
const checkedCouponList = this.checkedCouponList.map((i) => this.item2Number(i));
|
|
const checkedCouponList = this.checkedCouponList.map((i) => this.item2Number(i));
|
|
- console.log(checkedCouponList);
|
|
|
|
const couponList = this.couponList.map((elm, index) => {
|
|
const couponList = this.couponList.map((elm, index) => {
|
|
elm.selected = false;
|
|
elm.selected = false;
|
|
- console.log(checkedCouponList, index);
|
|
|
|
if (this.checkedCouponList.indexOf(`coupon${index}`) > -1) {
|
|
if (this.checkedCouponList.indexOf(`coupon${index}`) > -1) {
|
|
elm.selected = true;
|
|
elm.selected = true;
|
|
}
|
|
}
|