优惠券列表显示,使用优惠券价格计算

This commit is contained in:
2020-08-20 11:28:49 +08:00
parent 51823edb12
commit 390bda7c0e
3 changed files with 29 additions and 30 deletions

View File

@@ -309,17 +309,7 @@ export default {
},
setTotalPrice() {
const goods = this.orderInfo.store_goods_total;
// console.log(this.freight);
let freight = 0, price = 0;
// 商品价格加上运费
// [goods, freight].forEach(object => {
// for (const key in object) {
// if (object.hasOwnProperty(key)) {
// const element = object[key];
// price += Number(element);
// }
// }
// })
let freight = 0, price = 0, minPrice;
// 运费
for (const key in this.freight) {
if (this.freight.hasOwnProperty(key)) {
@@ -327,27 +317,35 @@ export default {
freight += Number(element);
}
}
// 商品价格
for (const key in goods) {
if (goods.hasOwnProperty(key)) {
const element = goods[key];
price += Number(element);
// 商品价格减去优惠券
// 店铺
for (const gid in goods) {
if (goods.hasOwnProperty(gid)) {
// 计算最小价格
minPrice += 0.01;
// 每个店铺所有商品的价格
let sprice = Number(goods[gid]);
if(JSON.stringify(this.storeCoupon) != '{}') {
for (const cid in this.storeCoupon) {
if (this.storeCoupon.hasOwnProperty(cid)) {
const cprice = this.storeCoupon[cid];
// 商品减去优惠券价格
if(gid == cid) {
sprice -= cprice.voucher_price;
// 每个店铺最低付款 0.01
if(sprice <= 0) sprice = 0.01;
}
}
}
}
// 所有商品总价
price += sprice;
}
}
// 减去优惠券
// 平台
if(JSON.stringify(this.choiceCoupon) != '{}') price -= Number(this.choiceCoupon.voucher_price);
// 店铺
if(JSON.stringify(this.storeCoupon) != '{}') {
for (const key in this.storeCoupon) {
if (this.storeCoupon.hasOwnProperty(key)) {
const element = this.storeCoupon[key];
price -= element.voucher_price;
}
}
}
// 最低付款 0.01
if(price <= 0) price = 0.01;
// 每个店铺最低付款 0.01
if(price <= minPrice) price = minPrice;
// console.log(price);
this.totalPrice = (price + freight).toFixed(2);
},