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

72 lines
1.4 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>
</template>
<script>
import {
getNoticeList
} from '@/api/userInfo.js'
export default {
data() {
return {
noticeList: [],
pageSize: 10,
pageNum: 1
}
},
created() {
this.getNoticeList();
},
// 下拉刷新
onPullDownRefresh() {
this.pageNum = 1
this.noticeList = []
this.getNoticeList()
uni.stopPullDownRefresh()
},
// 上划加载更多
onReachBottom() {
if (this.noticeList.length > 9) {
this.pageNum += 1
this.getNoticeList();
}
},
methods: {
// 获取公告分页
async getNoticeList() {
const res = await getNoticeList({
pageSize: this.pageSize,
pageNum: this.pageNum,
})
//console.log('res', res)
if (res.data.code === 200) {
this.noticeList.push(...res.data.rows)
//console.log('noticeList', this.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">
</style>