uview-plus组件库全面升级更新,订单结算判断支付方式是否可用代码调整,公众号关注二维码修改
This commit is contained in:
@@ -201,7 +201,7 @@
|
||||
></u-image>
|
||||
</view>
|
||||
<text class="name u-m-l-16 no-wrap"> {{ item.name }} </text>
|
||||
<template v-if="item.type == 'points' && !disabledPointsUse">
|
||||
<template v-if="item.type == 'points' && !pointObj.disabled">
|
||||
<text
|
||||
class="u-p-l-6"
|
||||
style="color: #666; max-width: 400rpx; font-size: 10px"
|
||||
@@ -227,8 +227,8 @@
|
||||
<template v-else>
|
||||
<text
|
||||
class="favorable_right_text red"
|
||||
v-if="disabledCouponUse"
|
||||
>{{ disabledCouponReason }}</text
|
||||
v-if="couponObj.disabled"
|
||||
>{{ couponObj.disabledReason }}</text
|
||||
>
|
||||
<text
|
||||
class="favorable_right_text red"
|
||||
@@ -239,7 +239,7 @@
|
||||
>暂无可用优惠券</text
|
||||
>
|
||||
</template>
|
||||
<template v-if="!disabledCouponUse">
|
||||
<template v-if="!couponObj.disabled">
|
||||
<up-icon
|
||||
name="arrow-right"
|
||||
color="#575B66"
|
||||
@@ -268,10 +268,10 @@
|
||||
v-if="item.type == 'points'"
|
||||
>
|
||||
<text
|
||||
v-if="disabledPointsUse"
|
||||
v-if="pointObj.disabled"
|
||||
class="u-p-l-6 red"
|
||||
style="max-width: 400rpx; font-size: 24rpx"
|
||||
>{{ disabledPointsUseReason }}</text
|
||||
style="max-width: 440rpx; font-size: 24rpx"
|
||||
>{{ pointObj.disabledReason }}</text
|
||||
>
|
||||
<template
|
||||
v-else-if="
|
||||
@@ -290,7 +290,7 @@
|
||||
|
||||
<template v-else>
|
||||
<view
|
||||
v-if="maxPointDiscount > 0 && !disabledPointsUse"
|
||||
v-if="maxPointDiscount > 0 && !pointObj.disabled"
|
||||
class="u-flex u-col-center"
|
||||
>
|
||||
<view class="round"></view>
|
||||
@@ -517,13 +517,67 @@ const discountActivityRes = ref(null);
|
||||
const discountActivity = ref(null);
|
||||
//备份当前使用的满减活动的门槛满减
|
||||
let back_discountActivity = null;
|
||||
//禁止使用优惠券
|
||||
const disabledCouponUse = ref(false);
|
||||
const disabledCouponReason = ref("");
|
||||
//禁止使用积分
|
||||
const disabledPointsUse = ref(false);
|
||||
//禁止使用积分原因
|
||||
const disabledPointsUseReason = ref("");
|
||||
|
||||
const couponObj = computed(() => {
|
||||
const obj = {
|
||||
disabled: false,
|
||||
disabledReason: "",
|
||||
};
|
||||
const freeDineConfig = props.orderVIP.freeDineConfig;
|
||||
if (props.isBwc && freeDineConfig.enable) {
|
||||
//使用了霸王餐
|
||||
if (!freeDineConfig.withCoupon) {
|
||||
obj.disabled = true;
|
||||
obj.disabledReason = "霸王餐与优惠券不可同时使用";
|
||||
}
|
||||
}
|
||||
//使用了满减活动
|
||||
const res = discountActivityRes.value;
|
||||
|
||||
if (discountActivity.value && res) {
|
||||
if (!res.couponShare) {
|
||||
obj.disabled = true;
|
||||
obj.disabledReason = "当前满减活动不可与其他优惠共享";
|
||||
}
|
||||
}
|
||||
if (obj.disabled) {
|
||||
cartStore.backendCoupons = [];
|
||||
}
|
||||
return obj;
|
||||
});
|
||||
|
||||
const pointObj = computed(() => {
|
||||
const obj = {
|
||||
disabled: false,
|
||||
disabledReason: "",
|
||||
};
|
||||
const freeDineConfig = props.orderVIP.freeDineConfig;
|
||||
if (props.isBwc && freeDineConfig.enable) {
|
||||
//使用了霸王餐
|
||||
if (!freeDineConfig.withPoints) {
|
||||
obj.disabled = true;
|
||||
obj.disabledReason = "霸王餐与积分不可同时使用";
|
||||
}
|
||||
}
|
||||
//使用了满减活动
|
||||
const res = discountActivityRes.value;
|
||||
if (discountActivity.value && res) {
|
||||
if (!res.pointsShare) {
|
||||
obj.disabled = true;
|
||||
obj.disabledReason = "当前满减活动不可与积分同享";
|
||||
}
|
||||
}
|
||||
|
||||
//积分抵扣不足
|
||||
if (pointsRes && !pointsRes.usable) {
|
||||
obj.disabledReason = pointsRes.unusableReason || "积分抵扣不足或不可用";
|
||||
}
|
||||
if (obj.disabled) {
|
||||
cartStore.setUserPoints(0);
|
||||
}
|
||||
|
||||
return obj;
|
||||
});
|
||||
|
||||
// 监听送餐/打包切换
|
||||
const tabClick = (item, index) => {
|
||||
@@ -534,10 +588,7 @@ const tabClick = (item, index) => {
|
||||
};
|
||||
cartStore.setDinnerType(tebtypeList[is_type.value].val);
|
||||
|
||||
// 操作优惠卷
|
||||
const dataprocessing = (data) => {
|
||||
favorablelist.value[1].value = data;
|
||||
};
|
||||
|
||||
|
||||
// 清空
|
||||
const bwcclear = () => {
|
||||
@@ -556,20 +607,19 @@ const goUrl = (item) => {
|
||||
|
||||
switch (item.type) {
|
||||
case "coupon":
|
||||
if (disabledCouponUse.value) {
|
||||
if (couponObj.value.disabled) {
|
||||
return uni.showToast({
|
||||
title: disabledCouponReason.value,
|
||||
title: couponObj.value.disabledReason,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
emits("learcoupons", "coupon");
|
||||
uni.pro.navigateTo("/pages/order/coupon", {});
|
||||
break;
|
||||
|
||||
case "points":
|
||||
if (disabledPointsUse.value) {
|
||||
if (pointObj.value.disabled) {
|
||||
return uni.showToast({
|
||||
title: disabledPointsUseReason.value,
|
||||
title: pointObj.value.disabledReason,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
@@ -598,31 +648,36 @@ const maxPointDiscount = ref(0);
|
||||
//积分可抵扣最大金额
|
||||
const maxMoney = computed(() => {
|
||||
return (
|
||||
cartStore.orderCostSummary.finalPayAmount +
|
||||
cartStore.orderCostSummary.orderOriginFinalPayAmount +
|
||||
cartStore.orderCostSummary.pointDeductionAmount
|
||||
);
|
||||
});
|
||||
|
||||
async function getMaxPointsDiscount() {
|
||||
if (!props.orderVIP.id) {
|
||||
return;
|
||||
}
|
||||
let res = await APImemberPointscalcUsablePoints({
|
||||
shopUserId: props.orderVIP.id,
|
||||
orderAmount: maxMoney.value,
|
||||
});
|
||||
if(res){
|
||||
if (res) {
|
||||
cartStore.setPointDeductionRule(
|
||||
res.equivalentPoints,
|
||||
res.maxDeductionAmount
|
||||
res.equivalentPoints || 0,
|
||||
res.maxDeductionAmount || 0
|
||||
);
|
||||
}
|
||||
Object.assign(pointsRes, res);
|
||||
|
||||
maxPointDiscount.value = res.maxDeductionAmount;
|
||||
maxPointDiscount.value = res.maxDeductionAmount || 0;
|
||||
console.log("积分可抵扣最大金额", maxPointDiscount.value);
|
||||
console.log("是否可以用积分", usePoints.value);
|
||||
if (usePoints.value) {
|
||||
|
||||
if (usePoints.value && res.usable) {
|
||||
console.log("积分抵扣金额", res.maxDeductionAmount);
|
||||
cartStore.setUserPoints(res.maxUsablePoints || 0);
|
||||
}
|
||||
if (!res.usable) {
|
||||
cartStore.setUserPoints(0);
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => maxMoney.value,
|
||||
@@ -680,7 +735,6 @@ const copyHandle = (e) => {
|
||||
|
||||
// 将方法暴露给父组件
|
||||
defineExpose({
|
||||
dataprocessing,
|
||||
getCalcUsablePoints,
|
||||
bwcclear,
|
||||
IntegralInputclose,
|
||||
@@ -746,8 +800,7 @@ const originalPrice = computed(() => {
|
||||
-cartStore.orderCostSummary.newUserDiscount +
|
||||
cartStore.orderCostSummary.packFee +
|
||||
cartStore.orderCostSummary.seatFee;
|
||||
console.log("originalPrice", originalPrice);
|
||||
return originalPrice;
|
||||
return originalPrice <= 0 ? 0 : originalPrice;
|
||||
});
|
||||
|
||||
watch(
|
||||
@@ -766,28 +819,9 @@ watch(
|
||||
if (newval) {
|
||||
discountActivity.value = null;
|
||||
cartStore.fullReductionActivities = [];
|
||||
if (!freeDineConfig.withCoupon) {
|
||||
disabledCouponUse.value = true;
|
||||
disabledCouponReason.value = "霸王餐与优惠券不可同时使用";
|
||||
cartStore.setCoupons([]);
|
||||
} else {
|
||||
disabledCouponUse.value = false;
|
||||
disabledCouponReason.value = "";
|
||||
}
|
||||
if (!freeDineConfig.withPoints) {
|
||||
disabledPointsUse.value = true;
|
||||
disabledPointsUseReason.value = "霸王餐与积分不可同时使用";
|
||||
usePoints.value = false;
|
||||
cartStore.setUserPoints(0);
|
||||
} else {
|
||||
disabledPointsUse.value = false;
|
||||
disabledPointsUseReason.value = "";
|
||||
}
|
||||
usePoints.value = false;
|
||||
cartStore.setUserPoints(0);
|
||||
} else {
|
||||
disabledPointsUse.value = false;
|
||||
disabledPointsUseReason.value = "";
|
||||
disabledCouponUse.value = false;
|
||||
disabledCouponReason.value = "";
|
||||
if (back_discountActivity) {
|
||||
calcDiscountActivity();
|
||||
}
|
||||
@@ -824,17 +858,7 @@ function calcDiscountActivity() {
|
||||
return;
|
||||
}
|
||||
console.log("当前满减门槛", discountActivity.value);
|
||||
if (!res.couponShare) {
|
||||
disabledCouponUse.value = true;
|
||||
cartStore.backendCoupons = [];
|
||||
disabledCouponReason.value = "当前满减活动不可与其他优惠共享";
|
||||
}
|
||||
//不与积分同享
|
||||
if (!res.pointsShare && discountActivity.value) {
|
||||
disabledPointsUse.value = true;
|
||||
disabledPointsUseReason.value = "当前满减活动不与积分同享";
|
||||
cartStore.setUserPoints(0);
|
||||
}
|
||||
|
||||
if (discountActivity.value) {
|
||||
cartStore.fullReductionActivities = [discountActivityRes.value];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user