新增新闻列表

This commit is contained in:
wenc000 2020-06-26 12:33:13 +08:00
parent 67f72bb4d8
commit e5db973125
7 changed files with 200 additions and 9 deletions

View File

@ -1,5 +1,5 @@
{
"pages":[
"pages": [
"pages/index/index",
"pages/volunteerRegister/volunteerRegister",
"pages/volunteer/volunteer",
@ -18,13 +18,14 @@
"pages/activitySign/activitySign",
"pages/activityDetail/activityDetail",
"pages/activity/activity",
"pages/newsDetail/newsDetail"
"pages/newsDetail/newsDetail",
"pages/newsList/newsList"
],
"window":{
"backgroundTextStyle":"light",
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#9F1512",
"navigationBarTitleText": "日喀则数字文化馆",
"navigationBarTextStyle":"white"
"navigationBarTextStyle": "white"
},
"tabBar": {
"color": "#BBBBBB",
@ -65,4 +66,4 @@
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
}

View File

@ -42,7 +42,7 @@ Page({
app.dialog.msg(data.msg);
});
} else {
console.log('登陆失败!' + res.errMsg);
app.dialog.msg('登录失败!'+ res.errMsg);
}
}
})
@ -78,7 +78,6 @@ Page({
page: 1,
rows: 5
}, null, function(code, data) {
console.log(data);
self.setData({
'news.newsList': data.rows
})
@ -91,6 +90,11 @@ Page({
url: '../newsDetail/newsDetail',
})
},
goNewsList: function() {
wx.navigateTo({
url: '../newsList/newsList',
})
},
goVolunteer: function () {
wx.navigateTo({
url: '../volunteer/volunteer',

View File

@ -55,7 +55,7 @@
</view>
<view class="news">
<view class="public-title">
<view class="title-text">
<view class="title-text" bindtap="goNewsList">
<image src="../../images/selected-l.png" class="selected-l"></image>
新闻资讯
<image src="../../images/selected-r.png" class="selected-r"></image>

View File

@ -0,0 +1,92 @@
// pages/newsList/newsList.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
news: {
newsUrl: app.newsUrl,
newsList: [],
},
currentPage: 1,
rows: 10
},
doGetNewsList: function(page) {
var self = this;
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
page: page,
rows: self.data.rows
}, null, function(code, data) {
if(data.length == 0) {
app.dialog.msg('暂无数据');
return;
}
self.setData({
currentPage: page,
'news.newsList': data.rows
})
}, function(code, data) {
app.dialog.msg(data.msg);
}, function() {
wx.stopPullDownRefresh();
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var self = this;
self.doGetNewsList(1);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.doGetNewsList(1);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.doGetNewsList(this.data.currentPage + 1);
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@ -0,0 +1,5 @@
{
"usingComponents": {},
"enablePullDownRefresh": true,
"onReachBottomDistance": 50
}

View File

@ -0,0 +1,55 @@
<view class="news">
<view wx:for="{{news.newsList}}" wx:for-index="idx" wx:for-item="item" wx:key="newsList">
<view class="news-box" bindtap="goNewsDetail" wx:if="{{item.typesettingCode == 'key_1'}}">
<view class="news-title">{{item.newsContentTitle}}</view>
<view class="news-small-pic">
<image src="{{news.newsUrl}}/route/file/downloadfile/true/{{coverItem.contentCoverId}}" wx:for="{{item.newsContentCoverList}}" wx:for-item="coverItem" wx:key="coverItem"></image>
</view>
<view class="news-info">
<text>来源:{{item.newsContentResource}}</text>
<text>{{item.newsContentPublishTime}}</text>
</view>
</view>
<view class="news-box transverse-news" bindtap="goNewsDetail" wx:if="{{item.typesettingCode == 'key_2'}}">
<view class="news-row-img">
<image src="{{news.newsUrl}}/route/file/downloadfile/true/{{coverItem.contentCoverId}}" wx:for="{{item.newsContentCoverList}}" wx:for-item="coverItem" wx:key="coverItem"></image>
</view>
<view class="news-row-info">
<view class="news-title">{{item.newsContentTitle}}</view>
<view class="news-info">
<text>来源:{{item.newsContentResource}}</text>
<text>{{item.newsContentPublishTime}}</text>
</view>
</view>
</view>
<view class="news-box transverse-news" bindtap="goNewsDetail" wx:if="{{item.typesettingCode == 'key_3'}}">
<view class="news-row-info">
<view class="news-title">{{item.newsContentTitle}}</view>
<view class="news-info">
<text>来源:{{item.newsContentResource}}</text>
<text>{{item.newsContentPublishTime}}</text>
</view>
</view>
<view class="news-row-img">
<image src="{{news.newsUrl}}/route/file/downloadfile/true/{{coverItem.contentCoverId}}" wx:for="{{item.newsContentCoverList}}" wx:for-item="coverItem" wx:key="coverItem"></image>
</view>
</view>
<view class="news-box" bindtap="goNewsDetail" wx:if="{{item.typesettingCode == 'key_4'}}">
<view class="news-title">{{item.newsContentTitle}}</view>
<view class="news-big-pic">
<image src="{{news.newsUrl}}/route/file/downloadfile/true/{{coverItem.contentCoverId}}" wx:for="{{item.newsContentCoverList}}" wx:for-item="coverItem" wx:key="coverItem"></image>
</view>
<view class="news-info">
<text>来源:{{item.newsContentResource}}</text>
<text>{{item.newsContentPublishTime}}</text>
</view>
</view>
<view class="news-box" bindtap="goNewsDetail" wx:if="{{item.typesettingCode == 'key_5'}}">
<view class="news-title">{{item.newsContentTitle}}</view>
<view class="news-info">
<text>来源:{{item.newsContentResource}}</text>
<text>{{item.newsContentPublishTime}}</text>
</view>
</view>
</view>
</view>

View File

@ -0,0 +1,34 @@
.news{
padding: 30rpx;
border-bottom: 5px solid #FBFBFB;
}
.news-box{
padding: 30rpx 0;
border-bottom: 1px solid #EBEBEB;
display: flex;
flex-direction: column;
}
.news-title{
color: #242424;
font-size: 30rpx;
font-weight: bold;
}
.news-info{
color: #949494;
margin-top: 15rpx;
font-size: 24rpx;
}
.news-info text{
margin-right: 20rpx;
}
.news-big-pic, .news-small-pic{
margin-top: 10rpx;
}
.news-big-pic image{
width: 100%;
}
.news-small-pic image{
width: 30%;
height: 150rpx;
margin-right: 20rpx;
}