parent
81977aa081
commit
386c1976cf
|
@ -0,0 +1,32 @@
|
||||||
|
// pages/collect/collect.js
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
news_list: [],
|
||||||
|
},
|
||||||
|
onLoad: function (options) {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
getList() {
|
||||||
|
wx.cloud.database().collection('news_collect').get()
|
||||||
|
.then(res => {
|
||||||
|
console.log('获取收藏页成功', res)
|
||||||
|
let len = res.data.length
|
||||||
|
console.log('收藏页新闻数量:', len)
|
||||||
|
let datalist = res.data
|
||||||
|
this.setData({
|
||||||
|
news_list: datalist,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
gotoDetail(event) {
|
||||||
|
console.log('用户点击的新闻id:', event.currentTarget.dataset.id)
|
||||||
|
console.log('用户点击的新闻所在数据库:', event.currentTarget.dataset.type)
|
||||||
|
let currentIndex = event.currentTarget.dataset.type
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/pages/news-detail/news-detail?id=' + event.currentTarget.dataset.id + '¤tIndex=' + currentIndex,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onShow: function () {
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
})
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!-- 新闻列表 -->
|
||||||
|
<view class="news_list">
|
||||||
|
<view wx:for="{{news_list}}" wx:key="_id">
|
||||||
|
<!-- 标题框(图片和文字) -->
|
||||||
|
<view class="pic-words" bindtap="gotoDetail" data-id="{{item._id}}" data-type="{{item.type}}">
|
||||||
|
<view wx:if="{{item.news_img != 'None'}}">
|
||||||
|
<image class="news_image" src="{{item.news_img}}"></image>
|
||||||
|
</view>
|
||||||
|
<view class="news_title title-words">{{item.news_title}}</view>
|
||||||
|
</view>
|
||||||
|
<!-- 发布单位与发布时间 -->
|
||||||
|
<view class="publish">
|
||||||
|
<view class="publisher">{{item.news_author}}</view>
|
||||||
|
<view class="create-time">{{item.news_date}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
|
@ -0,0 +1,38 @@
|
||||||
|
/* 新闻列表样式 */
|
||||||
|
.news_list {
|
||||||
|
padding: 10rpx 30rpx 30rpx 30rpx;
|
||||||
|
}
|
||||||
|
/* 标题图文框 */
|
||||||
|
.pic-words {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
margin-top: 30rpx;
|
||||||
|
}
|
||||||
|
/* 新闻图片 */
|
||||||
|
.news_image {
|
||||||
|
width: 250rpx;
|
||||||
|
height: 175rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 新闻标题 */
|
||||||
|
.news_title {
|
||||||
|
font-size: 20px;
|
||||||
|
margin-left: 15rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 发布单位 */
|
||||||
|
.publish {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
font-size: 14px;
|
||||||
|
color: grey;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
border-bottom: 1px solid;
|
||||||
|
border-bottom-color: rgb(163, 147, 147);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 发布时间 */
|
||||||
|
.create-time {
|
||||||
|
margin-left: 30rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
Loading…
Reference in New Issue