客服聊天
This commit is contained in:
@ -15,3 +15,10 @@ export function sendMsg(data) {
|
||||
data
|
||||
});
|
||||
}
|
||||
// 消息改为已读
|
||||
export function readMsg(params) {
|
||||
return request({
|
||||
url: '/chat/readMsg',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
@ -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;
|
||||
},
|
||||
|
Reference in New Issue
Block a user