客服聊天

This commit is contained in:
熊丽君
2021-08-18 11:40:10 +08:00
parent 1e26d51d92
commit 7dbcb3b57f
2 changed files with 14 additions and 3 deletions

View File

@ -15,3 +15,10 @@ export function sendMsg(data) {
data
});
}
// 消息改为已读
export function readMsg(params) {
return request({
url: '/chat/readMsg',
params
});
}

View File

@ -60,7 +60,7 @@
</template>
<script>
import { getChatRecords, sendMsg } from '@/api/service';
import { getChatRecords, sendMsg, readMsg } from '@/api/service';
export default {
data() {
return {
@ -102,7 +102,7 @@ export default {
},
open() {
console.log('socket连接成功');
this.getMsgList();
this.getMsgList(true);
},
error: function () {
if (!this.$store.state.user.userId) {
@ -135,7 +135,7 @@ export default {
this.getMsgList();
}
},
getMsgList() {
getMsgList(flag) {
this.isLoading = 1;
getChatRecords(this.queryParams).then(({ data }) => {
data.list.map((item) => {
@ -151,6 +151,9 @@ export default {
if (this.queryParams.pageNum == 1) {
this.chatWindowActive();
}
if (flag) {
readMsg({ userId: '1385154178159804416' });
}
});
},
// 原回车键失去回车功能
@ -222,6 +225,7 @@ export default {
},
},
destroyed() {
console.log('out');
// 销毁监听
this.socket.onclose = this.close;
},