创作者微信小程序端
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.
 
 
 
 

104 lines
2.1 KiB

<template>
<view class="container">
<uni-list border-full v-for="(item,index) in noticeList" :key="index">
<uni-list-item showArrow clickable :title="item.title" :note="item.createTime" :thumb="item.img"
thumb-size="lg" @click="targetToDetail(item.id)" />
</uni-list>
<view class="ivOver" v-if="flag">-----已经到底啦-----</view>
</view>
</template>
<script>
import {
getNoticeList
} from '@/api/userInfo.js'
export default {
data() {
return {
noticeList: [],
pageSize: 10,
pageNum: 1,
flag: false,
userInfo:{}
}
},
created() {
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo) {
console.log('havent userInfo')
uni.showModal({
content: '艺术家账户过期,请重新登录!',
showCancel: false,
success() {
//没有缓存则跳转登录页面
uni.reLaunch({
url: '/pages/login/login'
});
}
});
} else {
this.userInfo = userInfo;
console.log('have userInfo')
}
this.getNoticeList();
},
// 下拉刷新
onPullDownRefresh() {
this.pageNum = 1
this.noticeList = []
this.getNoticeList()
uni.stopPullDownRefresh()
},
// 上划加载更多
onReachBottom() {
if (this.noticeList.length > this.pageSize*this.pageNum-1) {
this.flag = false;
this.pageNum += 1
this.getNoticeList();
}else{
this.flag = true;
}
},
methods: {
// 获取公告分页
async getNoticeList() {
let that = this;
const res = await getNoticeList({
pageSize: that.pageSize,
pageNum: that.pageNum,
})
//console.log('res', res)
if (res.data.code === 200) {
that.noticeList.push(...res.data.rows)
//console.log('noticeList', that.noticeList)
} else {
uni.showModal({
content: '公告列表加载失败!',
showCancel: false
});
}
},
targetToDetail(id) {
console.log('id', id)
if (id) {
uni.navigateTo({
url: 'noticeDetail?id=' + id
})
}
}
},
}
</script>
<style lang="scss">
.ivOver{
width: 100%;
height:100rpx;
line-height: 100rpx;
text-align: center;
background: #fff;
font-size: 20rpx;
}
</style>