|
@@ -104,7 +104,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
|
|
import { useSocket } from '/@/utils/websocket';
|
|
|
-import { ElMessageBox, ElNotification } from 'element-plus';
|
|
|
+import { ElMessageBox } from 'element-plus';
|
|
|
import { getImageUrl } from '/@/utils/tools';
|
|
|
import axios from 'axios';
|
|
|
import { storeToRefs } from 'pinia';
|
|
@@ -113,9 +113,10 @@ import { useRoute } from 'vue-router';
|
|
|
import { formatDate } from '/@/utils/formatTime';
|
|
|
import Empty from '/@/components/Empty/index.vue';
|
|
|
const emit = defineEmits(['orderOverwrite']);
|
|
|
+import mittBus from '/@/utils/mitt';
|
|
|
// 消息列表
|
|
|
const messageList = ref<any>([
|
|
|
- {
|
|
|
+ /*{
|
|
|
body: {
|
|
|
content: {
|
|
|
callSentenceInfo: {
|
|
@@ -140,7 +141,7 @@ const messageList = ref<any>([
|
|
|
callerNumber: '19136073037',
|
|
|
},
|
|
|
timestamps: new Date().getTime(),
|
|
|
- },
|
|
|
+ },*/
|
|
|
]); // 消息列表
|
|
|
const recognizeList = ref<EmptyObjectType>({}); // 识别信息
|
|
|
|
|
@@ -148,43 +149,12 @@ const useTelStatusStore = useTelStatus();
|
|
|
const { telStatusInfo } = storeToRefs(useTelStatusStore); // 电话状态
|
|
|
|
|
|
const socket = ref<any>(null);
|
|
|
-// 打开websocket链接
|
|
|
-const seatAssistOn = () => {
|
|
|
- if (telStatusInfo.value.telsNo) {
|
|
|
- axios
|
|
|
- .get(`${import.meta.env.VITE_VOICE_ASSISTANT_API_URL}/users/getUserByAgentId/${telStatusInfo.value.telsNo}`)
|
|
|
- .then((res) => {
|
|
|
- const { data } = res;
|
|
|
- const { result } = data;
|
|
|
- const uid = `8#User-${result.uid}`;
|
|
|
- const subscribe = `/trans/${result.orgCode}/${result.groupUid}/${uid}`;
|
|
|
- console.log(result, '获取到的用户信息');
|
|
|
- socket.value = useSocket(import.meta.env.VITE_VOICE_ASSISTANT_SOCKET_URL, { uid, subscribe });
|
|
|
- socket.value.on('open', () => {
|
|
|
- console.log('坐席辅助链接已打开');
|
|
|
- socket.value.send({
|
|
|
- // 调用登录
|
|
|
- id: '',
|
|
|
- type: 1,
|
|
|
- from: uid,
|
|
|
- to: 'sys',
|
|
|
- timestamps: new Date().getTime(),
|
|
|
- body: result.userName,
|
|
|
- });
|
|
|
- });
|
|
|
- socket.value.on('message', wsReceive); // 接收消息
|
|
|
- socket.value.on('error', onError); // 错误
|
|
|
- socket.value.on('close', onClose); // 关闭
|
|
|
- console.log(socket.value);
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.log(err, '获取用户信息失败');
|
|
|
- });
|
|
|
- }
|
|
|
-};
|
|
|
// 设置初始化,防止刷新时恢复默认
|
|
|
onMounted(() => {
|
|
|
- seatAssistOn();
|
|
|
+ // 接受消息
|
|
|
+ mittBus.on('wsReceive', (message: any) => {
|
|
|
+ wsReceive(message);
|
|
|
+ });
|
|
|
});
|
|
|
const route = useRoute();
|
|
|
const talkEnd = ref(false); // 通话结束
|
|
@@ -213,8 +183,6 @@ const wsReceive = (message: any) => {
|
|
|
//通话结束
|
|
|
talkEnd.value = true;
|
|
|
getRecognize();
|
|
|
- console.log('通话转写结束了');
|
|
|
- socket.value.socket.ws.close(); // 关闭websocket
|
|
|
}, 1000);
|
|
|
}
|
|
|
}
|
|
@@ -280,9 +248,6 @@ const fillSingle = () => {
|
|
|
watch(messageList.value, (val) => {
|
|
|
scrollToBottom();
|
|
|
});
|
|
|
-onUnmounted(() => {
|
|
|
- socket.value.socket.ws.close(); // 关闭websocket
|
|
|
-});
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|