feat(uniapp): 多行展示商品名

This commit is contained in:
Kroytz committed 2026-07-31 13:35:41 +08:00
1 parent 0e117875c7
commit c902d018d9
3 files changed
+34 -22

No files matched your search

+15 -2
View File
@@ -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 {
@@ -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)
}
</script>
@@ -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('请点击生成规格!');
}