后端:商品价格计算,接入促销活动

H5 前端:购物车接入促销
This commit is contained in:
YunaiV 2019-04-17 20:45:44 +08:00
parent d672976b84
commit 8962631b6a
1 changed files with 22 additions and 0 deletions

View File

@ -28,6 +28,9 @@
<div class="card" v-for="(item, j) in itemGroup.items" :key="j">
<van-checkbox :key="item.id" :name="item.id" v-model="item.selected" style="position: relative;top: 40px;" />
<product-card :product='convertProduct(item)'/>
<van-cell title="优惠信息">
{{ formatTimeLimitedDiscountText(item.activity) }}
</van-cell>
</div>
<div style="height:15px;"></div>
</div>
@ -88,6 +91,9 @@ export default {
},
methods: {
formatFullPrivilegeText(activity) {
if (!activity) {
return '';
}
let text = '';
let fullPrivilege = activity.fullPrivilege;
for (let i in fullPrivilege.privileges) {
@ -111,6 +117,22 @@ export default {
}
return text;
},
formatTimeLimitedDiscountText(activity) {
if (!activity) {
return '';
}
let text = '';
let timeLimitedDiscount = activity.timeLimitedDiscount.items[0];
if (timeLimitedDiscount.preferentialType === 1) {
text += '减 ' + timeLimitedDiscount.preferentialValue / 100.0 + ' 元';
} else if (timeLimitedDiscount.preferentialType === 2) {
text += '打 ' + timeLimitedDiscount.preferentialValue / 10.0 + ' 折';
}
if (activity.timeLimitedDiscount.quota > 0) {
text += '【限购 ' + activity.timeLimitedDiscount.quota + ' 件】';
}
return text;
},
formatItemGroupDiscountPriceText() {
let price = 0;
for (let i in this.itemGroups) {