Files
product-uniapp/pages/mine/my_newmsg.vue
T

125 lines
2.8 KiB
Vue
Raw Normal View History

2025-12-03 16:07:38 +08:00
<template>
<view class="home-page">
<z-paging ref="paging" v-model="contList" @query="queryList" empty-view-text="暂无消息">
<template #top>
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="最新消息"></uni-nav-bar>
</template>
<view class="msg-list">
<view class="msg-item" v-for="item in contList" :key="item.id">
<image class="msg-avatar" :src="item.sender_user.avatar_pull" mode="aspectFill"></image>
<view class="msg-body">
<view class="msg-header">
<text class="msg-name">{{item.sender_user.nickname}}</text>
<text class="msg-time">{{item.created_at}}</text>
</view>
<text class="msg-text">
<text>{{ item.type==1?'点赞了': item.type==2?'收藏了':'评论了' }} </text>
<text>{{ formatContent(item.post && item.post.content) }}</text>
</text>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
export default {
data() {
return {
contList: [],
defaultAvatar: '/static/image/mine/user.png'
}
},
methods: {
leftClick(){
uni.navigateBack({})
},
queryList(pageNo, pageSize) {
request({
url:'common/post/messageNotice/list',
method:'get',
data: {
current:pageNo,
size:pageSize || 10
}
}).then(res => {
if(res.data.code === 200){
const datas = res.data.data.records || [];
this.$refs.paging.complete(datas);
}else{
this.$refs.paging.complete(false);
uni.showToast({
title:res.data.message || '加载失败',
icon:'none'
});
}
uni.stopPullDownRefresh();
}).catch(() => {
this.$refs.paging.complete(false);
})
},
formatContent(content){
if(!content) return '';
const text = content.trim();
return text.length > 10 ? `${text.slice(0,10)}...` : text;
}
}
}
</script>
<style lang="scss">
.home-page{
min-height: 100vh;
background: #F5F6FA;
box-sizing: border-box;
padding-bottom: 120rpx;
}
.msg-list{
padding: 20rpx;
}
.msg-item{
display: flex;
align-items: center;
padding: 24rpx 20rpx;
margin-bottom: 20rpx;
border-bottom: 1px solid #e4e4e4;
}
.msg-avatar{
width: 96rpx;
height: 96rpx;
border-radius: 50%;
margin-right: 20rpx;
}
.msg-body{
flex: 1;
display: flex;
flex-direction: column;
width: 80%;
}
.msg-header{
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10rpx;
}
.msg-name{
font-size: 26rpx;
font-weight: 600;
color: #333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 40%;
}
.msg-time{
font-size: 24rpx;
color: #999;
}
.msg-text{
font-size: 24rpx;
color: #666;
line-height: 38rpx;
}
</style>