部分显示问题调整,问题修复,增加购物车初始化和商品更新未找到对应商品发送删除消息

This commit is contained in:
2025-12-24 09:21:14 +08:00
parent 9a09ac901f
commit addb9f0e75
12 changed files with 319 additions and 237 deletions

View File

@@ -246,14 +246,15 @@ export const useCartsStore = defineStore("cart", () => {
const goodsIsloading = ref(true);
//商品数据Map
const goodsMap = reactive({});
const goodsMap = ref({})
function returnGoods(product_id) {
return goodsMap[product_id * 1];
return goodsMap.value[product_id * 1];
}
//获取商品数据
async function goodsInit() {
goodsMap.value={}
goodsIsloading.value = true;
//获取招牌菜商品
const hotres = await productminiApphotsquery();
@@ -272,13 +273,13 @@ export const useCartsStore = defineStore("cart", () => {
}
function setGoodsMap(product_id, data) {
goodsMap[product_id] = data;
goodsMap.value[product_id] = data;
}
const isLoading = ref(true);
function getProductDetails(v) {
const goods = goodsMap[v.product_id];
const goods = goodsMap.value[v.product_id];
if (!goods) {
return undefined;
}
@@ -327,17 +328,18 @@ export const useCartsStore = defineStore("cart", () => {
const item = getProductDetails(v);
if (!item) {
socketSendMsg({
id: v.id,
operate_type: "del",
type: "shopping",
});
return null
}
console.log('v',v);
console.log('limitTimeDiscount',limitTimeDiscount.value);
console.log('shopInfo',shopInfo.value);
console.log('shopUserInfo',shopUserInfo.value);
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount({...v,memberPrice:item.memberPrice}, limitTimeDiscount
.value,
shopInfo.value,
shopUserInfo.value, 'product_id');
console.log('is_time_discount',is_time_discount);
return {
...item,
is_time_discount: is_time_discount ? 1 : 0
@@ -391,7 +393,7 @@ export const useCartsStore = defineStore("cart", () => {
// 初始化
if (Message.operate_type == "init") {
if (!oldOrder.value.id) {
limitTimeDiscount.value = Message.time_dis_info;
// limitTimeDiscount.value = Message.time_dis_info;
}
cartsGoodsInfoInit(msgData);
isLoading.value = false;
@@ -428,7 +430,7 @@ export const useCartsStore = defineStore("cart", () => {
Message.operate_type == "product_update"
) {
await goodsInit();
await cartsGoodsInfoInit();
await cartsGoodsInfoInit(carts.value);
}
// 提示
@@ -440,12 +442,11 @@ export const useCartsStore = defineStore("cart", () => {
}
//获取限时折扣
if (Message.operate_type == "time_discount_get") {
console.log("time_discount_get", Message.data);
limitTimeDiscount.value = Message.data;
}
if (Message.operate_type == "time_discount_save") {
limitTimeDiscount.value = Message.data;
// limitTimeDiscount.value = Message.data;
}
// if (Message.operate_type == "time_discount_save") {
// limitTimeDiscount.value = Message.data;
// }
if (Message.type == "no_suit_num") {
uni.showModal({
@@ -703,7 +704,7 @@ export const useCartsStore = defineStore("cart", () => {
carts,
isEmpty,
setGoodsMap,
goodsMap: goodsMap,
goodsMap: goodsMap.value,
goodsIsloading,
goodsInit,
onMessage,