Compare commits
4 Commits
5c2aa2b617
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f15137c7f | |||
| b637a6dea9 | |||
| d5c42f2092 | |||
| 129bc1276a |
@@ -55,3 +55,13 @@ export const productRelated = (data) => {
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
//获取相关推荐商品
|
||||
export const getConsStock = (data) => {
|
||||
return request({
|
||||
url: urlProduct + '/user/product/consStock',
|
||||
method: 'get',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<text class="u-m-l-22">积分:{{ allConfig.pointNum }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<image :src="imgs.code" class="code"></image>
|
||||
<!-- <image :src="imgs.code" class="code"></image> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="new-menus-box">
|
||||
|
||||
@@ -356,6 +356,17 @@
|
||||
}
|
||||
},
|
||||
},
|
||||
cartNumber:{
|
||||
//当前购物车数量
|
||||
type:Number,
|
||||
default:0
|
||||
},
|
||||
consStockList:{
|
||||
type:Array,
|
||||
default:()=>{
|
||||
return []
|
||||
}
|
||||
},
|
||||
GoodsIDInCartNumMap: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
@@ -647,7 +658,34 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 封装成 Promise 的确认弹窗
|
||||
const showConfirmModal = (title, content) => {
|
||||
return new Promise((resolve) => {
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: content,
|
||||
showCancel: true,
|
||||
cancelText: '取消添加',
|
||||
confirmText: '继续',
|
||||
success(res) {
|
||||
// 确认返回 true,取消/关闭返回 false
|
||||
resolve(res.confirm === true);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
// 提取合并 orderinfo.detailMap 数组的逻辑
|
||||
function combineOrderInfoDetailMap(orderinfo) {
|
||||
if (!orderinfo) return [];
|
||||
let combinedArray = [];
|
||||
for (const key in orderinfo.detailMap) {
|
||||
if (orderinfo.detailMap.hasOwnProperty(key)) {
|
||||
let subArray = orderinfo.detailMap[key];
|
||||
combinedArray = [...combinedArray, ...subArray];
|
||||
}
|
||||
}
|
||||
return combinedArray;
|
||||
}
|
||||
// 提交选择并执行下一步操作的方法
|
||||
const submitSelection = async (goods) => {
|
||||
if (!isProductAvailable(goods.days, goods.startTime,
|
||||
@@ -664,7 +702,7 @@
|
||||
if (goods.type == 'package' && goods.groupType != 0 && !allConditionsSatisfied.value) {
|
||||
return
|
||||
}
|
||||
|
||||
const oldGoodsArr = combineOrderInfoDetailMap(props.orderinfo)
|
||||
if ((goods.type == 'package' && allConditionsSatisfied.value) || (goods.type ==
|
||||
'sku' && canSubmit.value)) {
|
||||
let res = null;
|
||||
@@ -688,6 +726,30 @@
|
||||
sku_id = selSku.value.id
|
||||
}
|
||||
console.log('goods', goods);
|
||||
console.log('res',res);
|
||||
const number=await calculateValue(res?res.number:0, '+', shopCartNumber.value)
|
||||
console.log('number',number);
|
||||
console.log('shopCartNumber',shopCartNumber.value);
|
||||
if(res && number*1===2){
|
||||
const isConfirm = await showConfirmModal(
|
||||
'购物车已有该商品,请确认是否重复',
|
||||
'菜品名称:《' + goods.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (oldGoodsArr.find(v => v.productId == goods.id)) {
|
||||
// 等待用户点击
|
||||
const isConfirm = await showConfirmModal(
|
||||
'该商品已下单过,请确认是否重复',
|
||||
'菜品名称:《' + goods.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
emits('websocketsendMessage', {
|
||||
id: res ? res.id : '',
|
||||
type: 'shopping',
|
||||
@@ -697,7 +759,7 @@
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
product_id: goods.id,
|
||||
sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
number: res ? number:
|
||||
shopCartNumber.value,
|
||||
pro_group_info: returnSelectedGroupSnap(),
|
||||
goods_type: goods.type == 'package' ? 'package' : '',
|
||||
@@ -708,6 +770,27 @@
|
||||
})
|
||||
} else {
|
||||
let res = cartStore.carts.find(cart => cart.product_id == goods.id && goods.skuList[0].id)
|
||||
const number=await calculateValue(res?res.number:0, '+', shopCartNumber.value)
|
||||
console.log('number',number);
|
||||
if(res && number*1===2){
|
||||
const isConfirm = await showConfirmModal(
|
||||
'购物车已有该商品,请确认是否重复',
|
||||
'菜品名称:《' + goods.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (oldGoodsArr.find(v => v.productId == goods.id)) {
|
||||
// 等待用户点击
|
||||
const isConfirm = await showConfirmModal(
|
||||
'该商品已下单过,请确认是否重复',
|
||||
'菜品名称:《' + goods.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
emits('websocketsendMessage', {
|
||||
id: res ? res.id : '',
|
||||
type: 'shopping',
|
||||
@@ -717,7 +800,7 @@
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
product_id: goods.id,
|
||||
sku_id: goods.skuList[0].id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
number: res ? number:
|
||||
shopCartNumber.value,
|
||||
memberPrice: goods.memberPrice,
|
||||
is_print: 1,
|
||||
@@ -739,12 +822,38 @@
|
||||
1 : 0;
|
||||
}
|
||||
|
||||
function returnStockNumber(item) {
|
||||
if (!item.isAutoSoldStock) {
|
||||
return 9999
|
||||
}
|
||||
const consList = item.consList
|
||||
const matchStockList = props.consStockList.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)
|
||||
return {
|
||||
...v,
|
||||
goodsNumber
|
||||
}
|
||||
}).sort((a, b) => {
|
||||
return a.goodsNumber - b.goodsNumber
|
||||
})
|
||||
|
||||
const minConsStockNumber = matchStockList[0] ? matchStockList[0].goodsNumber : 9999
|
||||
return minConsStockNumber
|
||||
}
|
||||
|
||||
|
||||
// 多规格 套餐 单规格添加数量
|
||||
const shopCart = async (i) => {
|
||||
if (i == '-' && shopCartNumber.value <= (props.goods.suitNum || 1)) {
|
||||
shopCartNumber.value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
const stockNumber=returnStockNumber(props.goods)-(props.cartNumber||0)
|
||||
console.log('stockNumber',stockNumber);
|
||||
let res = null
|
||||
|
||||
if (i == '-') {
|
||||
@@ -760,15 +869,34 @@
|
||||
} else {
|
||||
|
||||
if (!res && shopCartNumber.value < 1) {
|
||||
|
||||
if (props.goods.type == 'sku') {
|
||||
if (!selSku.value) {
|
||||
return
|
||||
}
|
||||
if(stockNumber<selSku.value.suitNum){
|
||||
return uni.showToast({
|
||||
title:'商品库存不足!',
|
||||
icon:'error'
|
||||
})
|
||||
}
|
||||
shopCartNumber.value = parseFloat(selSku.value.suitNum);
|
||||
} else {
|
||||
if(stockNumber<props.goods.suitNum){
|
||||
return uni.showToast({
|
||||
title:'商品库存不足!',
|
||||
icon:'error'
|
||||
})
|
||||
}
|
||||
shopCartNumber.value = parseFloat(props.goods.suitNum);
|
||||
}
|
||||
} else {
|
||||
if(shopCartNumber.value>=stockNumber){
|
||||
return uni.showToast({
|
||||
title:'商品库存不足!',
|
||||
icon:'error'
|
||||
})
|
||||
}
|
||||
shopCartNumber.value++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,13 +58,11 @@
|
||||
限时折扣{{ limitDiscountCountdown }}</view>
|
||||
<!-- <view class="limitDiscount" v-if="item.is_time_discount">
|
||||
限时折扣{{ limitDiscountCountdown }}</view> -->
|
||||
<view class="stock_warning"
|
||||
v-if="item.isStock&&item.stockNumber<=10&&item.stockNumber>0">
|
||||
仅剩{{item.stockNumber}}份</view>
|
||||
<view class="stock_warning" v-if="showStockNumber(item)&& !showNoBuy(item)">
|
||||
仅剩{{returnStockNumber(item)}}份</view>
|
||||
</view>
|
||||
|
||||
<view class="vifgoodsImg flex-center"
|
||||
v-if="item.isSale == 0 || (item.isSaleTime == 0 && !item.isSaleTimeshow) || item.isSoldStock == 1 || (item.isStock == 1 && item.stockNumber <= 0)">
|
||||
<view class="vifgoodsImg flex-center" v-if="showNoBuy(item)">
|
||||
<image v-if="item.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
||||
style="width: 200rpx; height: 100%" mode=""></image>
|
||||
<image v-else-if="item.isSaleTime == 0 && !item.isSaleTimeshow"
|
||||
@@ -72,8 +70,8 @@
|
||||
</image>
|
||||
<image v-else-if="item.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
||||
style="width: 200rpx; height: 100%" mode=""></image>
|
||||
<image v-else-if="item.isStock == 1 && item.stockNumber <= 0"
|
||||
src="@/static/ztt/icon_goods_kcbz.svg" style="width: 200rpx; height: 100%" mode="">
|
||||
<image v-else src="@/static/ztt/icon_goods_kcbz.svg" style="width: 200rpx; height: 100%"
|
||||
mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-32 u-row-between">
|
||||
@@ -201,9 +199,7 @@
|
||||
style="width:600rpx;height: 188rpx;"></image>
|
||||
<view class="absolute swiper-mask" @click.stop="swiperClick(scope.item)">
|
||||
<view class="share-btn-box" v-if="showShare(scope.item)">
|
||||
<ymf-share
|
||||
@shareClick="shareBtnClick(scope.item)"
|
||||
>
|
||||
<ymf-share @shareClick="shareBtnClick(scope.item)">
|
||||
<view class="share-btn">分享</view>
|
||||
</ymf-share>
|
||||
</view>
|
||||
@@ -236,17 +232,11 @@
|
||||
|
||||
<!-- <view class="limitDiscount" v-if="item1.is_time_discount">
|
||||
限时折扣{{ limitDiscountCountdown }}</view> -->
|
||||
<view class="stock_warning"
|
||||
v-if="item1.isStock&&item1.stockNumber<=10&&item.stockNumber>0">
|
||||
仅剩{{item1.stockNumber}}份</view>
|
||||
<view class="stock_warning" v-if="showStockNumber(item1)&&!showNoBuy(item1)">
|
||||
仅剩{{returnStockNumber(item1)}}份</view>
|
||||
</view>
|
||||
|
||||
<view class="vifgoodsImg" v-if="
|
||||
item1.isSale == 0 ||
|
||||
(item1.isSaleTime == 0 && !item1.isSaleTimeshow) ||
|
||||
item1.isSoldStock == 1 ||
|
||||
(item1.isStock == 1 && item1.stockNumber <= 0)
|
||||
">
|
||||
<view class="vifgoodsImg" v-if="showNoBuy(item1)">
|
||||
<image v-if="item1.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
||||
style="width: 200rpx; height: 100%" mode=""></image>
|
||||
<image v-else-if="item1.isSaleTime == 0 && !item1.isSaleTimeshow"
|
||||
@@ -254,9 +244,8 @@
|
||||
mode=""></image>
|
||||
<image v-else-if="item1.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
||||
style="width: 200rpx; height: 100%" mode=""></image>
|
||||
<image v-else-if="item1.isStock == 1 && item1.stockNumber <= 0"
|
||||
src="@/static/ztt/icon_goods_kcbz.svg" style="width: 200rpx; height: 100%"
|
||||
mode=""></image>
|
||||
<image v-else src="@/static/ztt/icon_goods_kcbz.svg"
|
||||
style="width: 200rpx; height: 100%" mode=""></image>
|
||||
</view>
|
||||
|
||||
<view v-if="index == '0'" class="topSort" :class="'c' + (index1 + 1)">
|
||||
@@ -378,7 +367,7 @@
|
||||
<text class="allDiscountMoney" v-if="allDiscountMoney * 1 > 0">共减¥{{ allDiscountMoney }}</text>
|
||||
</view>
|
||||
<view class="btn" @tap="$u.debounce(orderdetail, 500)" v-if="orderType == 'scan'">
|
||||
<text class="t">结算</text>
|
||||
<text class="t">去下单</text>
|
||||
</view>
|
||||
<view class="btn" v-else>
|
||||
<u-button type="primary" shape="circle" plain @click="beforehandHandle">扫码下单</u-button>
|
||||
@@ -401,193 +390,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 规格 -->
|
||||
<up-popup :show="showShopsku" :round="20" mode="bottom" @close="(showShopsku = false), (pagemetashow = false)">
|
||||
<view class="shop_sku">
|
||||
<scroll-view scroll-y style="max-height: 60vh; width: 100%">
|
||||
<view class="positionabsolute">
|
||||
<up-icon name="close-circle" @click="
|
||||
showShopsku = false;
|
||||
pagemetashow = false;
|
||||
" color="#000" size="25"></up-icon>
|
||||
</view>
|
||||
<up-swiper :list="specifications.item.images" @change="swiperChange" :current="swiperCurrent"
|
||||
radius="6px" height="250"
|
||||
@click="prveImgs(specifications.item.images, specifications.item.images[swiperCurrent])">
|
||||
<!-- <template v-slot:default="{item}">
|
||||
<image :src=item></image>
|
||||
</templte> -->
|
||||
</up-swiper>
|
||||
|
||||
<view class="shop_sku_name">{{ specifications.item.name }}</view>
|
||||
<view class="shop_sku_description" v-if="isSkuGoods">
|
||||
{{ specifications.item.shortTitle ? specifications.item.shortTitle : '' }}
|
||||
</view>
|
||||
<view v-if="specifications.item.type != 'package'">
|
||||
<view class="shop_sku_box" v-for="(specOptions, specType) in specifications.item.selectSpecInfo"
|
||||
:key="specType">
|
||||
<view class="shop_sku_box_name">
|
||||
{{ specType }}
|
||||
</view>
|
||||
<view class="flex-start">
|
||||
<view class="shop_sku_box_item" v-for="option in specOptions" :key="option"
|
||||
@click="selectSpec(specType, option)" :class="{
|
||||
shop_sku_box_item_selected: isSkuSelected(specType, option)
|
||||
}">
|
||||
{{ option }}
|
||||
<view class="shop_sku_box_item_tip"
|
||||
v-if="specifications.item.result && specifications.item.result.isSoldStock == 1 && selectedSpecs[specType] === option">
|
||||
<view>售罄</view>
|
||||
</view>
|
||||
<view class="shop_sku_box_item_tip"
|
||||
v-if="specifications.item.result == 'kong' && canSubmit == false && selectedSpecs[specType] === option">
|
||||
<view>已下架</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 套餐 -->
|
||||
<view v-else>
|
||||
<view class="shop_sku_box">
|
||||
<view v-for="(setmenu, setmenuindex) in specifications.item.groupSnap" :key="setmenuindex">
|
||||
<view class="shop_sku_box_name">{{ setmenu.title }} {{ setmenu.count }}
|
||||
选{{ setmenu.number }}</view>
|
||||
<view class="flex-start">
|
||||
<view class="shop_sku_box_item" v-for="(option, goodsid) in setmenu.goods"
|
||||
:key="goodsid" @click="goodsidClick(setmenuindex, option, goodsid)" :class="{
|
||||
shop_sku_box_item_selected: isOptionSelected(setmenuindex, option)
|
||||
}" :disabled="isMaxSelected(setmenuindex) && !isOptionSelected(setmenuindex, option)">
|
||||
{{ option.proName }}
|
||||
<text v-if="option.unitName">/{{ option.unitName }}</text>
|
||||
<view class="shop_sku_box_item_tip" v-if="specifications.item.isSoldStock == 1">
|
||||
<view>售罄</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 推荐搭配 -->
|
||||
<view class="u-m-t-48 u-p-30">
|
||||
<view class="font-bold u-font-32 ">推荐搭配</view>
|
||||
<view class="u-flex recommand-goods">
|
||||
<view class=" item" v-for="(item,index) in 6" :key="index">
|
||||
<up-image width="210rpx" height="210rpx" radius="12rpx"></up-image>
|
||||
<view class="info">
|
||||
<view class="u-line-2 name u-m-t-10 u-font-32 font-500">
|
||||
商品名
|
||||
</view>
|
||||
|
||||
<view class="u-flex u-row-between">
|
||||
<view class="font-bold">
|
||||
<text class="u-font-24">¥</text>
|
||||
<text class="u-font-32">40</text>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</scroll-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="cartStore.limitTimeDiscount"
|
||||
:cart="specifications.item.result" :shopUserInfo="shopUserInfo"
|
||||
:shopInfo="shopInfo"></GoodsPrice>
|
||||
</view>
|
||||
|
||||
<text class="num" v-if="false">
|
||||
{{
|
||||
shopUserInfo.isVip == 1 && shopUserInfo.isMemberPrice == 1
|
||||
? specifications.item.result.memberPrice || specifications.item.result.salePrice
|
||||
: specifications.item.result.salePrice
|
||||
}}
|
||||
</text>
|
||||
<text class="i"
|
||||
v-if="specifications.item.unitName">/{{ specifications.item.unitName }}</text>
|
||||
<text
|
||||
v-if="specifications.item.result.suitNum > 1">「{{ specifications.item.result.suitNum }}{{ specifications.item.result.unitName }}起点」</text>
|
||||
</view>
|
||||
<view class="price price-package" v-else>
|
||||
<text class="i">¥</text>
|
||||
<view class="num">
|
||||
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="specifications.item"
|
||||
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
|
||||
</view>
|
||||
<text class="num" v-if="false">
|
||||
{{
|
||||
shopUserInfo.isVip == 1 && shopUserInfo.isMemberPrice == 1
|
||||
? specifications.item.memberPrice || specifications.item.salePrice
|
||||
: specifications.item.salePrice
|
||||
}}
|
||||
</text>
|
||||
<text class="i"
|
||||
v-if="specifications.item.unitName">/{{ specifications.item.unitName }}</text>
|
||||
<text
|
||||
v-if="specifications.item.suitNum > 1">「{{ specifications.item.suitNum }}{{ specifications.item.unitName }}起点」</text>
|
||||
</view>
|
||||
|
||||
<view class="operation-wrap"
|
||||
v-if="specifications.item.type != 'package'&&stockNumberIsFull(specifications.item)">
|
||||
<view class="btn">
|
||||
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
|
||||
v-if="shopCartNumber > 0"></up-icon>
|
||||
<view class="btnClick" @click="shopCart('-')"></view>
|
||||
</view>
|
||||
<text class="num">{{ shopCartNumber }}</text>
|
||||
<view class="btn">
|
||||
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
|
||||
<view class="btnClick" @click="shopCart('+')"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shop_skuselect flex-start" v-if="selectedSpecsStr">
|
||||
<view class="shop_skuselectname">{{ selectedSpecsStr }}</view>
|
||||
</view>
|
||||
<template v-if="!stockNumberIsFull(specifications.item)">
|
||||
<view class="addShopping">
|
||||
库存不足
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-if="isSkuGoods">
|
||||
<view v-if="specifications.item.type == 'package'" class="addShopping"
|
||||
:class="shopCartNumber > 0 && allConditionsSatisfied ? 'active' : ''"
|
||||
@click="submitSelection()">
|
||||
{{ skuBtnText }}
|
||||
</view>
|
||||
<view v-else class="addShopping" :class="shopCartNumber > 0 && canSubmit ? 'active' : ''"
|
||||
@click="submitSelection()">
|
||||
{{ skuBtnText }}
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view class="addShopping" :class="shopCartNumber > 0 ? 'active' : ''"
|
||||
@click="submitSelection()">
|
||||
{{ skuBtnText }}
|
||||
</view>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</up-popup>
|
||||
<view class="history_order" @click="toHistory"
|
||||
v-if="shopInfo && shopInfo.registerType == 'after' && orderinfo.id">
|
||||
<image class="img" src="@/static/history.png" mode=""></image>
|
||||
@@ -598,7 +401,9 @@
|
||||
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
|
||||
|
||||
<view v-for="(item,index) in goodsModalList" :key="index">
|
||||
<goodsModal :key="index" v-model="item.show" :goods="item.goods" @prveImgs="prveImgs"
|
||||
<goodsModal :key="index" v-model="item.show" :goods="item.goods" @prveImgs="prveImgs" :orderinfo="orderinfo"
|
||||
:cartNumber="returnGoodsImCartNum(item.goods)"
|
||||
:consStockList="consStockList"
|
||||
@shareClick="shareClick" @close="goodsModalClose(index)" @websocketsendMessage="websocketsendMessage"
|
||||
@modalAdd="modalAdd" :GoodsIDInCartNumMap="GoodsIDInCartNumMap"></goodsModal>
|
||||
</view>
|
||||
@@ -663,6 +468,7 @@
|
||||
APIgroupquery,
|
||||
APIminiAppinfo,
|
||||
APIminiAppskuinfo,
|
||||
getConsStock,
|
||||
productRelated
|
||||
} from '@/common/api/product/product.js';
|
||||
|
||||
@@ -758,6 +564,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)<sku.suitNum){
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (returnStockNumber(item) <= 0) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const storeMemberpay = Memberpay();
|
||||
const store = useNavbarStore();
|
||||
// 动态更新导航栏配置
|
||||
@@ -1031,6 +863,7 @@
|
||||
/*商品区域轮播图 start*/
|
||||
|
||||
const shareSwiperItem = ref(null)
|
||||
|
||||
function swiperClick(item) {
|
||||
console.log('swiperClick', item);
|
||||
shareSwiperItem.value = item
|
||||
@@ -1091,6 +924,7 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function showShare(item) {
|
||||
if (item.isShareable && item.isEnabled) {
|
||||
return true
|
||||
@@ -1098,8 +932,6 @@
|
||||
return false
|
||||
}
|
||||
/*商品区域轮播图 end*/
|
||||
// 点击详情
|
||||
const showShopsku = ref(false);
|
||||
|
||||
// 规格信息
|
||||
const specifications = reactive({
|
||||
@@ -1368,6 +1200,7 @@
|
||||
|
||||
// 提交选择并执行下一步操作的方法
|
||||
const submitSelection = async () => {
|
||||
console.log('submitSelection', submitSelection)
|
||||
if (!isProductAvailable(specifications.productListitem.days, specifications.productListitem.startTime,
|
||||
specifications.productListitem.endTime)) {
|
||||
uni.showToast({
|
||||
@@ -1392,6 +1225,33 @@
|
||||
selectedGroupSnap.value = [];
|
||||
}
|
||||
console.log('specifications.item', specifications.item);
|
||||
const number = await calculateValue(res.cartNumber, '+', shopCartNumber.value)
|
||||
|
||||
const oldGoodsArr = combineOrderInfoDetailMap(orderinfo.value)
|
||||
if (oldGoodsArr.find(v => v.productId == specifications.item.id)) {
|
||||
// 等待用户点击
|
||||
const isConfirm = await showConfirmModal(
|
||||
'该商品已下单过,请确认是否重复',
|
||||
'菜品名称:《' + specifications.item.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (res && number * 1 === 2) {
|
||||
const isConfirm = await showConfirmModal(
|
||||
'购物车已有该商品,请确认是否重复',
|
||||
'菜品名称:《' + specifications.item.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
@@ -1401,8 +1261,7 @@
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
product_id: specifications.product_id,
|
||||
sku_id: specifications.sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
shopCartNumber.value,
|
||||
number: res ? number : shopCartNumber.value,
|
||||
pro_group_info: selectedGroupSnap.value,
|
||||
goods_type: specifications.item.type == 'package' ? 'package' : '',
|
||||
memberPrice: specifications.item.memberPrice,
|
||||
@@ -1412,8 +1271,31 @@
|
||||
});
|
||||
// 清空套餐选中
|
||||
selectedGroupSnap.value = [];
|
||||
showShopsku.value = false;
|
||||
} else {
|
||||
const number = await calculateValue(res.cartNumber, '+', shopCartNumber.value)
|
||||
const oldGoodsArr = combineOrderInfoDetailMap(orderinfo.value)
|
||||
if (oldGoodsArr.find(v => v.productId == specifications.item.id)) {
|
||||
// 等待用户点击
|
||||
const isConfirm = await showConfirmModal(
|
||||
'该商品已下单过,请确认是否重复',
|
||||
'菜品名称:《' + specifications.item.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (res && number * 1 === 2) {
|
||||
const isConfirm = await showConfirmModal(
|
||||
'购物车已有该商品,请确认是否重复',
|
||||
'菜品名称:《' + specifications.item.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
websocketsendMessage({
|
||||
id: res ? res.cartListId : '',
|
||||
type: 'shopping',
|
||||
@@ -1423,14 +1305,12 @@
|
||||
operate_type: res ? 'edit' : 'add',
|
||||
product_id: specifications.product_id,
|
||||
sku_id: specifications.sku_id,
|
||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
||||
shopCartNumber.value,
|
||||
number: res ? number : shopCartNumber.value,
|
||||
memberPrice: specifications.item.memberPrice,
|
||||
is_print: 1,
|
||||
product_type: specifications.item.type,
|
||||
is_time_discount: showLimitDiscount(specifications.item)
|
||||
});
|
||||
showShopsku.value = false;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1545,7 +1425,6 @@
|
||||
.filter(([_, value]) => value.length > 0));
|
||||
// 给默认数量
|
||||
specifications.item.amountcartNumber = 0;
|
||||
// showShopsku.value = true;
|
||||
goodsModalList.value.push({
|
||||
show: true,
|
||||
goods: {
|
||||
@@ -1623,6 +1502,23 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 封装成 Promise 的确认弹窗
|
||||
const showConfirmModal = (title, content) => {
|
||||
return new Promise((resolve) => {
|
||||
uni.showModal({
|
||||
title: title,
|
||||
content: content,
|
||||
showCancel: true,
|
||||
cancelText: '取消添加',
|
||||
confirmText: '继续',
|
||||
success(res) {
|
||||
// 确认返回 true,取消/关闭返回 false
|
||||
resolve(res.confirm === true);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
// 单规格
|
||||
const singleclick = async (item, i) => {
|
||||
console.log('单规格商品点击事件:', item, i);
|
||||
@@ -1650,17 +1546,53 @@
|
||||
} else if (item.suitNum >= cartNumberFloat && i === '-') {
|
||||
suitNum = item.cartNumber;
|
||||
}
|
||||
|
||||
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)) {
|
||||
// 等待用户点击
|
||||
const isConfirm = await showConfirmModal(
|
||||
'该商品已下单过,请确认是否重复',
|
||||
'菜品名称:《' + item.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (number * 1 == 2) {
|
||||
const isConfirm = await showConfirmModal(
|
||||
'购物车已有该商品,请确认是否重复',
|
||||
'菜品名称:《' + item.name + '》'
|
||||
);
|
||||
if (!isConfirm) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const sendMsg = {
|
||||
type: 'shopping',
|
||||
suitNum: item.suitNum,
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
operate_type: (await calculateValue(item.cartNumber, i, suitNum)) == 'del' ? 'del' : res ? 'edit' :
|
||||
'add',
|
||||
operate_type: number == 'del' ? 'del' : res ? 'edit' : 'add',
|
||||
product_id: item.id,
|
||||
sku_id: item.skuId,
|
||||
memberPrice: item.memberPrice,
|
||||
number: await calculateValue(item.cartNumber, i, suitNum),
|
||||
number: number,
|
||||
is_print: 1,
|
||||
product_type: item.type,
|
||||
is_time_discount: showLimitDiscount(item)
|
||||
@@ -2094,6 +2026,7 @@
|
||||
const orderinfo = ref({});
|
||||
const confirmorderref = ref(null);
|
||||
|
||||
|
||||
// 结账
|
||||
const orderdetail = async () => {
|
||||
isAutoClose = false;
|
||||
@@ -2567,7 +2500,8 @@
|
||||
handleMixinOnLoad,
|
||||
returnQuery,
|
||||
jsonToUrl,
|
||||
wxShare,returnPageTags,
|
||||
wxShare,
|
||||
returnPageTags,
|
||||
returnCommonQuery
|
||||
} from '@/utils/share.js'
|
||||
// defineOptions({
|
||||
@@ -2584,17 +2518,20 @@
|
||||
function getPage(pageStr) {
|
||||
|
||||
}
|
||||
|
||||
function shareBtnClick(item) {
|
||||
console.log('shareBtnClick', item);
|
||||
shareSwiperItem.value = item
|
||||
}
|
||||
|
||||
function swiperShare(queryJson) {
|
||||
console.log('shareSwiperItem', shareSwiperItem.value);
|
||||
const pTag = returnPageTags(shareSwiperItem.value.jumpPagePath)
|
||||
let query = jsonToUrl(queryJson)
|
||||
query += ('&' + shareSwiperItem.value.extendParam)
|
||||
const shopName = uni.cache.get('shopInfo').shopName || ''
|
||||
const path=shareSwiperItem.value.jumpPagePath?shareSwiperItem.value.jumpPagePath:'/pages/product/index?type=beforehand'
|
||||
const path = shareSwiperItem.value.jumpPagePath ? shareSwiperItem.value.jumpPagePath :
|
||||
'/pages/product/index?type=beforehand'
|
||||
console.log('path', path);
|
||||
const json = {
|
||||
imageUrl: shareSwiperItem.value.imageUrl,
|
||||
@@ -2653,6 +2590,42 @@
|
||||
const pageOptions = reactive({})
|
||||
|
||||
const carouselList = ref([])
|
||||
|
||||
async function getConsStocks() {
|
||||
const res = await getConsStock({
|
||||
shopId: userStore.shopInfo.id
|
||||
})
|
||||
consStockList.value = res || []
|
||||
}
|
||||
const consStockList = ref([])
|
||||
|
||||
|
||||
// 是否显示剩余库存数量
|
||||
function showStockNumber(item) {
|
||||
return !item.isSoldStock && returnStockNumber(item) <= 10 && returnStockNumber(item) > 0
|
||||
}
|
||||
|
||||
function returnStockNumber(item) {
|
||||
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)
|
||||
return {
|
||||
...v,
|
||||
goodsNumber
|
||||
}
|
||||
}).sort((a, b) => {
|
||||
return a.goodsNumber - b.goodsNumber
|
||||
})
|
||||
|
||||
const minConsStockNumber = matchStockList[0] ? matchStockList[0].goodsNumber : 9999
|
||||
return minConsStockNumber
|
||||
}
|
||||
onLoad(async (e) => {
|
||||
Object.assign(pageOptions, e)
|
||||
if (e.type) {
|
||||
@@ -2822,6 +2795,9 @@
|
||||
// if(!topArr.value.length){
|
||||
// getElementTop()
|
||||
// }
|
||||
|
||||
//耗材列表
|
||||
await getConsStocks()
|
||||
});
|
||||
|
||||
//是否自动关闭socket
|
||||
@@ -4090,6 +4066,7 @@
|
||||
right: 8rpx;
|
||||
bottom: 14rpx;
|
||||
}
|
||||
|
||||
.share-btn {
|
||||
|
||||
padding: 10rpx 32rpx;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
<view class="right-icons">
|
||||
<image class="my_info_right_qr" src="/static/icon/code.png" mode="aspectFill"></image>
|
||||
<!-- <image class="my_info_right_qr" src="/static/icon/code.png" mode="aspectFill"></image> -->
|
||||
<view class="msg-view" @click="viewUserMsgList">
|
||||
<view class="msg-icon-wrapper">
|
||||
<image v-if="unreadMsgCount > 0" class="my-msg-icon" src="/static/mine/msg_select.png" mode="aspectFill"></image>
|
||||
|
||||
Reference in New Issue
Block a user