kl-boss-iframe-outbound
v0.0.6
Published
```bash npm install kl-boss-iframe-outbound # 或者 yarn add kl-boss-iframe-outbound ```
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',
// 传外呼中台对应枚举,例如找人才传7;3是boss,这个只是个例子,要跟据业务来传
callType: 3,
// 脱敏手机号码,phone如果是加密字符串必须传,明文手机号可以不传
// desensitizedPhone: '132****xxx3',
// 额外扩展信息 非必填
// ext: {},
});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);
});