Fix:5043 【商城小程序】体验项目简介内容过长会被遮挡

This commit is contained in:
linxi
2026-04-02 19:31:41 +08:00
parent c0afa773a4
commit 50f5de6601
+30 -3
View File
@@ -92,20 +92,23 @@
<swiper <swiper
v-if="projectList.length > 0" v-if="projectList.length > 0"
class="experience-swiper" class="experience-swiper"
:style="{ height: experienceSwiperHeight ? (experienceSwiperHeight + 'px') : '520rpx' }"
circular circular
:autoplay="true" :autoplay="true"
:interval="3000" :interval="3000"
:indicator-dots="false" :indicator-dots="false"
indicator-color="rgba(255, 255, 255, .4)" indicator-color="rgba(255, 255, 255, .4)"
indicator-active-color="#ffffff" indicator-active-color="#ffffff"
@change="handleExperienceSwiperChange"
> >
<swiper-item v-for="(item, index) in projectList" :key="index"> <swiper-item v-for="(item, index) in projectList" :key="index">
<view class="experience-card"> <view :id="'experience-card-' + index" class="experience-card">
<image <image
v-if="item.projectImage" v-if="item.projectImage"
:src="item.projectImage" :src="item.projectImage"
class="experience-image" class="experience-image"
mode="widthFix|heightFix" mode="widthFix|heightFix"
@load="onExperienceImageLoad"
/> />
<view class="experience-info"> <view class="experience-info">
<view class="experience-title-wrap"> <view class="experience-title-wrap">
@@ -191,7 +194,9 @@ export default {
projectList: [], projectList: [],
userLatitude: null, userLatitude: null,
userLongitude: null, userLongitude: null,
distanceText: '' distanceText: '',
currentExperienceIndex: 0,
experienceSwiperHeight: 0
} }
}, },
computed: { computed: {
@@ -268,6 +273,24 @@ export default {
this.videoContext.play() this.videoContext.play()
} }
}, },
handleExperienceSwiperChange(e) {
this.currentExperienceIndex = e.detail.current || 0
this.updateExperienceSwiperHeight(this.currentExperienceIndex)
},
onExperienceImageLoad() {
this.updateExperienceSwiperHeight(this.currentExperienceIndex)
},
updateExperienceSwiperHeight(index) {
const targetIndex = Number.isInteger(index) ? index : this.currentExperienceIndex
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this)
query.select('#experience-card-' + targetIndex).boundingClientRect(rect => {
if (rect && rect.height) {
this.experienceSwiperHeight = rect.height
}
}).exec()
})
},
fetchProjectDetail() { fetchProjectDetail() {
if (!this.experienceMerchantId) { if (!this.experienceMerchantId) {
return return
@@ -317,10 +340,15 @@ export default {
} }
if (project.projectList && project.projectList.length) { if (project.projectList && project.projectList.length) {
this.projectList = project.projectList this.projectList = project.projectList
this.currentExperienceIndex = 0
this.detailList = project.projectList.map(item => ({ this.detailList = project.projectList.map(item => ({
name: item.projectName || '', name: item.projectName || '',
count: item.projectIntro || '' count: item.projectIntro || ''
})) }))
this.updateExperienceSwiperHeight(0)
setTimeout(() => {
this.updateExperienceSwiperHeight(0)
}, 200)
} }
} }
}).finally(() => { }).finally(() => {
@@ -620,7 +648,6 @@ export default {
.experience-swiper { .experience-swiper {
margin-top: 16rpx; margin-top: 16rpx;
width: 100%; width: 100%;
height: 520rpx;
} }
.experience-image { .experience-image {
width: 100%; width: 100%;