修复判断是否有可用优惠券
This commit is contained in:
@@ -258,7 +258,8 @@
|
||||
watchEffect,
|
||||
defineExpose,
|
||||
toRaw,
|
||||
onMounted
|
||||
onMounted,
|
||||
nextTick
|
||||
|
||||
} from 'vue'
|
||||
import {
|
||||
@@ -420,9 +421,9 @@
|
||||
// 跳转
|
||||
const goUrl = (item) => {
|
||||
const canDikouGoodsArr = props.nowCarts
|
||||
const goodsOrderPrice = props.listinfo.totalPrices
|
||||
// const goodsOrderPrice = props.listinfo.totalPrices
|
||||
// const user=uni.cache.get('shopUserInfo')
|
||||
uni.setStorageSync('goodsOrderPrice', goodsOrderPrice)
|
||||
uni.setStorageSync('goodsOrderPrice', cartStore.orderCostSummary.goodsRealAmount)
|
||||
|
||||
if (props.isBwc) {
|
||||
uni.showToast({
|
||||
@@ -474,14 +475,14 @@
|
||||
})
|
||||
Object.assign(pointsRes, res)
|
||||
maxPointDiscount.value = res.maxDeductionAmount
|
||||
if(usePoints.value){
|
||||
if (usePoints.value) {
|
||||
cartStore.setUserPoints(res.maxUsablePoints || 0)
|
||||
}
|
||||
console.log('getMaxPointsDiscount:cartStore.orderCostSummary.pointUsed', cartStore.orderCostSummary.pointUsed);
|
||||
}
|
||||
watch(() => maxMoney.value, (newval) => {
|
||||
console.log('maxMoney.value', newval);
|
||||
getMaxPointsDiscount()
|
||||
getMaxPointsDiscount()
|
||||
})
|
||||
watch(() => usePoints.value, (newval) => {
|
||||
if (newval) {
|
||||
@@ -548,7 +549,7 @@
|
||||
const consumeDiscountRes = await consumeDiscount({
|
||||
shopId: uni.cache.get('shopId'),
|
||||
})
|
||||
if(!consumeDiscountRes){
|
||||
if (!consumeDiscountRes) {
|
||||
favorablelist.value = back_favorablelist.filter(v => v.name != '新客立减')
|
||||
return
|
||||
}
|
||||
@@ -563,27 +564,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化订单计算可能为计算完毕,所以判断监听价格变化后再获取优惠券
|
||||
let loadFinish = false
|
||||
watch(() => cartStore.orderCostSummary.goodsRealAmount,async (newval) => {
|
||||
if (newval && !loadFinish) {
|
||||
const goodsOrderPrice = cartStore.orderCostSummary.goodsRealAmount
|
||||
const dinnerType = cartStore.dinnerType
|
||||
const shopInfo = cartStore.shopInfo
|
||||
const shopId = cartStore.shopInfo.shopId
|
||||
const user = uni.cache.get('shopUserInfo')
|
||||
const shopUserId = user.id
|
||||
const allGoods = cartStore.allGoods
|
||||
|
||||
onMounted(async () => {
|
||||
hasCouponCanUse.value = await returnHasCouponCanUse({
|
||||
goodsOrderPrice,
|
||||
dinnerType,
|
||||
shopId,
|
||||
shopInfo,
|
||||
shopUserId,
|
||||
allGoods,
|
||||
user
|
||||
})
|
||||
console.log('hasCouponCanUse', hasCouponCanUse.value);
|
||||
}
|
||||
})
|
||||
onMounted(() => {
|
||||
getConsumeDiscount()
|
||||
//积分可抵扣最大金额
|
||||
const goodsOrderPrice = cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary
|
||||
const dinnerType = cartStore.dinnerType
|
||||
const shopInfo = cartStore.shopInfo
|
||||
const shopId = cartStore.shopInfo.shopId
|
||||
const user = uni.cache.get('shopUserInfo')
|
||||
const shopUserId = user.id
|
||||
const allGoods = cartStore.allGoods
|
||||
hasCouponCanUse.value = await returnHasCouponCanUse({
|
||||
goodsOrderPrice,
|
||||
dinnerType,
|
||||
shopId,
|
||||
shopInfo,
|
||||
shopUserId,
|
||||
allGoods,
|
||||
user
|
||||
})
|
||||
console.log('hasCouponCanUse', hasCouponCanUse.value);
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ export async function returnHasCouponCanUse(args) {
|
||||
if(!res||res.length<=0){
|
||||
return false
|
||||
}
|
||||
|
||||
console.log('returnHasCouponCanUse:goodsOrderPrice',goodsOrderPrice);
|
||||
console.log('returnHasCouponCanUse:allGoods',allGoods);
|
||||
const canDikouGoodsArr = UTILS.returnCanDikouGoods(allGoods, [], user);
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const coupon = res[i]
|
||||
|
||||
@@ -126,12 +126,11 @@ export function returnCouponCanUse(args) {
|
||||
selCoupon,
|
||||
shopInfo
|
||||
} = args;
|
||||
|
||||
// 优惠券未启用
|
||||
if (!coupon.use) {
|
||||
return {
|
||||
canUse: false,
|
||||
reason: "优惠券未启用"
|
||||
reason:coupon.noUseRestrictions|| "不在可用时间段内"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user