83 lines
2.4 KiB
Vue
83 lines
2.4 KiB
Vue
<template>
|
|
<view class="flex-col align-center">
|
|
<view class="w700 radius bg-white padding margin-xs radius flex-row justify-between "
|
|
v-for="(item,index) in noticeList" :key="index"
|
|
@click="this.$tab.navigateTo('/subNoticePages/info/info?noticeId='+ item.noticeId)">
|
|
<view class="margin-right">
|
|
<u--image :src="item.image" radius="20rpx" width="250rpx" height="158rpx">
|
|
<view slot="error" style="font-size: 24rpx;">加载失败</view>
|
|
</u--image>
|
|
</view>
|
|
<view class="flex-col" style="width: 400rpx;">
|
|
<view>
|
|
<u--text :lines="1" size="32rpx" bold :text="item.noticeTitle">
|
|
</u--text>
|
|
</view>
|
|
<view class="margin-top-xs" style="width: 400rpx;"> <text class="text-blue">{{ item.createTime }}</text>
|
|
</view>
|
|
<view class="margin-top-xs">
|
|
<u--text :lines="2" size="24rpx" :text="item.noticeContent">
|
|
</u--text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
noticeType: null,
|
|
baseUrl: getApp().globalData.config.baseUrl,
|
|
noticeList: [],
|
|
params: {
|
|
pageSize: 10,
|
|
pageNum: 1
|
|
}
|
|
}
|
|
},
|
|
onLoad(option) {
|
|
this.noticeType = option.noticeType
|
|
this.getNoticeList(this.noticeType)
|
|
},
|
|
onReachBottom() {
|
|
if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
|
|
this.isLoadMore = true
|
|
this.params.pageNum++
|
|
this.getNoticeList(this.noticeType)
|
|
}
|
|
},
|
|
methods: {
|
|
// 获取公告列表
|
|
async getNoticeList(noticeType) {
|
|
const res = await this.$request({
|
|
url: '/system/notice/listWx',
|
|
data: {
|
|
noticeType,
|
|
pageSize: this.params.pageSize,
|
|
pageNum: this.params.pageNum,
|
|
},
|
|
})
|
|
// 过滤html 和 处理 图片路径
|
|
for (let i = 0; i < res.rows.length; i++) {
|
|
let noticeContent = (res.rows[i].noticeContent).replace(/<\/?[^>]*>/g, ''); //去除HTML Tag
|
|
noticeContent = noticeContent.replace(/[|]*\n/, ''); //去除行尾空格
|
|
res.rows[i].noticeContent = noticeContent.replace(/ /gi, ''); //去掉nbsp
|
|
res.rows[i].image = this.baseUrl + res.rows[i].image
|
|
}
|
|
this.noticeList = this.noticeList.concat(res.rows);
|
|
if (res.rows.length < this.params.pageSize) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
|
|
this.isLoadMore = true
|
|
} else {
|
|
this.isLoadMore = false
|
|
}
|
|
console.log(this.noticeList);
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style> |