Merge pull request '优惠券列表显示,使用优惠券价格计算' (#259) from zhy into master

Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/259
This commit is contained in:
hansu 2020-08-20 11:29:22 +08:00
commit 96d7ad439a
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);
},

View File

@ -61,6 +61,7 @@ export default {
})
},
async getMemberCouponList({ load = 'reload' }) {
if(load == 'reload') this.page = 0;
const res = await this.$u.api.getMemberCouponList({
status: this.current + 1, // 1: 2: 3: 4:
page: this.page,

View File

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