|
@@ -46,7 +46,7 @@
|
|
|
<div class="item-right">
|
|
|
<div>
|
|
|
<div class="item-price">预估 <span>{{ computePrice(item.deliveryAmount, tipAmount, couponPrice, order.firstCoupon || 0, item.isMine) }}</span> 元</div>
|
|
|
- <!-- <div class="item-coupon">优惠合计2元</div> -->
|
|
|
+ <div v-if="!item.isMine && item.deliveryAmount.toFixed(2) > couponParams.limitFee" class="item-coupon">优惠合计{{discount(item.deliveryAmount, tipAmount, couponPrice, order.firstCoupon || 0, item.isMine)}}元</div>
|
|
|
</div>
|
|
|
<div class="item-choose">
|
|
|
<img v-if="!item.isChoose" src="../../../static/image/item-choose-icon.png" />
|
|
@@ -451,6 +451,31 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ discount(cost, tipPrice, couponPrice, firstCoupon, select) {
|
|
|
+ if (
|
|
|
+ this.couponParams.type == 1 &&
|
|
|
+ select == 0 &&
|
|
|
+ cost >= this.couponParams.limitFee
|
|
|
+ ) {
|
|
|
+ let price = couponPrice + firstCoupon;
|
|
|
+ return price >= 0 ? price.toFixed(2) : 0;
|
|
|
+ } else if (this.couponParams.type == 3 && select == 0) {
|
|
|
+ let price = couponPrice + firstCoupon;
|
|
|
+ return price >= 0 ? price.toFixed(2) : 0;
|
|
|
+ } else if (this.couponParams.type == 2 && select == 0) {
|
|
|
+ let newCouponPrice =
|
|
|
+ cost * (1 - this.couponParams.discount / 10) <
|
|
|
+ this.couponParams.maxDiscount
|
|
|
+ ? cost * (1 - this.couponParams.discount / 10)
|
|
|
+ : this.couponParams.maxDiscount;
|
|
|
+ let price = newCouponPrice + firstCoupon;
|
|
|
+ return price >= 0 ? price.toFixed(2) : 0;
|
|
|
+ } else {
|
|
|
+ let price = firstCoupon;
|
|
|
+ console.log("初始加载值", this.couponParams.type);
|
|
|
+ return price >= 0 ? price.toFixed(2) : 0;
|
|
|
+ }
|
|
|
+ },
|
|
|
computePrice(cost, tipPrice, couponPrice, firstCoupon, select) {
|
|
|
if (
|
|
|
this.couponParams.type == 1 &&
|
|
@@ -482,6 +507,7 @@ export default {
|
|
|
this.couponList.find((item) => {
|
|
|
return item.id == e && e != -1;
|
|
|
}) || {};
|
|
|
+ console.log("couponParams", this.couponParams);
|
|
|
if (this.couponParams.type == 1 || this.couponParams.type == 3) {
|
|
|
this.couponPrice = this.couponParams.money;
|
|
|
} else if (this.couponParams.type == 2) {
|
|
@@ -539,7 +565,12 @@ export default {
|
|
|
getCouponList(params).then((res) => {
|
|
|
if (res.code == 200) {
|
|
|
console.log(res.data);
|
|
|
- this.couponList = this.couponList.concat(res.data.data);
|
|
|
+ this.couponList = [
|
|
|
+ {
|
|
|
+ id: -1,
|
|
|
+ name: "不使用优惠券",
|
|
|
+ },
|
|
|
+ ].concat(res.data.data);
|
|
|
}
|
|
|
});
|
|
|
},
|