上传文件至 '新闻小程序/pages/home'
改进新闻详情页的跳转(新增:判断对应板块新闻应该查找那个数据库集合)
This commit is contained in:
parent
ee7f33c4c9
commit
afcb73a2a4
|
@ -1,6 +1,8 @@
|
||||||
// pages/home/home.js
|
// pages/home/home.js
|
||||||
|
let newsType = 'neidi-news'
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
|
navState: 0,//导航状态
|
||||||
//存放轮播图数据的列表
|
//存放轮播图数据的列表
|
||||||
lunboList: [],
|
lunboList: [],
|
||||||
msgList: [
|
msgList: [
|
||||||
|
@ -26,12 +28,32 @@ Page({
|
||||||
// 获取新闻列表数据
|
// 获取新闻列表数据
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
// 点击事件-去往详情页
|
navSwitch(e) {
|
||||||
gotoDetail(event) {
|
let index = e.currentTarget.dataset.index
|
||||||
// console.log('用户点击的新闻id:', event.currentTarget.dataset.id)
|
this.setData({
|
||||||
wx.navigateTo({
|
navState: index,
|
||||||
url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id,
|
|
||||||
})
|
})
|
||||||
|
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) {
|
getList(page) {
|
||||||
|
@ -62,6 +84,14 @@ Page({
|
||||||
console.log('新闻列表请求失败', res)
|
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,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
</block>
|
</block>
|
||||||
</swiper>
|
</swiper>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 新闻板块导航栏 -->
|
<!-- 新闻板块导航栏 -->
|
||||||
<scroll-view class="types" scroll-x="true">
|
<scroll-view class="types" scroll-x="true">
|
||||||
<view class="type-item">内地新闻</view>
|
<view class="type-item" bindtap="navSwitch" data-index="0"><view class="{{navState==0 ? 'item_sel_style' : ''}}">内地新闻</view></view>
|
||||||
<view class="type-item">香港新闻</view>
|
<view class="type-item" bindtap="navSwitch" data-index="1"><view class="{{navState==1 ? 'item_sel_style' : ''}}">香港新闻</view></view>
|
||||||
<view class="type-item">台湾新闻</view>
|
<view class="type-item" bindtap="navSwitch" data-index="2"><view class="{{navState==2 ? 'item_sel_style' : ''}}">两岸新闻</view></view>
|
||||||
<view class="type-item">国际新闻</view>
|
<view class="type-item" bindtap="navSwitch" data-index="3"><view class="{{navState==3 ? 'item_sel_style' : ''}}">国际新闻</view></view>
|
||||||
<view class="type-item">军事新闻</view>
|
<view class="type-item" bindtap="navSwitch" data-index="4"><view class="{{navState==4 ? 'item_sel_style' : ''}}">军事新闻</view></view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 顶部轮播图 -->
|
<!-- 顶部轮播图 -->
|
||||||
|
|
|
@ -33,11 +33,11 @@ swiper image {
|
||||||
/* 新闻板块导航栏 */
|
/* 新闻板块导航栏 */
|
||||||
.types {
|
.types {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: 34px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
border-bottom: 1px solid;
|
border-bottom: 1px solid;
|
||||||
border-bottom-color: black;
|
border-bottom-color: black;
|
||||||
background-color: rgba(153, 151, 151, 0.151);
|
background-color: snow;
|
||||||
}
|
}
|
||||||
.type-item {
|
.type-item {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
|
@ -45,6 +45,10 @@ swiper image {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 10rpx 20rpx;
|
margin: 10rpx 20rpx;
|
||||||
}
|
}
|
||||||
|
.item_sel_style {
|
||||||
|
background-color: #2b4b6b;
|
||||||
|
color: snow;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 新闻列表 */
|
/* 新闻列表 */
|
||||||
|
|
Loading…
Reference in New Issue