From afcb73a2a4736ff63b059364c24c610efcccc4f9 Mon Sep 17 00:00:00 2001 From: link_1999 <1402246900@qq.com> Date: Thu, 7 Apr 2022 18:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'=E6=96=B0=E9=97=BB=E5=B0=8F=E7=A8=8B=E5=BA=8F/pages/home'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改进新闻详情页的跳转(新增:判断对应板块新闻应该查找那个数据库集合) --- 新闻小程序/pages/home/home.js | 40 ++++++++++++++++++++++++++++----- 新闻小程序/pages/home/home.wxml | 11 ++++----- 新闻小程序/pages/home/home.wxss | 8 +++++-- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/新闻小程序/pages/home/home.js b/新闻小程序/pages/home/home.js index 6750a6b..bde3ed3 100644 --- a/新闻小程序/pages/home/home.js +++ b/新闻小程序/pages/home/home.js @@ -1,6 +1,8 @@ // pages/home/home.js +let newsType = 'neidi-news' Page({ data: { + navState: 0,//导航状态 //存放轮播图数据的列表 lunboList: [], msgList: [ @@ -26,12 +28,32 @@ Page({ // 获取新闻列表数据 this.getList() }, - // 点击事件-去往详情页 - gotoDetail(event) { - // console.log('用户点击的新闻id:', event.currentTarget.dataset.id) - wx.navigateTo({ - url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id, + navSwitch(e) { + let index = e.currentTarget.dataset.index + this.setData({ + navState: index, }) + if (index == 0) { + wx.navigateTo({ + url: '/pages/home/home', + }) + }else if (index == 1) { + wx.navigateTo({ + url: '/pages/xg/xg', + }) + }else if (index == 2) { + wx.navigateTo({ + url: '/pages/tw/tw', + }) + }else if (index == 3) { + wx.navigateTo({ + url: '/pages/gj/gj', + }) + }else if (index == 4) { + wx.navigateTo({ + url: '/pages/junshi/junshi', + }) + } }, // 获取新闻列表数据 getList(page) { @@ -62,6 +84,14 @@ Page({ console.log('新闻列表请求失败', res) }) }, + // 点击事件-去往详情页 + gotoDetail(event) { + // console.log('用户点击的新闻id:', event.currentTarget.dataset.id) + wx.navigateTo({ + url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '&newsType=' + newsType, + }) + }, + /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/新闻小程序/pages/home/home.wxml b/新闻小程序/pages/home/home.wxml index d3017e2..db231b2 100644 --- a/新闻小程序/pages/home/home.wxml +++ b/新闻小程序/pages/home/home.wxml @@ -8,13 +8,14 @@ + - 内地新闻 - 香港新闻 - 台湾新闻 - 国际新闻 - 军事新闻 + 内地新闻 + 香港新闻 + 两岸新闻 + 国际新闻 + 军事新闻 diff --git a/新闻小程序/pages/home/home.wxss b/新闻小程序/pages/home/home.wxss index 4e3e892..cbddf91 100644 --- a/新闻小程序/pages/home/home.wxss +++ b/新闻小程序/pages/home/home.wxss @@ -33,11 +33,11 @@ swiper image { /* 新闻板块导航栏 */ .types { width: 100%; - height: auto; + height: 34px; white-space: nowrap; border-bottom: 1px solid; border-bottom-color: black; - background-color: rgba(153, 151, 151, 0.151); + background-color: snow; } .type-item { font-size: 18px; @@ -45,6 +45,10 @@ swiper image { display: inline-block; margin: 10rpx 20rpx; } +.item_sel_style { + background-color: #2b4b6b; + color: snow; +} /* 新闻列表 */