增加优惠券,积分抵扣

This commit is contained in:
2024-11-11 14:03:49 +08:00
parent 28fdcd9e5c
commit 176fc55a5c
5 changed files with 393 additions and 124 deletions

View File

@@ -857,7 +857,7 @@
</div>
<div class="forms" v-if="vipUser.id">
<div class="u-m-b-20 u-m-t-10" >
<div class="u-m-b-20 u-m-t-10">
<div class="u-flex u-flex-wrap">
<span class="font-bold no-wrap u-m-r-20">积分抵扣</span>
<el-radio-group
@@ -872,12 +872,16 @@
<el-input-number
@change="pointsValueChange"
v-if="points.selected == 1"
:step="1"
disabled
step-strictly
v-model="points.value"
:min="points.minDeductionPoints"
:max="points.maxUsablePoints"
></el-input-number>
<el-input-number
:step="1"
step-strictly
@change="pointsValueChange"
v-if="points.selected == 2"
v-model="points.value"
@@ -889,6 +893,9 @@
<div class="color-999 u-m-t-10">
<template v-if="points.res.usable">
<span class="color-red">*</span>
<span v-if="points.res.equivalentPoints">
1积分抵扣{{ points.res.equivalentPoints }}元,
</span>
<span
>最大抵扣积分{{ points.res.maxUsablePoints }}</span
>
@@ -905,7 +912,7 @@
</div>
</div>
<div class="u-flex flex-wrap" >
<div class="u-flex flex-wrap">
<span class="font-bold no-wrap">优惠券</span>
<div
class="border u-p-l-20 cur-pointer u-m-r-20 u-flex no-wrap u-p-t-10 u-p-b-10 border-r-4 selQuan"
@@ -934,18 +941,35 @@
</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="描述">
<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="discountAmount" label="抵扣">
<template v-slot="scope">
<span class="color-red">
¥{{ scope.row.discountAmount }}
</span>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="">
<template v-slot="scope">
<el-button
type="danger"
size="mini"
@click="delQuan(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</div>
@@ -1345,7 +1369,14 @@
<money-discount ref="refDiscount" @confirm="ChangeDiscount">
</money-discount>
<!-- 优惠券 -->
<quans-pop ref="refQuans" :vipUser="vipUser" :orderPrice="currentPayMoney" :goodsArr="createOrder.data.detailList||[]" @confirm="quansConfirm"> </quans-pop>
<quans-pop
ref="refQuans"
:vipUser="vipUser"
:orderPrice="currentPayMoney"
:goodsArr="createOrder.data.detailList || []"
@confirm="quansConfirm"
>
</quans-pop>
<!-- 选择人数 -->
<choose-diners-number
@@ -1418,7 +1449,7 @@ import {
returnPackFee,
formatOrderGoodsList,
returnVipDiscountPrice,
returnCouponAllPrice
returnCouponAllPrice,
} from "./util.js";
import { $status } from "@/utils/table.js";
@@ -1655,24 +1686,34 @@ export default {
return this.vipUser.isVip ? true : false;
},
coupdiscount() {
return returnCouponAllPrice(this.quansSelArr,this.createOrder.data.detailList||[],this.vipUser)
return returnCouponAllPrice(
this.quansSelArr,
this.createOrder.data.detailList || [],
this.vipUser
);
},
goodsDisCount(){
const goodsQuanArr=this.quansSelArr.filter(v=>v.type==2);
let result=0;
if(goodsQuanArr.length<0){
result=0;
}else{
result=goodsQuanArr.reduce((a,b)=>{
const item=this.createOrder.data.detailList.find(v=>v.productId==b.proId);
const memberPrice=item.memberPrice?item.memberPrice:item.price;
const price=item?(this.vipUser.isVip?memberPrice:item.price):0;
return a+price;
},0);
goodsDisCount() {
const goodsQuanArr = this.quansSelArr.filter((v) => v.type == 2);
let result = 0;
if (goodsQuanArr.length < 0) {
result = 0;
} else {
result = goodsQuanArr.reduce((a, b) => {
const item = this.createOrder.data.detailList.find(
(v) => v.productId == b.proId
);
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item
? this.vipUser.isVip
? memberPrice
: item.price
: 0;
return a + price;
}, 0);
}
return result.toFixed(2);
},
currentPayMoney() {
const amount = this.createOrder.data.amount || 0;
const discount = this.createOrder.discount || 1;
@@ -2089,6 +2130,13 @@ export default {
this.open(this.$route.query);
},
methods: {
delQuan(row) {
const index=this.quansSelArr.findIndex(v=>v.id==row.id);
console.log(index);
if(index!=-1){
this.quansSelArr.splice(index, 1);
}
},
async getCalcUsablePoints() {
const memberId = this.createOrder.data.memberId || this.vipUser.id;
if (!memberId) {
@@ -2099,7 +2147,7 @@ export default {
orderAmount: this.currentPayMoney.toFixed(2),
});
this.points.res = pointsRes;
this.points.minDeductionPoints = pointsRes.minDeductionPoints;
// this.points.minDeductionPoints = pointsRes.minDeductionPoints;
this.points.maxUsablePoints = pointsRes.maxUsablePoints;
if (this.points.selected) {
this.points.value = Math.min(
@@ -2138,11 +2186,11 @@ export default {
this.$refs.refQuans.open({
id: this.createOrder.data.id,
memberId: this.createOrder.data.memberId || this.vipUser.id,
});
},[...this.quansSelArr]);
},
quansConfirm(e) {
console.log(e);
this.quansSelArr = e;
this.quansSelArr = [...e];
},
searchInput(e) {
console.log(e);
@@ -2706,11 +2754,11 @@ export default {
const userCouponInfos = this.quansSelArr.reduce((prve, cur) => {
const index = prve.findIndex((v) => v.userCouponId == cur.couponId);
if (index != -1) {
prve[index].num += 1;
prve[index].num += cur.num;
} else {
prve.push({
userCouponId: cur.couponId,
num: 1,
num: cur.num,
});
}
return prve;
@@ -2804,10 +2852,8 @@ export default {
payAfter: this.payAfter,
orderld: this.order.orderId,
});
} else {
res = true;
}
await this.getOrderData();
}
await this.getOrderData(res?{orderId: res.id}:{orderId:this.createOrder.data.id});
res = true;
} catch (error) {}
if (!res) {
@@ -2968,7 +3014,8 @@ export default {
return;
}
if (key === "returnCart") {
this.refToggle("refReturnCart", true);
const selGoods=this.order.old.list[this.order.old.selIndex];
this.refToggle("refReturnCart", true,selGoods);
}
},
//选择挂单确认