diff --git a/app.json b/app.json index 4cd5158..006db48 100644 --- a/app.json +++ b/app.json @@ -53,7 +53,7 @@ ], "window": { "backgroundTextStyle": "light", - "navigationBarBackgroundColor": "#fff", + "navigationBarBackgroundColor": "#ffffff", "navigationBarTitleText": "又鸟蛋平台", "navigationBarTextStyle": "black" }, diff --git a/pages/index/index.js b/pages/index/index.js index d1c65fc..89bb566 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -60,6 +60,25 @@ Page({ testMode: true, partnerstatus: '', viewedGoods: [], // 已浏览商品ID列表 + + // 广告轮播图数据 + adCarouselList: [ + { + id: 1, + imageUrl: '/images/招商图片.jpg', + link: '' + }, + { + id: 2, + imageUrl: '/images/立即入驻导航图片.jpg', + link: '' + }, + { + id: 3, + imageUrl: '/images/首页分享照片.jpg', + link: '' + } + ], // 侧边栏相关 showSidebar: false, @@ -1233,33 +1252,26 @@ Page({ // 广告点击事件处理 onAdClick: function (e) { - const adSlot = e.currentTarget.dataset.ad; - let imageSrc = e.currentTarget.dataset.src; - - // 如果没有从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 + const ad = e.currentTarget.dataset.ad; + const index = e.currentTarget.dataset.index; + console.log('广告被点击:', ad, '索引:', index); + + // 如果广告有链接,跳转到链接 + if (ad.link) { + wx.navigateTo({ + url: ad.link }); - console.log('广告图片预览已打开,图片URL:', validImageUrls[0]); } else { - console.error('无法获取广告图片路径'); - wx.showToast({ - title: '图片加载失败', - icon: 'none' - }); + // 否则预览广告图片,支持左右切换 + const { adCarouselList } = this.data; + const validImageUrls = adCarouselList.map(item => item.imageUrl).filter(url => url); + if (validImageUrls.length > 0) { + this.setData({ + previewImageUrls: validImageUrls, + previewImageIndex: index, + showImagePreview: true + }); + } } }, diff --git a/pages/index/index.json b/pages/index/index.json index d0caaa6..c9a48ba 100644 --- a/pages/index/index.json +++ b/pages/index/index.json @@ -4,5 +4,9 @@ }, "enablePullDownRefresh": false, "backgroundTextStyle": "dark", - "backgroundColor": "#f8f8f8" + "backgroundColor": "#f8f8f8", + "navigationBarBackgroundColor": "#ffffff", + "navigationBarTitleText": "", + "navigationBarTextStyle": "black", + "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 6fbb427..bf29e90 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -1,8 +1,31 @@ - - 专业的鸡蛋交易平台 + + + + + + + + + @@ -21,6 +44,21 @@ 筛选 + + + + + + {{item}} + + + @@ -41,21 +79,6 @@ - - - - - {{item}} - - - -