增加商品券抵扣以及商品券抵扣后价格计算过滤不满足满减条件的优惠券,修改部分代客下单逻辑

This commit is contained in:
2024-11-07 17:04:00 +08:00
parent a9a4efabe9
commit 28fdcd9e5c
3 changed files with 196 additions and 58 deletions

View File

@@ -9,7 +9,12 @@
:data="quans.fullReductionCoupon"
@cell-click="fullReductionCouponClick"
>
<el-table-column type="index" width="80" label="" v-if="quans.fullReductionCoupon.length>0">
<el-table-column
type="index"
width="80"
label=""
v-if="quans.fullReductionCoupon.length > 0"
>
<template v-slot="scope">
<el-checkbox
@change="fullReductionCouponClick(scope.row)"
@@ -21,8 +26,17 @@
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
</el-table-column>
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column prop="discountAmount" label="抵扣">
<template v-slot="scope">
<span class="color-red">
{{ scope.row.discountAmount }}
</span>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
@@ -39,32 +53,55 @@
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="u-flex ">
<el-image
:src="scope.row.productCover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productCover]"
></el-image>
<div class="u-m-l-10">{{ scope.row.productName }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
</el-table-column>
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<div v-if="quansSelArr.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table
empty-text="未选择优惠券"
:data="quansSelArr"
>
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="未选择优惠券" :data="quansSelArr">
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="u-flex " v-if="scope.row.type == 2">
<el-image
:src="scope.row.productCover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productCover]"
></el-image>
<div class="u-m-l-10">{{ scope.row.productName }}</div>
</div>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</div>
<div class="u-flex u-row-center u-m-t-50">
<el-button size="medium" @click="close">取消</el-button>
<el-button size="medium" type="primary" @click="confirm"
@@ -77,12 +114,30 @@
</template>
<script>
import { $activateByOrderId } from "@/api/table";
import {returnProductCouponAllPrice} from '../util'
let $originFullReductionCoupon=[]
export default {
props: {
title: {
type: String,
default: "选择优惠券",
},
goodsArr:{
type:Array,
default:[]
},
vipUser:{
type:Object,
default:()=>{
return {
isVip:false,
}
}
},
orderPrice:{
type:Number,
default:0
}
},
data() {
return {
@@ -103,30 +158,52 @@ export default {
show: false,
};
},
watch: {},
watch: {
activeName(newval){
if(newval=='youhui'){
this.quans.fullReductionCoupon=$originFullReductionCoupon.filter(v=>(this.orderPrice-this.goodsDiscount)>=v.fullAmount)
}
}
},
computed:{
goodsDiscount(){
const coupArr=this.productCouponSelArr.filter(v=>v.type==2);
return returnProductCouponAllPrice(coupArr,this.goodsArr,this.vipUser)
}
},
methods: {
productCouponChange(val) {
console.log(val)
this.productCouponSelArr = val;
if (this.productCouponSelArr.length > 0) {
this.productCouponSelArr.length = val.length + 1;
const dikouQuan=this.quansSelArr[0]
if (this.productCouponSelArr.length > 0&&(dikouQuan&&dikouQuan.type==1) ) {
for (let i in val) {
this.quansSelArr[i + 1] = val[i];
this.$set(this.quansSelArr, i+1, val[i])
}
} else {
this.quansSelArr = val;
}
},
fullReductionCouponClick(row) {
if (this.fullReductionCouponSel.id == row.id) {
this.fullReductionCouponSel = { id: "" };
this.quansSelArr.shift();
} else {
this.fullReductionCouponSel = row;
this.quansSelArr.unshift(row);
if(dikouQuan){
this.quansSelArr=[dikouQuan]
}else{
this.quansSelArr = val;
}
}
console.log(this.quansSelArr)
},
fullReductionCouponClick(row) {
if(row.id==this.fullReductionCouponSel.id){
this.fullReductionCouponSel={id:''}
this.quansSelArr.splice(0,1);
return
}
const dikouQuan=this.quansSelArr[0]
this.fullReductionCouponSel = row;
if(dikouQuan&&dikouQuan.type==1){
this.$set(this.quansSelArr, 0, row)
}else{
this.quansSelArr.unshift(row);
}
},
handleCurrentChange(val) {
this.currentRow = val;
},
@@ -154,6 +231,7 @@ export default {
quans.fullReductionCoupon = quans.fullReductionCoupon.filter(
(v) => v.use
);
$originFullReductionCoupon=quans.fullReductionCoupon
quans.productCoupon = quans.productCoupon.filter((v) => v.use);
this.quans = quans;
}