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