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.
155 lines
3.4 KiB
155 lines
3.4 KiB
<template>
|
|
<BaseContainer class="notice flex">
|
|
<NavBar title="消息中心" />
|
|
<view class="notice-list" :style="{ background: noticeList.length > 0 ? '' : 'transparent'}">
|
|
<view v-for="(item, index) in noticeList" class="notice-item flex flex-center-x" @click="toDetail(item)">
|
|
<image :src="item.message_types.pic" mode="aspectFill"></image>
|
|
<view class="item-info">
|
|
<view>{{ item.message_types.name }}</view>
|
|
<view>{{ item.content }}</view>
|
|
</view>
|
|
<view class="item-right">
|
|
<view>{{ item.time }}</view>
|
|
<view v-if="item.is_read === 0" class="num">1</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="noticeList.length && !loading" class="finished">{{ loadTitle }}</view>
|
|
<view v-if="finished && !noticeList.length" class="empty">
|
|
<image mode="aspectFill" :src="getImgPath('/wap/first/zsff/images/empty.png')" alt="暂无课程" />
|
|
<view>暂无消息</view>
|
|
</view>
|
|
</view>
|
|
</BaseContainer>
|
|
</template>
|
|
|
|
<script>
|
|
import { messageList } from '@/api/user';
|
|
export default {
|
|
data() {
|
|
return {
|
|
noticeList: [],
|
|
page: 1,
|
|
limit: 10,
|
|
loading: false,
|
|
finished: false,
|
|
loadTitle: '',
|
|
};
|
|
},
|
|
onShow() {
|
|
this.page = 1;
|
|
this.finished = false;
|
|
this.noticeList = [];
|
|
this.getNoticeList();
|
|
},
|
|
onReachBottom() {
|
|
this.getNoticeList();
|
|
},
|
|
methods: {
|
|
async getNoticeList() {
|
|
if (this.loading || this.finished) {
|
|
return;
|
|
}
|
|
uni.showLoading();
|
|
const { data } = await messageList(
|
|
{
|
|
page: this.page++,
|
|
limit: this.limit,
|
|
}
|
|
);
|
|
uni.hideLoading();
|
|
this.noticeList = this.noticeList.concat(data);
|
|
console.log(this.noticeList);
|
|
this.finished = data.length < this.limit;
|
|
this.loadTitle = this.finished ? "已全部加载完" : "上拉加载更多";
|
|
},
|
|
toDetail(item) {
|
|
uni.navigateTo({
|
|
url: `/pages/my/noticeDetail?info=${JSON.stringify(item)}`
|
|
})
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.notice {
|
|
flex-direction: column;
|
|
.notice-list {
|
|
flex: 1;
|
|
width: 100%;
|
|
padding: 20rpx 30rpx;
|
|
background: #fff;
|
|
.notice-item {
|
|
height: 164rpx;
|
|
border-bottom: 1px solid #E6E6E6;
|
|
image {
|
|
width: 84rpx;
|
|
height: 84rpx;
|
|
}
|
|
.item-info {
|
|
width: 450rpx;
|
|
margin: 0 auto 0 22rpx;
|
|
>view {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
font-size: 24rpx;
|
|
line-height: 24rpx;
|
|
color: #999;
|
|
&:first-child {
|
|
font-size: 30rpx;
|
|
line-height: 30rpx;
|
|
color: #333;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
}
|
|
}
|
|
.item-right {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
>view{
|
|
&:first-child {
|
|
font-size: 20rpx;
|
|
line-height: 30rpx;
|
|
color: #999;
|
|
margin-bottom: 28rpx;
|
|
}
|
|
&.num {
|
|
width: 22rpx;
|
|
height: 22rpx;
|
|
background: #FE4944;
|
|
border-radius: 50%;
|
|
font-size: 18rpx;
|
|
color: #fff;
|
|
text-align: center;
|
|
line-height: 22rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
.finished,
|
|
.loading {
|
|
font-size: 28rpx;
|
|
line-height: 100rpx;
|
|
text-align: center;
|
|
color: #bbb;
|
|
}
|
|
.empty {
|
|
margin-top: 100rpx;
|
|
font-size: 28rpx;
|
|
text-align: center;
|
|
color: #bbb;
|
|
}
|
|
|
|
.empty image {
|
|
display: block;
|
|
width: 414rpx;
|
|
height: 305rpx;
|
|
margin: 0 auto;
|
|
pointer-events: none;
|
|
}
|
|
}
|
|
}
|
|
</style> |