diff --git a/.env b/.env index a80741d..1ec75da 100644 --- a/.env +++ b/.env @@ -19,16 +19,16 @@ VITE_OAUTH2_APP_CLIENT='mini:mini' # --------------------------- 开发环境 api地址 ---------------------------------- # VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/api # 域名线上 #VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上 -#VITE_APP_DEV_SERVICE = http://192.168.101.174:9999 # 邓-本地 - VITE_APP_DEV_SERVICE = http://127.0.0.1:9999 # 邓-本地 -# VITE_APP_DEV_SERVICE = http://123.157.250.162:8089/api # 测试线上 +# VITE_APP_DEV_SERVICE = http://192.168.101.174:9999 # 邓-本地 +# VITE_APP_DEV_SERVICE = http://127.0.0.1:9999 # 邓-本地 +VITE_APP_DEV_SERVICE = http://123.157.250.162:8089/api # 测试线上 # --------------------------- 开发环境 图片访问基础地址 --------------------------- # VITE_IMAGE_DEV_PATH = https://stgl.pj.gov.cn/api # 域名线上 #VITE_IMAGE_DEV_PATH = http://59.202.170.152:81/api # 信创线上 -#VITE_IMAGE_DEV_PATH = http://192.168.101.174:9999 # 邓-本地 - VITE_IMAGE_DEV_PATH = http://127.0.0.1:9999 -# VITE_IMAGE_DEV_PATH = http://123.157.250.162:8089/api # 测试线上 +# VITE_IMAGE_DEV_PATH = http://192.168.101.174:9999 # 邓-本地 + # VITE_IMAGE_DEV_PATH = http://127.0.0.1:9999 +VITE_IMAGE_DEV_PATH = http://123.157.250.162:8089/api # 测试线上 # --------------------------- 生产环境 api地址 ---------------------------------- VITE_APP_PROD_SERVICE = https://stgl.pj.gov.cn/api # 域名线上 diff --git a/src/pages/canteen/components/product-row.vue b/src/pages/canteen/components/product-row.vue index c416893..1ce7d2c 100644 --- a/src/pages/canteen/components/product-row.vue +++ b/src/pages/canteen/components/product-row.vue @@ -30,7 +30,9 @@ const props = withDefaults(defineProps(), { // 点击加 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 = () => { x{{ props.count }} - {{ hooks.useFormatNum("库存", "", props.stock) }} + + 库存:{{ props.stock }} {{ hooks.useFormatNum("销量", "", props.salesCount) }} diff --git a/src/pages/canteen/detail.vue b/src/pages/canteen/detail.vue index 1fa9177..03be740 100644 --- a/src/pages/canteen/detail.vue +++ b/src/pages/canteen/detail.vue @@ -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: hooks.useTime(new Date(), "{y}-{m}-{d}"), } 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 = () => { - 包厢预订 + 餐桌信息 diff --git a/src/pages/canteen/product-detail.vue b/src/pages/canteen/product-detail.vue index c5f2426..86058c3 100644 --- a/src/pages/canteen/product-detail.vue +++ b/src/pages/canteen/product-detail.vue @@ -32,7 +32,7 @@ const getDetail = async () => {