NewsDialog.vue
3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
<div class="NewsDialog">
<div class="news-title">
<div class="left">我的消息</div>
<div class="right">
<el-button type="primary" size="small" @click="toReadAll">标记全部已读</el-button>
</div>
</div>
<div class="infinite-list-wrapper" style="overflow: auto">
<ul
class="list"
v-infinite-scroll="load"
infinite-scroll-disabled="disabled"
infinite-scroll-immediate
>
<li class="list-item" v-for="v in messageList" :key="v.id">
<div class="item-title">{{v.title}}</div>
<!-- <p>这个应用应该归属到青羊区,不在金牛区的管辖范围内。</p> -->
<div class="item-info">
<div class="left">发送人:{{v.creatorUser}}</div>
</div>
<div class="item-info">
<div class="right">时间:{{ncc.dateFormat(v.lastModifyTime)}}</div>
</div>
</li>
</ul>
<p v-if="loading">加载中...</p>
<p v-if="noMore">没有更多了</p>
</div>
</div>
</template>
<script>
import {getMessageList} from "@/api/system/message";
export default {
name: "NewsDialog",
data() {
return {
count: 10,
loading: false,
messageList: [],
searchList: {
pageIndex: 1,
pageSize: 10
},
total: 0,
};
},
computed: {
noMore() {
return this.messageList.length == this.total;
},
disabled() {
return this.loading || this.noMore;
},
},
created() {
this.load();
},
mounted() {},
methods: {
load() {
this.loading = true;
getMessageList(this.searchList).then(({data}) => {
this.messageList = this.messageList.concat(data.list);
this.total = data.pagination.total;
this.loading = false;
this.searchList.pageIndex += 1
this.$emit('changeMagNum', data.pagination.total);
});
},
toReadAll() {
MessageAllRead().then(() => {
this.load();
})
}
},
};
</script>
<style scoped lang="scss">
.NewsDialog {
margin: -14px;
.news-title {
display: flex;
justify-content: space-between;
align-items: center;
flex-direction: row;
padding: 0 12px;
width: 100%;
height: 40px;
line-height: 40px;
background-color: rgba(59, 130, 246, 1);
color: #fff;
}
.infinite-list-wrapper {
height: 40vh;
text-align: center;
// .list {
// margin-right: -8px;
// }
.list-item {
text-align: left;
margin: 5px;
padding: 8px;
border-radius: 5px;
background-color: rgb(243, 244, 246);
cursor: pointer;
.item-title {
color: #000;
font-weight: 600;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
&::after {
content: "";
display: inline-block;
width: 25px;
text-align: center;
height: 15px;
background-image: url("@/assets/images/Group.png");
background-size: 100% 100%; /* 确保图片覆盖整个元素 */
background-position: center; /* 将图片居中显示 */
margin-left: 8px;
}
}
p {
margin: 5px 0;
font-size: 12px;
color: #898989;
}
.item-info {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
color: #ccc;
font-size: 12px;
}
}
}
}
</style>