Files
pupil/packageReport/newsList/newsList.vue
2023-02-03 19:31:50 +08:00

85 lines
1.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<view class="xw_content" v-for="(item,index) in newsList" :key="index" @click="clickNews(item)">
<u--image :src="imgUrl+item.cover" width="192rpx" height="122rpx" :lazy-load="true">
</u--image>
<view class="xw_right">
<view class="xw_title">
{{item.title}}
</view>
<view style="display: flex;">
<text class="xw_time">
{{item.pub_time_str}}
</text>
<text class="xw_time xw_place">
{{item.pub_name}}
</text>
</view>
</view>
</view>
<view v-if="newsShow" class="no-data">已经到底啦</view>
</view>
</template>
<script>
import {
dateFormat
} from '../../utills/date.js'
export default {
data() {
return {
newsShow: true,
imgUrl: '',
newsList: [],
pageNum: 1, // 当前页
pageSize: 4, // 每页条数
}
},
onLoad() {
this.getNews()
this.imgUrl = uni.getStorageSync('img_url')
},
onReachBottom() {
this.pageNum++
this.getNews()
},
methods: {
getNews() {
this.$apiServe.getNews({
pageSize: this.pageSize,
pageNum: this.pageNum
}).then(res => {
// console.log('行业新闻', res.data.data)
let newsData = res.data.data
for (const item of newsData) {
item.pub_time_str = dateFormat(item.pub_time_str)
}
this.newsList = [...this.newsList, ...newsData]
}).finally(_ => {})
},
// 跳转到新闻详情页
clickNews(item) {
uni.navigateTo({
url: '../newsDetail/newsDetail?id=' + item.id
})
},
}
}
</script>
<style lang="scss">
page {
background: #FFFFFF;
}
.no-data {
text-align: center;
margin-top: 29rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #BBBBBB;
line-height: 28rpx;
}
</style>