|
@@ -10,6 +10,8 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
let HS_CTI = null;
|
|
|
|
|
|
+ const telephoneNumber = ref(null);
|
|
|
+
|
|
|
// 是否是拨打电话 true: 外呼 false: 来电
|
|
|
const isMakingCall = ref(false);
|
|
|
|
|
@@ -19,7 +21,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
const callDialing = ref(false);
|
|
|
|
|
|
// 横条来电显示
|
|
|
- const noiceBarVisibleState = ref(true);
|
|
|
+ const noiceBarVisibleState = ref(false);
|
|
|
// 盒子来电显示
|
|
|
const noiceBoxVisibleState = ref(false);
|
|
|
|
|
@@ -31,11 +33,13 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
const startTime = '';
|
|
|
const endTime = '';
|
|
|
|
|
|
+ const sessionId = ref(null);
|
|
|
+
|
|
|
// 是否有拨打电话权限
|
|
|
const isAuthPane = computed(() => usePermission.routes.findIndex(({ name }) => name === 'Console') !== -1);
|
|
|
|
|
|
// 拨打电话
|
|
|
- const onMakingCall = (phoneNum) => {
|
|
|
+ const onMakingCall = async (phoneNum) => {
|
|
|
if ( callAnswered.value ) {
|
|
|
return ElMessage({
|
|
|
message: '当前状态不允许操作,无法呼出',
|
|
@@ -43,6 +47,14 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
})
|
|
|
};
|
|
|
|
|
|
+ callAnswered.value = true;
|
|
|
+
|
|
|
+ const { data } = await makeCall();
|
|
|
+
|
|
|
+ sessionId.value = data;
|
|
|
+
|
|
|
+ telephoneNumber.value = phoneNum;
|
|
|
+
|
|
|
isMakingCall.value = true;
|
|
|
|
|
|
noiceBarVisibleState.value = true;
|
|
@@ -63,6 +75,9 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
timer.resetTimer();
|
|
|
const currentTimer = timer.updateDisplay();
|
|
|
|
|
|
+ // 挂断
|
|
|
+ // bye();
|
|
|
+
|
|
|
ElMessage({
|
|
|
message: '通话已经结束,挂断成功',
|
|
|
type: 'success',
|
|
@@ -74,13 +89,15 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
// 置忙
|
|
|
const setBusy = () => {
|
|
|
- HS_CTI.setBusy().then(res => { console.log(res) })
|
|
|
- }
|
|
|
+ try {
|
|
|
+ HS_CTI.setBusy().then(res => { console.log(res) })
|
|
|
+ } catch(error) {
|
|
|
+ console.log("111", error);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
// 置闲
|
|
|
- const setIdle = () => {
|
|
|
- HS_CTI.setIdle().then(res => { console.log(res) })
|
|
|
- }
|
|
|
+ const setIdle = () => HS_CTI.setIdle();
|
|
|
|
|
|
// 获取坐席状态
|
|
|
const getAgentStatus = () => {
|
|
@@ -88,9 +105,7 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
}
|
|
|
|
|
|
// 主动外呼
|
|
|
- const makeCall = () => {
|
|
|
- HS_CTI.makeCall({ called: '' }).then(res => { console.log(res) })
|
|
|
- }
|
|
|
+ const makeCall = called => HS_CTI.makeCall({ called })
|
|
|
|
|
|
// 接听电话
|
|
|
const answer = () => {
|
|
@@ -108,9 +123,8 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
}
|
|
|
|
|
|
// 下面开始事件监听
|
|
|
- const listenScoketEvent = () => {
|
|
|
+ const listenScoketEvent = (CTIEvent) => {
|
|
|
HS_CTI.on(CTIEvent.OnAgentWorkReport, ({ workStatus, description }) => {
|
|
|
- message.info(`OnAgentWorkReport: ${workStatus}: ${description}`)
|
|
|
|
|
|
// 销毁实例调用签出接口成功后 - 坐席签出
|
|
|
if ( workStatus === -1 ) {
|
|
@@ -123,46 +137,55 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
|
|
|
// 登录CTI 成功
|
|
|
if ( workStatus === 0 ) {
|
|
|
- ElMessage({
|
|
|
- message: '坐席登入成功',
|
|
|
- type: 'success',
|
|
|
- plain: true,
|
|
|
- })
|
|
|
+ // ElMessage({
|
|
|
+ // message: '坐席登入成功',
|
|
|
+ // type: 'success',
|
|
|
+ // plain: true,
|
|
|
+ // })
|
|
|
}
|
|
|
|
|
|
// 登录CTI 成功
|
|
|
if ( workStatus === 2 ) {
|
|
|
- ElMessage({
|
|
|
- message: '登入成功',
|
|
|
- type: 'success',
|
|
|
- plain: true,
|
|
|
- })
|
|
|
+ // ElMessage({
|
|
|
+ // message: '登入成功',
|
|
|
+ // type: 'success',
|
|
|
+ // plain: true,
|
|
|
+ // })
|
|
|
}
|
|
|
|
|
|
// 调用置闲接口成功后
|
|
|
if ( workStatus === 2 ) {
|
|
|
- ElMessage({
|
|
|
- message: '坐席状态变更为:置闲',
|
|
|
- type: 'success',
|
|
|
- plain: true,
|
|
|
- })
|
|
|
+ // ElMessage({
|
|
|
+ // message: '坐席状态变更为:置闲',
|
|
|
+ // type: 'success',
|
|
|
+ // plain: true,
|
|
|
+ // })
|
|
|
}
|
|
|
|
|
|
// 调用置忙接口成功后
|
|
|
if ( workStatus === 3 ) {
|
|
|
- ElMessage({
|
|
|
- message: '坐席状态变更为:置忙',
|
|
|
- type: 'success',
|
|
|
- plain: true,
|
|
|
- })
|
|
|
+ // ElMessage({
|
|
|
+ // message: '当前坐席状态:置忙',
|
|
|
+ // type: 'warning',
|
|
|
+ // plain: true,
|
|
|
+ // })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 座席振铃
|
|
|
+ if ( workStatus === 5 ) {
|
|
|
+ // console.log("座席振铃");
|
|
|
+ // ElMessage({
|
|
|
+ // message: '当前坐席状态:置忙',
|
|
|
+ // type: 'warning',
|
|
|
+ // plain: true,
|
|
|
+ // })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 初始化 通话实例
|
|
|
- const HS_CTI_INSTANCE = (agentId) => {
|
|
|
+ const HS_CTI_INSTANCE = (agent_id) => {
|
|
|
const { Scene, getInstance, LoggerLevels , CTIEvent} = window.HS_CTI;
|
|
|
-
|
|
|
HS_CTI = getInstance({
|
|
|
// 业务返回的坐席outId
|
|
|
agent_id,
|
|
@@ -177,9 +200,12 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
})
|
|
|
|
|
|
HS_CTI.init()
|
|
|
+
|
|
|
+ listenScoketEvent(CTIEvent);
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
+ sessionId,
|
|
|
isAuthPane,
|
|
|
|
|
|
callTime,
|
|
@@ -194,8 +220,13 @@ const useVoiceStore = defineStore('voice', () => {
|
|
|
noiceBarVisibleState,
|
|
|
noiceBoxVisibleState,
|
|
|
|
|
|
+ // 电话号码
|
|
|
+ telephoneNumber,
|
|
|
+
|
|
|
// 通话相关
|
|
|
HS_CTI_INSTANCE,
|
|
|
+ setBusy,
|
|
|
+ setIdle
|
|
|
}
|
|
|
})
|
|
|
|