fix: 修复选择券死循环问题,修复赠菜nan问题

This commit is contained in:
YeMingfei666 2025-10-11 11:20:55 +08:00
parent 7ceca3b917
commit 8087d9844b
6 changed files with 635 additions and 346 deletions

View File

@ -275,6 +275,7 @@ export const useCartsStore = defineStore("carts", () => {
// 订单费用汇总(调用内部的 getAllGoodsList
const orderCostSummary = computed(() => {
allGoods.value = getAllGoodsList();
console.log(' allGoods.value', allGoods.value);
const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
allGoods.value,
dinnerType.value,
@ -284,6 +285,8 @@ export const useCartsStore = defineStore("carts", () => {
cartOrder.value,
new Date()
);
console.log('costSummary', costSummary);
return costSummary;
});
@ -671,10 +674,14 @@ export const useCartsStore = defineStore("carts", () => {
}
if (msg.operate_type === "manage_edit") {
const newCart = msg.data;
const skuData = getProductDetails({ product_id: msg.data.product_id, sku_id: msg.data.sku_id });
console.log('skuData,', skuData);
const newCart = { ...skuData, ...msg.data };
const listIndex = list.value.findIndex(item => item.id === newCart.id);
const giftIndex = giftList.value.findIndex(item => item.id === newCart.id);
if (giftIndex > -1) {
if (!newCart.is_gift) {
giftList.value.splice(giftIndex, 1);

File diff suppressed because it is too large Load Diff

View File

@ -212,6 +212,7 @@ const vipAllPrice = computed(() => {
return n;
});
const allPrice = computed(() => {
console.log("allPrice", props.item);
if (props.item.discount_sale_amount * 1 > 0) {
return props.item.discount_sale_amount * props.item.number;
}

View File

@ -144,7 +144,7 @@
<el-button
type="primary"
size="large"
:disabled="!carts.isLinkFinshed"
:disabled="disabledMorePay"
@click="createOrder('to-pay')"
>
去结账

View File

@ -93,19 +93,8 @@
</el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
<div v-if="scope.row.type == 2">
<div class="u-flex">
<el-image
:src="scope.row.productImg"
fit="cover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productImg]"
></el-image>
</div>
<div class="u-m-t-10">
<div class="">{{ scope.row.productName }}</div>
<div class="u-m-t-4">x{{ scope.row.num || "" }}</div>
</div>
<div>
{{ scope.row.foods }}
</div>
</template>
</el-table-column>
@ -408,12 +397,13 @@ watch(
//002-使
const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0 });
const usePointsNumber = ref(0);
const orderAmountOrderAmount = computed(() => {
return (carts.goodsTotal - checkOrderPay.discountAmount).toFixed(2);
//
const scoreMaxMoney = computed(() => {
return carts.orderCostSummary.finalPayAmount - carts.orderCostSummary.pointDeductionAmount;
});
const pointsDiscountAmount = ref(0);
watch(
() => orderAmountOrderAmount.value,
() => scoreMaxMoney.value,
(newval) => {
pointsInit();
}
@ -426,7 +416,7 @@ function returnPointsDiscountAmount() {
}
async function pointsInit() {
if (!props.user.id || score.sel == -1) {
if (!props.user.id) {
return;
}
const res = await PointsApi.calcOrderUsablePoints({
@ -435,6 +425,9 @@ async function pointsInit() {
});
pointsRes.value = res;
carts.pointDeductionRule.pointsPerYuan = res.equivalentPoints;
if (score.sel == -1) {
return;
}
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
if (res.usable) {

View File

@ -360,6 +360,7 @@ async function getcoup() {
function couponClick(checked, row) {
couponSel.value = checked ? row : { id: "" };
updateSelCoupon();
}
const AllCouponPrice = computed(() => {
return quansSelArr.value.reduce((pre, cur) => pre + cur.discountAmount, 0);
@ -370,6 +371,7 @@ const payPrice = computed(() => {
});
function productCouponClick(checked, item) {
goodsCouponSel.value = checked ? item : { id: "" };
updateSelCoupon();
}
//
@ -403,10 +405,8 @@ watch(
getcoup();
}
);
watch(
() => quansSelArr.value,
(newval) => {
console.log("quansSelArr", newval);
function updateSelCoupon() {
const newval = quansSelArr.value;
if (newval.length >= 2) {
let goodsCoupon = newval.filter((v) => v.type == 2);
let otherCoupon = newval.filter((v) => v.type != 2);
@ -443,6 +443,13 @@ watch(
couponSel.value = otherCoupon[0];
goodsCouponSel.value = goodsCoupon[0];
}
}
watch(
() => quansSelArr.value,
(newval) => {
console.log("quansSelArr", newval);
getcoup();
}
);