点餐页面限时折扣回显问题修复

This commit is contained in:
2025-12-22 18:09:29 +08:00
parent 8bd5956340
commit 47076b2d4b
4 changed files with 1072 additions and 1081 deletions

View File

@@ -91,6 +91,10 @@
<script setup> <script setup>
import * as distributionApi from "@/common/api/market/distribution.js"; import * as distributionApi from "@/common/api/market/distribution.js";
import { productStore } from "@/stores/user.js"; import { productStore } from "@/stores/user.js";
import {
APIuserlogin,
APIuser
} from "@/common/api/api.js";
const storeuser = productStore(); const storeuser = productStore();
import { ref, onMounted, reactive } from "vue"; import { ref, onMounted, reactive } from "vue";
import { onLoad, onReachBottom, onShow } from "@dcloudio/uni-app"; import { onLoad, onReachBottom, onShow } from "@dcloudio/uni-app";
@@ -222,7 +226,7 @@ onLoad(() => {
}); });
onShow(() => { onShow(() => {
storeuser.actionsAPIuser().then((res) => { APIuser.then((res) => {
userinfo.value = res; userinfo.value = res;
}); });
}); });

File diff suppressed because it is too large Load Diff

View File

@@ -49,14 +49,13 @@
<view class="panelfive_list"> <view class="panelfive_list">
<view class="panelfiveitem" @click="clickspecifications(item, index, index, '热销')" <view class="panelfiveitem" @click="clickspecifications(item, index, index, '热销')"
v-for="(item, index) in shopProductList.hots" :key="index"> v-for="(item, index) in shopProductList.hots" :key="index">
<view class="relative"> <view class="relative">
<image @click.stop="getImgs(item)" class="panelfiveitemimage" :src="item.coverImg" <image @click.stop="getImgs(item)" class="panelfiveitemimage" :src="item.coverImg"
mode="aspectFill"></image> mode="aspectFill"></image>
<view class="limitDiscount" v-if="showLimitDiscount(item)" <view class="limitDiscount" v-if="showLimitDiscount(item)">
>限时折扣{{ limitDiscountCountdown }}</view 限时折扣{{ limitDiscountCountdown }}</view>
>
<!-- <view class="limitDiscount" v-if="item.is_time_discount"> <!-- <view class="limitDiscount" v-if="item.is_time_discount">
限时折扣{{ limitDiscountCountdown }}</view> --> 限时折扣{{ limitDiscountCountdown }}</view> -->
<view class="stock_warning" v-if="item.isStock&&item.stockNumber<=10"> <view class="stock_warning" v-if="item.isStock&&item.stockNumber<=10">
@@ -204,11 +203,10 @@
<image class="goodsImg" <image class="goodsImg"
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/1.gif" mode="" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/1.gif" mode=""
v-else :lazy-load="true"></image> v-else :lazy-load="true"></image>
<view class="limitDiscount" v-if="showLimitDiscount(item1)" <view class="limitDiscount" v-if="showLimitDiscount(item1)">
>限时折扣{{ limitDiscountCountdown }}</view 限时折扣{{ limitDiscountCountdown }}</view>
>
<!-- <view class="limitDiscount" v-if="item1.is_time_discount">
<!-- <view class="limitDiscount" v-if="item1.is_time_discount">
限时折扣{{ limitDiscountCountdown }}</view> --> 限时折扣{{ limitDiscountCountdown }}</view> -->
<view class="stock_warning" v-if="item1.isStock&&item1.stockNumber<=10"> <view class="stock_warning" v-if="item1.isStock&&item1.stockNumber<=10">
仅剩{{item1.stockNumber}}</view> 仅剩{{item1.stockNumber}}</view>
@@ -239,7 +237,7 @@
<view class="name">{{ item1.name }}</view> <view class="name">{{ item1.name }}</view>
<!-- <view class="lookBack" v-if="index=='0'">本店销量第{{index1+1}}名</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="lookBack" v-if="returnIsHot(item1,item,index)">热销</view>
<view class="describe">{{ item1.shortTitle ? item1.shortTitle : '' }}</view> <view class="describe">{{ item1.shortTitle ? item1.shortTitle : '' }}</view>
<view class="describe" v-if="item1.suitNum > 1 && item1.type != 'sku'" <view class="describe" v-if="item1.suitNum > 1 && item1.type != 'sku'"
@@ -272,10 +270,10 @@
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice> :shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view> </view>
<text class="money_num" v-if="item1.unitName">/{{ item1.unitName }}</text> <text class="money_num" v-if="item1.unitName">/{{ item1.unitName }}</text>
<text class="old-price" <text class="old-price"
v-if="showLimitDiscount(item1)">¥{{ item1.salePrice }}</text> v-if="showLimitDiscount(item1)">¥{{ item1.salePrice }}</text>
<!-- <text class="old-price" <!-- <text class="old-price"
v-if="item1.is_time_discount">¥{{ item1.salePrice }}</text> --> v-if="item1.is_time_discount">¥{{ item1.salePrice }}</text> -->
<!-- <text v-if="item1.suitNum>1 && item1.type!= 'sku'" <!-- <text v-if="item1.suitNum>1 && item1.type!= 'sku'"
style="font-size: 14rpx;"> style="font-size: 14rpx;">
@@ -327,9 +325,9 @@
<shopindex ref="showShopInfoRef"></shopindex> <shopindex ref="showShopInfoRef"></shopindex>
<!-- 购物车 --> <!-- 购物车 -->
<shoppingCartes :cartLists_count="cartLists_count" :cartList="matchedProducts" :showCart="showCart" <shoppingCartes :cartLists_count="cartLists_count" :cartList="matchedProducts" :showCart="showCart"
:limitDiscount="cartStore.limitTimeDiscount" @customevent="websocketsendMessage" @close="showCart = !showCart" :limitDiscount="cartStore.limitTimeDiscount" @customevent="websocketsendMessage"
:orderinfo="orderinfo" @clickcancelOrder="clickcancelOrder" v-if="cartLists_count > 0" @close="showCart = !showCart" :orderinfo="orderinfo" @clickcancelOrder="clickcancelOrder"
:nextFullAmountActivty="nextFullAmountActivty"></shoppingCartes> v-if="cartLists_count > 0" :nextFullAmountActivty="nextFullAmountActivty"></shoppingCartes>
<!-- 显示购物车栏 --> <!-- 显示购物车栏 -->
<view class="cart-wrap" v-if="cartLists_count > 0 && !confirmordershow && isBusinessTime"> <view class="cart-wrap" v-if="cartLists_count > 0 && !confirmordershow && isBusinessTime">
@@ -446,8 +444,9 @@
v-if="specifications.item.type != 'package' && specifications.item.result"> v-if="specifications.item.type != 'package' && specifications.item.result">
<text class="i">¥</text> <text class="i">¥</text>
<view class="num"> <view class="num">
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="specifications.item.result" <GoodsPrice :limitDiscount="cartStore.limitTimeDiscount"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice> :cart="specifications.item.result" :shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"></GoodsPrice>
</view> </view>
<text class="num" v-if="false"> <text class="num" v-if="false">
@@ -481,7 +480,8 @@
v-if="specifications.item.suitNum > 1">「{{ specifications.item.suitNum }}{{ specifications.item.unitName }}起点」</text> v-if="specifications.item.suitNum > 1">「{{ specifications.item.suitNum }}{{ specifications.item.unitName }}起点」</text>
</view> </view>
<view class="operation-wrap" v-if="specifications.item.type != 'package'&&stockNumberIsFull(specifications.item)"> <view class="operation-wrap"
v-if="specifications.item.type != 'package'&&stockNumberIsFull(specifications.item)">
<view class="btn"> <view class="btn">
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25" <up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
v-if="shopCartNumber > 0"></up-icon> v-if="shopCartNumber > 0"></up-icon>
@@ -521,8 +521,8 @@
</view> </view>
</template> </template>
</template> </template>
</view> </view>
</view> </view>
</up-popup> </up-popup>
@@ -1101,10 +1101,10 @@
} }
} }
}; };
//返回是否是热销商品 //返回是否是热销商品
function returnIsHot(item,category,index){ function returnIsHot(item, category, index) {
return item.isHot&& category.name=='热销' &&index==0 && shopProductList.hots.find(v=>v.id==item.id) return item.isHot && category.name == '热销' && index == 0 && shopProductList.hots.find(v => v.id == item.id)
} }
@@ -1360,15 +1360,15 @@
return isInRange; return isInRange;
}; };
function stockNumberIsFull(item){ function stockNumberIsFull(item) {
if(item.isStock && item.stockNumber < item.suitNum){ if (item.isStock && item.stockNumber < item.suitNum) {
return false return false
} }
return true return true
} }
/** /**
* 判断商品是否可售 * 判断商品是否可售
* @param {Object} item * @param {Object} item
@@ -1380,7 +1380,7 @@
}); });
return false; return false;
} }
if ( item.isStock && item.stockNumber < item.suitNum && i == '+') { if (item.isStock && item.stockNumber < item.suitNum && i == '+') {
uni.showToast({ uni.showToast({
title: '库存不足', title: '库存不足',
icon: 'none' icon: 'none'
@@ -1430,7 +1430,7 @@
number: await calculateValue(item.cartNumber, i, suitNum), number: await calculateValue(item.cartNumber, i, suitNum),
is_print: 1, is_print: 1,
product_type: item.type, product_type: item.type,
is_time_discount: showLimitDiscount(item) is_time_discount: showLimitDiscount(item)
}; };
if (item.cartListId) { if (item.cartListId) {
sendMsg.id = item.cartListId; sendMsg.id = item.cartListId;
@@ -1608,7 +1608,7 @@
// 初始化 // 初始化
if (Message.operate_type == 'init') { if (Message.operate_type == 'init') {
cartStore.limitTimeDiscount = Message.time_dis_info; cartStore.limitTimeDiscount = Message.time_dis_info;
console.log('onMessage限时折扣',cartStore.limitTimeDiscount) console.log('onMessage限时折扣', cartStore.limitTimeDiscount)
cartInit(Message.data) cartInit(Message.data)
uni.hideLoading(); uni.hideLoading();
@@ -1629,7 +1629,7 @@
cancelText: '舍弃', cancelText: '舍弃',
confirmText: '合并', confirmText: '合并',
success(res) { success(res) {
showTableInfoPeopleNumPopup.value=false; showTableInfoPeopleNumPopup.value = false;
if (res.confirm) { if (res.confirm) {
startUseTable({ startUseTable({
is_hb: 2 is_hb: 2
@@ -1669,7 +1669,7 @@
shop_id: uni.cache.get('shopId'), shop_id: uni.cache.get('shopId'),
time_dis_info: cartStore.limitTimeDiscount time_dis_info: cartStore.limitTimeDiscount
}; };
console.log('cartStore.limitTimeDiscount', cartStore.limitTimeDiscount)
useSocket.sendMessage({ useSocket.sendMessage({
type: 'shopping', type: 'shopping',
operate_type: 'time_discount_save', operate_type: 'time_discount_save',
@@ -1741,7 +1741,7 @@
} }
}); });
} }
if (Message.operate_type == 'time_discount_save') { if (Message.operate_type == 'time_discount_save') {
cartStore.limitTimeDiscount = Message.data; cartStore.limitTimeDiscount = Message.data;
} }
@@ -1890,8 +1890,9 @@
} }
}); });
} }
console.log('limitTimeDiscountRes',item) console.log('limitTimeDiscountRes', item)
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo.is_time_discount == if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo
.is_time_discount ==
1) { 1) {
//限时折扣 //限时折扣
const price = limitUtils.returnPrice({ const price = limitUtils.returnPrice({
@@ -1901,7 +1902,7 @@
shopUserInfo: shopUserInfo.value, shopUserInfo: shopUserInfo.value,
idKey: 'id' idKey: 'id'
}); });
console.log('限时折扣',price) console.log('限时折扣', price)
return total + parseFloat(price) * parseFloat(item.cartNumber); return total + parseFloat(price) * parseFloat(item.cartNumber);
} }
// 是否启用会员价 0否1是 // 是否启用会员价 0否1是
@@ -2301,10 +2302,13 @@
extraInitPar.order_id = e.order_id extraInitPar.order_id = e.order_id
extraInitPar.user_id = uni.cache.get('userInfo').id || '' extraInitPar.user_id = uni.cache.get('userInfo').id || ''
} }
const time_dis_info= await getLimitDiscount()
useSocket.connect({ useSocket.connect({
...options.initMessage, ...options.initMessage,
...extraInitPar ...extraInitPar,
time_dis_info
}, onMessage); }, onMessage);
@@ -2351,9 +2355,9 @@
function showLimitDiscount(item) { function showLimitDiscount(item) {
if (!cartStore.limitTimeDiscount || !cartStore.limitTimeDiscount.id) { if (!cartStore.limitTimeDiscount || !cartStore.limitTimeDiscount.id) {
return false; return 0;
} }
return limitUtils.canUseLimitTimeDiscount(item, cartStore.limitTimeDiscount, shopInfo, shopUserInfo.value, 'id'); return limitUtils.canUseLimitTimeDiscount(item, cartStore.limitTimeDiscount, shopInfo, shopUserInfo.value, 'id')?1:0;
} }
function returnLimitPrice(item) { function returnLimitPrice(item) {
@@ -2471,6 +2475,29 @@
return 0 return 0
}) })
const oldOrder = ref(null); const oldOrder = ref(null);
// 限时折扣
async function getLimitDiscount(){
const limitRes = await limitTimeDiscountapi.getConfig({
shopId: uni.cache.get('shopId')
});
if (limitRes && typeof limitRes == 'object') {
cartStore.limitTimeDiscount = limitRes;
} else {
cartStore.limitTimeDiscount = null;
}
return cartStore.limitTimeDiscount
websocketsendMessage({
type: 'shopping',
operate_type: 'time_discount_save',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: 'time_discount_save',
data: cartStore.limitTimeDiscount
});
console.log('onMounted:限时折扣', cartStore.limitTimeDiscount);
}
onMounted(async () => { onMounted(async () => {
await proxy.$onLaunched; await proxy.$onLaunched;
// 获取当前页面栈 // 获取当前页面栈
@@ -2484,37 +2511,11 @@
getNewUserDiscount(); getNewUserDiscount();
// 满减活动 // 满减活动
getDiscountActivity(); getDiscountActivity();
let res = await APIhistoryOrder({ let res = await APIhistoryOrder({
tableCode: uni.cache.get('tableCode') tableCode: uni.cache.get('tableCode')
}); });
oldOrder.value = res; oldOrder.value = res;
const limitRes = await limitTimeDiscountapi.getConfig({
shopId: uni.cache.get('shopId')
});
if (limitRes && typeof limitRes == 'object') {
cartStore.limitTimeDiscount = limitRes;
console.log('onMounted:限时折扣',cartStore.limitTimeDiscount );
websocketsendMessage({
type: 'shopping',
operate_type: 'time_discount_save',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: 'time_discount_save',
data: limitRes
});
} else {
cartStore.limitTimeDiscount = null;
console.log('onMounted:限时折扣',cartStore.limitTimeDiscount );
websocketsendMessage({
type: 'shopping',
operate_type: 'time_discount_save',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: 'time_discount_save',
data: null
});
}
await productqueryProduct(); await productqueryProduct();
if (res && res.id && shopInfo.registerType == 'after') { if (res && res.id && shopInfo.registerType == 'after') {
toHistory(); toHistory();

View File

@@ -319,6 +319,9 @@ export const useCartsStore = defineStore("cart", () => {
//购物车商品信息补全初始化 //购物车商品信息补全初始化
function cartsGoodsInfoInit(arr) { function cartsGoodsInfoInit(arr) {
console.log('cartsGoodsInfoInit', arr) console.log('cartsGoodsInfoInit', arr)
if(oldOrder.value&&oldOrder.value.status=='done'){
return ''
}
carts.value = arr carts.value = arr
.map((v) => { .map((v) => {