|
@@ -58,7 +58,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
callAnswered.value = true;
|
|
|
|
|
|
- const { data } = await makeCall();
|
|
|
+ const { data } = await makeCall(phoneNum);
|
|
|
|
|
|
sessionId.value = data;
|
|
|
|
|
@@ -70,22 +70,24 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
}
|
|
|
|
|
|
// 接听电话
|
|
|
- const onCallAnswered = () => {
|
|
|
+ const onCallAnswered = async () => {
|
|
|
callDialing.value = true;
|
|
|
+ callAnswered.value = true;
|
|
|
+ await answer();
|
|
|
timer.start();
|
|
|
// TODO 这里需要补充其他逻辑
|
|
|
}
|
|
|
|
|
|
// 挂断电话
|
|
|
- const onCallDisconnected = () => {
|
|
|
+ const onCallDisconnected = async () => {
|
|
|
noiceBarVisibleState.value = false;
|
|
|
noiceBoxVisibleState.value = false;
|
|
|
callAnswered.value = false;
|
|
|
timer.resetTimer();
|
|
|
- const currentTimer = timer.updateDisplay();
|
|
|
+ // const currentTimer = timer.updateDisplay();
|
|
|
|
|
|
// 挂断
|
|
|
- bye();
|
|
|
+ await bye();
|
|
|
|
|
|
ElMessage({
|
|
|
message: '通话已经结束,挂断成功',
|
|
@@ -122,18 +124,18 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
}
|
|
|
|
|
|
// 挂断电话
|
|
|
- const bye = () => {
|
|
|
- HS_CTI.bye().then(res => { console.log(res) })
|
|
|
+ const bye = async () => {
|
|
|
+ return await HS_CTI.serverBye().then(res => { console.log(res) })
|
|
|
}
|
|
|
|
|
|
// 卸载实例
|
|
|
- const unInit = () => {
|
|
|
- HS_CTI.unInit()
|
|
|
+ const unInit = async () => {
|
|
|
+ return await HS_CTI.unInit()
|
|
|
}
|
|
|
|
|
|
// 下面开始事件监听
|
|
|
const listenScoketEvent = (CTIEvent) => {
|
|
|
- HS_CTI.on(CTIEvent.OnAgentWorkReport, ({ workStatus, description }) => {
|
|
|
+ HS_CTI.on(CTIEvent.OnAgentWorkReport, ({ workStatus, description, callId, phone }) => {
|
|
|
|
|
|
console.log( "workStatus", workStatus );
|
|
|
|
|
@@ -184,13 +186,31 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
// 座席振铃
|
|
|
if ( workStatus === 5 ) {
|
|
|
- // console.log("座席振铃");
|
|
|
+
|
|
|
+ sessionId.value = callId;
|
|
|
+
|
|
|
+ telephoneNumber.value = phone;
|
|
|
+
|
|
|
+ isMakingCall.value = false;
|
|
|
+
|
|
|
+ noiceBarVisibleState.value = true;
|
|
|
+
|
|
|
ElMessage({
|
|
|
- message: '当前坐席状态:置忙',
|
|
|
+ message: '来电话了',
|
|
|
type: 'warning',
|
|
|
plain: true,
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ // 挂断 任意一方挂断
|
|
|
+ if ( workStatus === 7 ) {
|
|
|
+
|
|
|
+ // ElMessage({
|
|
|
+ // message: '当前坐席状态:置忙',
|
|
|
+ // type: 'warning',
|
|
|
+ // plain: true,
|
|
|
+ // })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -234,10 +254,14 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
// 电话号码
|
|
|
telephoneNumber,
|
|
|
|
|
|
+ // 系统状态
|
|
|
+ systemState,
|
|
|
+
|
|
|
// 通话相关
|
|
|
HS_CTI_INSTANCE,
|
|
|
setBusy,
|
|
|
- setIdle
|
|
|
+ setIdle,
|
|
|
+ unInit
|
|
|
}
|
|
|
})
|
|
|
|