问题修复
This commit is contained in:
@@ -13,16 +13,15 @@
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="t2">
|
||||
<span>原价:¥{{ goodsStore.cartInfo.costSummary.goodsOriginalAmount }}</span>
|
||||
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.seatFee || 0)
|
||||
}}</span>
|
||||
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.packFee || 0)
|
||||
}}</span>
|
||||
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount -
|
||||
goodsStore.cartInfo.costSummary.finalPayAmount) }}</span>
|
||||
<span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
||||
<span>商品原价:¥{{ goodsStore.cartInfo.costSummary.goodsRealAmount || 0 }}</span>
|
||||
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.seatFee || 0)
|
||||
}}</span>
|
||||
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.packFee || 0)
|
||||
}}</span>
|
||||
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.totalDiscountAmount || 0) }}</span>
|
||||
<!-- <span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
||||
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
||||
</span>
|
||||
</span> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -123,8 +122,9 @@
|
||||
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showCoupon" :title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount)})`"
|
||||
@open="couponDialogOpen" @closed="resetCouponFormHandle" top="5vh" width="80%">
|
||||
<el-dialog v-model="showCoupon"
|
||||
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`"
|
||||
top="5vh" width="80%" @open="couponDialogOpen">
|
||||
<div class="coupom_dialog">
|
||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||
<el-form-item label="选择会员">
|
||||
@@ -284,7 +284,9 @@ const props = defineProps({
|
||||
const discountAmount = ref(null)
|
||||
|
||||
watch(props, () => {
|
||||
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
|
||||
if (goodsStore.cartInfo.costSummary) {
|
||||
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
|
||||
}
|
||||
// originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
|
||||
// (goodsStore.cartInfo.packFee || 0))
|
||||
})
|
||||
@@ -449,7 +451,7 @@ function upadatePayData() {
|
||||
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||
couponList: couponResList1.value.map(item => item.id), // 用户使用的卡券
|
||||
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, // 订单金额
|
||||
roundAmount: goodsStore.cartInfo.costSummary.goodsDiscountAmount, // 抹零金额 减免多少钱
|
||||
roundAmount: 0, // 抹零金额 减免多少钱
|
||||
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, // 积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: goodsStore.cartInfo.costSummary.pointUsed, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||
isPrint: 1
|
||||
@@ -564,29 +566,67 @@ function delHandle() {
|
||||
payData.value.checkOrderPay.orderAmount = money.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查goodsStore.cartInfo.costSummary是否为真值的Promise
|
||||
* @param {number} [interval=100] 轮询检查间隔(ms)
|
||||
* @param {number} [timeout=5000] 超时时间(ms),超过则reject
|
||||
* @returns {Promise} 当costSummary为真时resolve,超时则reject
|
||||
*/
|
||||
function checkCostSummaryIsTruthy(interval = 100, timeout = 5000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 记录开始时间,用于超时判断
|
||||
const startTime = Date.now();
|
||||
|
||||
// 轮询检查函数
|
||||
const check = () => {
|
||||
const targetValue = goodsStore.cartInfo.costSummary;
|
||||
|
||||
// 检查是否为真值(非null、undefined、0、''、false、NaN)
|
||||
if (targetValue) {
|
||||
resolve(targetValue); // 成功时返回该值
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否超时
|
||||
if (Date.now() - startTime >= timeout) {
|
||||
reject(new Error('检查超时:costSummary始终为假值'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 未满足条件且未超时,继续轮询
|
||||
setTimeout(check, interval);
|
||||
};
|
||||
|
||||
// 立即开始第一次检查
|
||||
check();
|
||||
});
|
||||
}
|
||||
|
||||
// 获取支付方式
|
||||
async function queryPayTypeAjax() {
|
||||
try {
|
||||
const res = await getPayType();
|
||||
function queryPayTypeAjax() {
|
||||
checkCostSummaryIsTruthy().then(async () => {
|
||||
try {
|
||||
const res = await getPayType();
|
||||
|
||||
res.map((item) => {
|
||||
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
|
||||
item.disabled = true;
|
||||
} else {
|
||||
item.disabled = false;
|
||||
}
|
||||
});
|
||||
res.map((item) => {
|
||||
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
|
||||
item.disabled = true;
|
||||
} else {
|
||||
item.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
payList.value = res.filter(item => item.isDisplay);
|
||||
if (payList.value.length) {
|
||||
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
|
||||
scanModalRef.value.show();
|
||||
payType.value = payList.value[0].payType;
|
||||
payList.value = res.filter(item => item.isDisplay);
|
||||
if (payList.value.length) {
|
||||
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
|
||||
scanModalRef.value.show();
|
||||
payType.value = payList.value[0].payType;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 添加优惠 start */
|
||||
@@ -637,7 +677,7 @@ function clearCouponUser() {
|
||||
|
||||
updateCartCalc()
|
||||
|
||||
resetCouponFormHandle()
|
||||
// resetCouponFormHandle()
|
||||
}
|
||||
|
||||
// 折扣格式化
|
||||
@@ -756,16 +796,16 @@ const calcPointMoney = async () => {
|
||||
|
||||
// 当dialog打开时
|
||||
function couponDialogOpen() {
|
||||
couponResList2Amount.value = 0
|
||||
couponForm.value.discountRatio = ''
|
||||
// couponResList2Amount.value = 0
|
||||
// couponForm.value.discountRatio = ''
|
||||
|
||||
// 需减去抹零金额
|
||||
couponForm.value.amount = formatDecimal(originOrderAmount.value - roundAmount.value)
|
||||
couponForm.value.originAmount = couponForm.value.amount
|
||||
resetCouponForm.value = { ...couponForm.value }
|
||||
// // 需减去抹零金额
|
||||
// couponForm.value.amount = formatDecimal(originOrderAmount.value - roundAmount.value)
|
||||
// couponForm.value.originAmount = couponForm.value.amount
|
||||
// resetCouponForm.value = { ...couponForm.value }
|
||||
|
||||
couponResList1.value = []
|
||||
couponResList2.value = []
|
||||
// couponResList1.value = []
|
||||
// couponResList2.value = []
|
||||
|
||||
// 当购物车已存在用户时
|
||||
if (goodsStore.vipUserInfo.id) {
|
||||
@@ -786,6 +826,10 @@ function couponDialogOpen() {
|
||||
// 关闭后初始化dialog
|
||||
function resetCouponFormHandle() {
|
||||
couponForm.value = { ...resetCouponForm.value }
|
||||
couponForm.value.pointsNum = ''
|
||||
couponForm.value.discountRatio = ''
|
||||
discountRateNumber.value = 0
|
||||
// clearCouponUser()
|
||||
cancelAllDiscount()
|
||||
}
|
||||
|
||||
@@ -1062,7 +1106,8 @@ async function payCardInit() {
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
payCardInit
|
||||
payCardInit,
|
||||
resetCouponFormHandle
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user