增加商品券限制,过滤不满足使用条件的商品券
This commit is contained in:
@@ -37,6 +37,11 @@
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex " v-if="item.userCouponId">
|
||||
<uni-tag text="商品券抵扣"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.pack">
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
@@ -56,7 +61,7 @@
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="isGift(item)">
|
||||
<template v-else-if="isGift(item)||item.userCouponId">
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}
|
||||
</view>
|
||||
@@ -149,7 +154,6 @@
|
||||
<view></view>
|
||||
<view>
|
||||
<text>总计¥</text>
|
||||
<!-- <text class="font-bold u-font-32">{{numSum([allPrice,seatFeePrice,packFee]) }}</text> -->
|
||||
<text class="font-bold u-font-32">{{to2(allPrice*1+seatFeePrice*1+packFee*1) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -276,8 +280,7 @@
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
const youhuiAllPrice=computed(()=>{
|
||||
console.log(freePrice.value);
|
||||
return (freePrice.value*1+vipDiscountPrice.value*1).toFixed(2)
|
||||
return (freePrice.value*1+vipDiscountPrice.value*1+props.orderInfo.fullCouponDiscountAmount+props.orderInfo.productCouponDiscountAmount+props.orderInfo.pointsDiscountAmount).toFixed(2)
|
||||
})
|
||||
const packFee = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
@@ -291,7 +294,7 @@
|
||||
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
return (goodsOriginAllPrice.value-freePrice.value-vipDiscountPrice.value).toFixed(2)
|
||||
return (goodsOriginAllPrice.value-youhuiAllPrice.value).toFixed(2)
|
||||
})
|
||||
|
||||
const goodsNumber = computed(() => {
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
<view class="u-m-t-32">
|
||||
<view class="u-font-32">{{goosZhonglei}}种商品,共{{goodsNumber}}件</view>
|
||||
<view class="border-bottom u-p-b-32">
|
||||
<view class="" v-for="(item,index) in data.detailList"
|
||||
:key="index">
|
||||
<view class="" v-for="(item,index) in data.detailList" :key="index">
|
||||
<view class="u-flex u-row-between u-col-top u-m-t-32" v-if="item.productId!=-999">
|
||||
<view>
|
||||
<view class=""> {{item.productName}}</view>
|
||||
@@ -44,7 +43,7 @@
|
||||
<template v-if="item.gift">
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text class="line-th">¥{{goodsPriceAmount(item)}}</text>
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;" >
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;">
|
||||
¥0
|
||||
</view>
|
||||
</view>
|
||||
@@ -52,24 +51,25 @@
|
||||
<template v-else-if="data.memberId&&item.memberPrice&&item.memberPrice!=item.price">
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text class="line-th">¥{{goodsPriceAmount(item)}}</text>
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;" >
|
||||
<view class="u-absolute" style="bottom: 100%;right: 0;">
|
||||
¥{{goodsVipPriceAmount(item)}}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="u-text-right u-relative" :style="computedPriceStyle()">
|
||||
<text >¥{{goodsPriceAmount(item)}}</text>
|
||||
<text>¥{{goodsPriceAmount(item)}}</text>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="border-bottom u-p-t-32 u-p-b-32" v-if="data.packFee>0||(data.seatInfo&&data.seatInfo.priceAmount>0)">
|
||||
<view class="border-bottom u-p-t-32 u-p-b-32"
|
||||
v-if="data.packFee>0||(data.seatInfo&&data.seatInfo.priceAmount>0)">
|
||||
<view class="u-flex u-row-between u-col-top" v-if="data.packFee>0">
|
||||
<view class="no-wrap u-m-r-32">打包费</view>
|
||||
<view>¥{{data.packFee||0}}</view>
|
||||
@@ -80,8 +80,24 @@
|
||||
<view>¥{{data.seatInfo.priceAmount}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="border-bottom u-p-b-32 u-m-t-32"
|
||||
v-if="data.fullCouponDiscountAmount>0||data.productCouponDiscountAmount>0||data.pointsDiscountAmount>0">
|
||||
<view class="u-flex u-row-between u-col-top" v-if="data.fullCouponDiscountAmount>0">
|
||||
<view class="no-wrap u-m-r-32">满减券抵扣</view>
|
||||
<view class="color-red">-¥{{data.fullCouponDiscountAmount||0}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32 u-col-top" v-if="data.productCouponDiscountAmount>0">
|
||||
<view class="no-wrap u-m-r-32">商品券抵扣</view>
|
||||
<view class="color-red">-¥{{data.productCouponDiscountAmount||0}}</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-32 u-col-top" v-if="data.pointsDiscountAmount>0">
|
||||
<view class="no-wrap u-m-r-32">积分抵扣</view>
|
||||
<view class="color-red">-¥{{data.pointsDiscountAmount||0}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<view class="u-flex u-row-between border-bottom u-m-t-32 u-p-b-32 u-col-top">
|
||||
<view class="no-wrap u-m-r-32">订单备注</view>
|
||||
<view>{{data.remark||'无'}}</view>
|
||||
@@ -103,7 +119,11 @@
|
||||
import dayjs from 'dayjs';
|
||||
import orderEnum from '@/commons/orderEnum.js'
|
||||
import go from '@/commons/utils/go.js'
|
||||
import {isTui,canTuiKuan,canTuicai} from '@/commons/utils/goodsUtil.js'
|
||||
import {
|
||||
isTui,
|
||||
canTuiKuan,
|
||||
canTuicai
|
||||
} from '@/commons/utils/goodsUtil.js'
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
@@ -115,11 +135,11 @@
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return{
|
||||
packFee:0,
|
||||
seatInfo:{
|
||||
productName:'客座费',
|
||||
priceAmount:0
|
||||
return {
|
||||
packFee: 0,
|
||||
seatInfo: {
|
||||
productName: '客座费',
|
||||
priceAmount: 0
|
||||
},
|
||||
detailList: []
|
||||
}
|
||||
@@ -133,14 +153,16 @@
|
||||
let $goodsMap = {}
|
||||
let goosZhonglei = ref(0)
|
||||
let goodsNumber = ref(0)
|
||||
|
||||
|
||||
const priceSize = 9
|
||||
function goodsPriceAmount(item){
|
||||
return (item.price*item.num).toFixed(2)
|
||||
|
||||
function goodsPriceAmount(item) {
|
||||
return (item.price * item.num).toFixed(2)
|
||||
}
|
||||
function goodsVipPriceAmount(item){
|
||||
const price=props.data.memberId?item.memberPrice: item.price
|
||||
return (price*item.num).toFixed(2)
|
||||
|
||||
function goodsVipPriceAmount(item) {
|
||||
const price = props.data.memberId ? item.memberPrice : item.price
|
||||
return (price * item.num).toFixed(2)
|
||||
}
|
||||
// const packeFee=computed(()=>{
|
||||
// return props.data.detailList.reduce((prve,cur)=>{
|
||||
@@ -153,9 +175,9 @@
|
||||
if (!item) {
|
||||
return ''
|
||||
}
|
||||
const minW=`${item.price}`.length * priceSize + 15
|
||||
const minW = `${item.price}`.length * priceSize + 15
|
||||
return {
|
||||
'min-width':(minW<36?36:minW) + 'px'
|
||||
'min-width': (minW < 36 ? 36 : minW) + 'px'
|
||||
}
|
||||
}
|
||||
// const computedPriceStyle = computed(() => {
|
||||
|
||||
@@ -46,14 +46,14 @@
|
||||
<view class="u-m-l-18">{{item.name}}</view>
|
||||
</view>
|
||||
<view class="color-red">
|
||||
¥{{item.discountAmount}}
|
||||
-¥{{item.discountAmount}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="border-bottom u-p-b-30" v-if="payPrice!=order.amount">
|
||||
<view class="border-bottom u-p-b-30" v-if="payPrice!=order.amount||accountPoints.sel">
|
||||
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
|
||||
v-if="discount.price&&discount.currentPrice!=order.amount">
|
||||
<view>服务员改价</view>
|
||||
|
||||
@@ -204,14 +204,14 @@
|
||||
console.log(order.value);
|
||||
const res = await $activateByOrderId(option)
|
||||
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
|
||||
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => !v.use)
|
||||
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => v.use)
|
||||
res.productCoupon = res.productCoupon.map(v => {
|
||||
const calcCoup = returnProductCoupon(v, canDikouGoodsArr, user.value)
|
||||
return {
|
||||
...calcCoup,
|
||||
checked: false
|
||||
}
|
||||
});
|
||||
}).filter((v) => v.use);
|
||||
myQuan.res = res
|
||||
myQuan.hasAjax = true;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ export function returnNewGoodsList(arr) {
|
||||
let goodsMap={}
|
||||
return arr.filter(v => !isTui(v))
|
||||
}
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该券是否可用
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
|
||||
export function returnCoupCanUse(goodsArr=[],coup,selCoupArr=[]) {
|
||||
if(!coup.use){
|
||||
return false
|
||||
}
|
||||
// if(!coup.use){
|
||||
// return false
|
||||
// }
|
||||
const findGoods=goodsArr.filter(v=>v.productId==coup.proId)
|
||||
if(!findGoods.length){
|
||||
return false
|
||||
@@ -36,10 +36,10 @@ export function returnCoupCanUse(goodsArr=[],coup,selCoupArr=[]) {
|
||||
if(selCoupNumber>=findGoodsTotalNumber){
|
||||
return false
|
||||
}
|
||||
return findGoodsTotalNumber<coup.num?false:true
|
||||
return findGoodsTotalNumber<(coup.num+selCoupNumber)?false:true
|
||||
}
|
||||
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser) {
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser,selCoupArr=[]) {
|
||||
const newGoodsArr = returnNewGoodsList(goodsArr)
|
||||
const item = newGoodsArr.find(v => v.productId == coup.proId);
|
||||
if(!item){
|
||||
@@ -49,7 +49,9 @@ export function returnProductCoupon(coup, goodsArr, vipUser) {
|
||||
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
|
||||
const discountAmount=(price*coup.num).toFixed(2)
|
||||
console.log(discountAmount);
|
||||
const canUse=!coup.use?false:(discountAmount>0)
|
||||
|
||||
const canUse=!coup.use?false:(discountAmount>0&&returnCoupCanUse(goodsArr,coup,selCoupArr))
|
||||
// const canUse=discountAmount>0
|
||||
return { ...coup, discountAmount: discountAmount,use:canUse}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user