|
|
|
@ -632,22 +632,34 @@ Page({ |
|
|
|
|
|
|
|
// 广告点击事件处理
|
|
|
|
onAdClick: function(e) { |
|
|
|
const adData = e.currentTarget.dataset.ad |
|
|
|
console.log('广告被点击, 广告ID:', adData ? adData.id : 'unknown') |
|
|
|
const adSlot = e.currentTarget.dataset.ad; |
|
|
|
let imageSrc = e.currentTarget.dataset.src; |
|
|
|
|
|
|
|
if (adData && adData.adType) { |
|
|
|
// 如果没有从data-src获取到,尝试从图片元素直接获取src
|
|
|
|
if (!imageSrc) { |
|
|
|
imageSrc = e.currentTarget.src; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('广告被点击, 广告位:', adSlot); |
|
|
|
console.log('广告图片路径:', imageSrc); |
|
|
|
|
|
|
|
// 直接预览广告图片(单击触发)
|
|
|
|
const validImageUrls = [imageSrc]; |
|
|
|
|
|
|
|
if (validImageUrls.length > 0 && validImageUrls[0]) { |
|
|
|
this.setData({ |
|
|
|
previewImageUrls: validImageUrls, |
|
|
|
previewImageIndex: 0, |
|
|
|
showImagePreview: true |
|
|
|
}); |
|
|
|
console.log('广告图片预览已打开,图片URL:', validImageUrls[0]); |
|
|
|
} else { |
|
|
|
console.error('无法获取广告图片路径'); |
|
|
|
wx.showToast({ |
|
|
|
title: '广告位: ' + adData.adType, |
|
|
|
icon: 'none', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
|
|
|
|
if (adData.adType === 'full_card') { |
|
|
|
console.log('完整卡片广告被点击') |
|
|
|
} else if (adData.adType === 'half_image') { |
|
|
|
console.log('半高图片广告被点击') |
|
|
|
} |
|
|
|
} |
|
|
|
title: '图片加载失败', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 加载商品分类列表
|
|
|
|
|