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

Merged
hansu merged 1 commits from zhy into master 2020-08-20 03:29:23 +00:00
3 changed files with 29 additions and 30 deletions
Showing only changes of commit 390bda7c0e - Show all commits

View File

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

View File

@@ -61,6 +61,7 @@ export default {
}) })
}, },
async getMemberCouponList({ load = 'reload' }) { async getMemberCouponList({ load = 'reload' }) {
if(load == 'reload') this.page = 0;
const res = await this.$u.api.getMemberCouponList({ const res = await this.$u.api.getMemberCouponList({
status: this.current + 1, // 代金券状态 1:未用 2:已用 3:过期 4:收回 status: this.current + 1, // 代金券状态 1:未用 2:已用 3:过期 4:收回
page: this.page, page: this.page,

View File

@@ -209,7 +209,7 @@ export default {
this.getOrderNumber(); this.getOrderNumber();
}, },
onNavigationBarButtonTap(e) { onNavigationBarButtonTap(e) {
console.log(e); // console.log(e);
if(e.index == 0) this.$u.route('/pageE/setting/Index'); if(e.index == 0) this.$u.route('/pageE/setting/Index');
}, },
methods: { methods: {
@@ -237,7 +237,7 @@ export default {
}) })
}, },
toOtherPage(url) { toOtherPage(url) {
console.log(url); // console.log(url);
uni.navigateTo({ uni.navigateTo({
url: '/pageE' + url url: '/pageE' + url
}); });