点餐页面热销修改

This commit is contained in:
2025-12-22 14:21:27 +08:00
parent a492440492
commit 8b3228e359

View File

@@ -129,7 +129,7 @@
:class="shopInfo.isVip == 0 || shopInfo.isMemberPrice == 0 ? 'lineThrough' : ''">¥</text>
<!-- 会员价与价格 -->
<view class="price">
<GoodsPrice :limitDiscount="limitTimeDiscountRes" :cart="item"
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="item"
:shopUserInfo="shopUserInfo" :key="item.id" :shopInfo="shopInfo">
</GoodsPrice>
</view>
@@ -195,7 +195,7 @@
<view>{{ item.name }}</view>
</view>
<view class="goods" @click="clickspecifications(item1, index, index1)"
v-for="(item1, index1) in item.productList" :key="index1">
v-for="(item1, index1) in item.productList" :key="item1.id">
<view class="relative">
<image class="goodsImg" @click.stop="getImgs(item1)" v-if="item1.coverImg != null"
:lazy-load="true" @load="imageLoaded(item1, index, index1)"
@@ -238,7 +238,8 @@
<view class="goods_right" style="overflow: hidden">
<view class="name">{{ item1.name }}</view>
<!-- <view class="lookBack" v-if="index=='0'">本店销量第{{index1+1}}名</view>-->
<view class="lookBack" v-if="specifications.item.isHot == 1">热销</view>
<!-- <view class="lookBack" v-if="specifications.item.isHot == 1">热销</view> -->
<view class="lookBack" v-if="returnIsHot(item1,item,index)">热销</view>
<view class="describe">{{ item1.shortTitle ? item1.shortTitle : '' }}</view>
<view class="describe" v-if="item1.suitNum > 1 && item1.type != 'sku'"
@@ -267,7 +268,7 @@
<view class="money">
<view>¥</view>
<view class="money_num">
<GoodsPrice :limitDiscount="limitTimeDiscountRes" :cart="item1"
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="item1"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
<text class="money_num" v-if="item1.unitName">/{{ item1.unitName }}</text>
@@ -326,7 +327,7 @@
<shopindex ref="showShopInfoRef"></shopindex>
<!-- 购物车 -->
<shoppingCartes :cartLists_count="cartLists_count" :cartList="matchedProducts" :showCart="showCart"
:limitDiscount="limitTimeDiscountRes" @customevent="websocketsendMessage" @close="showCart = !showCart"
:limitDiscount="cartStore.limitTimeDiscount" @customevent="websocketsendMessage" @close="showCart = !showCart"
:orderinfo="orderinfo" @clickcancelOrder="clickcancelOrder" v-if="cartLists_count > 0"
:nextFullAmountActivty="nextFullAmountActivty"></shoppingCartes>
@@ -437,13 +438,15 @@
</view>
</view>
</scroll-view>
<!-- 占位 -->
<view style="height: 42rpx;"></view>
<view class="shop_bottom">
<view class="flex-between">
<view class="price price-sku"
v-if="specifications.item.type != 'package' && specifications.item.result">
<text class="i">¥</text>
<view class="num">
<GoodsPrice :limitDiscount="limitTimeDiscountRes" :cart="specifications.item.result"
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="specifications.item.result"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
@@ -462,7 +465,7 @@
<view class="price price-package" v-else>
<text class="i">¥</text>
<view class="num">
<GoodsPrice :limitDiscount="limitTimeDiscountRes" :cart="specifications.item"
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="specifications.item"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
<text class="num" v-if="false">
@@ -1098,7 +1101,11 @@
}
}
};
//返回是否是热销商品
function returnIsHot(item,category,index){
return item.isHot&& category.name=='热销' &&index==0 && shopProductList.hots.find(v=>v.id==item.id)
}
@@ -1502,9 +1509,9 @@
const websocketsendMessage = (data) => {
console.log('websocketsendMessage', data);
delete data.memberPrice;
useSocket.sendMessage(data);
// uni.$u.debounce(() => {
// }, 500);
uni.$u.debounce(() => {
useSocket.sendMessage(data);
}, 200);
};
// 用于记录已经处理过的消息的 msg_id
@@ -1601,6 +1608,7 @@
// 初始化
if (Message.operate_type == 'init') {
cartStore.limitTimeDiscount = Message.time_dis_info;
console.log('onMessage限时折扣',cartStore.limitTimeDiscount)
cartInit(Message.data)
uni.hideLoading();
@@ -1621,6 +1629,7 @@
cancelText: '舍弃',
confirmText: '合并',
success(res) {
showTableInfoPeopleNumPopup.value=false;
if (res.confirm) {
startUseTable({
is_hb: 2
@@ -1732,6 +1741,7 @@
}
});
}
if (Message.operate_type == 'time_discount_save') {
cartStore.limitTimeDiscount = Message.data;
}
@@ -1881,13 +1891,13 @@
});
}
console.log('limitTimeDiscountRes',item)
if (limitTimeDiscountRes.value && limitTimeDiscountRes.value.id && item.cartListinfo.is_time_discount ==
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo.is_time_discount ==
1) {
//限时折扣
const price = limitUtils.returnPrice({
goods: item,
shopInfo,
limitTimeDiscountRes: limitTimeDiscountRes.value,
limitTimeDiscountRes: cartStore.limitTimeDiscount,
shopUserInfo: shopUserInfo.value,
idKey: 'id'
});
@@ -2324,14 +2334,14 @@
}
const limitDiscountCountdown = computed(() => {
if (!limitTimeDiscountRes.value && !limitTimeDiscountRes.value.id) {
if (!cartStore.limitTimeDiscount && !cartStore.limitTimeDiscount.id) {
return '';
}
if (limitTimeDiscountRes.value.useTimeType != 'custom') {
if (cartStore.limitTimeDiscount.useTimeType != 'custom') {
return '';
}
//根据当前时间和限时折扣的结束时间计算倒计时,结束时间是hh:mm,将hh:mm转换为时间多少秒然后再减去当前时间就得到了倒计时
const endTime = getEndTimeInSeconds(limitTimeDiscountRes.value.useEndTime);
const endTime = getEndTimeInSeconds(cartStore.limitTimeDiscount.useEndTime);
const countdown = endTime - nowTime.value;
if (countdown <= 0) {
return '';
@@ -2482,8 +2492,8 @@
shopId: uni.cache.get('shopId')
});
if (limitRes && typeof limitRes == 'object') {
limitTimeDiscountRes.value = limitRes;
cartStore.limitTimeDiscount = limitRes;
console.log('onMounted:限时折扣',cartStore.limitTimeDiscount );
websocketsendMessage({
type: 'shopping',
operate_type: 'time_discount_save',
@@ -2494,6 +2504,7 @@
});
} else {
cartStore.limitTimeDiscount = null;
console.log('onMounted:限时折扣',cartStore.limitTimeDiscount );
websocketsendMessage({
type: 'shopping',
operate_type: 'time_discount_save',