|
@@ -32,61 +32,71 @@ export function callNumber(customerId,contactsId,orderId,callerLine){
|
|
|
const callHa1 = store.getters && store.getters.callHa1
|
|
|
JsSIP.C.SESSION_EXPIRES=120,JsSIP.C.MIN_SESSION_EXPIRES=360;
|
|
|
|
|
|
- console.log(callUser)
|
|
|
- console.log(callRealm)
|
|
|
- console.log(callHa1)
|
|
|
- if(_phone==null){
|
|
|
-
|
|
|
- _phone = new WebPhoneSDK({
|
|
|
- lib: JsSIP,
|
|
|
- debug: true,
|
|
|
- debugLib: true,
|
|
|
- user: callUser,
|
|
|
- ha1: callHa1,
|
|
|
- realm: callRealm,
|
|
|
- server: server,
|
|
|
- audioElement: document.getElementById('remoteAudio'),
|
|
|
- httpsConfirmFrame: 'httpsConfirmFrame',
|
|
|
- pcConfig:{"iceServers":[{"urls":["stun:211.159.161.254"]}]},
|
|
|
- events: {
|
|
|
- 'ua.connecting': (type, data) => webphoneHandle(type, data),
|
|
|
- 'ua.connected': (type, data) => webphoneHandle(type, data), //WEBPHONE链接OK
|
|
|
- 'ua.disconnected': (type, data) => webphoneHandle(type, data), //WEBPHONE链接断开
|
|
|
- 'reg.registered': (type, data) => webphoneHandle(type, data), //WEBPHONE 分机注册
|
|
|
- 'reg.unregistered': (type, data) => webphoneHandle(type, data), //WEBPHONE 分机取消注册
|
|
|
- 'reg.failed': (type, data) => webphoneHandle(type, data), //WEBPHONE 注册失败
|
|
|
- 'incoming.notify': (type, data, options) => webphoneHandle(type, data, options), //有电话进来了
|
|
|
- 'incoming.failed': (type, data, options) => webphoneHandle(type, data, options),//WEBPHONE 有电话进来,然后处理失败了(如,我们拒绝了,或者客户侧直接挂断了)
|
|
|
- 'incoming.ended': (type, options) => webphoneHandle(type, options),// WEBPHONE 有电话进来了,呼叫正常结束了
|
|
|
- 'incoming.accecpted': (type, options) => webphoneHandle(type, options),//有电话进来了,呼叫接听了额
|
|
|
- 'outgoing.connecting': (type, options) => webphoneHandle(type, options),//WEBPHONE正在尝试呼出
|
|
|
- 'outgoing.progress': (type, options) => webphoneHandle(type, options),//WEBPHONE开始振铃了
|
|
|
- 'outgoing.failed': (type, data, options) => webphoneHandle(type, data, options),//WEBPHONE呼出失败了,如被叫拒绝了,线路异常呼出失败了
|
|
|
- 'outgoing.ended': (type, options) => webphoneHandle(type, options), //呼出正常结束
|
|
|
- 'outgoing.accecpted': (type, data, options) => webphoneHandle(type, data, options), //呼出被叫接听
|
|
|
- 'call.hold': (type, data) => webphoneHandle(type, data), //呼叫保持
|
|
|
- 'call.unhold': (type, data) => webphoneHandle(type, data), //呼叫解除保持
|
|
|
- }
|
|
|
- })
|
|
|
- _phone.start({});
|
|
|
+
|
|
|
+
|
|
|
+ // 2. 销毁旧实例
|
|
|
+ if (_phone) {
|
|
|
+ try {
|
|
|
+ _phone.stop && _phone.stop()
|
|
|
+ } catch (e) {
|
|
|
+ console.warn('旧 _phone 停止失败', e)
|
|
|
+ }
|
|
|
+ _phone = null
|
|
|
}
|
|
|
+
|
|
|
+ // 3. 新建实例
|
|
|
+ _phone = new WebPhoneSDK({
|
|
|
+ lib: JsSIP,
|
|
|
+ debug: true,
|
|
|
+ debugLib: true,
|
|
|
+ user: callUser,
|
|
|
+ ha1: callHa1,
|
|
|
+ realm: callRealm,
|
|
|
+ server: server,
|
|
|
+ audioElement: document.getElementById('remoteAudio'),
|
|
|
+ httpsConfirmFrame: 'httpsConfirmFrame',
|
|
|
+ pcConfig:{"iceServers":[{"urls":["stun:211.159.161.254"]}]},
|
|
|
+ events: {
|
|
|
+ 'ua.connecting': (type, data) => webphoneHandle(type, data),
|
|
|
+ 'ua.connected': (type, data) => webphoneHandle(type, data), //WEBPHONE链接OK
|
|
|
+ 'ua.disconnected': (type, data) => webphoneHandle(type, data), //WEBPHONE链接断开
|
|
|
+ 'reg.registered': (type, data) => webphoneHandle(type, data), //WEBPHONE 分机注册
|
|
|
+ 'reg.unregistered': (type, data) => webphoneHandle(type, data), //WEBPHONE 分机取消注册
|
|
|
+ 'reg.failed': (type, data) => webphoneHandle(type, data), //WEBPHONE 注册失败
|
|
|
+ 'incoming.notify': (type, data, options) => webphoneHandle(type, data, options), //有电话进来了
|
|
|
+ 'incoming.failed': (type, data, options) => webphoneHandle(type, data, options),//WEBPHONE 有电话进来,然后处理失败了(如,我们拒绝了,或者客户侧直接挂断了)
|
|
|
+ 'incoming.ended': (type, options) => webphoneHandle(type, options),// WEBPHONE 有电话进来了,呼叫正常结束了
|
|
|
+ 'incoming.accecpted': (type, options) => webphoneHandle(type, options),//有电话进来了,呼叫接听了额
|
|
|
+ 'outgoing.connecting': (type, options) => webphoneHandle(type, options),//WEBPHONE正在尝试呼出
|
|
|
+ 'outgoing.progress': (type, options) => webphoneHandle(type, options),//WEBPHONE开始振铃了
|
|
|
+ 'outgoing.failed': (type, data, options) => webphoneHandle(type, data, options),//WEBPHONE呼出失败了,如被叫拒绝了,线路异常呼出失败了
|
|
|
+ 'outgoing.ended': (type, options) => webphoneHandle(type, options), //呼出正常结束
|
|
|
+ 'outgoing.accecpted': (type, data, options) => webphoneHandle(type, data, options), //呼出被叫接听
|
|
|
+ 'call.hold': (type, data) => webphoneHandle(type, data), //呼叫保持
|
|
|
+ 'call.unhold': (type, data) => webphoneHandle(type, data), //呼叫解除保持
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+ _phone.start({}) // 必须重新启动
|
|
|
+
|
|
|
var data={customerId:customerId,contactsId:contactsId,orderId:orderId,callerId:callerLine};
|
|
|
-
|
|
|
+
|
|
|
this.callMobile(data).then(response => {
|
|
|
if(response.code==200){
|
|
|
_phone.call(response.mobile,{userdata:response.logs.sessionId});
|
|
|
this.$store.dispatch('Call', {
|
|
|
- mobile: response.displayMobile,
|
|
|
- sessionId: response.logs.sessionId
|
|
|
- })
|
|
|
+ mobile: response.displayMobile,
|
|
|
+ sessionId: response.logs.sessionId
|
|
|
+ })
|
|
|
}
|
|
|
else{
|
|
|
that.$notify.error({
|
|
|
- title: response.msg,
|
|
|
- showClose: false
|
|
|
+ title: response.msg,
|
|
|
+ showClose: false
|
|
|
});
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
export function callOff(){
|