This commit is contained in:
1 parent
0c2a68a43e
commit
5ec0fe487e
2 files changed
+13
-7
No files matched your search
@@ -30,7 +30,9 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
|
||||
// 点击加
|
||||
const add = () => {
|
||||
// if (props.modelValue + 1 >= props.stock) return uni.showToast({ title: "库存不足", icon: "none" })
|
||||
if (props.mode !== "cart") {
|
||||
if (props.modelValue + 1 > props.stock) return uni.showToast({ title: "库存不足", icon: "none" })
|
||||
}
|
||||
emit("update:modelValue", props.modelValue + 1)
|
||||
emit("add")
|
||||
}
|
||||
@@ -58,7 +60,8 @@ const remove = () => {
|
||||
<view v-if="props.mode == 'cart'" class="m-l-40rpx second-text-24">x{{ props.count }}</view>
|
||||
</view>
|
||||
<view v-if="props.mode == 'default'" class="flex-row items-center MT 10rpx">
|
||||
<view class="second-text-24">{{ hooks.useFormatNum("库存", "", props.stock) }}</view>
|
||||
<!-- <view class="second-text-24">{{ hooks.useFormatNum("库存", "", props.stock) }}</view> -->
|
||||
<view class="second-text-24">库存:{{ props.stock }}</view>
|
||||
<view class="w-1px h-20rpx m-x-5rpx bg-#999 mx-2" />
|
||||
<view class="second-text-24">{{ hooks.useFormatNum("销量", "", props.salesCount) }}</view>
|
||||
</view>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { isEmpty } from "radash"
|
||||
import { hooks, router } from "@@/index"
|
||||
import { merchantApi, foodApi, payApi, orderApi } from "@@/api"
|
||||
import { filePath } from "@@/utils/file"
|
||||
|
||||
import ProductRow from "./components/product-row.vue"
|
||||
import ProductCart from "./components/product-cart.vue"
|
||||
import ProductTotal from "./components/product-total.vue"
|
||||
@@ -99,6 +98,7 @@ const getFoodList = async () => {
|
||||
const _pa = {
|
||||
merchantId: state.detailId,
|
||||
categoryId: target.id,
|
||||
time: "2025-08-14",
|
||||
}
|
||||
const { data } = await foodApi.product(_pa)
|
||||
data.forEach((i: any) => {
|
||||
@@ -111,7 +111,7 @@ const getFoodList = async () => {
|
||||
// 切换选中的分类
|
||||
const doClassify = (i: any) => {
|
||||
state.currentClassifyIndex = i
|
||||
getClassify()
|
||||
getFoodList()
|
||||
}
|
||||
|
||||
// 设置购物车商品的数量
|
||||
@@ -119,8 +119,11 @@ const chentProductCartCount = async (item: any) => {
|
||||
try {
|
||||
uni.showLoading({ title: "加载中", mask: true })
|
||||
// 检查商品库存
|
||||
const { code }: any = await foodApi.checkSpuStock({ spuId: item.productId, incrCount: item.productCount })
|
||||
if (code != 0) throw new Error()
|
||||
const { code, msg }: any = await foodApi.checkSpuStock({ spuId: item.productId, incrCount: item.productCount })
|
||||
if (code != 0) {
|
||||
item.productCount--
|
||||
return uni.showToast({ title: msg, icon: "none" })
|
||||
}
|
||||
|
||||
const targetIndex = state.cartList.findIndex((v) => v.productId == item.productId)
|
||||
if (targetIndex !== -1) {
|
||||
@@ -292,7 +295,7 @@ const doFood = () => {
|
||||
<view class="flex-row-center w-50rpx h-50rpx bg-#167aff rounded-full">
|
||||
<text class="font-size-28rpx! color-white iconfont icon-yuding" />
|
||||
</view>
|
||||
<text class="m-l-20rpx sub-text-28">包厢预订</text>
|
||||
<text class="m-l-20rpx sub-text-28">餐桌信息</text>
|
||||
</view>
|
||||
<view class="w-1px h-30rpx bg-#c4c4c4" />
|
||||
<view class="flex-row-center" @tap="doFood">
|
||||
|
||||
Reference in new issue
Block a user