fix: 代客下单可选套餐确定无法点击,优惠价格计算

This commit is contained in:
2025-03-11 11:30:02 +08:00
parent 8bec7f1f6c
commit 4e956987d5
8 changed files with 258 additions and 105 deletions

View File

@@ -22,7 +22,7 @@ export const useCartsStore = defineStore("carts", () => {
})
//台桌id
const table_code = ref('');
const table_code = useStorage('Instead_table_code', '');
//购物车是否初始化连接加载完成
const isLinkFinshed = ref(false)
@@ -82,11 +82,13 @@ export const useCartsStore = defineStore("carts", () => {
let oldGiftMoney = 0
for (let i in oldOrder.value.detailMap) {
oldGiftMoney += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
return prve + cur.number * cur.salePrice
const memberPrice = cur.memberPrice || cur.salePrice
return prve + cur.number * (useVipPrice.value ? memberPrice : cur.salePrice)
}, 0)
}
return giftList.value.reduce((acc: number, cur: any) => {
return acc + cur.number * cur.salePrice
const memberPrice = cur.memberPrice || cur.salePrice
return acc + cur.number * (useVipPrice.value ? memberPrice : cur.salePrice)
}, 0)
})
//打包数量
@@ -130,8 +132,18 @@ export const useCartsStore = defineStore("carts", () => {
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
return acc + (n <= 0 ? 0 : n)
}, 0)
return listTotal
const giftTotal = giftList.value.reduce((acc: number, cur: any) => {
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
return acc + (n <= 0 ? 0 : n)
}, 0)
let oldTotal = 0;
for (let i in oldOrder.value.detailMap) {
oldTotal += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
return prve + (n <= 0 ? 0 : n)
}, 0)
}
return listTotal + giftTotal + oldTotal
})
//单品改价优惠
const singleDiscount = computed(() => {
@@ -302,7 +314,7 @@ export const useCartsStore = defineStore("carts", () => {
}
function del(data: any) {
sendMessage('del', data);
sendMessage('del', { id: data.id });
}
function update(data: any) {
@@ -433,7 +445,7 @@ export const useCartsStore = defineStore("carts", () => {
// const cache_table_code = localStorage.getItem('cache_table_code');
// const randomTableCode = cache_table_code ? cache_table_code : ('APC' + (1000 + Math.floor(Math.random() * 9000)))
if (initParams) {
initParams.table_code = initParams.table_code ? initParams.table_code : ''
initParams.table_code = initParams.table_code ? initParams.table_code : table_code.value
table_code.value = initParams.table_code
}
// localStorage.setItem('cache_table_code', table_code.value);
@@ -540,8 +552,9 @@ export const useCartsStore = defineStore("carts", () => {
}
if (msg.operate_type === "manage_del") {
const cartId = Array.isArray(msg.data) ? msg.data[0].id : msg.data.id
if (!isSelGift.value) {
const index = list.value.findIndex((item) => item.id === msg.data.id)
const index = list.value.findIndex((item) => item.id == cartId)
if (index > -1) {
list.value.splice(index, 1)
if (list.value.length >= 1) {
@@ -550,7 +563,7 @@ export const useCartsStore = defineStore("carts", () => {
return ElMessage.success(msg.message || '删除成功')
}
} else {
const index = giftList.value.findIndex((item) => item.id === msg.data.id)
const index = giftList.value.findIndex((item) => item.id == cartId)
if (index > -1) {
giftList.value.splice(index, 1)
if (giftList.value.length >= 1) {