From b637a6dea985f941b12f8dfcd79b548efb09827e Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Wed, 22 Apr 2026 10:21:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=A4=E6=96=AD=E5=BA=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/product/index.vue | 283 +++++++++------------------------------- 1 file changed, 64 insertions(+), 219 deletions(-) diff --git a/pages/product/index.vue b/pages/product/index.vue index b9b3b74..9dbad6a 100644 --- a/pages/product/index.vue +++ b/pages/product/index.vue @@ -58,12 +58,11 @@ 限时折扣{{ limitDiscountCountdown }} - + 仅剩{{returnStockNumber(item)}}份 - + 限时折扣{{ limitDiscountCountdown }} --> - + 仅剩{{returnStockNumber(item1)}}份 - + - - - - - - - - - - {{ specifications.item.name }} - - {{ specifications.item.shortTitle ? specifications.item.shortTitle : '' }} - - - - - {{ specType }} - - - - {{ option }} - - 售罄 - - - 已下架 - - - - - - - - - - {{ setmenu.title }} {{ setmenu.count }} - 选{{ setmenu.number }} - - - {{ option.proName }} - /{{ option.unitName }} - - 售罄 - - - - - - - - - - 推荐搭配 - - - - - - 商品名 - - - - - - 40 - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ - shopUserInfo.isVip == 1 && shopUserInfo.isMemberPrice == 1 - ? specifications.item.result.memberPrice || specifications.item.result.salePrice - : specifications.item.result.salePrice - }} - - /{{ specifications.item.unitName }} - 「{{ specifications.item.result.suitNum }}{{ specifications.item.result.unitName }}起点」 - - - - - - - - {{ - shopUserInfo.isVip == 1 && shopUserInfo.isMemberPrice == 1 - ? specifications.item.memberPrice || specifications.item.salePrice - : specifications.item.salePrice - }} - - /{{ specifications.item.unitName }} - 「{{ specifications.item.suitNum }}{{ specifications.item.unitName }}起点」 - - - - - - - - {{ shopCartNumber }} - - - - - - - - {{ selectedSpecsStr }} - - - - - - - - @@ -754,6 +562,32 @@ productStore } from '@/stores/user.js'; + // 是否显示禁止购买 + function showNoBuy(item) { + if (item.isSale == 0) { + return true + } + if (item.isSaleTime == 0 && !item.isSaleTimeshow) { + return true + } + if (item.isSoldStock == 1) { + return true + } + if(item.type==="single"){ + const sku=item.skuList[0] + if(!sku){ + return true + } + if(sku&&returnStockNumber(item) v.productId == specifications.item.id)) { // 等待用户点击 @@ -1403,7 +1235,7 @@ if (!isConfirm) { return } - }else{ + } else { if (res && number * 1 === 2) { const isConfirm = await showConfirmModal( '购物车已有该商品,请确认是否重复', @@ -1412,7 +1244,7 @@ if (!isConfirm) { return } - + } } @@ -1437,7 +1269,6 @@ }); // 清空套餐选中 selectedGroupSnap.value = []; - showShopsku.value = false; } else { const number = await calculateValue(res.cartNumber, '+', shopCartNumber.value) const oldGoodsArr = combineOrderInfoDetailMap(orderinfo.value) @@ -1450,7 +1281,7 @@ if (!isConfirm) { return } - }else{ + } else { if (res && number * 1 === 2) { const isConfirm = await showConfirmModal( '购物车已有该商品,请确认是否重复', @@ -1461,8 +1292,8 @@ } } } - - + + websocketsendMessage({ id: res ? res.cartListId : '', type: 'shopping', @@ -1478,7 +1309,6 @@ product_type: specifications.item.type, is_time_discount: showLimitDiscount(specifications.item) }); - showShopsku.value = false; return; } @@ -1593,7 +1423,6 @@ .filter(([_, value]) => value.length > 0)); // 给默认数量 specifications.item.amountcartNumber = 0; - // showShopsku.value = true; goodsModalList.value.push({ show: true, goods: { @@ -1717,8 +1546,16 @@ } const number = await calculateValue(item.cartNumber, i, suitNum) + const goodsStockNumber = returnStockNumber(item) + console.log('number', number); if (i === '+') { + if (goodsStockNumber < suitNum) { + return uni.showToast({ + title: '库存不足', + icon: 'none' + }) + } const oldGoodsArr = combineOrderInfoDetailMap(orderinfo.value) if (oldGoodsArr.find(v => v.productId == item.id)) { // 等待用户点击 @@ -1729,7 +1566,7 @@ if (!isConfirm) { return } - }else{ + } else { if (number * 1 == 2) { const isConfirm = await showConfirmModal( '购物车已有该商品,请确认是否重复', @@ -1740,7 +1577,7 @@ } } } - + } @@ -2760,25 +2597,31 @@ } const consStockList = ref([]) + + // 是否显示剩余库存数量 + function showStockNumber(item) { + return !item.isSoldStock && returnStockNumber(item) <= 10 && returnStockNumber(item) > 0 + } + function returnStockNumber(item) { - if(!item.isAutoSoldStock){ + if (!item.isAutoSoldStock) { return 9999 } const consList = item.consList const matchStockList = consStockList.value.filter(v => { return consList.find(c => c.consInfoId == v.consId) - }).map(v=>{ - const cItem=item.consList.find(c=>c.consInfoId==v.consId) - const goodsNumber=Math.floor(v.stockNumber/cItem.surplusStock) + }).map(v => { + const cItem = item.consList.find(c => c.consInfoId == v.consId) + const goodsNumber = Math.floor(v.stockNumber / cItem.surplusStock) return { ...v, goodsNumber } - }).sort((a,b)=>{ - return a.goodsNumber-b.goodsNumber + }).sort((a, b) => { + return a.goodsNumber - b.goodsNumber }) - - const minConsStockNumber=matchStockList[0]?matchStockList[0].goodsNumber:9999 + + const minConsStockNumber = matchStockList[0] ? matchStockList[0].goodsNumber : 9999 return minConsStockNumber } onLoad(async (e) => { @@ -2812,8 +2655,7 @@ } options.initMessage.shop_id = userStore.shopInfo.id shopUserInfo.value = userStore.shopUserInfo - //耗材列表 - await getConsStocks() + await productqueryProduct(); const extraInitPar = {} @@ -2951,6 +2793,9 @@ // if(!topArr.value.length){ // getElementTop() // } + + //耗材列表 + await getConsStocks() }); //是否自动关闭socket