fix:修正优化首页、个人中心页面广告图url跳转
This commit is contained in:
@@ -247,14 +247,12 @@
|
||||
|
||||
// 监听广告图片变化,启动或停止轮播
|
||||
watch(() => props.bannerImages, (newImages, oldImages) => {
|
||||
console.log('广告图片变化:', newImages?.length, '张')
|
||||
// 先停止旧的轮播
|
||||
stopBannerRotation()
|
||||
currentBannerIndex.value = 0
|
||||
|
||||
// 如果有多张图片,启动新的轮播
|
||||
if (newImages && newImages.length > 1) {
|
||||
console.log('启动广告轮播,共', newImages.length, '张图片')
|
||||
// 使用 nextTick 确保 DOM 已更新
|
||||
nextTick(() => {
|
||||
startBannerRotation()
|
||||
@@ -384,29 +382,23 @@ const handleSearch = () => {
|
||||
|
||||
// 处理广告点击
|
||||
const handleBannerTap = () => {
|
||||
console.log('点击地图广告:', currentBannerIndex.value, currentBannerImage.value)
|
||||
// 触发父组件处理点击事件
|
||||
emit('bannerClick', currentBannerIndex.value)
|
||||
// 默认跳转到合作加盟页面
|
||||
handleJoinTap()
|
||||
}
|
||||
|
||||
// 启动广告轮播
|
||||
const startBannerRotation = () => {
|
||||
// 如果只有一张或没有图片,不需要轮播
|
||||
if (!props.bannerImages || props.bannerImages.length <= 1) {
|
||||
console.log('图片数量不足,不启动轮播')
|
||||
return
|
||||
}
|
||||
|
||||
// 清除旧的定时器
|
||||
stopBannerRotation()
|
||||
|
||||
console.log('开始广告轮播定时器')
|
||||
// 每3秒切换一次
|
||||
bannerTimer = setInterval(() => {
|
||||
const nextIndex = (currentBannerIndex.value + 1) % props.bannerImages.length
|
||||
console.log('轮播切换:', currentBannerIndex.value, '->', nextIndex)
|
||||
currentBannerIndex.value = nextIndex
|
||||
}, 3000)
|
||||
}
|
||||
@@ -414,7 +406,6 @@ const handleSearch = () => {
|
||||
// 停止广告轮播
|
||||
const stopBannerRotation = () => {
|
||||
if (bannerTimer) {
|
||||
console.log('停止广告轮播')
|
||||
clearInterval(bannerTimer)
|
||||
bannerTimer = null
|
||||
}
|
||||
@@ -450,7 +441,6 @@ const handleSearch = () => {
|
||||
|
||||
// 初始化广告轮播
|
||||
if (props.bannerImages && props.bannerImages.length > 1) {
|
||||
console.log('onMounted: 初始化广告轮播')
|
||||
startBannerRotation()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user