From 5e349e2c1f183bd89c782ecdea4e86fa595d65af Mon Sep 17 00:00:00 2001 From: Default User Date: Sat, 17 Jan 2026 13:03:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=9A=E4=BB=85=E9=A6=96=E9=A1=B5=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AF=BC=E8=88=AA=E6=A0=8F?= =?UTF-8?q?=EF=BC=8C=E6=81=A2=E5=A4=8D=E5=85=B6=E4=BB=96=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 2 +- pages/index/index.js | 62 +++++++++++++++++++++++++----------------- pages/index/index.json | 6 +++- pages/index/index.wxml | 57 ++++++++++++++++++++++++++------------ pages/index/index.wxss | 61 +++++++++++++++++++++++++++++------------ 5 files changed, 126 insertions(+), 62 deletions(-) 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}} - - - -