From c902d018d9d871768ab137ca26704d506abd45fc Mon Sep 17 00:00:00 2001 From: Kroytz Date: Fri, 31 Jul 2026 13:35:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(uniapp):=20=E5=A4=9A=E8=A1=8C=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=95=86=E5=93=81=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yshop-drink-uniapp-vue3/pages/menu/menu.vue | 17 ++++++++-- .../components/Materials/src/Materials.vue | 31 +++++++------------ .../product/storeProduct/StoreProductForm.vue | 8 +++++ 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/yshop-drink-uniapp-vue3/pages/menu/menu.vue b/yshop-drink-uniapp-vue3/pages/menu/menu.vue index f77dd7c..01199b1 100644 --- a/yshop-drink-uniapp-vue3/pages/menu/menu.vue +++ b/yshop-drink-uniapp-vue3/pages/menu/menu.vue @@ -957,6 +957,17 @@ $menu-divider-height: 2rpx; white-space: nowrap; } +// 商品名:最多三行展示,超出省略 +@mixin text-ellipsis-3 { + display: -webkit-box; + overflow: hidden; + text-overflow: ellipsis; + white-space: normal; + word-break: break-all; + -webkit-box-orient: vertical; + -webkit-line-clamp: 3; +} + @mixin quantity-control($size) { .btn, .number { @@ -1247,8 +1258,10 @@ page { .name { width: 100%; margin-bottom: $menu-gap-sm; - font-size: $font-size-base; - @include text-ellipsis; + font-size: 24rpx; + line-height: 32rpx; + font-weight: 600; + @include text-ellipsis-3; } .tips { diff --git a/yshop-drink-vue3/src/components/Materials/src/Materials.vue b/yshop-drink-vue3/src/components/Materials/src/Materials.vue index 43963f2..23930d3 100644 --- a/yshop-drink-vue3/src/components/Materials/src/Materials.vue +++ b/yshop-drink-vue3/src/components/Materials/src/Materials.vue @@ -185,7 +185,7 @@ import { getPage, addObj, delObj } from '@/api/tools/material' const props = defineProps({ modelValue: { - type: Array, + type: [String, Array], default() { return [] } @@ -280,15 +280,10 @@ function deleteMaterial(index) { cancelButtonText: '取消', type: 'warning' }).then(function () { - value.value.splice(index, 1) + const nextValue = [...value.value] + nextValue.splice(index, 1) urls.value = [] - // if (urls.value.length > 1 || props.num > 1) { - // emit('update:modelValue', urls.value) - // } else { - // emit('update:modelValue', urls.value[0]) - // } - emit('update:modelValue', value.value) - + emitMaterialValue(nextValue) }) } function toSeleteMaterial() { @@ -472,20 +467,16 @@ function beforeUpload(file) { } const emit = defineEmits(['update:modelValue']) +function emitMaterialValue(materials) { + emit('update:modelValue', props.num === 1 ? (materials[0] || '') : materials) +} + function sureUrls() { console.log('value.value.length:',value.value.length) - urls.value.forEach((item) => { - value.value[value.value.length] = item - }) - console.log('urls.value:',value.value) + const nextValue = [...value.value, ...urls.value] + console.log('urls.value:',nextValue) listDialogVisible.value = false - if (urls.value.length > 1 || props.num > 1) { - emit('update:modelValue', value.value) - } else { - emit('update:modelValue', value.value[0]) - } - - + emitMaterialValue(nextValue) } diff --git a/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue b/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue index 2224f52..1a548fc 100644 --- a/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue +++ b/yshop-drink-vue3/src/views/mall/product/storeProduct/StoreProductForm.vue @@ -497,6 +497,9 @@ const getList = async () => { /** 提交表单 */ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 +const normalizeSingleImage = (image: string | string[] | null | undefined) => + Array.isArray(image) ? (image[0] || '') : (image || '') + const submitForm = async () => { // 校验表单 if (!formRef) return @@ -520,6 +523,11 @@ const submitForm = async () => { formValidate.value.items = attrs.value; formValidate.value.attrs = manyFormValidate.value; } + formValidate.value.image = normalizeSingleImage(formValidate.value.image) + formValidate.value.attrs = formValidate.value.attrs.map((item) => ({ + ...item, + pic: normalizeSingleImage(item.pic) + })) if(formValidate.value.spec_type === 1 && manyFormValidate.value.length===0){ message.warning('请点击生成规格!'); }