客服聊天
This commit is contained in:
@ -15,3 +15,10 @@ export function sendMsg(data) {
|
|||||||
data
|
data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 消息改为已读
|
||||||
|
export function readMsg(params) {
|
||||||
|
return request({
|
||||||
|
url: '/chat/readMsg',
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getChatRecords, sendMsg } from '@/api/service';
|
import { getChatRecords, sendMsg, readMsg } from '@/api/service';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -102,7 +102,7 @@ export default {
|
|||||||
},
|
},
|
||||||
open() {
|
open() {
|
||||||
console.log('socket连接成功');
|
console.log('socket连接成功');
|
||||||
this.getMsgList();
|
this.getMsgList(true);
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
if (!this.$store.state.user.userId) {
|
if (!this.$store.state.user.userId) {
|
||||||
@ -135,7 +135,7 @@ export default {
|
|||||||
this.getMsgList();
|
this.getMsgList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getMsgList() {
|
getMsgList(flag) {
|
||||||
this.isLoading = 1;
|
this.isLoading = 1;
|
||||||
getChatRecords(this.queryParams).then(({ data }) => {
|
getChatRecords(this.queryParams).then(({ data }) => {
|
||||||
data.list.map((item) => {
|
data.list.map((item) => {
|
||||||
@ -151,6 +151,9 @@ export default {
|
|||||||
if (this.queryParams.pageNum == 1) {
|
if (this.queryParams.pageNum == 1) {
|
||||||
this.chatWindowActive();
|
this.chatWindowActive();
|
||||||
}
|
}
|
||||||
|
if (flag) {
|
||||||
|
readMsg({ userId: '1385154178159804416' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 原回车键失去回车功能
|
// 原回车键失去回车功能
|
||||||
@ -222,6 +225,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
|
console.log('out');
|
||||||
// 销毁监听
|
// 销毁监听
|
||||||
this.socket.onclose = this.close;
|
this.socket.onclose = this.close;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user