问题修复,下单优化,订单结算问题修复

This commit is contained in:
2025-10-31 16:30:47 +08:00
parent 09fc28de06
commit 31d91f7de5
10 changed files with 379 additions and 148 deletions

View File

@@ -891,7 +891,7 @@ async function getDiscountActivity() {
}
onMounted(async () => {
await getConsumeDiscount();
// getDiscountActivity();
getDiscountActivity();
});
</script>

View File

@@ -83,7 +83,7 @@
></goodsPrice>
<text
class="originalprice"
class="originalprice" v-if="showLimitDiscount(item)"
>{{ item.salePrice }}</text
>

View File

@@ -58,7 +58,10 @@
v-for="(item, index) in shopProductList.hots"
:key="index"
>
<view class="limitDiscount" v-if="showLimitDiscount(item)"
<!-- <view class="limitDiscount" v-if="showLimitDiscount(item)"
>限时折扣</view
> -->
<view class="limitDiscount" v-if="item.is_time_discount"
>限时折扣</view
>
<image
@@ -441,7 +444,12 @@
<text class="money_num" v-if="item1.unitName"
>/{{ item1.unitName }}</text
>
<text class="old-price">¥{{ item1.salePrice }}</text>
<!-- <text class="old-price" v-if=" showLimitDiscount(item1)"
>¥{{ item1.salePrice }}</text
> -->
<text class="old-price" v-if="item1.is_time_discount"
>¥{{ item1.salePrice }}</text
>
<!-- <text v-if="item1.suitNum>1 && item1.type!= 'sku'"
style="font-size: 14rpx;">
@@ -703,10 +711,9 @@
:shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"
></GoodsPrice>
</view>
</view>
<text class="num" v-if="false">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
? specifications.item.result.memberPrice ||
@@ -731,7 +738,7 @@
:shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"
></GoodsPrice>
</view>
</view>
<text class="num" v-if="false">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
@@ -1440,6 +1447,8 @@ const submitSelection = async () => {
memberPrice: specifications.item.memberPrice,
is_print: 1,
product_type: specifications.item.type,
is_time_discount:specifications.item.is_time_discount
});
// 清空套餐选中
selectedGroupSnap.value = [];
@@ -1587,6 +1596,7 @@ const singleclick = async (item, i) => {
number: await calculateValue(item.cartNumber, i, suitNum),
is_print: 1,
product_type: item.type,
is_time_discount:item.is_time_discount
});
};
@@ -1663,23 +1673,9 @@ const updateProductQuantities = () => {
//websocket产值
const websocketsendMessage = (data) => {
console.log("websocketsendMessage", data);
const sendData = { ...data, is_time_discount: 0 };
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id) {
const canUse = orderUtils.canUseLimitTimeDiscount(
data,
cartStore.limitTimeDiscount,
shopInfo,
shopUserInfo.value,
"product_id"
);
console.log("canUse", canUse);
if (canUse) {
sendData.is_time_discount = 1;
}
}
delete sendData.memberPrice;
delete data.memberPrice;
uni.$u.debounce(() => {
useSocket.sendMessage(sendData);
useSocket.sendMessage(data);
}, 500);
};
@@ -1792,7 +1788,11 @@ async function onMessage(Message) {
}
// 提示
if (Message.status == 0 && Message.type != "no_suit_num") {
if (
Message.status == 0 &&
Message.type != "no_suit_num" &&
Message.type != "time_discount"
) {
uni.showToast({
title: Message.msg,
icon: "none",
@@ -2038,29 +2038,6 @@ function ifcartNumber(item) {
// 如果类型不匹配,返回原始值
return item.cartNumber;
}
// const ifcartNumber = computed(() => {
// return (item) => {
// // 如果 item 为空或者 cartNumber 不是字符串类型,返回 0
// if (!item || typeof item.cartNumber !== 'string') {
// return 0;
// }
// let numValue = parseFloat(item.cartNumber);
// if (isNaN(numValue)) {
// // 如果转换结果是 NaN说明 cartNumber 不是有效的数字字符串,返回 0
// return 0;
// }
// // type string 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
// if (item.type === 'weight') {
// // 如果类型是称重重量,将值保留两位小数
// return parseFloat(numValue.toFixed(2));
// } else {
// // 如果类型是整数,将值转换为整数
// return Math.round(numValue);
// }
// // 如果类型不匹配,返回原始值
// return item.cartNumber;
// };
// })
// 计算处理后的购物车列表 // 用于筛选后的购物车数组
const cartListFilter = computed(() => {
@@ -2146,6 +2123,9 @@ const productqueryProduct = async () => {
product.startTime,
product.endTime
);
product.is_time_discount = showLimitDiscount(product)?1:0;
product.limitSalePrice = returnLimitPrice(product);
cartStore.setGoodsMap(product.id, product);
});
});
@@ -2156,6 +2136,8 @@ const productqueryProduct = async () => {
i.startTime,
i.endTime
);
i.is_time_discount = showLimitDiscount(i)?1:0;
i.limitSalePrice = returnLimitPrice(i);
cartStore.setGoodsMap(i.id, i);
});
@@ -2204,6 +2186,16 @@ function showLimitDiscount(item) {
);
}
function returnLimitPrice(item) {
return orderUtils.returnPrice({
goods: item,
limitTimeDiscountRes: cartStore.limitTimeDiscount,
shopInfo: shopInfo,
shopUserInfo: shopUserInfo.value,
idKey: "id",
});
}
onShow(async () => {
// 监听页面显示和隐藏
useSocket.setOnMessage(onMessage);
@@ -2242,6 +2234,7 @@ onMounted(async () => {
});
if (limitRes && typeof limitRes == "object") {
limitTimeDiscountRes.value = limitRes;
cartStore.limitTimeDiscount = limitRes;
websocketsendMessage({
type: "shopping",
operate_type: "time_discount_save",
@@ -2251,6 +2244,7 @@ onMounted(async () => {
data: limitRes,
});
} else {
cartStore.limitTimeDiscount = null;
websocketsendMessage({
type: "shopping",
operate_type: "time_discount_save",
@@ -2259,6 +2253,7 @@ onMounted(async () => {
operate_type: "time_discount_save",
data: null,
});
}
await productqueryProduct();