优化切换店铺没有清除代客下单历史订单干的问题

This commit is contained in:
gyq
2025-11-24 10:52:42 +08:00
parent f51d0d44e4
commit 7f76996829
8 changed files with 94 additions and 199 deletions

View File

@@ -146,6 +146,7 @@ export const useCartsStore = defineStore("carts", () => {
};
console.log('changeUser', vipUser.value);
await getConsumeDiscountAjax()
await getGoods({})
// 选择用户后重新刷新历史订单限时折扣信息
@@ -157,6 +158,24 @@ export const useCartsStore = defineStore("carts", () => {
payParamsInit()
}
// 根据用户id获取新客立减金额返回null代表不可用
async function getConsumeDiscountAjax() {
try {
if (vipUser.value.id) {
const res = await limitTimeDiscountApi.getConsumeDiscount({
shopId: localStorage.getItem("shopId"),
shopUserId: vipUser.value.id,
orderId: oldOrder.value.id,
});
console.log("根据用户id获取新客立减金额返回null代表不可用", res);
if (res !== null) {
newUserDiscount.value = res;
}
}
} catch (error) {
console.log(error);
}
}
// 给长连接发送更新购物车限时折扣信息
const sendWsTimeDiscount = _.throttle(function () {
@@ -406,8 +425,8 @@ export const useCartsStore = defineStore("carts", () => {
//使用积分数量
const userPoints = ref(0);
// 新客立减金额
const newUserDiscount = ref(0)
// 新客立减配置
const newUserDiscount = ref(null)
// 订单额外配置(现在依赖响应式的 merchantReduction
const orderExtraConfig = computed<OrderExtraConfig>(() => ({
@@ -424,7 +443,7 @@ export const useCartsStore = defineStore("carts", () => {
currentDinnerType: dinnerType.value,
limitTimeDiscount: limitDiscountRes.value,
shopUserInfo: vipUser.value,
newUserDiscount: newUserDiscount.value
newUserDiscount: newUserDiscount.value !== null ? newUserDiscount.value.amount : 0
}) as OrderExtraConfig);
// 营销活动列表
@@ -1001,6 +1020,7 @@ export const useCartsStore = defineStore("carts", () => {
// 支付成功后清楚订单/用户信息
function clearHistory() {
vipUser.value = {}
newUserDiscount.value = {}
}
return {