fix: 修复选择券死循环问题,修复赠菜nan问题
This commit is contained in:
parent
7ceca3b917
commit
8087d9844b
|
|
@ -275,6 +275,7 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
// 订单费用汇总(调用内部的 getAllGoodsList)
|
// 订单费用汇总(调用内部的 getAllGoodsList)
|
||||||
const orderCostSummary = computed(() => {
|
const orderCostSummary = computed(() => {
|
||||||
allGoods.value = getAllGoodsList();
|
allGoods.value = getAllGoodsList();
|
||||||
|
console.log(' allGoods.value', allGoods.value);
|
||||||
const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
|
const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
|
||||||
allGoods.value,
|
allGoods.value,
|
||||||
dinnerType.value,
|
dinnerType.value,
|
||||||
|
|
@ -284,6 +285,8 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
cartOrder.value,
|
cartOrder.value,
|
||||||
new Date()
|
new Date()
|
||||||
);
|
);
|
||||||
|
console.log('costSummary', costSummary);
|
||||||
|
|
||||||
return costSummary;
|
return costSummary;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -671,10 +674,14 @@ export const useCartsStore = defineStore("carts", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.operate_type === "manage_edit") {
|
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 listIndex = list.value.findIndex(item => item.id === newCart.id);
|
||||||
const giftIndex = giftList.value.findIndex(item => item.id === newCart.id);
|
const giftIndex = giftList.value.findIndex(item => item.id === newCart.id);
|
||||||
|
|
||||||
|
|
||||||
if (giftIndex > -1) {
|
if (giftIndex > -1) {
|
||||||
if (!newCart.is_gift) {
|
if (!newCart.is_gift) {
|
||||||
giftList.value.splice(giftIndex, 1);
|
giftList.value.splice(giftIndex, 1);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -212,6 +212,7 @@ const vipAllPrice = computed(() => {
|
||||||
return n;
|
return n;
|
||||||
});
|
});
|
||||||
const allPrice = computed(() => {
|
const allPrice = computed(() => {
|
||||||
|
console.log("allPrice", props.item);
|
||||||
if (props.item.discount_sale_amount * 1 > 0) {
|
if (props.item.discount_sale_amount * 1 > 0) {
|
||||||
return props.item.discount_sale_amount * props.item.number;
|
return props.item.discount_sale_amount * props.item.number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="large"
|
size="large"
|
||||||
:disabled="!carts.isLinkFinshed"
|
:disabled="disabledMorePay"
|
||||||
@click="createOrder('to-pay')"
|
@click="createOrder('to-pay')"
|
||||||
>
|
>
|
||||||
去结账
|
去结账
|
||||||
|
|
|
||||||
|
|
@ -93,19 +93,8 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="商品信息">
|
<el-table-column label="商品信息">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<div v-if="scope.row.type == 2">
|
<div>
|
||||||
<div class="u-flex">
|
{{ scope.row.foods }}
|
||||||
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -408,12 +397,13 @@ watch(
|
||||||
//002-获取订单可用积分及抵扣金额(支付页面使用)
|
//002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||||
const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0 });
|
const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0 });
|
||||||
const usePointsNumber = ref(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);
|
const pointsDiscountAmount = ref(0);
|
||||||
watch(
|
watch(
|
||||||
() => orderAmountOrderAmount.value,
|
() => scoreMaxMoney.value,
|
||||||
(newval) => {
|
(newval) => {
|
||||||
pointsInit();
|
pointsInit();
|
||||||
}
|
}
|
||||||
|
|
@ -426,7 +416,7 @@ function returnPointsDiscountAmount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pointsInit() {
|
async function pointsInit() {
|
||||||
if (!props.user.id || score.sel == -1) {
|
if (!props.user.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await PointsApi.calcOrderUsablePoints({
|
const res = await PointsApi.calcOrderUsablePoints({
|
||||||
|
|
@ -435,6 +425,9 @@ async function pointsInit() {
|
||||||
});
|
});
|
||||||
pointsRes.value = res;
|
pointsRes.value = res;
|
||||||
carts.pointDeductionRule.pointsPerYuan = res.equivalentPoints;
|
carts.pointDeductionRule.pointsPerYuan = res.equivalentPoints;
|
||||||
|
if (score.sel == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
|
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
|
||||||
if (res.usable) {
|
if (res.usable) {
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,7 @@ async function getcoup() {
|
||||||
|
|
||||||
function couponClick(checked, row) {
|
function couponClick(checked, row) {
|
||||||
couponSel.value = checked ? row : { id: "" };
|
couponSel.value = checked ? row : { id: "" };
|
||||||
|
updateSelCoupon();
|
||||||
}
|
}
|
||||||
const AllCouponPrice = computed(() => {
|
const AllCouponPrice = computed(() => {
|
||||||
return quansSelArr.value.reduce((pre, cur) => pre + cur.discountAmount, 0);
|
return quansSelArr.value.reduce((pre, cur) => pre + cur.discountAmount, 0);
|
||||||
|
|
@ -370,6 +371,7 @@ const payPrice = computed(() => {
|
||||||
});
|
});
|
||||||
function productCouponClick(checked, item) {
|
function productCouponClick(checked, item) {
|
||||||
goodsCouponSel.value = checked ? item : { id: "" };
|
goodsCouponSel.value = checked ? item : { id: "" };
|
||||||
|
updateSelCoupon();
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除选中的优惠券
|
//删除选中的优惠券
|
||||||
|
|
@ -403,10 +405,8 @@ watch(
|
||||||
getcoup();
|
getcoup();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
watch(
|
function updateSelCoupon() {
|
||||||
() => quansSelArr.value,
|
const newval = quansSelArr.value;
|
||||||
(newval) => {
|
|
||||||
console.log("quansSelArr", newval);
|
|
||||||
if (newval.length >= 2) {
|
if (newval.length >= 2) {
|
||||||
let goodsCoupon = newval.filter((v) => v.type == 2);
|
let goodsCoupon = newval.filter((v) => v.type == 2);
|
||||||
let otherCoupon = newval.filter((v) => v.type != 2);
|
let otherCoupon = newval.filter((v) => v.type != 2);
|
||||||
|
|
@ -443,6 +443,13 @@ watch(
|
||||||
couponSel.value = otherCoupon[0];
|
couponSel.value = otherCoupon[0];
|
||||||
goodsCouponSel.value = goodsCoupon[0];
|
goodsCouponSel.value = goodsCoupon[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => quansSelArr.value,
|
||||||
|
(newval) => {
|
||||||
|
console.log("quansSelArr", newval);
|
||||||
|
|
||||||
getcoup();
|
getcoup();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue