You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
3.2 KiB

<template>
<view>
<topnav title="消息列表" @tohome='tohome'></topnav>
<view class="content">
<view class="listBox">
<block v-for="(item,index) in news">
<navigator :url="'../newsinfo/newsinfo?id='+item.id">
<view class="listBoxItem">
<view class="listBoxItemLeft">
<view class="leftbg">
<text class="iconfont icon-details"></text>
</view>
</view>
<view class="listBoxItemRight">
<text class="listBoxItemRightText">{{item.title}}</text>
<text class="listBoxItemRightfText">{{item.created_at}}</text>
</view>
</view>
</navigator>
<view class="listBoxline"></view>
</block>
</view>
</view>
</view>
</template>
<script>
var util = require("../../../../utils/util.js");
export default {
data() {
return {
news: [],
currentPage: 1,
host: ""
}
},
onLoad: function() {
this.loadPage(1);
this.host = util.HOST;
},
onReachBottom: function(e) {
this.loadPage(this.currentPage + 1);
},
onPullDownRefresh: function(e) {
this.loadPage(1);
},
methods: {
tohome:function(){
uni.navigateTo({
url:"../../../../pages/index/index"
})
},
loadPage: function(page) {
var that = this;
util.request({
bindThis: that,
api: 'manager/get-notifications',
customLoading: false,
data: {
page: page,
page_size: 10
},
utilSuccess: function(r) {
var res = r.data;
uni.stopPullDownRefresh(); // 服务器总条数 < 每页条数, 会将第一页的条数重新返回
console.log(res);
var hasNoMore = that.news.length < 10 && page > 1;
if (hasNoMore || res.length == 0 && page > 1) {
// 已加载到最后一页
uni.showToast({
title: '已加载到最后一页',
icon: 'none'
});
return;
}
var news = that.news;
var _res = [];
if (page == 1) {
news = res;
} else {
news.push(...res);
}
that.currentPage = page;
that.news = news;
},
utilFail: function(res) {
uni.stopPullDownRefresh();
if (page == 1) {
that.currentPage = page;
that.news = [];
}
util.alert(res);
}
});
}
}
}
</script>
<style>
page {
padding-top: 160rpx;
}
.listBoxItemLeftVideoBox {
width: 240rpx;
height: 133rpx;
}
.listBoxItemRight {
flex-direction: column;
align-items: unset !important;
}
.listBoxItemRightText {
text-align: left;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 600rpx;
font-family: SourceHanSansCN-Normal;
font-size: 28rpx;
color: #333333;
letter-spacing: 0;
}
.listBoxItemRightfText {
font-family: PingFangSC-Regular;
font-size: 24rpx;
color: #666666;
letter-spacing: 0;
text-align: left;
}
.icon-details {
font-size: 40rpx;
color: #43C9CF;
}
.leftbg {
background: rgba(19, 169, 135, 0.10);
border-radius: 100%;
width: 80rpx;
height: 80rpx;
margin-right: 20rpx;
align-items: center;
justify-content: center;
display: flex;
}
</style>