修改库存回显计算,增加多次加菜弹窗确认
This commit is contained in:
@@ -54,4 +54,14 @@ export const productRelated = (data) => {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取相关推荐商品
|
||||||
|
export const getConsStock = (data) => {
|
||||||
|
return request({
|
||||||
|
url: urlProduct + '/user/product/consStock',
|
||||||
|
method: 'get',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
||||||
// const debug = false; // false线上 true本地
|
// const debug = false; // false线上 true本地
|
||||||
const debug = false; // false线上 true本地
|
const debug = true; // false线上 true本地
|
||||||
let baseUrl = ''
|
let baseUrl = ''
|
||||||
let baseUrlwws = ''
|
let baseUrlwws = ''
|
||||||
|
|
||||||
|
|||||||
@@ -647,7 +647,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) => {
|
const submitSelection = async (goods) => {
|
||||||
if (!isProductAvailable(goods.days, goods.startTime,
|
if (!isProductAvailable(goods.days, goods.startTime,
|
||||||
@@ -664,7 +691,7 @@
|
|||||||
if (goods.type == 'package' && goods.groupType != 0 && !allConditionsSatisfied.value) {
|
if (goods.type == 'package' && goods.groupType != 0 && !allConditionsSatisfied.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const oldGoodsArr = combineOrderInfoDetailMap(props.orderinfo)
|
||||||
if ((goods.type == 'package' && allConditionsSatisfied.value) || (goods.type ==
|
if ((goods.type == 'package' && allConditionsSatisfied.value) || (goods.type ==
|
||||||
'sku' && canSubmit.value)) {
|
'sku' && canSubmit.value)) {
|
||||||
let res = null;
|
let res = null;
|
||||||
@@ -688,6 +715,30 @@
|
|||||||
sku_id = selSku.value.id
|
sku_id = selSku.value.id
|
||||||
}
|
}
|
||||||
console.log('goods', goods);
|
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', {
|
emits('websocketsendMessage', {
|
||||||
id: res ? res.id : '',
|
id: res ? res.id : '',
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
@@ -697,7 +748,7 @@
|
|||||||
operate_type: res ? 'edit' : 'add',
|
operate_type: res ? 'edit' : 'add',
|
||||||
product_id: goods.id,
|
product_id: goods.id,
|
||||||
sku_id,
|
sku_id,
|
||||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
number: res ? number:
|
||||||
shopCartNumber.value,
|
shopCartNumber.value,
|
||||||
pro_group_info: returnSelectedGroupSnap(),
|
pro_group_info: returnSelectedGroupSnap(),
|
||||||
goods_type: goods.type == 'package' ? 'package' : '',
|
goods_type: goods.type == 'package' ? 'package' : '',
|
||||||
@@ -708,6 +759,27 @@
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let res = cartStore.carts.find(cart => cart.product_id == goods.id && goods.skuList[0].id)
|
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', {
|
emits('websocketsendMessage', {
|
||||||
id: res ? res.id : '',
|
id: res ? res.id : '',
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
@@ -717,7 +789,7 @@
|
|||||||
operate_type: res ? 'edit' : 'add',
|
operate_type: res ? 'edit' : 'add',
|
||||||
product_id: goods.id,
|
product_id: goods.id,
|
||||||
sku_id: goods.skuList[0].id,
|
sku_id: goods.skuList[0].id,
|
||||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
number: res ? number:
|
||||||
shopCartNumber.value,
|
shopCartNumber.value,
|
||||||
memberPrice: goods.memberPrice,
|
memberPrice: goods.memberPrice,
|
||||||
is_print: 1,
|
is_print: 1,
|
||||||
|
|||||||
@@ -58,13 +58,12 @@
|
|||||||
限时折扣{{ 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"
|
<view class="stock_warning" v-if="returnStockNumber(item)<=10&&returnStockNumber(item)>0">
|
||||||
v-if="item.isStock&&item.stockNumber<=10&&item.stockNumber>0">
|
仅剩{{returnStockNumber(item)}}份</view>
|
||||||
仅剩{{item.stockNumber}}份</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="vifgoodsImg flex-center"
|
<view class="vifgoodsImg flex-center"
|
||||||
v-if="item.isSale == 0 || (item.isSaleTime == 0 && !item.isSaleTimeshow) || item.isSoldStock == 1 || (item.isStock == 1 && item.stockNumber <= 0)">
|
v-if="item.isSale == 0 || (item.isSaleTime == 0 && !item.isSaleTimeshow) || item.isSoldStock == 1 || returnStockNumber(item)<=0">
|
||||||
<image v-if="item.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
<image v-if="item.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
||||||
style="width: 200rpx; height: 100%" mode=""></image>
|
style="width: 200rpx; height: 100%" mode=""></image>
|
||||||
<image v-else-if="item.isSaleTime == 0 && !item.isSaleTimeshow"
|
<image v-else-if="item.isSaleTime == 0 && !item.isSaleTimeshow"
|
||||||
@@ -72,8 +71,8 @@
|
|||||||
</image>
|
</image>
|
||||||
<image v-else-if="item.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
<image v-else-if="item.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
||||||
style="width: 200rpx; height: 100%" mode=""></image>
|
style="width: 200rpx; height: 100%" mode=""></image>
|
||||||
<image v-else-if="item.isStock == 1 && item.stockNumber <= 0"
|
<image v-else src="@/static/ztt/icon_goods_kcbz.svg" style="width: 200rpx; height: 100%"
|
||||||
src="@/static/ztt/icon_goods_kcbz.svg" style="width: 200rpx; height: 100%" mode="">
|
mode="">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex u-m-t-32 u-row-between">
|
<view class="u-flex u-m-t-32 u-row-between">
|
||||||
@@ -201,13 +200,11 @@
|
|||||||
style="width:600rpx;height: 188rpx;"></image>
|
style="width:600rpx;height: 188rpx;"></image>
|
||||||
<view class="absolute swiper-mask" @click.stop="swiperClick(scope.item)">
|
<view class="absolute swiper-mask" @click.stop="swiperClick(scope.item)">
|
||||||
<view class="share-btn-box" v-if="showShare(scope.item)">
|
<view class="share-btn-box" v-if="showShare(scope.item)">
|
||||||
<ymf-share
|
<ymf-share @shareClick="shareBtnClick(scope.item)">
|
||||||
@shareClick="shareBtnClick(scope.item)"
|
|
||||||
>
|
|
||||||
<view class="share-btn">分享</view>
|
<view class="share-btn">分享</view>
|
||||||
</ymf-share>
|
</ymf-share>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -236,16 +233,15 @@
|
|||||||
|
|
||||||
<!-- <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"
|
<view class="stock_warning" v-if="returnStockNumber(item1)<=10&&returnStockNumber(item1)>0">
|
||||||
v-if="item1.isStock&&item1.stockNumber<=10&&item.stockNumber>0">
|
仅剩{{returnStockNumber(item1)}}份</view>
|
||||||
仅剩{{item1.stockNumber}}份</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="vifgoodsImg" v-if="
|
<view class="vifgoodsImg" v-if="
|
||||||
item1.isSale == 0 ||
|
item1.isSale == 0 ||
|
||||||
(item1.isSaleTime == 0 && !item1.isSaleTimeshow) ||
|
(item1.isSaleTime == 0 && !item1.isSaleTimeshow) ||
|
||||||
item1.isSoldStock == 1 ||
|
item1.isSoldStock == 1 ||
|
||||||
(item1.isStock == 1 && item1.stockNumber <= 0)
|
(returnStockNumber(item1)<=0)
|
||||||
">
|
">
|
||||||
<image v-if="item1.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
<image v-if="item1.isSale == 0" src="@/static/ztt/icon_goods_yxj.svg"
|
||||||
style="width: 200rpx; height: 100%" mode=""></image>
|
style="width: 200rpx; height: 100%" mode=""></image>
|
||||||
@@ -254,9 +250,8 @@
|
|||||||
mode=""></image>
|
mode=""></image>
|
||||||
<image v-else-if="item1.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
<image v-else-if="item1.isSoldStock == 1" src="@/static/ztt/icon_goods_sq.svg"
|
||||||
style="width: 200rpx; height: 100%" mode=""></image>
|
style="width: 200rpx; height: 100%" mode=""></image>
|
||||||
<image v-else-if="item1.isStock == 1 && item1.stockNumber <= 0"
|
<image v-else src="@/static/ztt/icon_goods_kcbz.svg"
|
||||||
src="@/static/ztt/icon_goods_kcbz.svg" style="width: 200rpx; height: 100%"
|
style="width: 200rpx; height: 100%" mode=""></image>
|
||||||
mode=""></image>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="index == '0'" class="topSort" :class="'c' + (index1 + 1)">
|
<view v-if="index == '0'" class="topSort" :class="'c' + (index1 + 1)">
|
||||||
@@ -598,7 +593,7 @@
|
|||||||
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
|
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
|
||||||
|
|
||||||
<view v-for="(item,index) in goodsModalList" :key="index">
|
<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"
|
||||||
@shareClick="shareClick" @close="goodsModalClose(index)" @websocketsendMessage="websocketsendMessage"
|
@shareClick="shareClick" @close="goodsModalClose(index)" @websocketsendMessage="websocketsendMessage"
|
||||||
@modalAdd="modalAdd" :GoodsIDInCartNumMap="GoodsIDInCartNumMap"></goodsModal>
|
@modalAdd="modalAdd" :GoodsIDInCartNumMap="GoodsIDInCartNumMap"></goodsModal>
|
||||||
</view>
|
</view>
|
||||||
@@ -640,7 +635,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
|
|
||||||
<ymf-share-popup ></ymf-share-popup>
|
<ymf-share-popup></ymf-share-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -663,6 +658,7 @@
|
|||||||
APIgroupquery,
|
APIgroupquery,
|
||||||
APIminiAppinfo,
|
APIminiAppinfo,
|
||||||
APIminiAppskuinfo,
|
APIminiAppskuinfo,
|
||||||
|
getConsStock,
|
||||||
productRelated
|
productRelated
|
||||||
} from '@/common/api/product/product.js';
|
} from '@/common/api/product/product.js';
|
||||||
|
|
||||||
@@ -934,9 +930,9 @@
|
|||||||
|
|
||||||
//左侧导航点击
|
//左侧导航点击
|
||||||
const leftTap = (index) => {
|
const leftTap = (index) => {
|
||||||
console.log('topArr.value[index] ',topArr.value[index] );
|
console.log('topArr.value[index] ', topArr.value[index]);
|
||||||
console.log('store.height',store.height);
|
console.log('store.height', store.height);
|
||||||
console.log('scrollTop',topArr.value[index] - store.height);
|
console.log('scrollTop', topArr.value[index] - store.height);
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: topArr.value[index] - store.height,
|
scrollTop: topArr.value[index] - store.height,
|
||||||
duration: 0
|
duration: 0
|
||||||
@@ -1029,70 +1025,72 @@
|
|||||||
|
|
||||||
|
|
||||||
/*商品区域轮播图 start*/
|
/*商品区域轮播图 start*/
|
||||||
|
|
||||||
const shareSwiperItem=ref(null)
|
const shareSwiperItem = ref(null)
|
||||||
|
|
||||||
function swiperClick(item) {
|
function swiperClick(item) {
|
||||||
console.log('swiperClick',item);
|
console.log('swiperClick', item);
|
||||||
shareSwiperItem.value=item
|
shareSwiperItem.value = item
|
||||||
const pTag=returnPageTags(item.jumpPagePath)
|
const pTag = returnPageTags(item.jumpPagePath)
|
||||||
|
|
||||||
if(pTag==='pp-list'){
|
if (pTag === 'pp-list') {
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:item.jumpPagePath+'&shopId='+uni.cache.get('shopId')
|
url: item.jumpPagePath + '&shopId=' + uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(pTag==='pp-detail'){
|
if (pTag === 'pp-detail') {
|
||||||
const url=item.jumpPagePath+'&shopId='+uni.cache.get('shopId')+'&'+item.extendParam
|
const url = item.jumpPagePath + '&shopId=' + uni.cache.get('shopId') + '&' + item.extendParam
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:url.replace('goodsId','id')
|
url: url.replace('goodsId', 'id')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(pTag==='gb-list'){
|
if (pTag === 'gb-list') {
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:item.jumpPagePath+'&shopId='+uni.cache.get('shopId')
|
url: item.jumpPagePath + '&shopId=' + uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(pTag==='gb-detail'){
|
if (pTag === 'gb-detail') {
|
||||||
const url=item.jumpPagePath+'&shopId='+uni.cache.get('shopId')+'&'+item.extendParam
|
const url = item.jumpPagePath + '&shopId=' + uni.cache.get('shopId') + '&' + item.extendParam
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:url.replace('goodsId','wareId')
|
url: url.replace('goodsId', 'wareId')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(pTag==='dis'){
|
if (pTag === 'dis') {
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:item.jumpPagePath+'&shopId='+uni.cache.get('shopId')
|
url: item.jumpPagePath + '&shopId=' + uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(pTag==='index'){
|
if (pTag === 'index') {
|
||||||
return uni.switchTab({
|
return uni.switchTab({
|
||||||
url:item.jumpPagePath+'&shopId='+uni.cache.get('shopId')
|
url: item.jumpPagePath + '&shopId=' + uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pTag==='eat'){
|
if (pTag === 'eat') {
|
||||||
if (item.extendParam) {
|
if (item.extendParam) {
|
||||||
const id=item.extendParam.split('=')[1]
|
const id = item.extendParam.split('=')[1]
|
||||||
const item = allGoodsArr.value.find(v => v.id == id)
|
const item = allGoodsArr.value.find(v => v.id == id)
|
||||||
if (item) {
|
if (item) {
|
||||||
clickspecifications(item)
|
clickspecifications(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pTag==='point'){
|
if (pTag === 'point') {
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:item.jumpPagePath+'&shopId='+uni.cache.get('shopId')
|
url: item.jumpPagePath + '&shopId=' + uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(pTag==='point-detail'){
|
if (pTag === 'point-detail') {
|
||||||
const url=item.jumpPagePath+'&shopId='+uni.cache.get('shopId')+'&'+item.extendParam
|
const url = item.jumpPagePath + '&shopId=' + uni.cache.get('shopId') + '&' + item.extendParam
|
||||||
return uni.navigateTo({
|
return uni.navigateTo({
|
||||||
url:url.replace('goodsId','id')
|
url: url.replace('goodsId', 'id')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showShare(item){
|
|
||||||
if(item.isShareable&&item.isEnabled){
|
function showShare(item) {
|
||||||
|
if (item.isShareable && item.isEnabled) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@@ -1368,6 +1366,7 @@
|
|||||||
|
|
||||||
// 提交选择并执行下一步操作的方法
|
// 提交选择并执行下一步操作的方法
|
||||||
const submitSelection = async () => {
|
const submitSelection = async () => {
|
||||||
|
console.log('submitSelection', submitSelection)
|
||||||
if (!isProductAvailable(specifications.productListitem.days, specifications.productListitem.startTime,
|
if (!isProductAvailable(specifications.productListitem.days, specifications.productListitem.startTime,
|
||||||
specifications.productListitem.endTime)) {
|
specifications.productListitem.endTime)) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@@ -1392,6 +1391,33 @@
|
|||||||
selectedGroupSnap.value = [];
|
selectedGroupSnap.value = [];
|
||||||
}
|
}
|
||||||
console.log('specifications.item', specifications.item);
|
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({
|
websocketsendMessage({
|
||||||
id: res ? res.cartListId : '',
|
id: res ? res.cartListId : '',
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
@@ -1401,8 +1427,7 @@
|
|||||||
operate_type: res ? 'edit' : 'add',
|
operate_type: res ? 'edit' : 'add',
|
||||||
product_id: specifications.product_id,
|
product_id: specifications.product_id,
|
||||||
sku_id: specifications.sku_id,
|
sku_id: specifications.sku_id,
|
||||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
number: res ? number : shopCartNumber.value,
|
||||||
shopCartNumber.value,
|
|
||||||
pro_group_info: selectedGroupSnap.value,
|
pro_group_info: selectedGroupSnap.value,
|
||||||
goods_type: specifications.item.type == 'package' ? 'package' : '',
|
goods_type: specifications.item.type == 'package' ? 'package' : '',
|
||||||
memberPrice: specifications.item.memberPrice,
|
memberPrice: specifications.item.memberPrice,
|
||||||
@@ -1414,6 +1439,30 @@
|
|||||||
selectedGroupSnap.value = [];
|
selectedGroupSnap.value = [];
|
||||||
showShopsku.value = false;
|
showShopsku.value = false;
|
||||||
} else {
|
} 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({
|
websocketsendMessage({
|
||||||
id: res ? res.cartListId : '',
|
id: res ? res.cartListId : '',
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
@@ -1423,8 +1472,7 @@
|
|||||||
operate_type: res ? 'edit' : 'add',
|
operate_type: res ? 'edit' : 'add',
|
||||||
product_id: specifications.product_id,
|
product_id: specifications.product_id,
|
||||||
sku_id: specifications.sku_id,
|
sku_id: specifications.sku_id,
|
||||||
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
|
number: res ? number : shopCartNumber.value,
|
||||||
shopCartNumber.value,
|
|
||||||
memberPrice: specifications.item.memberPrice,
|
memberPrice: specifications.item.memberPrice,
|
||||||
is_print: 1,
|
is_print: 1,
|
||||||
product_type: specifications.item.type,
|
product_type: specifications.item.type,
|
||||||
@@ -1558,7 +1606,7 @@
|
|||||||
};
|
};
|
||||||
// 判断商品是否在可售时间内
|
// 判断商品是否在可售时间内
|
||||||
const isProductAvailable = async (sellDaysStr, startTimeStr, endTimeStr) => {
|
const isProductAvailable = async (sellDaysStr, startTimeStr, endTimeStr) => {
|
||||||
if(!sellDaysStr){
|
if (!sellDaysStr) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 将后端返回的字符串转换为数组
|
// 将后端返回的字符串转换为数组
|
||||||
@@ -1623,6 +1671,23 @@
|
|||||||
return true;
|
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) => {
|
const singleclick = async (item, i) => {
|
||||||
console.log('单规格商品点击事件:', item, i);
|
console.log('单规格商品点击事件:', item, i);
|
||||||
@@ -1650,17 +1715,45 @@
|
|||||||
} else if (item.suitNum >= cartNumberFloat && i === '-') {
|
} else if (item.suitNum >= cartNumberFloat && i === '-') {
|
||||||
suitNum = item.cartNumber;
|
suitNum = item.cartNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const number = await calculateValue(item.cartNumber, i, suitNum)
|
||||||
|
console.log('number', number);
|
||||||
|
if (i === '+') {
|
||||||
|
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 = {
|
const sendMsg = {
|
||||||
type: 'shopping',
|
type: 'shopping',
|
||||||
suitNum: item.suitNum,
|
suitNum: item.suitNum,
|
||||||
table_code: uni.cache.get('tableCode'),
|
table_code: uni.cache.get('tableCode'),
|
||||||
shop_id: uni.cache.get('shopId'),
|
shop_id: uni.cache.get('shopId'),
|
||||||
operate_type: (await calculateValue(item.cartNumber, i, suitNum)) == 'del' ? 'del' : res ? 'edit' :
|
operate_type: number == 'del' ? 'del' : res ? 'edit' : 'add',
|
||||||
'add',
|
|
||||||
product_id: item.id,
|
product_id: item.id,
|
||||||
sku_id: item.skuId,
|
sku_id: item.skuId,
|
||||||
memberPrice: item.memberPrice,
|
memberPrice: item.memberPrice,
|
||||||
number: await calculateValue(item.cartNumber, i, suitNum),
|
number: number,
|
||||||
is_print: 1,
|
is_print: 1,
|
||||||
product_type: item.type,
|
product_type: item.type,
|
||||||
is_time_discount: showLimitDiscount(item)
|
is_time_discount: showLimitDiscount(item)
|
||||||
@@ -2094,6 +2187,7 @@
|
|||||||
const orderinfo = ref({});
|
const orderinfo = ref({});
|
||||||
const confirmorderref = ref(null);
|
const confirmorderref = ref(null);
|
||||||
|
|
||||||
|
|
||||||
// 结账
|
// 结账
|
||||||
const orderdetail = async () => {
|
const orderdetail = async () => {
|
||||||
isAutoClose = false;
|
isAutoClose = false;
|
||||||
@@ -2509,7 +2603,7 @@
|
|||||||
|
|
||||||
console.log('options.initMessage', options.initMessage)
|
console.log('options.initMessage', options.initMessage)
|
||||||
const newTableCode = userStore.getQueryString(res.result, 'code');
|
const newTableCode = userStore.getQueryString(res.result, 'code');
|
||||||
console.log('newTableCode',newTableCode);
|
console.log('newTableCode', newTableCode);
|
||||||
const shopInfoRes = await APIproductqueryShop({
|
const shopInfoRes = await APIproductqueryShop({
|
||||||
tableCode: newTableCode
|
tableCode: newTableCode
|
||||||
});
|
});
|
||||||
@@ -2567,7 +2661,8 @@
|
|||||||
handleMixinOnLoad,
|
handleMixinOnLoad,
|
||||||
returnQuery,
|
returnQuery,
|
||||||
jsonToUrl,
|
jsonToUrl,
|
||||||
wxShare,returnPageTags,
|
wxShare,
|
||||||
|
returnPageTags,
|
||||||
returnCommonQuery
|
returnCommonQuery
|
||||||
} from '@/utils/share.js'
|
} from '@/utils/share.js'
|
||||||
// defineOptions({
|
// defineOptions({
|
||||||
@@ -2580,39 +2675,42 @@
|
|||||||
function shareClick() {
|
function shareClick() {
|
||||||
isGoodsShare.value = true
|
isGoodsShare.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPage(pageStr){
|
function getPage(pageStr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
function shareBtnClick(item){
|
|
||||||
console.log('shareBtnClick',item);
|
function shareBtnClick(item) {
|
||||||
shareSwiperItem.value=item
|
console.log('shareBtnClick', item);
|
||||||
|
shareSwiperItem.value = item
|
||||||
}
|
}
|
||||||
function swiperShare(queryJson){
|
|
||||||
console.log('shareSwiperItem',shareSwiperItem.value);
|
function swiperShare(queryJson) {
|
||||||
const pTag=returnPageTags(shareSwiperItem.value.jumpPagePath)
|
console.log('shareSwiperItem', shareSwiperItem.value);
|
||||||
|
const pTag = returnPageTags(shareSwiperItem.value.jumpPagePath)
|
||||||
let query = jsonToUrl(queryJson)
|
let query = jsonToUrl(queryJson)
|
||||||
query +=('&'+shareSwiperItem.value.extendParam)
|
query += ('&' + shareSwiperItem.value.extendParam)
|
||||||
const shopName = uni.cache.get('shopInfo').shopName || ''
|
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 :
|
||||||
console.log('path',path);
|
'/pages/product/index?type=beforehand'
|
||||||
const json={
|
console.log('path', path);
|
||||||
imageUrl:shareSwiperItem.value.imageUrl,
|
const json = {
|
||||||
path: path+'&'+query,
|
imageUrl: shareSwiperItem.value.imageUrl,
|
||||||
title:shareSwiperItem.value.name+ (shopName ? `-${shopName}` : ''),
|
path: path + '&' + query,
|
||||||
|
title: shareSwiperItem.value.name + (shopName ? `-${shopName}` : ''),
|
||||||
}
|
}
|
||||||
if(pTag==='pp-detail'){
|
if (pTag === 'pp-detail') {
|
||||||
json.path=json.path.replace('goodsId','id')
|
json.path = json.path.replace('goodsId', 'id')
|
||||||
}
|
}
|
||||||
if(pTag==='gb-detail'){
|
if (pTag === 'gb-detail') {
|
||||||
json.path=json.path.replace('goodsId','wareId')
|
json.path = json.path.replace('goodsId', 'wareId')
|
||||||
}
|
}
|
||||||
if(pTag==='point-detail'){
|
if (pTag === 'point-detail') {
|
||||||
json.path=json.path.replace('goodsId','id')
|
json.path = json.path.replace('goodsId', 'id')
|
||||||
}
|
}
|
||||||
if(pTag.includes('eat')){
|
if (pTag.includes('eat')) {
|
||||||
if(shareSwiperItem.value.extendParam){
|
if (shareSwiperItem.value.extendParam) {
|
||||||
json.path=json.path.replace('goodsId','showGoodsId')
|
json.path = json.path.replace('goodsId', 'showGoodsId')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wxShare(json)
|
return wxShare(json)
|
||||||
@@ -2621,7 +2719,7 @@
|
|||||||
|
|
||||||
async function onShare() {
|
async function onShare() {
|
||||||
const queryJson = await returnCommonQuery()
|
const queryJson = await returnCommonQuery()
|
||||||
if(shareSwiperItem.value){
|
if (shareSwiperItem.value) {
|
||||||
return swiperShare(queryJson)
|
return swiperShare(queryJson)
|
||||||
}
|
}
|
||||||
let query = jsonToUrl(queryJson)
|
let query = jsonToUrl(queryJson)
|
||||||
@@ -2638,7 +2736,7 @@
|
|||||||
json.title = shopName
|
json.title = shopName
|
||||||
json.imageUrl = uni.cache.get('shopInfo').logo || ''
|
json.imageUrl = uni.cache.get('shopInfo').logo || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxShare({
|
return wxShare({
|
||||||
query,
|
query,
|
||||||
...json,
|
...json,
|
||||||
@@ -2653,6 +2751,36 @@
|
|||||||
const pageOptions = reactive({})
|
const pageOptions = reactive({})
|
||||||
|
|
||||||
const carouselList = ref([])
|
const carouselList = ref([])
|
||||||
|
|
||||||
|
async function getConsStocks() {
|
||||||
|
const res = await getConsStock({
|
||||||
|
shopId: userStore.shopInfo.id
|
||||||
|
})
|
||||||
|
consStockList.value = res || []
|
||||||
|
}
|
||||||
|
const consStockList = ref([])
|
||||||
|
|
||||||
|
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) => {
|
onLoad(async (e) => {
|
||||||
Object.assign(pageOptions, e)
|
Object.assign(pageOptions, e)
|
||||||
if (e.type) {
|
if (e.type) {
|
||||||
@@ -2684,7 +2812,8 @@
|
|||||||
}
|
}
|
||||||
options.initMessage.shop_id = userStore.shopInfo.id
|
options.initMessage.shop_id = userStore.shopInfo.id
|
||||||
shopUserInfo.value = userStore.shopUserInfo
|
shopUserInfo.value = userStore.shopUserInfo
|
||||||
|
//耗材列表
|
||||||
|
await getConsStocks()
|
||||||
await productqueryProduct();
|
await productqueryProduct();
|
||||||
|
|
||||||
const extraInitPar = {}
|
const extraInitPar = {}
|
||||||
@@ -2728,14 +2857,14 @@
|
|||||||
tableCode: uni.cache.get('tableCode')
|
tableCode: uni.cache.get('tableCode')
|
||||||
});
|
});
|
||||||
oldOrder.value = res;
|
oldOrder.value = res;
|
||||||
nextTick(()=>{
|
nextTick(() => {
|
||||||
getElementTop();
|
getElementTop();
|
||||||
})
|
})
|
||||||
if (res && res.id && shopInfo.registerType == 'after' && !e.noJump) {
|
if (res && res.id && shopInfo.registerType == 'after' && !e.noJump) {
|
||||||
toHistory();
|
toHistory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 启动网络监听
|
// 启动网络监听
|
||||||
useSocket.initNetworkListener();
|
useSocket.initNetworkListener();
|
||||||
@@ -2835,7 +2964,7 @@
|
|||||||
}
|
}
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
isGoodsShare.value = false
|
isGoodsShare.value = false
|
||||||
shareSwiperItem.value=null
|
shareSwiperItem.value = null
|
||||||
closeSocket();
|
closeSocket();
|
||||||
});
|
});
|
||||||
onUnload(() => {
|
onUnload(() => {
|
||||||
@@ -4085,11 +4214,12 @@
|
|||||||
padding: 32rpx 28rpx;
|
padding: 32rpx 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share-btn-box{
|
.share-btn-box {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 8rpx;
|
right: 8rpx;
|
||||||
bottom: 14rpx;
|
bottom: 14rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.share-btn {
|
.share-btn {
|
||||||
|
|
||||||
padding: 10rpx 32rpx;
|
padding: 10rpx 32rpx;
|
||||||
|
|||||||
Reference in New Issue
Block a user