diff --git a/src/components/u-charts/config-ucharts.js b/src/components/u-charts/config-ucharts.js index 3ddd6f6..80bb368 100644 --- a/src/components/u-charts/config-ucharts.js +++ b/src/components/u-charts/config-ucharts.js @@ -135,9 +135,7 @@ const cfu = { }, // 食堂喜好分析饼图提示格式化 canteenPieTooltip: function (item, category, index, opts) { - return `分类:${item.classifyName || ""}/br/购买总人数:${item.payUserCount}/br/购买总金额:${ - Number(item.totalPrice) / 100.0 - }元/br/购买总次数:${item.timeCount}` + return `分类:${item.classifyName || ""}/br/购买总数量:${item.payCount}/br/购买总金额:${Number(item.totalPrice) / 100.0}元` }, // 食堂喜好分析折现图提示格式化 canteenAreaTooltip: function (item, category, index, opts) { diff --git a/src/pages/boxes/list.vue b/src/pages/boxes/list.vue index a1c4988..daa00ae 100644 --- a/src/pages/boxes/list.vue +++ b/src/pages/boxes/list.vue @@ -6,23 +6,12 @@ import { isEmpty } from "radash" import { hooks, router } from "@@/index" import { boxesApi } from "@@/api" -import zTabs from "@@/components/other/z-tabs/z-tabs.vue" -import CustomWaterfallsFlow from "@@/components/other/custom-waterfalls-flow/custom-waterfalls-flow.vue" import { filePath } from "@/sheep/utils/file" -const data = { - tabs: [ - { id: null, name: "全部", disabled: false }, - { id: 0, name: "空闲", disabled: false }, - { id: 1, name: "部分空闲", disabled: false }, - { id: 2, name: "已满", disabled: false }, - ], -} - const state = reactive({ detailId: null, pa: { - status: data.tabs[0].id, + status: null, // 移除状态筛选 }, }) @@ -35,35 +24,47 @@ const boxesList = computed(() => { const pageRef = ref(null) const pageHook = hooks.usePage(pageRef, boxesApi.page, null, "data.records") + const query = (page: number, pagesize: number) => { pageHook.startPage(page, pagesize, false, state.pa) } +// 获取状态样式类 +const getStatusClass = (status: number) => { + const statusMap: Record = { + 0: 'status-available', + 1: 'status-partial', + 2: 'status-full' + } + return statusMap[status] || 'status-available' +} + +// 获取状态文本 +const getStatusText = (status: number) => { + const statusMap: Record = { + 0: '空闲', + 1: '部分空闲', + 2: '已满' + } + return statusMap[status] || '空闲' +} + onLoad((options: any) => { if (!isEmpty(options.id)) { state.detailId = options.id state.pa.merchantId = options.id } }) + onShow(() => { if (pageRef.value) { pageRef.value.reload(false) } }) - -const doTab = (e: any) => { - const target = data.tabs[e] - state.pa.status = target.id - pageRef.value.reload(true) -} - -const doCard = (v: any) => { - router.jump("/pages/boxes/detail", { id: v.id }) -} - + 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 () => {