修复临时菜和数签子显示问题,修复下单页面商品弹窗问题

This commit is contained in:
2025-12-26 16:14:42 +08:00
parent ac7af51a92
commit bde30fa70c
10 changed files with 206 additions and 88 deletions

View File

@@ -1,9 +1,9 @@
<template>
<up-popup :show="visible" :round="20" mode="bottom" @close="close" :close-on-click-overlay="true">
<view class="" style="height: calc(100vh - 70px);">
<view class="shop_sku" >
<scroll-view scroll-y style="height: calc(100vh - 240px); width: 100%">
<view class="u-flex u-flex-col box" :style="{maxHeight:boxHeight+'px'}">
<view class="shop_sku">
<scroll-view scroll-y class="scroll-view" :style="{maxHeight:boxHeight +'px'}">
<!-- <view class="positionabsolute">
<up-icon name="arrow-down" @click="close" color="#333" size="22"></up-icon>
</view> -->
@@ -13,13 +13,14 @@
<up-swiper :list="goods.images" @change="swiperChange" :current="swiperCurrent" radius="6px"
height="250" @click="prveImgs(goods.images, goods.images[swiperCurrent])">
</up-swiper>
<view class="shop_sku_name">{{ goods.name }}</view>
<view class="shop_sku_description" v-if="isSkuGoods">
{{ goods.shortTitle ? goods.shortTitle : '' }}
</view>
<view v-if="goods.type != 'package'">
<view class="shop_sku_box" v-for="(specOptions, specType) in goods.selectSpecInfo" :key="specType">
<view class="shop_sku_box" v-for="(specOptions, specType) in goods.selectSpecInfo"
:key="specType">
<view class="shop_sku_box_name">
{{ specType }}
</view>
@@ -45,11 +46,14 @@
<view v-else>
<view class="shop_sku_box">
<view v-for="(setmenu, setmenuindex) in goods.groupSnap" :key="setmenuindex">
<view class="shop_sku_box_name">{{ setmenu.title }} {{ setmenu.count }}
<view class="shop_sku_box_name" v-if="goods.groupType!=0">{{ setmenu.title }}
{{ setmenu.count }}
{{ setmenu.number }}</view>
<view class="shop_sku_box_name" v-else>{{ setmenu.title }} {{ setmenu.count }}件商品</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="{
:key="goodsid" @click="goodsidClick(setmenuindex, option, goodsid,setmenu)"
:class="{
shop_sku_box_item_selected: isOptionSelected(setmenuindex, option)
}" :disabled="isMaxSelected(setmenuindex) && !isOptionSelected(setmenuindex, option)">
{{ option.proName }}
@@ -62,7 +66,7 @@
</view>
</view>
</view>
<!-- 推荐搭配 -->
<view class="u-m-t-48 u-p-30" v-if="goods.relatedRecommendJson.length">
<view class="font-bold u-font-32 ">推荐搭配</view>
@@ -92,13 +96,13 @@
<view class="u-line-2 name u-m-t-10 u-font-32 font-500">
{{product.name}}
</view>
<view class="u-flex u-row-between">
<view class="font-bold u-flex u-col-baseline">
<text class="u-font-24"></text>
<view class="u-font-32">
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount"
:cart="returnFirstSku(product)" :shopUserInfo="shopUserInfo"
:shopInfo="shopInfo"></GoodsPrice>
@@ -111,17 +115,81 @@
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 占位 -->
<view class="shop_bottom" style="opacity: 0;">
<view class="flex-between">
<view class="price price-sku" v-if="goods.type != 'package' && goods.result">
<text class="i"></text>
<view class="num">
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="selSku"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
<text class="num" v-if="false">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
? goods.result.memberPrice || goods.result.salePrice
: goods.result.salePrice
}}
</text>
<text class="i" v-if="goods.unitName">/{{ goods.unitName }}</text>
<text
v-if="goods.result.suitNum > 1">{{ goods.result.suitNum }}{{ goods.result.unitName }}起点</text>
</view>
<view class="price price-package" v-else>
<text class="i"></text>
<view class="num">
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="goods"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
<text class="num" v-if="false">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
? goods.memberPrice || goods.salePrice
: goods.salePrice
}}
</text>
<text class="i" v-if="goods.unitName">/{{ goods.unitName }}</text>
<text v-if="goods.suitNum > 1">{{ goods.suitNum }}{{ goods.unitName }}起点</text>
</view>
<view class="operation-wrap" v-if="goods.type != 'package'&&stockNumberIsFull(goods)">
<view class="btn">
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
v-if="shopCartNumber > 0"></up-icon>
<view class="btnClick"></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"></view>
</view>
</view>
</view>
<view class="shop_skuselect flex-start" v-if="selectedSpecsStr">
<view class="shop_skuselectname">{{ selectedSpecsStr }}</view>
</view>
<view class="addShopping">
库存不足
</view>
</view>
<!-- <view style="width: 100%;height: 123px;"></view> -->
</scroll-view>
<view class="shop_bottom">
<view class="shop_bottom" style="position: absolute;bottom: 0;">
<view class="flex-between">
<view class="price price-sku" v-if="goods.type != 'package' && goods.result">
<text class="i"></text>
@@ -129,7 +197,7 @@
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="selSku"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
<text class="num" v-if="false">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
@@ -141,24 +209,19 @@
<text
v-if="goods.result.suitNum > 1">{{ goods.result.suitNum }}{{ goods.result.unitName }}起点</text>
</view>
<view class="price price-package" v-else>
<view class="price price-package " v-else>
<text class="i"></text>
<view class="num">
<GoodsPrice :limitDiscount="cartStore.limitTimeDiscount" :cart="goods"
:shopUserInfo="shopUserInfo" :shopInfo="shopInfo"></GoodsPrice>
</view>
<text class="num" v-if="false">
{{
shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1
? goods.memberPrice || goods.salePrice
: goods.salePrice
}}
</text>
<text class="i" v-if="goods.unitName">/{{ goods.unitName }}</text>
<text v-if="goods.suitNum > 1">{{ goods.suitNum }}{{ goods.unitName }}起点</text>
</view>
<view class="operation-wrap" v-if="goods.type != 'package'&&stockNumberIsFull(goods)">
<view v-if="goods.type == 'package'&&goods.groupType==1">
</view>
<view class="operation-wrap" v-else-if="stockNumberIsFull(goods)">
<view class="btn">
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"
v-if="shopCartNumber > 0"></up-icon>
@@ -181,11 +244,13 @@
</template>
<template v-else>
<template v-if="isSkuGoods">
<view v-if="goods.type == 'package'" class="addShopping package"
<view v-if="goods.type == 'package' && goods.groupType!=0" class="addShopping package"
:class=" allConditionsSatisfied ? 'active' : ''" @click="submitSelection(goods)">
添加到购物车
</view>
<view v-else class="sku addShopping" :class="shopCartNumber > 0 && canSubmit ? 'active' : ''"
<view v-else class="sku addShopping"
:class="shopCartNumber > 0 && canSubmit ? 'active' : ''"
@click="submitSelection(goods)">
添加到购物车
</view>
@@ -197,12 +262,10 @@
</view>
</template>
</template>
</view>
</view>
</view>
</up-popup>
</template>
@@ -236,6 +299,7 @@
import {
computed,
inject,
onMounted,
ref,
watch
} from "vue";
@@ -266,7 +330,10 @@
});
// / 选择规格的方法
const goodsidClick = (setmenuindex, option, goodsid) => {
const goodsidClick = (setmenuindex, option, goodsid, setmenu) => {
if (props.goods.groupType == 0) {
return
}
if (!selectedOptions.value[setmenuindex]) {
// 如果 selectedOptions.value[setmenuindex] 不存在,初始化一个空数组
selectedOptions.value[setmenuindex] = [];
@@ -278,11 +345,14 @@
} else if (!isMaxSelected(setmenuindex)) {
// 如果未达到最大选择数量,添加到选中列表
selectedOptions.value[setmenuindex].push(option);
} else if (isMaxSelected(setmenuindex) && setmenu.number == 1) {
selectedOptions.value[setmenuindex] = [option]
}
};
// 计算所有选中条件是否都符合
const allConditionsSatisfied = computed(() => {
console.log('props.goods', props.goods);
// 检查 specifications.item.groupSnap 是否存在
if (!props.goods?.groupSnap) {
return false;
@@ -306,6 +376,8 @@
const selSku = ref(null)
// 处理规格选择的方法
const selectSpec = async (specType, option) => {
console.log('specType', specType)
console.log('option', option)
// 规格清零
shopCartNumber.value = 0;
@@ -405,6 +477,9 @@
const visible = defineModel({
default: false,
});
function stockNumberIsFull(item) {
@@ -542,7 +617,7 @@
if (goods.type != 'package' && shopCartNumber.value <= 0) {
return;
}
if (goods.type == 'package' && !allConditionsSatisfied.value) {
if (goods.type == 'package' && goods.groupType!=0 && !allConditionsSatisfied.value) {
return
}
@@ -649,16 +724,30 @@
}
}
};
const boxHeight = ref(500)
onMounted(async () => {
// #ifdef MP-WEIXIN || MP-ALIPAY
const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
const systemInfo = uni.getSystemInfoSync();
const statusBarHeight = systemInfo.statusBarHeight;
// 计算标题的垂直偏移量
const verticalOffset = menuButtonInfo.top;
const titleHeight = menuButtonInfo.height;
console.log('systemInfo', systemInfo);
boxHeight.value = systemInfo.windowHeight - verticalOffset - menuButtonInfo.height - systemInfo
.safeAreaInsets.bottom - 4
// #endif
})
</script>
<style lang="scss" scoped>
.box {
height: 100vh;
display: flex;
flex-direction: column;
background: transparent;
.top {
width: 750rpx;
}
.scroll-view {}
}
.shop_sku {
@@ -668,7 +757,11 @@
border-radius: 20rpx;
background: #fff;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
overflow: hidden;
.positionabsolute {
position: absolute;
top: 30rpx;
@@ -803,6 +896,7 @@
background-color: #fff;
box-shadow: 0rpx -6rpx 14rpx 2rpx rgba(0, 0, 0, 0.1);
.price {
display: flex;
align-items: flex-end;

View File

@@ -26,17 +26,18 @@
<view class="limit-discount" v-if="showLimitDiscount(item)">
限时折扣
</view>
<up-image :src="item.coverImg" width="124rpx" height="124rpx" mode="aspectFill"
<up-image v-if="!item.cartListinfo.is_temporary" :src="item.coverImg" width="124rpx" height="124rpx" mode="aspectFill"
radius="10"></up-image>
<up-image v-else-if="item.cartListinfo.is_temporary&&item.cartListinfo.product_name=='签子'" src="https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/5/b97054debd83486ab7ad8e20ca6a360a.png" width="124rpx" height="124rpx" mode="aspectFill"
radius="10"></up-image>
<up-image v-else width="124rpx" height="124rpx" mode="aspectFill"
radius="10"></up-image>
</view>
<view class="info">
<view class="name">
{{
item.cartListinfo.is_temporary == 1
? "临时菜"
: item.name
}}
<view class="name" v-if=" item.cartListinfo.is_temporary == 1">
{{item.cartListinfo.product_name||item.cartListinfo.name|| item.name}}
</view>
<view class="name" v-else>{{item.name}}</view>
<view class="select-sku-wrap" v-if="item.type == 'sku'">
<text v-for="i in item.skuList" :key="i.id">
{{ item.cartListinfo.sku_id == i.id ? i.name : "" }}
@@ -206,9 +207,6 @@
limitDiscount: props.limitDiscount.id ? props.limitDiscount : null,
shopUserInfo: shopUserInfo,
});
if (goods.name == "纯生纯生纯生") {
console.log("returnRealPrice", price);
}
return price;
}

View File

@@ -750,7 +750,7 @@
useCartStore
} from '@/stores/order.js';
import {
computed
computed, provide
} from 'vue';
const cartStore = useCartStore();
/**
@@ -762,7 +762,6 @@
proxy
} = getCurrentInstance();
//点单智能推荐
function onBuyClick(item) {
let index = -1;
@@ -802,7 +801,6 @@
/**
* 通用数据合集 start
*/
const showGoodsModal = ref(false)
// 门店信息
const shopInfo = reactive({});
@@ -1450,7 +1448,6 @@
show:true,
goods:specifications.item
})
// showGoodsModal.value=true
};
// 判断商品是否在可售时间内
const isProductAvailable = async (sellDaysStr, startTimeStr, endTimeStr) => {
@@ -1692,12 +1689,13 @@
const goodsSkuList = goods ? goods.skuList : []
const findSku = goodsSkuList.find(sku => sku.id == v.sku_id)
const memberPrice = findSku ? findSku.memberPrice : 0
const is_temporary=v.is_temporary||v.isTemporary
const is_time_discount = limitUtils.canUseLimitTimeDiscount({
...v,
memberPrice
}, cartStore.limitTimeDiscount, shopInfo,
shopUserInfo.value, 'product_id');
if (!goods) {
if (!goods&&!is_temporary) {
console.log('删除未匹配到的商品', {
id: v.id,
operate_type: "del",