chatlist.vue
3.3 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>
<nav-bar class="noticebar">
<div slot="left" class="back" @click="goBack">
<img src="../../assets/img/back.png" alt="" />
</div>
<div slot="center" class="userinfotitle">聊天记录</div>
<div slot="right" class="result"></div>
</nav-bar>
<div class="notices">
<van-list @load="scrollEnd">
<div style="padding-bottom: 0.52rem; box-sizing: border-box">
<router-link
:to="{ path: '/chatrecord', query: { id: item.teacher_id } }"
v-for="(item, index) in notices"
:key="index"
class="notice_items display-flex-between"
>
<div style="position: relative">
<div class="dian" v-if="item.is_read == 0"></div>
<img src="../../assets/img/notice.png" alt="" />
</div>
<div style="flex: 1">
<div class="notice_title display-flex-between">
<div>{{ item.teacher.name }}</div>
<div style="color: rgba(150, 151, 153, 1)">
{{ item.update_time }}
</div>
</div>
<div class="notice_detail p-2">
{{ item.last_content }}
</div>
</div>
</router-link>
</div>
</van-list>
</div>
</div>
</template>
<script>
export default {
data() {
return {
scrollX: false,
notices: [],
page: 1,
ifmore: false,
height: "",
time: "",
};
},
mounted() {
this.height = document.documentElement.clientHeight - 20;
this.getlist();
},
methods: {
scrollEnd() {
if (this.ifmore) {
++this.page;
this.getlist();
}
// else {
// this.$toast({ message: "没有更多了", duration: 1000 });
// }
},
goBack() {
this.$router.go(-1);
},
async getlist() {
const params = {
page: this.page,
page_num: 20,
};
const res = await this.api.chatlist(params);
if (res.code === 1) {
const list = res.data.list.data;
if (list.length === 0) {
this.ifmore = false;
this.notices = this.notices.concat(list);
} else {
this.ifmore = true;
this.notices = this.page === 1 ? list : this.notices.concat(list);
}
}
},
},
};
</script>
<style lang="scss">
body {
background: #fff;
}
.noticebar {
position: fixed;
top: 0;
background: #fff;
z-index: 2;
}
.notices {
width: 100%;
padding: 0 0.32rem;
box-sizing: border-box;
background-color: #ffffff;
margin-top: 0.88rem;
}
.notice_items {
width: 100%;
height: auto;
padding: 0.16rem 0;
align-items: flex-start;
border-bottom: 0.01rem solid #eee;
}
.notice_items img {
width: 0.88rem;
height: 0.88rem;
border-radius: 50%;
margin-right: 0.32rem;
}
.notice_title {
color: rgba(50, 50, 51, 1);
font-size: 0.28rem;
}
.notice_detail {
color: rgba(50, 50, 51, 1);
font-size: 0.24rem;
font-weight: 400;
font-family: "PingFang SC";
text-align: left;
line-height: 0.44rem;
margin-top: 0.16rem;
word-break: break-all;
}
.dian {
position: absolute;
width: 0.15rem;
height: 0.15rem;
background: red;
border-radius: 50%;
top: 0.05rem;
left: 0.05rem;
}
</style>