From b452cb2b508b550e3eecc27b68530fc8b6684841 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Wed, 15 Apr 2026 09:29:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env.development | 4 +- src/locale/en.json | 21 ++- src/locale/zh-Hans.json | 21 ++- src/manifest.json | 4 +- src/pages-login/pages/sign-up/index.vue | 25 +++- src/pages-user/pages/food/add-food.vue | 89 +++++++---- src/pages-user/pages/food/add-item.vue | 141 ++++++++++-------- .../menu-swiper-list/menu-swiper-list.vue | 78 ++++++++-- src/static/app/images/SoldOut.png | Bin 0 -> 7332 bytes 9 files changed, 250 insertions(+), 133 deletions(-) create mode 100644 src/static/app/images/SoldOut.png diff --git a/env/.env.development b/env/.env.development index f403dd5..4d56587 100644 --- a/env/.env.development +++ b/env/.env.development @@ -5,7 +5,7 @@ VITE_DELETE_CONSOLE=false #本地环境 #VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai -#VITE_SERVER_BASEURL=http://192.168.5.58:8080 -VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api +VITE_SERVER_BASEURL=http://192.168.5.4:8080 +#VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api #VITE_SERVER_BASEURL=http://192.168.1.8:8811 #VITE_SERVER_BASEURL=http://mifengchuantou.natapp1.cc/meiguowaimai diff --git a/src/locale/en.json b/src/locale/en.json index 65c4810..adf30f8 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -317,6 +317,10 @@ "discountedPrice": "Actual selling price:", "enterPlaceholder": "Enter", "frequentlyBoughtTogether": "Frequently Bought Together", + "specManagement": "Specification Management", + "priceAutoFillTip": "Price is auto-filled from the first specification", + "originalPriceAutoFillTip": "Auto-filled from the first specification's list price", + "discountPriceAutoFillTip": "Auto-filled from the first specification's member price", "itemActiveDesc": "Customers can view and order this dish", "itemIsActive": "Item is Active", "itemIsNot": "The dish is not activated", @@ -346,19 +350,20 @@ }, "add-item": { "add": "Add", - "addSideDishes": "+ Add Side Dishes", "enterPlaceholder": "Enter", "isRequired": "Is Required", "name": "Name", "price": "Price($)", - "sideDish": "Side Dish", - "sideDishesFlavorValue": "Side Dishes/Flavor Value:", - "title": "Add Side Dish", - "typeOfSideDishes": "Type of Side Dishes/Flavor:", + "memberPrice": "Member price($)", + "actualSalePrice": "Actual sale price($)", + "spec": "Specification", + "specValue": "Specification Value:", + "title": "Add Specification", + "specType": "Specification Type:", "validation": { - "addAtLeastOne": "Please add at least one side dish", - "completeAllFields": "Please complete all fields for side dish {index}", - "enterSideDishName": "Please enter side dish name for item {index}", + "addAtLeastOne": "Please add at least one specification", + "completeAllFields": "Please complete all fields for specification {index}", + "enterSpecName": "Please enter specification name for item {index}", "submittedSuccessfully": "Submitted successfully" }, "value": "Value" diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index f67d222..248a756 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -317,6 +317,10 @@ "discountedPrice": "实际销售价格:", "enterPlaceholder": "输入", "frequentlyBoughtTogether": "经常一起购买", + "specManagement": "规格管理", + "priceAutoFillTip": "价格由第一项规格自动填充", + "originalPriceAutoFillTip": "由第一项规格中的「价格」自动填充", + "discountPriceAutoFillTip": "由第一项规格中的「会员价」自动填充", "itemActiveDesc": "客户可以查看并订购此菜品", "itemIsActive": "菜品已激活", "itemIsNot": "菜品未激活", @@ -346,19 +350,20 @@ }, "add-item": { "add": "添加", - "addSideDishes": "+ 添加配菜", "enterPlaceholder": "输入", "isRequired": "是否必选", "name": "名称", "price": "价格($)", - "sideDish": "配菜", - "sideDishesFlavorValue": "配菜/口味值:", - "title": "添加配菜", - "typeOfSideDishes": "配菜类型/口味:", + "memberPrice": "会员价($)", + "actualSalePrice": "实际支付价格($)", + "spec": "规格", + "specValue": "规格值:", + "title": "添加规格", + "specType": "规格类型:", "validation": { - "addAtLeastOne": "请至少添加一个配菜", - "completeAllFields": "请完成配菜 {index} 的所有字段", - "enterSideDishName": "请输入配菜 {index} 的配菜名称", + "addAtLeastOne": "请至少添加一个规格", + "completeAllFields": "请完成规格 {index} 的所有字段", + "enterSpecName": "请输入规格 {index} 的规格名称", "submittedSuccessfully": "提交成功" }, "value": "值" diff --git a/src/manifest.json b/src/manifest.json index 9aeb198..f5d1907 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "CHEFLINK Merchant", "appid" : "__UNI__BB8E3C9", "description" : "美国外卖商户端", - "versionName" : "2.0.1", - "versionCode" : 201, + "versionName" : "3.0.0", + "versionCode" : 300, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/src/pages-login/pages/sign-up/index.vue b/src/pages-login/pages/sign-up/index.vue index 55403ee..942e65b 100644 --- a/src/pages-login/pages/sign-up/index.vue +++ b/src/pages-login/pages/sign-up/index.vue @@ -80,15 +80,24 @@ const btnLoading = ref(false) function codeSubmit() { // console.log(data) btnLoading.value = true + const body: Record = { + ...logicStore.registerForm, + phone: logicStore.registerForm.phone, + areaCode: areaCode.value, + // captcha: data.code, + // uuid: data.uuid, + userPort: 2, // 登录端口2 商户端 + } + if (!body.email) { + delete body.email + delete body.confirmEmail + } + if (logicStore.registerForm.type === 'email' && !String(body.phone ?? '').trim()) { + delete body.phone + delete body.areaCode + } appUserRegisterPost({ - body: { - ...logicStore.registerForm, - phone: logicStore.registerForm.phone, - areaCode: areaCode.value, - // captcha: data.code, - // uuid: data.uuid, - userPort: 2, // 登录端口2 商户端 - } + body }).then((res) => { ;(userStore as any).token = (res as any).data?.token; logicStore.reset() diff --git a/src/pages-user/pages/food/add-food.vue b/src/pages-user/pages/food/add-food.vue index a6e3fd5..fae6992 100644 --- a/src/pages-user/pages/food/add-food.vue +++ b/src/pages-user/pages/food/add-food.vue @@ -45,16 +45,12 @@ const FormSchema = z.object({ }, {message: t('pages-user.food.add-food.schema.discountPricePositive') ?? '折扣价必须大于0'}, ), - // dishImage: z.array(z.string()).min(1, t('pages-user.food.add-food.schema.dishImage')), stock: z.string() .min(1, t('pages-user.food.add-food.stockRequired')) .refine( (val) => { - // 检查是否为空字符串或仅包含空格 const trimmed = val.trim() if (trimmed === '') return false - - // 检查是否为整数 const num = Number(trimmed) return Number.isInteger(num) }, @@ -68,12 +64,9 @@ const FormSchema = z.object({ {message: t('pages-user.food.add-food.stockMustBeNonNegative')} ) }).refine((data) => { - // 验证折扣价不能高于原价 if (data.discountPrice && data.discountPrice.trim() !== '') { const originalPrice = parseFloat(data.originalPrice) const discountPrice = parseFloat(data.discountPrice) - - // 检查是否为有效数字 if (!isNaN(originalPrice) && !isNaN(discountPrice)) { return discountPrice <= originalPrice } @@ -99,9 +92,56 @@ const removeImage = (index: number) => { formData.value.dishImage.splice(index, 1) } -// 配菜数据 const merchantSideDishVoList = ref([]) +function syncPriceFromSpec() { + const specList = merchantSideDishVoList.value.merchantSideDishBoList + if (specList && specList.length > 0) { + const firstGroup = specList[0] + const items = firstGroup.merchantSideDishItemBoList + if (items && items.length > 0) { + const first = items[0] as { price?: string; memberPrice?: string } + const listPrice = first.price != null && String(first.price).trim() !== '' ? String(first.price).trim() : '' + const memberPrice = + first.memberPrice != null && String(first.memberPrice).trim() !== '' ? String(first.memberPrice).trim() : '' + if (listPrice) { + formData.value.originalPrice = listPrice + } + if (memberPrice) { + formData.value.discountPrice = memberPrice + } + } + } +} + +/** 提交用:保持规格完整传递(包含第一项) */ +function buildMerchantSideDishBoListForSubmit() { + const raw = merchantSideDishVoList.value.merchantSideDishBoList + if (!raw || !Array.isArray(raw) || raw.length === 0) { + return raw || [] + } + return JSON.parse(JSON.stringify(raw)) as any[] +} + +/** 保存/编辑请求体:去掉详情里的 Vo 列表与旧 Bo 列表,只传去重后的 merchantSideDishBoList,避免修改时重复提交 */ +function buildDishSaveBody(stockValue: number) { + const fd = formData.value as Record + const { + merchantSideDishVoList: _vo, + merchantSideDishBoList: _bo, + dishImage: _dishImgArr, + ...rest + } = fd + return { + ...rest, + tax: Number(formData.value.tax) / 100 || 0, + stock: stockValue, + merchantSideDishBoList: buildMerchantSideDishBoListForSubmit(), + dishImage: formData.value.dishImage.join(','), + delFlag: formData.value.isActive ? 1 : 3 + } +} + function navigateTo(url: string) { uni.navigateTo({ url, @@ -110,11 +150,11 @@ function navigateTo(url: string) { console.log(data) if (data) { merchantSideDishVoList.value = data + syncPriceFromSpec() } }, }, success: function (res) { - // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('acceptDataFromOpenerPage', {data: merchantSideDishVoList.value.merchantSideDishBoList || []}) } }) @@ -297,17 +337,11 @@ function saveDish() { // 安全处理库存值 const stockValue = formData.value.stock ? Number(formData.value.stock.trim()) : 0 + const body = buildDishSaveBody(stockValue) if (formData.value.id) { appMerchantDishEditDishPost({ - body: { - ...formData.value, - tax: Number(formData.value.tax) / 100 || 0, - stock: stockValue, - merchantSideDishBoList: merchantSideDishVoList.value.merchantSideDishBoList, - dishImage: formData.value.dishImage.join(','), - delFlag: formData.value.isActive ? 1 : 3 - } + body }).then(() => { uni.showToast({ title: t('toast.submitSuccess'), @@ -317,14 +351,7 @@ function saveDish() { }) } else { appMerchantDishAddDishPost({ - body: { - ...formData.value, - tax: Number(formData.value.tax) / 100 || 0, - stock: stockValue, - merchantSideDishBoList: merchantSideDishVoList.value.merchantSideDishBoList, - dishImage: formData.value.dishImage.join(','), - delFlag: formData.value.isActive ? 1 : 3 - } + body }).then(() => { uni.showToast({ title: t('toast.submitSuccess'), @@ -455,7 +482,7 @@ function saveDish() { - + {{ t('pages-user.food.add-food.price') @@ -466,8 +493,8 @@ function saveDish() { + {{ t('pages-user.food.add-food.originalPriceAutoFillTip') }} - + {{ t('pages-user.food.add-food.discountedPrice') }} @@ -487,8 +515,8 @@ function saveDish() { + {{ t('pages-user.food.add-food.discountPriceAutoFillTip') }} @@ -580,7 +609,7 @@ function saveDish() { - {{ t('pages-user.food.add-food.frequentlyBoughtTogether') }} + {{ t('pages-user.food.add-food.specManagement') }} diff --git a/src/pages-user/pages/food/add-item.vue b/src/pages-user/pages/food/add-item.vue index b5bc793..a8de9da 100644 --- a/src/pages-user/pages/food/add-item.vue +++ b/src/pages-user/pages/food/add-item.vue @@ -1,68 +1,65 @@ @@ -132,33 +140,28 @@ function handleClickItem(group: SideDishGroup) { - - - - {{ t('pages-user.food.add-item.sideDish') }} {{ + {{ t('pages-user.food.add-item.spec') }} {{ groupIndex + 1 }}: - - {{ - t('pages-user.food.add-item.typeOfSideDishes') + t('pages-user.food.add-item.specType') }} @@ -177,13 +180,11 @@ function handleClickItem(group: SideDishGroup) { - {{ t('pages-user.food.add-item.isRequired') }} - - {{ t('pages-user.food.add-item.sideDishesFlavorValue') }} + {{ t('pages-user.food.add-item.specValue') }} - - - {{ t('pages-user.food.add-item.value') }} {{ valueIndex + 1 }}: - - {{ t('pages-user.food.add-item.name') }} @@ -243,8 +238,7 @@ function handleClickItem(group: SideDishGroup) { - - + {{ t('pages-user.food.add-item.price') }} + + + {{ t('pages-user.food.add-item.memberPrice') }} + + + + + + + + {{ t('pages-user.food.add-item.actualSalePrice') }} + + + + + - + {{ t('pages-user.food.add-item.add') }} - - - - {{ t('pages-user.food.add-item.addSideDishes') }} - diff --git a/src/pages/home/components/tabbar-menu/components/menu-swiper-list/menu-swiper-list.vue b/src/pages/home/components/tabbar-menu/components/menu-swiper-list/menu-swiper-list.vue index b220a7e..2953c3e 100644 --- a/src/pages/home/components/tabbar-menu/components/menu-swiper-list/menu-swiper-list.vue +++ b/src/pages/home/components/tabbar-menu/components/menu-swiper-list/menu-swiper-list.vue @@ -211,6 +211,14 @@ function getStock(item: any) { return Number(stock).toFixed(0) } +/** 已售完:有明确库存且数量 <= 0(未返回 stock 时不视为售完,避免误盖) */ +function isSoldOut(item: any) { + const stock = (item as any)?.stock + if (stock === undefined || stock === null || stock === '') return false + const n = Number(stock) + return !Number.isNaN(n) && n <= 0 +} + function initData() { console.log('页面回来的时候获取最新的数据', props.currentIndex) if (+props.currentIndex === +props.tabIndex) { @@ -382,11 +390,21 @@ const isMerchant = computed(() => {