This commit is contained in:
BianLzhaoMin 2025-09-18 09:19:15 +08:00
parent f756f00e69
commit 74ff8affe5
3 changed files with 95 additions and 23 deletions

View File

@ -41,7 +41,7 @@
<div class="case-right-content"> <div class="case-right-content">
<h3>{{ item.caseCompany }}</h3> <h3>{{ item.caseCompany }}</h3>
<!-- <div>{{ item.caseIntroduction }} </div> --> <!-- <div>{{ item.caseIntroduction }} </div> -->
<div> <div v-if="item.isTextOverflow">
<el-tooltip effect="dark" placement="top"> <el-tooltip effect="dark" placement="top">
<div <div
slot="content" slot="content"
@ -54,6 +54,14 @@
</div> </div>
</el-tooltip> </el-tooltip>
</div> </div>
<div
class="product-info-content"
v-else
:ref="`caseInfoContent-${index}`"
>
{{ item.caseIntroduction }}
</div>
</div> </div>
</div> </div>
</div> </div>
@ -106,19 +114,19 @@ export default {
transitionDuration: '0.5s', // transitionDuration: '0.5s', //
timer: null, // timer: null, //
interval: 5000, // (ms) interval: 5000, // (ms)
extendedCardList: [],
} }
}, },
computed: { computed: {
// //
extendedCardList() { // extendedCardList() {
if (this.cardList.length <= 1) return this.cardList // if (this.cardList.length <= 1) return this.cardList
// return [
return [ // this.cardList[this.cardList.length - 1], //
this.cardList[this.cardList.length - 1], // // ...this.cardList, //
...this.cardList, // // this.cardList[0], //
this.cardList[0], // // ]
] // },
},
}, },
mounted() { mounted() {
// //
@ -219,6 +227,34 @@ export default {
}) })
}, },
}, },
watch: {
cardList: {
handler(newValue) {
if (newValue <= 1) {
this.extendedCardList = newValue
} else {
this.extendedCardList = [
this.cardList[this.cardList.length - 1], //
...this.cardList, //
this.cardList[0], //
]
}
this.$nextTick(() => {
this.extendedCardList.forEach((item, index) => {
item.isTextOverflow =
this.$refs[`caseInfoContent-${index}`][0]
.clientHeight <
this.$refs[`caseInfoContent-${index}`][0]
.scrollHeight
})
})
},
deep: true,
immediate: true,
},
},
} }
</script> </script>
@ -264,7 +300,7 @@ export default {
// - // -
.carousel-wrapper { .carousel-wrapper {
width: 100%; width: 100%;
// overflow: hidden; overflow: hidden;
position: relative; position: relative;
// padding: 0 10px; // padding: 0 10px;
// //

View File

@ -30,11 +30,8 @@
<div class="case-right-content"> <div class="case-right-content">
<h3>{{ item.caseCompany }}</h3> <h3>{{ item.caseCompany }}</h3>
<!-- <div>{{ item.caseIntroduction }} </div> -->
<!-- <TextTip :maxLines="2" :content="item.caseIntroduction" /> --> <div v-if="item.isTextOverflow">
<div>
<el-tooltip effect="dark" placement="top"> <el-tooltip effect="dark" placement="top">
<div slot="content" class="product-info-tooltip"> <div slot="content" class="product-info-tooltip">
{{ item.caseIntroduction }} {{ item.caseIntroduction }}
@ -44,6 +41,13 @@
</div> </div>
</el-tooltip> </el-tooltip>
</div> </div>
<div
v-else
class="product-info-content"
:ref="`caseInfoContent-${item.id}`"
>
{{ item.caseIntroduction }}
</div>
</div> </div>
</div> </div>
</div> </div>
@ -89,7 +93,21 @@ export default {
async getProductCenterDetailInScreenFun(id) { async getProductCenterDetailInScreenFun(id) {
const res = await getProductCenterDetailAPI({ id }) const res = await getProductCenterDetailAPI({ id })
const { list } = res.data const { list } = res.data
this.cardList = list this.cardList = list.map((item) => {
return {
...item,
isTextOverflow: false,
}
})
this.$nextTick(() => {
this.cardList.forEach((item) => {
item.isTextOverflow =
this.$refs[`caseInfoContent-${item.id}`][0]
.clientHeight <
this.$refs[`caseInfoContent-${item.id}`][0].scrollHeight
})
})
}, },
}, },
} }

View File

@ -42,7 +42,15 @@
</span> </span>
</div> </div>
<div class="product-container"> <div
v-if="!isTextOverflow"
ref="productInfoContent"
class="product-info-content"
>
{{ productDetail.introduction }}
</div>
<div class="product-container" v-else>
<el-tooltip effect="dark" placement="top"> <el-tooltip effect="dark" placement="top">
<div slot="content" class="product-info-tooltip"> <div slot="content" class="product-info-tooltip">
{{ productDetail.introduction }} {{ productDetail.introduction }}
@ -136,6 +144,8 @@ export default {
this.getProductCenterDetailInScreenFun(this.$route.params?.id) this.getProductCenterDetailInScreenFun(this.$route.params?.id)
}, },
mounted() {},
methods: { methods: {
// //
async getProductCenterDetailInScreenFun(id) { async getProductCenterDetailInScreenFun(id) {
@ -162,14 +172,23 @@ export default {
typeName, typeName,
linkImage, linkImage,
isAccess, isAccess,
introduction: introduction,
introduction ||
'这是一个测试用的长文本内容,用来验证悬浮提示功能是否正常工作。这段文字应该超过四行,从而触发悬浮显示效果。我们添加了更多的文字内容来确保文本能够溢出容器,这样用户就可以通过鼠标悬停来查看完整的产品介绍内容了。这个功能对于长文本的展示非常有用,能够提供更好的用户体验。',
} }
this.productCases = list this.productCases = list.map((item) => {
return {
...item,
isTextOverflow: false,
}
})
this.productVideos = videoList this.productVideos = videoList
this.productBrochures = fileList this.productBrochures = fileList
this.$nextTick(() => {
this.isTextOverflow =
this.$refs.productInfoContent.clientHeight <
this.$refs.productInfoContent.scrollHeight
})
}, },
goBack() { goBack() {
@ -869,7 +888,7 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
box-sizing: border-box; // box-sizing: border-box;
} }
.product-info-header { .product-info-header {
@ -919,7 +938,6 @@ export default {
font-family: 'PingFang SC', sans-serif; font-family: 'PingFang SC', sans-serif;
letter-spacing: 1px; letter-spacing: 1px;
line-height: 1.8; line-height: 1.8;
cursor: pointer;
transition: all 0.3s ease; transition: all 0.3s ease;
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;