kl-boss-iframe-outbound
v0.0.5
Published
```bash npm install kl-boss-iframe-outbound # 或者 yarn add kl-boss-iframe-outbound ```
Downloads
314
Readme
安装
npm install kl-boss-iframe-outbound
# 或者
yarn add kl-boss-iframe-outbound
使用说明
1. 初始化
import Outbound from 'kl-boss-iframe-outbound'
const phone = Outbound.create()
2. call 拨打电话
import Outbound from 'kl-boss-iframe-outbound'
const phone = Outbound.create()
// 调用该事件后 boss会主动 发送电话状态消息回来 见序5(通话状态回调监听)
phone.call({
phone: '1327279xxx3',
callType: 7
})
3. hungUp 挂断电话
import Outbound from 'kl-boss-iframe-outbound'
const phone = Outbound.create()
// 调用该事件后 boss会主动 发送电话状态消息回来 见序5(通话状态回调监听)
phone.hangUp()
4. getStatus 获取电话状态
import Outbound from 'kl-boss-iframe-outbound'
const phone = Outbound.create()
// 调用该事件后 boss会主动 发送电话状态消息回来 见序5(通话状态回调监听)
phone.getStatus()
5. 通话状态回调监听
import Outbound from 'kl-boss-iframe-outbound'
import { onMounted, onUnmounted } from 'vue'
type BossOutboundIfameBack = {
/** 事件 固定传BossOutboundIfame */
event: string;
/** 传输动作,BossOutboundIfameBack 回调,BossOutboundIfameRquest 请求 */
eventType: string;
/** 电话状态:progress(响铃中),accepted(接听中),ended(挂断),failed(拨打异常) */
callStatus: string;
/** 话单id */
zuid: string;
/** 话单id */
selectItem: SeatItem;
/** callStatus为failed的时候会返回 */
errorInfo: ErrorInfo | undefined;
}
// 注意 如果在boss中未拨打过电话,此时调用同步状态序5(获取电话状态),则callStatus 返回值会为空字符串''
const phone = Outbound.create()
const onMessage = (data: BossOutboundIfameBack) => {
console.log(data)
}
phone.onMessage(onMessage)
onUnmounted(() => {
// 注意销毁监听,防止内存泄漏
phone.offMessage(onMessage)
})